net.minecraft.entity.passive.EntityAnimal Java Examples

The following examples show how to use net.minecraft.entity.passive.EntityAnimal. 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: BreedModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
@Listener
public void onUpdate(EventPlayerUpdate event) {
    if (event.getStage() == EventStageable.EventStage.PRE) {
        final Minecraft mc = Minecraft.getMinecraft();
        for(Entity e : mc.world.loadedEntityList) {
            if(e != null && e instanceof EntityAnimal) {
                final EntityAnimal animal = (EntityAnimal) e;
                if(animal.getHealth() > 0) {
                    if (!animal.isChild() && !animal.isInLove() && mc.player.getDistance(animal) <= 4.5f && animal.isBreedingItem(mc.player.inventory.getCurrentItem())) {
                        mc.playerController.interactWithEntity(mc.player, animal, EnumHand.MAIN_HAND);
                    }
                }
            }
        }
    }
}
 
Example #2
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
private void feedBaby(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
	int currentAge = animal.getGrowingAge();
	int age = (int) (-currentAge * 0.1F);
	animal.setGrowingAge(currentAge + age);
	player.swingItem();

	Random itemRand = animal.worldObj.rand;
	for (int i = 0; i < 3; i++) {
		double d0 = itemRand.nextGaussian() * 0.02D;
		double d1 = itemRand.nextGaussian() * 0.02D;
		double d2 = itemRand.nextGaussian() * 0.02D;
		animal.worldObj.spawnParticle("happyVillager", animal.posX + itemRand.nextFloat() * 0.5, animal.posY + 0.5 + itemRand.nextFloat() * 0.5, animal.posZ + itemRand.nextFloat() * 0.5, d0, d1, d2);
	}

	if (!player.capabilities.isCreativeMode)
		if (--stack.stackSize <= 0)
			player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
}
 
Example #3
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
	ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
	if (stack == null)
		return;
	if (!(event.target instanceof EntityAnimal))
		return;

	EntityAnimal animal = (EntityAnimal) event.target;
	if (!animal.isChild()) {
		if (animal instanceof EntityPig) {
			if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
		} else if (animal instanceof EntityChicken)
			if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
				setAnimalInLove(animal, event.entityPlayer, stack);
	} else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
		feedBaby(animal, event.entityPlayer, stack);
}
 
Example #4
Source File: CivilizationHandlers.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void breed(BabyEntitySpawnEvent event) {
	if (!ToroQuestConfiguration.animalsAffectRep) {
		return;
	}
	if (!(event.getParentA() instanceof EntityAnimal)) {
		return;
	}

	if (!(event.getParentB() instanceof EntityAnimal)) {
		return;
	}

	EntityPlayer playerA = ((EntityAnimal) event.getParentA()).getLoveCause();
	EntityPlayer playerB = ((EntityAnimal) event.getParentB()).getLoveCause();

	if (playerA != null) {
		adjustPlayerRep(playerA, event.getParentA().chunkCoordX, event.getParentA().chunkCoordZ, 1);
	}

	if (playerB != null) {
		adjustPlayerRep(playerB, event.getParentB().chunkCoordX, event.getParentB().chunkCoordZ, 1);
	}
}
 
Example #5
Source File: PneumaticCraftUtils.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static boolean isEntityValidForName(String filter, Entity entity) throws IllegalArgumentException{
    if(filter.equals("")) {
        return true;
    } else if(filter.startsWith("@")) {//entity type selection
        filter = filter.substring(1); //cut off the '@'.
        Class typeClass = null;
        if(filter.equals("mob")) {
            typeClass = EntityMob.class;
        } else if(filter.equals("animal")) {
            typeClass = EntityAnimal.class;
        } else if(filter.equals("living")) {
            typeClass = EntityLivingBase.class;
        } else if(filter.equals("player")) {
            typeClass = EntityPlayer.class;
        } else if(filter.equals("item")) {
            typeClass = EntityItem.class;
        } else if(filter.equals("minecart")) {
            typeClass = EntityMinecart.class;
        } else if(filter.equals("drone")) {
            typeClass = EntityDrone.class;
        }
        if(typeClass != null) {
            return typeClass.isAssignableFrom(entity.getClass());
        } else {
            throw new IllegalArgumentException(filter + " is not a valid entity type.");
        }
    } else {
        try {
            String regex = filter.toLowerCase().replaceAll(".", "[$0]").replace("[*]", ".*");//Wildcard regex
            return entity.getCommandSenderName().toLowerCase().matches(regex);//TODO when player, check if entity is tamed by the player (see EntityAIAvoidEntity for example)
        } catch(PatternSyntaxException e) {
            return entity.getCommandSenderName().toLowerCase().equals(filter.toLowerCase());
        }
    }
}
 
Example #6
Source File: EntityDeer.java    From Sakura_mod with MIT License 5 votes vote down vote up
protected void initEntityAI()
{
    this.tasks.addTask(0, new EntityAISwimming(this));
    this.tasks.addTask(1, new EntityAIPanic(this, 1.25D));
    this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
    this.tasks.addTask(4, new EntityAITempt(this, 1.2D, Items.WHEAT, true));
    this.tasks.addTask(5, new EntityAIFollowParent(this, 1.1D));
    this.tasks.addTask(6, new EntityAIWanderAvoidWater(this, 1.0D));
    this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 7.0F));
    this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityAnimal.class, 6.0F));
    this.tasks.addTask(9, new EntityAILookIdle(this));
}
 
Example #7
Source File: UpgradeKilling.java    From BetterChests with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void update(IUpgradableBlock chest, ItemStack stack) {
	if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 100) != 0) {
		return;
	}

	AxisAlignedBB bb = new AxisAlignedBB(chest.getPosition()).grow(RADIUS);

	TObjectIntMap<Class<? extends EntityLiving>> map = new TObjectIntHashMap<>();

	for (EntityLiving entity : chest.getWorldObj().getEntitiesWithinAABB(EntityLiving.class, bb)) {
		if (entity.isDead) {
			continue;
		}

		if (entity instanceof EntityAnimal) {
			EntityAnimal animal = (EntityAnimal) entity;
			if (entity.isChild()) {
				continue;
			}
			int currentAnimals = map.get(animal.getClass());
			if (currentAnimals < ANIMALS_TO_KEEP_ALIVE) {
				map.put(animal.getClass(), currentAnimals + 1);
				continue;
			}
		}

		if (hasUpgradeOperationCost(chest)) {
			EntityPlayer source = null;
			if (chest.isUpgradeInstalled(DummyUpgradeType.AI.getStack())) {
				source = chest.getFakePlayer();
			}
			entity.attackEntityFrom(getDamageSource(source), 10);
			drawUpgradeOperationCode(chest);
		}
	}
}
 
Example #8
Source File: EntityFluidCow.java    From Moo-Fluids with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean canMateWith(EntityAnimal entityAnimal) {
  if (entityAnimal != this) {
    if (isInLove() && entityAnimal.isInLove()) {
      if (entityAnimal instanceof EntityFluidCow) {
        final Fluid mateEntityFluid = ((EntityFluidCow) entityAnimal).getEntityFluid();
        if (getEntityFluid().getName().equals(mateEntityFluid.getName())) {
          return true;
        }
      }
    }
  }

  return false;
}
 
Example #9
Source File: EntityAIHerdMove.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public EntityAIHerdMove(EntityAnimal creatureIn, double speedIn, int chance)
{
	this.entity = creatureIn;
	this.speed = speedIn;
	this.executionChance = chance;
	this.setMutexBits(1);
}
 
Example #10
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private boolean isFoodItem(EntityAnimal animal, ItemStack food) {
	if (animal.isBreedingItem(food))
		return true;
	else if (animal instanceof EntityPig && food.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
		return true;
	else if (animal instanceof EntityChicken && food.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
		return true;
	else
		return false;
}
 
Example #11
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 5 votes vote down vote up
private void setAnimalInLove(EntityAnimal animal, EntityPlayer player, ItemStack stack) {
	if (!animal.isInLove()) {
		animal.func_146082_f(player);
		if (!player.capabilities.isCreativeMode)
			if (--stack.stackSize <= 0)
				player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
	}
}
 
Example #12
Source File: EntityVampireBat.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
protected void initEntityAI() {
	tasks.addTask(2, new EntityAIAttackMelee(this, 0.4D, false));
	targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true));
	targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityToroNpc.class, true));
	targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityVillager.class, false));
	targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntityAnimal.class, false));
}
 
Example #13
Source File: RadarHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	EntityPlayerSP player = event.getPlayer();
	World world = WPlayer.getWorld(player);
	
	entities.clear();
	Stream<Entity> stream = world.loadedEntityList.parallelStream()
		.filter(e -> !e.isDead && e != player)
		.filter(e -> !(e instanceof EntityFakePlayer))
		.filter(e -> e instanceof EntityLivingBase)
		.filter(e -> ((EntityLivingBase)e).getHealth() > 0);
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer
			&& ((EntityPlayer)e).isPlayerSleeping()));
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof IMob));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAnimal
			|| e instanceof EntityAmbientCreature
			|| e instanceof EntityWaterMob));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	entities.addAll(stream.collect(Collectors.toList()));
}
 
Example #14
Source File: ActivationRange.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity) {
    // quick checks.
    if (entity.inWater || entity.fire > 0) {
        return true;
    }
    if (!(entity instanceof EntityArrow)) {
        if (!entity.onGround || !entity.riddenByEntities.isEmpty() || entity.isRiding()) {
            return true;
        }
    } else if (!((EntityArrow) entity).inGround) {
        return true;
    }
    // special cases.
    if (entity instanceof EntityLiving) {
        EntityLiving living = (EntityLiving) entity;
        if ( /*TODO: Missed mapping? living.attackTicks > 0 || */ living.hurtTime > 0 || living.activePotionsMap.size() > 0) {
            return true;
        }
        if (entity instanceof EntityCreature && ((EntityCreature) entity).getAttackTarget() != null) {
            return true;
        }
        if (entity instanceof EntityVillager && ((EntityVillager) entity).isMating()) {
            return true;
        }
        if (entity instanceof EntityAnimal) {
            EntityAnimal animal = (EntityAnimal) entity;
            if (animal.isChild() || animal.isInLove()) {
                return true;
            }
            if (entity instanceof EntitySheep && ((EntitySheep) entity).getSheared()) {
                return true;
            }
        }
        if (entity instanceof EntityCreeper && ((EntityCreeper) entity).hasIgnited()) { // isExplosive
            return true;
        }
    }
    return false;
}
 
Example #15
Source File: MixinEntityRenderer.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "orientCamera", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Vec3;distanceTo(Lnet/minecraft/util/Vec3;)D"), cancellable = true)
private void cameraClip(float partialTicks, CallbackInfo callbackInfo) {
    if (LiquidBounce.moduleManager.getModule(CameraClip.class).getState()) {
        callbackInfo.cancel();

        Entity entity = this.mc.getRenderViewEntity();
        float f = entity.getEyeHeight();

        if(entity instanceof EntityLivingBase && ((EntityLivingBase) entity).isPlayerSleeping()) {
            f = (float) ((double) f + 1D);
            GlStateManager.translate(0F, 0.3F, 0.0F);

            if(!this.mc.gameSettings.debugCamEnable) {
                BlockPos blockpos = new BlockPos(entity);
                IBlockState iblockstate = this.mc.theWorld.getBlockState(blockpos);
                net.minecraftforge.client.ForgeHooksClient.orientBedCamera(this.mc.theWorld, blockpos, iblockstate, entity);

                GlStateManager.rotate(entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F, 0.0F, -1.0F, 0.0F);
                GlStateManager.rotate(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks, -1.0F, 0.0F, 0.0F);
            }
        }else if(this.mc.gameSettings.thirdPersonView > 0) {
            double d3 = (double) (this.thirdPersonDistanceTemp + (this.thirdPersonDistance - this.thirdPersonDistanceTemp) * partialTicks);

            if(this.mc.gameSettings.debugCamEnable) {
                GlStateManager.translate(0.0F, 0.0F, (float) (-d3));
            }else{
                float f1 = entity.rotationYaw;
                float f2 = entity.rotationPitch;

                if(this.mc.gameSettings.thirdPersonView == 2)
                    f2 += 180.0F;

                if(this.mc.gameSettings.thirdPersonView == 2)
                    GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F);

                GlStateManager.rotate(entity.rotationPitch - f2, 1.0F, 0.0F, 0.0F);
                GlStateManager.rotate(entity.rotationYaw - f1, 0.0F, 1.0F, 0.0F);
                GlStateManager.translate(0.0F, 0.0F, (float) (-d3));
                GlStateManager.rotate(f1 - entity.rotationYaw, 0.0F, 1.0F, 0.0F);
                GlStateManager.rotate(f2 - entity.rotationPitch, 1.0F, 0.0F, 0.0F);
            }
        }else
            GlStateManager.translate(0.0F, 0.0F, -0.1F);

        if(!this.mc.gameSettings.debugCamEnable) {
            float yaw = entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTicks + 180.0F;
            float pitch = entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTicks;
            float roll = 0.0F;
            if(entity instanceof EntityAnimal) {
                EntityAnimal entityanimal = (EntityAnimal) entity;
                yaw = entityanimal.prevRotationYawHead + (entityanimal.rotationYawHead - entityanimal.prevRotationYawHead) * partialTicks + 180.0F;
            }

            Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.mc.theWorld, entity, partialTicks);
            net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup event = new net.minecraftforge.client.event.EntityViewRenderEvent.CameraSetup((EntityRenderer) (Object) this, entity, block, partialTicks, yaw, pitch, roll);
            net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
            GlStateManager.rotate(event.roll, 0.0F, 0.0F, 1.0F);
            GlStateManager.rotate(event.pitch, 1.0F, 0.0F, 0.0F);
            GlStateManager.rotate(event.yaw, 0.0F, 1.0F, 0.0F);
        }

        GlStateManager.translate(0.0F, -f, 0.0F);
        double d0 = entity.prevPosX + (entity.posX - entity.prevPosX) * (double) partialTicks;
        double d1 = entity.prevPosY + (entity.posY - entity.prevPosY) * (double) partialTicks + (double) f;
        double d2 = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) partialTicks;
        this.cloudFog = this.mc.renderGlobal.hasCloudFog(d0, d1, d2, partialTicks);
    }
}
 
Example #16
Source File: UpgradeBreeding.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
private boolean isEntityOk(EntityAnimal entity) {
	return !entity.isDead && !entity.isInLove() && entity.getGrowingAge() == 0;
}
 
Example #17
Source File: EntityUtils.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isAnimal(final Entity entity) {
    return entity instanceof EntityAnimal || entity instanceof EntitySquid || entity instanceof EntityGolem ||
            entity instanceof EntityBat;
}
 
Example #18
Source File: EntityFallenMount.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public boolean canMateWith(EntityAnimal p_70878_1_) {
  return false;
}
 
Example #19
Source File: EntityHamster.java    From Hyperium with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canMateWith(EntityAnimal otherAnimal) {
    return false;
}
 
Example #20
Source File: CraftAnimals.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftAnimals(CraftServer server, EntityAnimal entity) {
    super(server, entity);
}
 
Example #21
Source File: EntityAIHerdMove.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public EntityAIHerdMove(EntityAnimal creatureIn, double speedIn)
{
	this(creatureIn, speedIn, 120);
}
 
Example #22
Source File: CraftAnimals.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityAnimal getHandle() {
    return (EntityAnimal) entity;
}
 
Example #23
Source File: KillauraHack.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onUpdate(WUpdateEvent event)
{
	EntityPlayerSP player = event.getPlayer();
	World world = WPlayer.getWorld(player);
	
	if(player.getCooledAttackStrength(0) < 1)
		return;
	
	double rangeSq = Math.pow(range.getValue(), 2);
	Stream<EntityLivingBase> stream = world.loadedEntityList
		.parallelStream().filter(e -> e instanceof EntityLivingBase)
		.map(e -> (EntityLivingBase)e)
		.filter(e -> !e.isDead && e.getHealth() > 0)
		.filter(e -> WEntity.getDistanceSq(player, e) <= rangeSq)
		.filter(e -> e != player)
		.filter(e -> !(e instanceof EntityFakePlayer));
	
	if(filterPlayers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer));
	
	if(filterSleeping.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPlayer
			&& ((EntityPlayer)e).isPlayerSleeping()));
	
	if(filterFlying.getValue() > 0)
		stream = stream.filter(e -> {
			
			if(!(e instanceof EntityPlayer))
				return true;
			
			AxisAlignedBB box = e.getEntityBoundingBox();
			box = box.union(box.offset(0, -filterFlying.getValue(), 0));
			// Using expand() with negative values doesn't work in 1.10.2.
			return world.collidesWithAnyBlock(box);
		});
	
	if(filterMonsters.isChecked())
		stream = stream.filter(e -> !(e instanceof IMob));
	
	if(filterPigmen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityPigZombie));
	
	if(filterEndermen.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityEnderman));
	
	if(filterAnimals.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAnimal
			|| e instanceof EntityAmbientCreature
			|| e instanceof EntityWaterMob));
	
	if(filterBabies.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityAgeable
			&& ((EntityAgeable)e).isChild()));
	
	if(filterPets.isChecked())
		stream = stream
			.filter(e -> !(e instanceof EntityTameable
				&& ((EntityTameable)e).isTamed()))
			.filter(e -> !WEntity.isTamedHorse(e));
	
	if(filterVillagers.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityVillager));
	
	if(filterGolems.isChecked())
		stream = stream.filter(e -> !(e instanceof EntityGolem));
	
	if(filterInvisible.isChecked())
		stream = stream.filter(e -> !e.isInvisible());
	
	target = stream.min(priority.getSelected().comparator).orElse(null);
	if(target == null)
		return;
	
	RotationUtils
		.faceVectorPacket(target.getEntityBoundingBox().getCenter());
	mc.playerController.attackEntity(player, target);
	player.swingArm(EnumHand.MAIN_HAND);
}
 
Example #24
Source File: ActivationRange.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
/**
 * If an entity is not in range, do some more checks to see if we should
 * give it a shot.
 *
 * @param entity
 * @return
 */
public static boolean checkEntityImmunities(Entity entity)
{
    // quick checks.
    if ( entity.inWater /* isInWater */ || entity.fire > 0 )
    {
        return true;
    }
    if ( !( entity instanceof EntityArrow ) )
    {
        if ( !entity.onGround || entity.riddenByEntity != null
                || entity.ridingEntity != null )
        {
            return true;
        }
    } else if ( !( (EntityArrow) entity ).inGround )
    {
        return true;
    }
    // special cases.
    if ( entity instanceof EntityLiving )
    {
        EntityLiving living = (EntityLiving) entity;
        if ( living.attackTime > 0 || living.hurtTime > 0 || living.activePotionsMap.size() > 0 )
        {
            return true;
        }
        if ( entity instanceof EntityCreature && ( (EntityCreature) entity ).entityToAttack != null )
        {
            return true;
        }
        if ( entity instanceof EntityVillager && ( (EntityVillager) entity ).isMating() /* Getter for first boolean */ )
        {
            return true;
        }
        if ( entity instanceof EntityAnimal )
        {
            EntityAnimal animal = (EntityAnimal) entity;
            if ( animal.isChild() || animal.isInLove() /*love*/ )
            {
                return true;
            }
            if ( entity instanceof EntitySheep && ( (EntitySheep) entity ).getSheared() )
            {
                return true;
            }
        }
    }
    return false;
}
 
Example #25
Source File: CraftAnimals.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityAnimal getHandle() {
    return (EntityAnimal) entity;
}
 
Example #26
Source File: CraftAnimals.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftAnimals(CraftServer server, EntityAnimal entity) {
    super(server, entity);
}
 
Example #27
Source File: BlockFluidWitchwater.java    From ExNihiloAdscensio with MIT License 4 votes vote down vote up
@Override
public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) {
	
	if (world.isRemote)
		return;
	
	if (entity.isDead)
		return;
	
	if (entity instanceof EntitySkeleton) {
		
		EntitySkeleton skeleton = (EntitySkeleton) entity;
		if (skeleton.getSkeletonType() == SkeletonType.NORMAL) {
			skeleton.setSkeletonType(SkeletonType.WITHER);
			skeleton.setHealth(skeleton.getMaxHealth());
			
			return;
		}
	}
	
	if (entity instanceof EntityCreeper) {
		EntityCreeper creeper = (EntityCreeper) entity;
		if (!creeper.getPowered()) {
			creeper.onStruckByLightning(null);
			creeper.setHealth(creeper.getMaxHealth());
			
			return;
		}
	}
	
	if (entity instanceof EntitySpider && !(entity instanceof EntityCaveSpider)) {
		EntitySpider spider = (EntitySpider) entity;
		spider.setDead();
		
		EntityCaveSpider caveSpider = new EntityCaveSpider(world);
		caveSpider.setLocationAndAngles(spider.posX, spider.posY, spider.posZ, spider.rotationYaw, spider.rotationPitch);
		caveSpider.renderYawOffset = spider.renderYawOffset;
		caveSpider.setHealth(caveSpider.getMaxHealth());
		
		world.spawnEntity(caveSpider);
		
		return;
	}
	
	if (entity instanceof EntitySquid) {
		EntitySquid squid = (EntitySquid) entity;
		squid.setDead();
		
		EntityGhast ghast = new EntityGhast(world);
		ghast.setLocationAndAngles(squid.posX, squid.posY, squid.posZ, squid.rotationYaw, squid.rotationPitch);
		ghast.renderYawOffset = squid.renderYawOffset;
		ghast.setHealth(ghast.getMaxHealth());
		
		world.spawnEntity(ghast);
		
		return;
	}
	
	if (entity instanceof EntityAnimal) {
		((EntityAnimal) entity).onStruckByLightning(null);
		return;
	}
	
	if (entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) entity;
		player.addPotionEffect(new PotionEffect(MobEffects.BLINDNESS, 210, 0));
		player.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, 210, 2));
		player.addPotionEffect(new PotionEffect(MobEffects.WITHER, 210, 0));
		player.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 210, 0));
	}
}
 
Example #28
Source File: EntityFairy.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean canMateWith(@NotNull EntityAnimal otherAnimal) {
	return false;
}