@Override public void onHackFinished(Entity entity, EntityPlayer player) { EntityTameable tameable = (EntityTameable) entity; if (entity.world.isRemote) { tameable.handleStatusUpdate((byte) 7); } else { tameable.getNavigator().clearPath(); tameable.setAttackTarget(null); tameable.setHealth(20.0F); tameable.setOwnerId(player.getUniqueID()); entity.world.setEntityState(tameable, (byte) 7); tameable.setTamed(true); // TODO: code smell // Would be better to have a HackableOcelot subclass, but HackableHandler.getHackableForEntity() isn't // set up to prioritise getting an ocelot over a generic tameable. if (entity instanceof EntityOcelot) { ((EntityOcelot) entity).setTameSkin(1 + entity.getEntityWorld().rand.nextInt(3)); } } }
private boolean shouldEat() { if(!Wrapper.getPlayer().canEat(false)) return false; if(Wrapper.getMinecraft().currentScreen != null) return false; if(Wrapper.getMinecraft().currentScreen == null && Wrapper.getMinecraft().objectMouseOver != null) { Entity entity = Wrapper.getMinecraft().objectMouseOver.entityHit; if(entity instanceof EntityVillager || entity instanceof EntityTameable) return false; if(Wrapper.getMinecraft().objectMouseOver.getBlockPos() != null && Wrapper.getWorld(). getBlockState(Wrapper.getMinecraft().objectMouseOver.getBlockPos()).getBlock() instanceof BlockContainer) return false; } return true; }
protected void alertOthers() { double d0 = this.getTargetDistance(); for (EntityCreature entitycreature : this.taskOwner.world.getEntitiesWithinAABB(this.taskOwner.getClass(), (new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0))) { if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && (!(this.taskOwner instanceof EntityTameable) || ((EntityTameable)this.taskOwner).getOwner() == ((EntityTameable)entitycreature).getOwner()) && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget())) { boolean flag = false; for (Class<?> oclass : this.targetClasses) { if (entitycreature.getClass() == oclass) { flag = true; break; } } if (!flag) { this.setEntityAttackTarget(entitycreature, this.taskOwner.getAITarget()); } } } }
protected void alertOthers() { double d0 = this.getTargetDistance(); for (EntityCreature entitycreature : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0))) { if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && (!(this.taskOwner instanceof EntityTameable) || ((EntityTameable)this.taskOwner).getOwner() == ((EntityTameable)entitycreature).getOwner()) && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget())) { boolean flag = false; for (Class<?> oclass : this.targetClasses) { if (entitycreature.getClass() == oclass) { flag = true; break; } } if (!flag) { this.setEntityAttackTarget(entitycreature, this.taskOwner.getAITarget()); } } } }
@Override public void onKillEntity(net.minecraft.entity.EntityLivingBase entity) { super.onKillEntity(entity); if (!(entity instanceof EntityTameable)) { PacketExpToClient packet; this.experience_to_get += entity.getMaxHealth() * 6; packet = new PacketExpToClient(this.experience_to_get); Packets.network.sendTo(packet, this.player); if (entity instanceof EntityOrc || entity instanceof EntityMageOrc) this.getPlayer().triggerAchievement(AchievementList.ORC_SLAYER); else if (entity instanceof EntityBossOrc) this.getPlayer().triggerAchievement(AchievementList.ORC_BOSS); } }
@Override public void performEffect(EntityLivingBase entity, int amplifier) { if (entity != null) { List<EntityLivingBase> mobsList = entity.world.getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(entity.posX - 3, entity.posY - 3, entity.posZ - 3, entity.posX + 3, entity.posY + 3, entity.posZ + 3)); for (EntityLivingBase mob : mobsList) { if (!(mob instanceof EntityTameable && ((EntityTameable) mob).isTamed() || !ExtendedConfig.infernoDealsDamageToPlayers && mob instanceof EntityPlayer)) { mob.setFire(10); } } entity.world.spawnParticle(EnumParticleTypes.FLAME, entity.posX + 1, entity.posY + 1, entity.posZ, 0, 0, 0); entity.world.spawnParticle(EnumParticleTypes.FLAME, entity.posX - 1, entity.posY + 1, entity.posZ, 0, 0, 0); entity.world.spawnParticle(EnumParticleTypes.FLAME, entity.posX, entity.posY + 1, entity.posZ + 1, 0, 0, 0); entity.world.spawnParticle(EnumParticleTypes.FLAME, entity.posX, entity.posY + 1, entity.posZ - 1, 0, 0, 0); } }
@Override public boolean isEntityApplicable(Entity var1) { // This class lets the minion know if they should attack the mob they // are looking at or not. // Never attack the owner, even if he attacks them. if (var1 != owner) { if (var1 instanceof EntityTameable) { if (((EntityTameable) var1).getOwner() != owner) { return true; } else { return false; } } if (var1 instanceof IMob) { return true; } } return false; }
protected void func_190105_f() { double d0 = this.getTargetDistance(); for (EntityCreature entitycreature : this.taskOwner.worldObj.getEntitiesWithinAABB(this.taskOwner.getClass(), (new AxisAlignedBB(this.taskOwner.posX, this.taskOwner.posY, this.taskOwner.posZ, this.taskOwner.posX + 1.0D, this.taskOwner.posY + 1.0D, this.taskOwner.posZ + 1.0D)).expand(d0, 10.0D, d0))) { if (this.taskOwner != entitycreature && entitycreature.getAttackTarget() == null && (!(this.taskOwner instanceof EntityTameable) || ((EntityTameable)this.taskOwner).getOwner() == ((EntityTameable)entitycreature).getOwner()) && !entitycreature.isOnSameTeam(this.taskOwner.getAITarget())) { boolean flag = false; for (Class<?> oclass : this.targetClasses) { if (entitycreature.getClass() == oclass) { flag = true; break; } } if (!flag) { this.setEntityAttackTarget(entitycreature, this.taskOwner.getAITarget()); } } } }
@Override public boolean func_142018_a(EntityLivingBase target, EntityLivingBase owner) { if (!(target instanceof EntityCreeper) && !(target instanceof EntityGhast)) { if (target instanceof EntityTameable) { EntityTameable entityTameable = (EntityTameable) target; if (entityTameable.isTamed() && entityTameable.getOwner() == owner) { return false; } } return target instanceof EntityPlayer && owner instanceof EntityPlayer && !((EntityPlayer) owner).canAttackPlayer((EntityPlayer) target) ? false : !(target instanceof EntityHorse) || !((EntityHorse) target).isTame(); } else { return false; } }
public EntityAITamedNearestAttackableTarget(EntityTameable p_i1665_1_, Class p_i1665_2_, int p_i1665_3_, boolean p_i1665_4_, boolean p_i1665_5_, final IEntitySelector p_i1665_6_) { super(p_i1665_1_, p_i1665_4_, p_i1665_5_); this.tameable = p_i1665_1_; this.targetClass = p_i1665_2_; this.targetChance = p_i1665_3_; this.theNearestAttackableTargetSorter = new EntityAITamedNearestAttackableTarget.Sorter(p_i1665_1_); this.setMutexBits(1); this.targetEntitySelector = new IEntitySelector() { private static final String __OBFID = "CL_00001621"; /** * Return whether the specified entity is applicable to this filter. */ public boolean isEntityApplicable(Entity p_82704_1_) { return p_82704_1_ instanceof EntityLivingBase && (p_i1665_6_ != null && !p_i1665_6_.isEntityApplicable(p_82704_1_) ? false : EntityAITamedNearestAttackableTarget.this.isSuitableTarget((EntityLivingBase) p_82704_1_, false)); } }; }
@Override public boolean onWornTick(World world, ItemStack stack, EntityLivingBase entity) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; double x = player.posX; double y = player.posY; double z = player.posZ; List<EntityTameable> entities = player.worldObj.getEntitiesWithinAABB(EntityTameable.class, AxisAlignedBB.getBoundingBox(x - 8, y - 8, z - 8, x + 8, y + 8, z + 8)); for (EntityTameable entityTame : entities) { if (!player.worldObj.isRemote) { if (player.worldObj.rand.nextInt(60) == 0 && entityTame.isTamed()) { entityTame.heal(1); return true; } } } } return false; }
@Override public int onWornTick(ItemStack stack, EntityLivingBase entity, ITrinket item) { if (!entity.worldObj.isRemote) { List<EntityTameable> entities = getEntitiesAround(entity, 8, EntityTameable.class); for (EntityTameable entityTame : entities) { if (entity.worldObj.rand.nextInt(60) == 0 && entityTame.isTamed() && hasEnergy(item, stack, getUsage())) { entityTame.heal(1); return getUsage(); } } } return 0; }
public final boolean func_130002_c(EntityPlayer p_130002_1_) { if(this.func_110167_bD() && this.func_110166_bE() == p_130002_1_) { this.func_110160_i(true, !p_130002_1_.field_71075_bZ.field_75098_d); return true; } else { ItemStack var2 = p_130002_1_.field_71071_by.func_70448_g(); if(var2 != null && var2.field_77993_c == Item.field_111214_ch.field_77779_bT && this.func_110164_bC()) { if(!(this instanceof EntityTameable) || !((EntityTameable)this).func_70909_n()) { this.func_110162_b(p_130002_1_, true); --var2.field_77994_a; return true; } if(p_130002_1_.func_70005_c_().equalsIgnoreCase(((EntityTameable)this).func_70905_p())) { this.func_110162_b(p_130002_1_, true); --var2.field_77994_a; return true; } } return this.func_70085_c(p_130002_1_)?true:super.func_130002_c(p_130002_1_); } }
public static void addDefaultEntries(){ PneumaticRegistry.getInstance().addHackable(Blocks.tnt, HackableTNT.class); PneumaticRegistry.getInstance().addHackable(Blocks.mob_spawner, HackableMobSpawner.class); PneumaticRegistry.getInstance().addHackable(Blocks.lever, HackableLever.class); PneumaticRegistry.getInstance().addHackable(Blocks.stone_button, HackableButton.class); PneumaticRegistry.getInstance().addHackable(Blocks.wooden_button, HackableButton.class); PneumaticRegistry.getInstance().addHackable(Blocks.wooden_door, HackableDoor.class); PneumaticRegistry.getInstance().addHackable(Blocks.tripwire_hook, HackableTripwire.class); PneumaticRegistry.getInstance().addHackable(Blocks.dispenser, HackableDispenser.class); PneumaticRegistry.getInstance().addHackable(Blocks.dropper, HackableDispenser.class); PneumaticRegistry.getInstance().addHackable(Blockss.securityStation, HackableSecurityStation.class); PneumaticRegistry.getInstance().addHackable(Blocks.monster_egg, HackableTripwire.class); PneumaticRegistry.getInstance().addHackable(Blocks.noteblock, HackableNoteblock.class); PneumaticRegistry.getInstance().addHackable(Blocks.jukebox, HackableJukebox.class); PneumaticRegistry.getInstance().addHackable(EntityCreeper.class, HackableCreeper.class); PneumaticRegistry.getInstance().addHackable(EntityTameable.class, HackableTameable.class); PneumaticRegistry.getInstance().addHackable(EntityCow.class, HackableCow.class); PneumaticRegistry.getInstance().addHackable(EntityCaveSpider.class, HackableCaveSpider.class); PneumaticRegistry.getInstance().addHackable(EntityBlaze.class, HackableBlaze.class); PneumaticRegistry.getInstance().addHackable(EntityGhast.class, HackableGhast.class); PneumaticRegistry.getInstance().addHackable(EntityWitch.class, HackableWitch.class); PneumaticRegistry.getInstance().addHackable(EntityLiving.class, HackableLivingDisarm.class); PneumaticRegistry.getInstance().addHackable(EntityEnderman.class, HackableEnderman.class); PneumaticRegistry.getInstance().addHackable(EntityBat.class, HackableBat.class); }
public static ScriptEntity createFromNative(Entity entity) { if (entity instanceof EntityPlayer) return new ScriptPlayer((EntityPlayer)entity); if (entity instanceof EntityOcelot) return new ScriptOcelot((EntityOcelot)entity); if (entity instanceof EntityWolf) return new ScriptWolf((EntityWolf)entity); if (entity instanceof EntityTameable) return new ScriptEntityTameable((EntityTameable)entity); if (entity instanceof EntityPig) return new ScriptPig((EntityPig)entity); if (entity instanceof EntitySheep) return new ScriptSheep((EntitySheep)entity); if (entity instanceof EntityVillager) return new ScriptVillager((EntityVillager)entity); if (entity instanceof EntityAgeable) return new ScriptEntityAgeable((EntityAgeable)entity); if (entity instanceof EntityLivingBase) return new ScriptEntityLivingBase((EntityLivingBase)entity); return new ScriptEntity(entity); }
private boolean mountTamedPet(AxisAlignedBB petArea, Class petClass) { List<EntityTameable> petsList = this.worldObj.getEntitiesWithinAABB(petClass, petArea); if (!petsList.isEmpty()) { Iterator<EntityTameable> it = petsList.iterator(); EntityTameable pet; while (it.hasNext()) { pet = it.next(); if (pet != null && pet.isTamed() && pet.getOwner() != null && pet.getOwner().equals(this.riddenByEntity) && pet.ridingEntity == null) { pet.setSitting(true); mountMob(pet); return true; } } } return false; }
@Override public void addInfo(Entity entity, List<String> curInfo) { EntityLivingBase owner = ((EntityTameable) entity).getOwner(); if (owner != null) { curInfo.add("Owner: " + owner.getName()); } else { curInfo.add("This animal can be tamed"); } }
public static void addDefaultEntries() { IPneumaticHelmetRegistry manager = PneumaticRegistry.getInstance().getHelmetRegistry(); manager.addHackable(Blocks.TNT, HackableTNT.class); manager.addHackable(Blocks.MOB_SPAWNER, HackableMobSpawner.class); manager.addHackable(Blocks.LEVER, HackableLever.class); manager.addHackable(Blocks.STONE_BUTTON, HackableButton.class); manager.addHackable(Blocks.WOODEN_BUTTON, HackableButton.class); manager.addHackable(Blocks.OAK_DOOR, HackableDoor.class); manager.addHackable(Blocks.SPRUCE_DOOR, HackableDoor.class); manager.addHackable(Blocks.BIRCH_DOOR, HackableDoor.class); manager.addHackable(Blocks.JUNGLE_DOOR, HackableDoor.class); manager.addHackable(Blocks.ACACIA_DOOR, HackableDoor.class); manager.addHackable(Blocks.DARK_OAK_DOOR, HackableDoor.class); manager.addHackable(Blocks.TRIPWIRE_HOOK, HackableTripwire.class); manager.addHackable(Blocks.DISPENSER, HackableDispenser.class); manager.addHackable(Blocks.DROPPER, HackableDispenser.class); manager.addHackable(Blockss.SECURITY_STATION, HackableSecurityStation.class); manager.addHackable(Blocks.MONSTER_EGG, HackableSilverfish.class); manager.addHackable(Blocks.NOTEBLOCK, HackableNoteblock.class); manager.addHackable(Blocks.JUKEBOX, HackableJukebox.class); manager.addHackable(EntityCreeper.class, HackableCreeper.class); manager.addHackable(EntityTameable.class, HackableTameable.class); manager.addHackable(EntityCow.class, HackableCow.class); manager.addHackable(EntityCaveSpider.class, HackableCaveSpider.class); manager.addHackable(EntityBlaze.class, HackableBlaze.class); manager.addHackable(EntityGhast.class, HackableGhast.class); manager.addHackable(EntityWitch.class, HackableWitch.class); manager.addHackable(EntityLiving.class, HackableLivingDisarm.class); manager.addHackable(EntityEnderman.class, HackableEnderman.class); manager.addHackable(EntityBat.class, HackableBat.class); }
public EntityAIFollowOwner(EntityTameable thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) { this.thePet = thePetIn; this.theWorld = thePetIn.worldObj; this.followSpeed = followSpeedIn; this.petPathfinder = thePetIn.getNavigator(); this.minDist = minDistIn; this.maxDist = maxDistIn; this.setMutexBits(3); if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal"); } }
/** * First layer of player interaction */ public final boolean interactFirst(EntityPlayer playerIn) { if (this.getLeashed() && this.getLeashedToEntity() == playerIn) { this.clearLeashed(true, !playerIn.capabilities.isCreativeMode); return true; } else { ItemStack itemstack = playerIn.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() == Items.lead && this.allowLeashing()) { if (!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) { this.setLeashedToEntity(playerIn, true); --itemstack.stackSize; return true; } if (((EntityTameable)this).isOwner(playerIn)) { this.setLeashedToEntity(playerIn, true); --itemstack.stackSize; return true; } } if (this.interact(playerIn)) { return true; } else { return super.interactFirst(playerIn); } } }
private boolean shouldEat() { // check hunger if(!WMinecraft.getPlayer().canEat(false)) return false; // check screen if(!ignoreScreen.isChecked() && mc.currentScreen != null) return false; // check for clickable objects if(mc.currentScreen == null && mc.objectMouseOver != null) { // clickable entities Entity entity = mc.objectMouseOver.entityHit; if(entity instanceof EntityVillager || entity instanceof EntityTameable) return false; // clickable blocks BlockPos pos = mc.objectMouseOver.getBlockPos(); if(pos != null) { Block block = WMinecraft.getWorld().getBlockState(pos).getBlock(); if(block instanceof BlockContainer || block instanceof BlockWorkbench) return false; } } return true; }
private boolean shouldEatSoup() { // check health if(WMinecraft.getPlayer().getHealth() > health.getValueF() * 2F) return false; // check screen if(!ignoreScreen.isChecked() && mc.currentScreen != null) return false; // check for clickable objects if(mc.currentScreen == null && mc.objectMouseOver != null) { // clickable entities Entity entity = mc.objectMouseOver.entityHit; if(entity instanceof EntityVillager || entity instanceof EntityTameable) return false; // clickable blocks if(mc.objectMouseOver.getBlockPos() != null && WBlock.getBlock( mc.objectMouseOver.getBlockPos()) instanceof BlockContainer) return false; } return true; }
/** * First layer of player interaction */ public final boolean interactFirst(EntityPlayer playerIn) { if (this.getLeashed() && this.getLeashedToEntity() == playerIn) { this.clearLeashed(true, !playerIn.capabilities.isCreativeMode); return true; } else { ItemStack itemstack = playerIn.inventory.getCurrentItem(); if (itemstack != null && itemstack.getItem() == Items.lead && this.allowLeashing()) { if (!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) { this.setLeashedToEntity(playerIn, true); --itemstack.stackSize; return true; } if (((EntityTameable)this).isOwner(playerIn)) { this.setLeashedToEntity(playerIn, true); --itemstack.stackSize; return true; } } return this.interact(playerIn) ? true : super.interactFirst(playerIn); } }
public EntityAIFollowOwner(EntityTameable thePetIn, double followSpeedIn, float minDistIn, float maxDistIn) { this.thePet = thePetIn; this.theWorld = thePetIn.world; this.followSpeed = followSpeedIn; this.petPathfinder = thePetIn.getNavigator(); this.minDist = minDistIn; this.maxDist = maxDistIn; this.setMutexBits(3); if (!(thePetIn.getNavigator() instanceof PathNavigateGround)) { throw new IllegalArgumentException("Unsupported mob type for FollowOwnerGoal"); } }
@Override public void onExecutionStart(EntityPlayer player) { ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand(); EnumWeaponWeight weight = EnumWeaponWeight.getWeaponWeight(is); player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 1F); Vec3d playerLook = player.getLookVec(); Vec3d playerPos = player.getPositionVector(); player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0); AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3)); List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player); for (EntityLivingBase ent : lst) { if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player) { continue; } Vec3d ePos = ent.getPositionVector(); Vec3d player2ent = ePos.subtract(playerPos).normalize(); float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook))); if (angle > 60) { continue; } ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.85F)); player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 1, 2F); if (!player.world.isRemote && weight == EnumWeaponWeight.HEAVY && player.world.rand.nextBoolean()) { ent.addPotionEffect(new PotionEffect(ExPPotions.stunned, 100, 0, false, false)); } } }
@Override public void onExecutionTick(EntityPlayer player, int progress) { player.rotationYaw += 40; Vec3d playerLook = player.getLookVec(); Vec3d playerPos = player.getPositionVector(); player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, playerPos.x + playerLook.x, playerPos.y + player.getEyeHeight() * 0.5F, playerPos.z + playerLook.z, 0, 0, 0); AxisAlignedBB aabb = new AxisAlignedBB(playerPos.addVector(-3, -1, -3), playerPos.addVector(3, 3, 3)); List<EntityLivingBase> lst = player.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, e -> e != player); for (EntityLivingBase ent : lst) { if (ent instanceof EntityTameable && ((EntityTameable)ent).getOwner() == player) { continue; } Vec3d ePos = ent.getPositionVector(); Vec3d player2ent = ePos.subtract(playerPos).normalize(); float angle = (float) Math.toDegrees(Math.acos(player2ent.dotProduct(playerLook))); if (angle > 40) { continue; } player.world.playSound(player, ent.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_SWEEP, SoundCategory.PLAYERS, 0.2F, 1.5F); ent.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) (player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue() * 0.75F)); } }
/** * Set entity sneaking */ private void setSneaking(EntityLivingBase entity) { if (entity instanceof EntityTameable) { ((EntityTameable) entity).setSitting(true); } else { entity.setSneaking(true); } }
private static void setTamed(final Entity entity, final EntityPlayer player) { if(entity instanceof EntityHorse) { ((EntityHorse)entity).setTamedBy(player); } else if(entity instanceof EntityTameable) { final EntityTameable tameable = (EntityTameable)entity; tameable.setTamed(true); tameable.func_152115_b(player.getPersistentID().toString()); } }
public MobAIWatchClosestWhenAwake(EntityTameable mob, Class mobThatIsWatched, float watchDistance) { this.theWatcher = mob; this.watchedClass = mobThatIsWatched; this.maxDistanceForPlayer = watchDistance; this.randomWatchChance = 0.02F; this.setMutexBits(2); }
public MobAIWatchClosestWhenAwake(EntityTameable mob, Class watchedClass, float watchDistance, float chanceOfWatch) { this.theWatcher = mob; this.watchedClass = watchedClass; this.maxDistanceForPlayer = watchDistance; this.randomWatchChance = chanceOfWatch; this.setMutexBits(2); }
public EntityAIFollowOwner(EntityTameable par1EntityTameable, double par2, float par4, float par5) { this.thePet = par1EntityTameable; this.theWorld = par1EntityTameable.worldObj; this.field_75336_f = par2; this.petPathfinder = par1EntityTameable.getNavigator(); this.minDist = par4; this.maxDist = par5; this.setMutexBits(3); }
/** * First layer of player interaction */ public final boolean interactFirst(EntityPlayer par1EntityPlayer) { if (this.getLeashed() && this.getLeashedToEntity() == par1EntityPlayer) { this.clearLeashed(true, !par1EntityPlayer.capabilities.isCreativeMode); return true; } else { ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); if (var2 != null && var2.getItem() == Items.lead && this.allowLeashing()) { if (!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed()) { this.setLeashedToEntity(par1EntityPlayer, true); --var2.stackSize; return true; } if (par1EntityPlayer.getCommandSenderName().equalsIgnoreCase(((EntityTameable)this).getOwnerName())) { this.setLeashedToEntity(par1EntityPlayer, true); --var2.stackSize; return true; } } return this.interact(par1EntityPlayer) ? true : super.interactFirst(par1EntityPlayer); } }
@Override public Object getMeta(EntityTameable target, Vec3 relativePos) { Map<String, Object> map = Maps.newHashMap(); boolean isTamed = target.isTamed(); map.put("isTamed", isTamed); if (isTamed) { map.put("isSitting", target.isSitting()); map.put("ownerUUID", target.func_152113_b()); } return map; }
/** * Adds the persistenceRequired flag to entities, if they need it in order to not despawn. * The checks are probably at most accurate for vanilla entities. * @param livingBase * @return */ public static boolean applyMobPersistence(EntityLiving living) { if (living.isNoDespawnRequired() == false) { boolean canDespawn = ((living instanceof EntityMob) && living.isNonBoss()) || (living instanceof EntityWaterMob) || ((living instanceof EntityTameable) && ((EntityTameable)living).isTamed() == false); if (canDespawn == false) { try { canDespawn = (boolean) methodHandle_EntityLiving_canDespawn.invokeExact(living); } catch (Throwable t) { EnderUtilities.logger.warn("Error while trying to invoke EntityLiving.canDespawn() on entity '{}' via a MethodHandle", living, t); } } if (canDespawn) { // Sets the persistenceRequired boolean living.enablePersistence(); living.getEntityWorld().playSound(null, living.getPosition(), Sounds.JAILER, SoundCategory.MASTER, 0.8f, 1.2f); return true; } } return false; }