net.minecraft.entity.boss.EntityDragon Java Examples

The following examples show how to use net.minecraft.entity.boss.EntityDragon. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DragonEgg.java    From Ex-Aliquo with MIT License 6 votes vote down vote up
@Override
   public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10)
{
	if (world.provider.dimensionId == 1 && !world.isRemote)
	{
		if (!player.capabilities.isCreativeMode)
		{
			--itemstack.stackSize;
		}
		
		double rx = player.posX + ((Math.random()*67)-33);
		double ry = player.posY + ((Math.random()*51)-25);
		double rz = player.posZ + ((Math.random()*67)-33);
		
		Random rand = new Random();
		
		EntityDragon dragon = new EntityDragon(world);
		dragon.setLocationAndAngles(rx, ry, rz, rand.nextFloat(), 0.0F);
		//dragon.setLocationAndAngles(player.posX, player.posY, player.posZ, player.rotationYaw, 90.0F);
		//dragon.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 100, 3));
		world.spawnEntityInWorld(dragon);
		
		return true;
	}
	return false;
}
 
Example #2
Source File: AliquoEvents.java    From Ex-Aliquo with MIT License 6 votes vote down vote up
@ForgeSubscribe
public void onLivingDrops(LivingDropsEvent event)
{
	if (event.entityLiving == null)
	{
		return;
	}
	
	if (event.entityLiving instanceof EntityDragon)
	{
		if (event.source.getEntity() != null && event.source.getEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) event.source.getEntity();
			if (!player.worldObj.isRemote)
			{
				EntityItem item = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(Registries.dragonEgg, 1, 0));
	            player.worldObj.spawnEntityInWorld(item);
	            if (!(player instanceof FakePlayer))
	            {
	                item.onCollideWithPlayer(player);
	            }
			}
		}
	}
}
 
Example #3
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onTick(LivingEvent.LivingUpdateEvent event) {
	EntityLivingBase e = event.getEntityLiving();
	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		boolean shouldFreeze = true;
		if(e.isDead || e.getHealth() <= 0) {
			shouldFreeze = false;
		}
		if(e instanceof EntityDragon && ((EntityDragon) e).getPhaseManager().getCurrentPhase().getType() == PhaseList.DYING) {
			shouldFreeze = false;
		}
		if(shouldFreeze) {
			handleImportantEntityTicks(e);
			event.setCanceled(true);
		}
	}
}
 
Example #4
Source File: EnchantmentEnderDamage.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityDamaged(EntityLivingBase hurtEntity, Entity damagingEntity, int level) {
    String entityName = EntityList.getEntityString(hurtEntity);
    if (hurtEntity instanceof EntityEnderman || hurtEntity instanceof EntityDragon || (entityName != null && entityName.toLowerCase().contains("ender"))) {
        hurtEntity.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, level * 200, Math.max(1, (5 * level) / 7)));
        hurtEntity.addPotionEffect(new PotionEffect(MobEffects.POISON, level * 200, Math.max(1, (5 * level) / 7)));
    }
}
 
Example #5
Source File: MetaTileEntityMagicEnergyAbsorber.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateConnectedCrystals() {
    this.connectedCrystalsIds.clear();
    final double maxDistance = 64 * 64;
    List<EntityEnderCrystal> enderCrystals = Arrays.stream(BiomeEndDecorator.getSpikesForWorld(getWorld()))
        .flatMap(endSpike -> getWorld().getEntitiesWithinAABB(EntityEnderCrystal.class, endSpike.getTopBoundingBox()).stream())
        .filter(crystal -> crystal.getDistanceSq(getPos()) < maxDistance)
        .collect(Collectors.toList());

    for (EntityEnderCrystal entityEnderCrystal : enderCrystals) {
        BlockPos beamTarget = entityEnderCrystal.getBeamTarget();
        if (beamTarget == null) {
            //if beam target is null, set ourselves as beam target
            entityEnderCrystal.setBeamTarget(getPos());
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        } else if (beamTarget.equals(getPos())) {
            //if beam target is ourselves, just add it to list
            this.connectedCrystalsIds.add(entityEnderCrystal.getEntityId());
        }
    }

    for (EntityDragon entityDragon : getWorld().getEntities(EntityDragon.class, EntitySelectors.IS_ALIVE)) {
        if (entityDragon.healingEnderCrystal != null && connectedCrystalsIds.contains(entityDragon.healingEnderCrystal.getEntityId())) {
            //if dragon is healing from crystal we draw energy from, reset it's healing crystal
            entityDragon.healingEnderCrystal = null;
            //if dragon is holding pattern, than deal damage and set it's phase to attack ourselves
            if (entityDragon.getPhaseManager().getCurrentPhase().getType() == PhaseList.HOLDING_PATTERN) {
                entityDragon.attackEntityFrom(DamageSource.causeExplosionDamage((EntityLivingBase) null), 10.0f);
                entityDragon.getPhaseManager().setPhase(PhaseList.CHARGING_PLAYER);
                ((PhaseChargingPlayer) entityDragon.getPhaseManager().getCurrentPhase()).setTarget(new Vec3d(getPos()));
            }
        }
    }
}
 
Example #6
Source File: PotionTimeSlow.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static void handleImportantEntityTicks(EntityLivingBase e) {
	if (e.hurtTime > 0) {
		e.hurtTime--;
	}
	if (e.hurtResistantTime > 0) {
		e.hurtResistantTime--;
	}

	e.prevLimbSwingAmount = e.limbSwingAmount;
	e.prevRenderYawOffset = e.renderYawOffset;
	e.prevRotationPitch = e.rotationPitch;
	e.prevRotationYaw = e.rotationYaw;
	e.prevRotationYawHead = e.rotationYawHead;
	e.prevSwingProgress = e.swingProgress;
	e.prevDistanceWalkedModified = e.distanceWalkedModified;
	e.prevCameraPitch = e.cameraPitch;

	if(e.isPotionActive(ModPotions.TIME_SLOW) && timeScale(e) == 0) {
		PotionEffect pe = e.getActivePotionEffect(ModPotions.TIME_SLOW);
		if (!pe.onUpdate(e)) {
			if (!e.world.isRemote) {
				e.removePotionEffect(ModPotions.TIME_SLOW);
			}
		}
	}

	if(e instanceof EntityDragon) {
		IPhase phase = ((EntityDragon) e).getPhaseManager().getCurrentPhase();
		if(phase.getType() != PhaseList.HOLDING_PATTERN && phase.getType() != PhaseList.DYING) {
			((EntityDragon) e).getPhaseManager().setPhase(PhaseList.HOLDING_PATTERN);
		}
	}
}
 
Example #7
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
/**
 * These entities are excluded from Activation range checks.
 *
 * @param entity
 * @param world
 * @return boolean If it should always tick.
 */
public static boolean initializeEntityActivationState(Entity entity, SpigotWorldConfig config)
{
    // Cauldron start - another fix for Proxy Worlds
    if (config == null && DimensionManager.getWorld(0) != null)
    {
        config = DimensionManager.getWorld(0).spigotConfig;
    }
    else
    {
        return true;
    }
    // Cauldron end

    if ( ( entity.activationType == 3 && config.miscActivationRange == 0 )
            || ( entity.activationType == 2 && config.animalActivationRange == 0 )
            || ( entity.activationType == 1 && config.monsterActivationRange == 0 )
            || (entity instanceof EntityPlayer && !(entity instanceof FakePlayer)) // Cauldron
            || entity instanceof EntityThrowable
            || entity instanceof EntityDragon
            || entity instanceof EntityDragonPart
            || entity instanceof EntityWither
            || entity instanceof EntityFireball
            || entity instanceof EntityWeatherEffect
            || entity instanceof EntityTNTPrimed
            || entity instanceof EntityFallingBlock // PaperSpigot - Always tick falling blocks
            || entity instanceof EntityEnderCrystal
            || entity instanceof EntityFireworkRocket
            || entity instanceof EntityVillager
            // Cauldron start - force ticks for entities with superclass of Entity and not a creature/monster
            || (entity.getClass().getSuperclass() == Entity.class && !entity.isCreatureType(EnumCreatureType.creature, false)
            && !entity.isCreatureType(EnumCreatureType.ambient, false) && !entity.isCreatureType(EnumCreatureType.monster, false)
            && !entity.isCreatureType(EnumCreatureType.waterCreature, false)))
    {
        return true;
    }

    return false;
}
 
Example #8
Source File: BlackLists.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static boolean isEntityBlacklistedForTeleport(Entity entity)
{
    return (entity instanceof MultiPartEntityPart && TELEPORT_BLACKLIST_CLASSES.contains(EntityDragon.class)) ||
            TELEPORT_BLACKLIST_CLASSES.contains(entity.getClass());
}
 
Example #9
Source File: EntityUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isMob(final Entity entity) {
    return entity instanceof EntityMob || entity instanceof EntityVillager || entity instanceof EntitySlime ||
            entity instanceof EntityGhast || entity instanceof EntityDragon;
}
 
Example #10
Source File: PurpurStairs.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #11
Source File: EndRod.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #12
Source File: PurpurSlab.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #13
Source File: ChorusPlant.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #14
Source File: EndBricks.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #15
Source File: PurpurPillar.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #16
Source File: ChorusFlower.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #17
Source File: PurpurBlock.java    From Et-Futurum with The Unlicense 4 votes vote down vote up
@Override
public boolean canEntityDestroy(IBlockAccess world, int x, int y, int z, Entity entity) {
	return !(entity instanceof EntityDragon);
}
 
Example #18
Source File: CraftEnderDragon.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityDragon getHandle() {
    return (EntityDragon) entity;
}
 
Example #19
Source File: CraftEnderDragon.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderDragon(CraftServer server, EntityDragon entity) {
    super(server, entity);
}
 
Example #20
Source File: CraftComplexPart.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public ComplexLivingEntity getParent() {
    return (ComplexLivingEntity) ((EntityDragon) getHandle().parent).getBukkitEntity();
}
 
Example #21
Source File: CraftEnderDragon.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Phase getPhase() {
    return Phase.values()[getHandle().getDataManager().get(EntityDragon.PHASE)];
}
 
Example #22
Source File: CraftEnderDragon.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityDragon getHandle() {
    return (EntityDragon) entity;
}
 
Example #23
Source File: CraftEnderDragon.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftEnderDragon(CraftServer server, EntityDragon entity) {
    super(server, entity);
}
 
Example #24
Source File: DragonCompanion.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
CustomDragon(EntityDragon dragon, AnimationState point) {
    this.dragon = dragon;
    animationState = point;
}
 
Example #25
Source File: DragonCompanion.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void tick() {
    if (Minecraft.getMinecraft().theWorld == null) return;

    for (Map.Entry<EntityPlayer, CustomDragon> entry : dragonHashMap.entrySet()) {
        EntityPlayer player = entry.getKey();
        CustomDragon customDragon = entry.getValue();
        EntityDragon entityDragon = customDragon.dragon;
        AnimationState animationState = customDragon.animationState;
        if (entityDragon != null) {
            entityDragon.setWorld(player.getEntityWorld());
            double v = animationState.next.distanceSqTo(new AnimationPoint(player.posX, player.posY, player.posZ));
            if (v > 7 * 7) animationState.switchToNext(player, true);

            entityDragon.lastTickPosX = entityDragon.posX;
            entityDragon.lastTickPosY = entityDragon.posY;
            entityDragon.lastTickPosZ = entityDragon.posZ;
            entityDragon.prevRotationYawHead = entityDragon.rotationYawHead;

            AnimationPoint current = animationState.getCurrent(player);
            entityDragon.posX = current.x / scale;
            entityDragon.posY = current.y / scale;
            entityDragon.posZ = current.z / scale;

            double dx = animationState.next.x - animationState.last.x;
            double dz = animationState.next.z - animationState.last.z;

            double angrad = Math.atan2(dx, -dz);
            double angle = MathHelper.wrapAngleTo180_float((float) Math.toDegrees(angrad));

            if (animationState.nextFrameisNewPoint(player)) {
                double dx1 = animationState.nextNext.x - animationState.next.x;
                double dz1 = animationState.nextNext.z - animationState.next.z;
                double angrad1 = Math.atan2(dx1, -dz1);
                double angle1 = MathHelper.wrapAngleTo180_float((float) Math.toDegrees(angrad1));
                //Average yaw
                angle = ((float) angle + (float) angle1) / 2;
                entityDragon.rotationYawHead = (float) angle1;
            }

            entityDragon.prevRotationYaw = entityDragon.rotationYaw;
            entityDragon.rotationYaw = (float) angle;
            entityDragon.onLivingUpdate();
        }
    }
}
 
Example #26
Source File: DragonCompanion.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@InvokeEvent
public void renderPlayer(RenderPlayerEvent event) {
    if (Minecraft.getMinecraft().theWorld == null || !isPurchasedBy(event.getEntity().getUniqueID())) return;

    HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());

    if (packageIfReady == null || packageIfReady.getCachedSettings().getCurrentCompanion() != EnumPurchaseType.DRAGON_COMPANION)
        return;

    scale = .1F;
    AbstractClientPlayer player = event.getEntity();

    CustomDragon customDragon = dragonHashMap.computeIfAbsent(event.getEntity(), player1 -> {
        EntityDragon dragon = new EntityDragon(player1.getEntityWorld());
        dragon.setSilent(true);
        return new CustomDragon(dragon, new AnimationState());
    });

    Entity entity = customDragon.dragon;
    RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();

    //Manage pos here
    float partialTicks = event.getPartialTicks();

    double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks;
    double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks;
    double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks;

    GlStateManager.pushMatrix();

    EntityDragon entityDragon = customDragon.dragon;
    AnimationState animationState = customDragon.animationState;
    AnimationPoint current = animationState.getCurrent(player);
    entityDragon.posX = current.x / scale;
    entityDragon.posY = current.y / scale;
    entityDragon.posZ = current.z / scale;

    GlStateManager.translate(-((IMixinRenderManager) renderManager).getPosX(),
        -((IMixinRenderManager) renderManager).getPosY(),
        -((IMixinRenderManager) renderManager).getPosZ());

    GlStateManager.translate(d0 * scale, d1 * scale, d2 * scale);
    GlStateManager.scale(scale, scale, scale);

    renderManager.renderEntitySimple(entity, event.getPartialTicks());
    GlStateManager.popMatrix();
    //render
}