/** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityZombieVillager entity) { switch (entity.func_190736_dl()) { case 0: return ZOMBIE_VILLAGER_FARMER_LOCATION; case 1: return ZOMBIE_VILLAGER_LIBRARIAN_LOC; case 2: return ZOMBIE_VILLAGER_PRIEST_LOCATION; case 3: return ZOMBIE_VILLAGER_SMITH_LOCATION; case 4: return ZOMBIE_VILLAGER_BUTCHER_LOCATION; case 5: default: return ZOMBIE_VILLAGER_TEXTURES; } }
private void saveCurrentRenderers(RenderManager rm) { // villagers saveRenderer(rm, EntityVillager.class); saveRenderer(rm, EntityZombieVillager.class); // zombies saveRenderer(rm, EntityZombie.class); saveRenderer(rm, EntityHusk.class); // pig zombie saveRenderer(rm, EntityPigZombie.class); // skeletons saveRenderer(rm, EntitySkeleton.class); saveRenderer(rm, EntityStray.class); saveRenderer(rm, EntityWitherSkeleton.class); // illagers saveRenderer(rm, EntityVex.class); saveRenderer(rm, EntityEvoker.class); saveRenderer(rm, EntityVindicator.class); saveRenderer(rm, EntityIllusionIllager.class); }
@SubscribeEvent public void onZombieVillagerDeath(LivingUpdateEvent event) { if (!event.getEntity().getEntityWorld().isRemote && event.getEntity().isDead && event.getEntity() instanceof EntityZombieVillager) { EntityLiving convertTo = null; if (hasRoyalEffect(event)) { convertTo = new EntityVillageLord(event.getEntity().world); } else if (hasLoyalEffect(event)) { convertTo = new EntityGuard(event.getEntity().world); } if (convertTo == null) { return; } if (handlePossibleConversion((EntityLiving) event.getEntity(), convertTo)) { removeVillager(event); } } }
@SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if(event.getEntity().world.isRemote) { Minecraft mc = Minecraft.getMinecraft(); if(event.getEntity() instanceof EntityFishHook) { fishHooks.add((EntityFishHook)event.getEntity()); } if(event.getEntity() instanceof EntityZombie && !(event.getEntity() instanceof EntityZombieVillager) || event.getEntity() instanceof EntitySkeleton || MobAmputation.config.playerGibs == 1 && event.getEntity() instanceof EntityPlayer && event.getEntity() != mc.player) { EntityLivingBase living = (EntityLivingBase)event.getEntity(); if(!amputationMap.containsKey(living) && !living.isChild()) { attachGibs(event.getEntity().world, living); } } } }
@Override public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, EnumHand hand) { if (entity instanceof EntityZombieVillager && entity.isChild() == false) { EntityZombieVillager zombie = ((EntityZombieVillager) entity); if (zombie.isConverting() == false) { // dont waste a second one if already converting //this is what we WANT to do, but the method is protected. we have to fake it by faking the interact event // zombie.startConverting(1200); consumeSelf(itemstack); startConverting(zombie, CONVTIME); zombie.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, 600, 1)); return true; } } return super.itemInteractionForEntity(itemstack, player, entity, hand); }
public BiomeDesert(Biome.BiomeProperties properties) { super(properties); this.spawnableCreatureList.clear(); this.topBlock = Blocks.SAND.getDefaultState(); this.fillerBlock = Blocks.SAND.getDefaultState(); this.theBiomeDecorator.treesPerChunk = -999; this.theBiomeDecorator.deadBushPerChunk = 2; this.theBiomeDecorator.reedsPerChunk = 50; this.theBiomeDecorator.cactiPerChunk = 10; this.spawnableCreatureList.clear(); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityRabbit.class, 4, 2, 3)); Iterator<Biome.SpawnListEntry> iterator = this.spawnableMonsterList.iterator(); while (iterator.hasNext()) { Biome.SpawnListEntry biome$spawnlistentry = (Biome.SpawnListEntry)iterator.next(); if (biome$spawnlistentry.entityClass == EntityZombie.class || biome$spawnlistentry.entityClass == EntityZombieVillager.class) { iterator.remove(); } } this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityZombie.class, 19, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityZombieVillager.class, 1, 1, 1)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityHusk.class, 80, 4, 4)); }
protected Biome(Biome.BiomeProperties properties) { this.biomeName = properties.biomeName; this.baseHeight = properties.baseHeight; this.heightVariation = properties.heightVariation; this.temperature = properties.temperature; this.rainfall = properties.rainfall; this.waterColor = properties.waterColor; this.enableSnow = properties.enableSnow; this.enableRain = properties.enableRain; this.baseBiomeRegName = properties.baseBiomeRegName; this.theBiomeDecorator = this.createBiomeDecorator(); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntitySheep.class, 12, 4, 4)); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityPig.class, 10, 4, 4)); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityChicken.class, 10, 4, 4)); this.spawnableCreatureList.add(new Biome.SpawnListEntry(EntityCow.class, 8, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySpider.class, 100, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityZombie.class, 95, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityZombieVillager.class, 5, 1, 1)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySkeleton.class, 100, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityCreeper.class, 100, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntitySlime.class, 100, 4, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityEnderman.class, 10, 1, 4)); this.spawnableMonsterList.add(new Biome.SpawnListEntry(EntityWitch.class, 5, 1, 1)); this.spawnableWaterCreatureList.add(new Biome.SpawnListEntry(EntitySquid.class, 10, 4, 4)); this.spawnableCaveCreatureList.add(new Biome.SpawnListEntry(EntityBat.class, 10, 8, 8)); }
protected void spawnVillagers(World worldIn, StructureBoundingBox structurebb, int x, int y, int z, int count) { if (this.villagersSpawned < count) { for (int i = this.villagersSpawned; i < count; ++i) { int j = this.getXWithOffset(x + i, z); int k = this.getYWithOffset(y); int l = this.getZWithOffset(x + i, z); if (!structurebb.isVecInside(new BlockPos(j, k, l))) { break; } ++this.villagersSpawned; if (this.isZombieInfested) { EntityZombieVillager entityzombievillager = new EntityZombieVillager(worldIn); entityzombievillager.setLocationAndAngles((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); entityzombievillager.onInitialSpawn(worldIn.getDifficultyForLocation(new BlockPos(entityzombievillager)), (IEntityLivingData)null); entityzombievillager.func_190733_a(this.chooseProfession(i, 0)); entityzombievillager.enablePersistence(); worldIn.spawnEntityInWorld(entityzombievillager); } else { EntityVillager entityvillager = new EntityVillager(worldIn); entityvillager.setLocationAndAngles((double)j + 0.5D, (double)k, (double)l + 0.5D, 0.0F, 0.0F); entityvillager.setProfession(this.chooseProfession(i, worldIn.rand.nextInt(6))); entityvillager.func_190672_a(worldIn.getDifficultyForLocation(new BlockPos(entityvillager)), (IEntityLivingData)null, false); worldIn.spawnEntityInWorld(entityvillager); } } } }
protected void rotateCorpse(EntityZombieVillager entityLiving, float p_77043_2_, float p_77043_3_, float partialTicks) { if (entityLiving.isConverting()) { p_77043_3_ += (float)(Math.cos((double)entityLiving.ticksExisted * 3.25D) * Math.PI * 0.25D); } super.rotateCorpse(entityLiving, p_77043_2_, p_77043_3_, partialTicks); }
@Override protected void applyRotations(EntityZombieVillager villager, float p_77043_2_, float p_77043_3_, float partialTicks) { if (villager.isConverting()) { p_77043_3_ += (float) (Math.cos(villager.ticksExisted * 3.25D) * Math.PI * 0.25D); } super.applyRotations(villager, p_77043_2_, p_77043_3_, partialTicks); }
@Override public void doRenderLayer(EntityLivingBase entity, float limbSwing, float p_177141_3_, float partialTicks, float p_177141_5_, float p_177141_6_, float p_177141_7_, float scale) { ItemStack itemstack = entity.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.isEmpty()) { AbstractPonyModel model = getModel().getModel(); Item item = itemstack.getItem(); pushMatrix(); boolean isVillager = entity instanceof EntityVillager || entity instanceof EntityZombieVillager; model.transform(BodyPart.HEAD); model.bipedHead.postRender(0.0625f); if (model instanceof ModelPlayerPony) { translate(0, .2, 0); } else { translate(0, 0, .15); } color(1, 1, 1, 1); if (item == Items.SKULL) { renderSkull(itemstack, isVillager, limbSwing); } else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { renderBlock(entity, itemstack); } popMatrix(); } }
private void startConverting(EntityZombieVillager v, int t) { // v.conversionTime = t; ObfuscationReflectionHelper.setPrivateValue(EntityZombieVillager.class, v, t, "conversionTime", "field_82234_d"); v.addPotionEffect(new PotionEffect(MobEffects.STRENGTH, t, Math.min(v.world.getDifficulty().getDifficultyId() - 1, 0))); v.world.setEntityState(v, (byte) 16); try { // v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); DataParameter<Boolean> CONVERTING = ObfuscationReflectionHelper.getPrivateValue(EntityZombieVillager.class, v, "CONVERTING", "field_184739_bx"); v.getDataManager().set(CONVERTING, Boolean.valueOf(true)); } catch (Exception e) {} }
private boolean doZombie(ItemStack itemStack, EntityPlayer player, EntityZombie entity) { if(entity instanceof EntityZombieVillager) return this.doZombieVillager(itemStack, player, (EntityZombieVillager)entity); return false; }
@SubscribeEvent public void somethingDied(LivingDropsEvent event) { if (!"player".equals(event.getSource().damageType)) { return; } EntityLivingBase entity = event.getEntityLiving(); int looting = event.getLootingLevel(); Random rng = entity.getEntityWorld().rand; ItemStack skull = null; if (entity instanceof EntityZombieVillager) { if (rng.nextFloat() < 0.025 + looting * 0.01) { skull = HEADS.get("minecraft:zombie_villager;" + ((EntityZombieVillager) entity).getForgeProfession().getRegistryName().toString()); } } else if (entity instanceof EntityLlama) { if (rng.nextFloat() < 0.025 + looting * 0.01) { skull = HEADS.get("minecraft:llama;" + ((EntityLlama) entity).getVariant()); } } else if (entity instanceof EntityOcelot) { if (rng.nextFloat() < 0.05 + looting * 0.02) { skull = HEADS.get("minecraft:ocelot;" + ((EntityOcelot) entity).getTameSkin()); } } else if (entity instanceof EntityRabbit) { if (rng.nextFloat() < 0.1 + looting * 0.05) { if ("Toast".equals(entity.getCustomNameTag())) { skull = HEADS.get("minecraft:rabbit;Toast"); } else { skull = HEADS.get("minecraft:rabbit;" + ((EntityRabbit) entity).getRabbitType()); } } } else if (entity instanceof EntityParrot) { skull = HEADS.get("minecraft:parrot;" + ((EntityParrot) entity).getVariant()); } else if (entity instanceof EntityHorse) { if (rng.nextFloat() < 0.2 + looting * 0.1) { skull = HEADS.get("minecraft:horse;" + ((EntityHorse) entity).getHorseVariant() % 256); } } else if (entity instanceof EntityWither) { skull = WITHER_HEADS.get(entity.getEntityWorld().rand.nextInt(WITHER_HEADS.size())); } if (skull != null) { event.getDrops().add(new EntityItem(entity.getEntityWorld(), entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ(), skull.copy())); } }
public void doRenderLayer(EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { ItemStack itemstack = entitylivingbaseIn.getItemStackFromSlot(EntityEquipmentSlot.HEAD); if (!itemstack.func_190926_b()) { Item item = itemstack.getItem(); Minecraft minecraft = Minecraft.getMinecraft(); GlStateManager.pushMatrix(); if (entitylivingbaseIn.isSneaking()) { GlStateManager.translate(0.0F, 0.2F, 0.0F); } boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager; if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager)) { float f = 2.0F; float f1 = 1.4F; GlStateManager.translate(0.0F, 0.5F * scale, 0.0F); GlStateManager.scale(0.7F, 0.7F, 0.7F); GlStateManager.translate(0.0F, 16.0F * scale, 0.0F); } this.modelRenderer.postRender(0.0625F); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); if (item == Items.SKULL) { float f2 = 1.1875F; GlStateManager.scale(1.1875F, -1.1875F, -1.1875F); if (flag) { GlStateManager.translate(0.0F, 0.0625F, 0.0F); } GameProfile gameprofile = null; if (itemstack.hasTagCompound()) { NBTTagCompound nbttagcompound = itemstack.getTagCompound(); if (nbttagcompound.hasKey("SkullOwner", 10)) { gameprofile = NBTUtil.readGameProfileFromNBT(nbttagcompound.getCompoundTag("SkullOwner")); } else if (nbttagcompound.hasKey("SkullOwner", 8)) { String s = nbttagcompound.getString("SkullOwner"); if (!StringUtils.isBlank(s)) { gameprofile = TileEntitySkull.updateGameprofile(new GameProfile((UUID)null, s)); nbttagcompound.setTag("SkullOwner", NBTUtil.writeGameProfile(new NBTTagCompound(), gameprofile)); } } } TileEntitySkullRenderer.instance.renderSkull(-0.5F, 0.0F, -0.5F, EnumFacing.UP, 180.0F, itemstack.getMetadata(), gameprofile, -1, limbSwing); } else if (!(item instanceof ItemArmor) || ((ItemArmor)item).getEquipmentSlot() != EntityEquipmentSlot.HEAD) { float f3 = 0.625F; GlStateManager.translate(0.0F, -0.25F, 0.0F); GlStateManager.rotate(180.0F, 0.0F, 1.0F, 0.0F); GlStateManager.scale(0.625F, -0.625F, -0.625F); if (flag) { GlStateManager.translate(0.0F, 0.1875F, 0.0F); } minecraft.getItemRenderer().renderItem(entitylivingbaseIn, itemstack, ItemCameraTransforms.TransformType.HEAD); } GlStateManager.popMatrix(); } }
@Override protected void preRenderCallback(EntityZombieVillager entity, float partialTickTime) { float scale = ((EntityZombieVillagerNemesis) entity).getNemesisScale(); GlStateManager.scale(scale, scale, scale); }
@Override public void doRenderLayer(@NotNull EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { if (BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO).isEmpty()) return; ItemStack halo = BaublesSupport.getItem(entitylivingbaseIn, ModItems.FAKE_HALO, ModItems.CREATIVE_HALO, ModItems.REAL_HALO); if (halo.getItem() == ModItems.FAKE_HALO) { GlStateManager.pushMatrix(); if (entitylivingbaseIn.isSneaking()) GlStateManager.translate(0.0f, 0.2f, 0.0f); boolean flag = entitylivingbaseIn instanceof EntityVillager || entitylivingbaseIn instanceof EntityZombieVillager; if (entitylivingbaseIn.isChild() && !(entitylivingbaseIn instanceof EntityVillager)) { GlStateManager.translate(0.0f, 0.5f * scale, 0.0f); GlStateManager.scale(0.7f, 0.7f, 0.7f); GlStateManager.translate(0.0f, 16.0f * scale, 0.0f); } if (flag) GlStateManager.translate(0.0f, 0.1875f, 0.0f); this.modelRenderer.postRender(0.0625f); GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f); GlStateManager.translate(0.0f, -0.25f, 0.0f); GlStateManager.rotate(180.0f, 0.0f, 1.0f, 0.0f); GlStateManager.scale(0.625f, -0.625f, -0.625f); Minecraft.getMinecraft().getItemRenderer().renderItem(entitylivingbaseIn, halo, ItemCameraTransforms.TransformType.HEAD); GlStateManager.popMatrix(); } else { ParticleBuilder glitter = new ParticleBuilder(3); glitter.setRender(new ResourceLocation(Wizardry.MODID, Constants.MISC.SPARKLE_BLURRED)); glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f)); glitter.disableMotionCalculation(); glitter.disableRandom(); ParticleSpawner.spawn(glitter, entitylivingbaseIn.world, new InterpCircle(entitylivingbaseIn.getPositionVector().addVector(0, entitylivingbaseIn.height + (entitylivingbaseIn.isSneaking() ? 0.2 : 0.4), 0), new Vec3d(0, 1, 0), 0.3f, RandUtil.nextFloat(), RandUtil.nextFloat()), 10, 0, (aFloat, particleBuilder) -> { if (RandUtil.nextInt(10) != 0) if (halo.getItem() == ModItems.CREATIVE_HALO) glitter.setColor(ColorUtils.changeColorAlpha(new Color(0xd600d2), RandUtil.nextInt(60, 100))); else glitter.setColor(ColorUtils.changeColorAlpha(Color.YELLOW, RandUtil.nextInt(60, 100))); else glitter.setColor(ColorUtils.changeColorAlpha(Color.WHITE, RandUtil.nextInt(60, 100))); glitter.setAlphaFunction(new InterpFadeInOut(1f, 1f)); glitter.setLifetime(10); glitter.setScaleFunction(new InterpFadeInOut(0.5f, 0.5f)); glitter.setMotion(new Vec3d(entitylivingbaseIn.motionX / 2.0, (entitylivingbaseIn.motionY + 0.0784) / 2.0, entitylivingbaseIn.motionZ / 2.0)); }); } }
@Override protected ResourceLocation getTexture(EntityZombieVillager villager) { return PROFESSIONS[villager.getProfession()]; }
public void initializeMobRenderers(RenderManager rm) { if (this.config.villagers) { ModUtilities.addRenderer(EntityVillager.class, new RenderPonyVillager(rm)); ModUtilities.addRenderer(EntityZombieVillager.class, new RenderPonyZombieVillager(rm)); logger.info("Villagers are now ponies."); } else { ModUtilities.addRenderer(EntityVillager.class, getRenderer(EntityVillager.class)); ModUtilities.addRenderer(EntityZombieVillager.class, getRenderer(EntityZombieVillager.class)); } if (this.config.zombies) { ModUtilities.addRenderer(EntityZombie.class, new RenderPonyZombie<>(rm)); ModUtilities.addRenderer(EntityHusk.class, new RenderPonyZombie.Husk(rm)); logger.info("Zombies are now ponies."); } else { ModUtilities.addRenderer(EntityZombie.class, getRenderer(EntityZombie.class)); ModUtilities.addRenderer(EntityHusk.class, getRenderer(EntityHusk.class)); } if (this.config.pigzombies) { ModUtilities.addRenderer(EntityPigZombie.class, new RenderPonyPigman(rm)); logger.info("Zombie pigmen are now ponies."); } else { ModUtilities.addRenderer(EntityPigZombie.class, getRenderer(EntityPigZombie.class)); } if (this.config.skeletons) { ModUtilities.addRenderer(EntitySkeleton.class, new RenderPonySkeleton<>(rm)); ModUtilities.addRenderer(EntityStray.class, new RenderPonySkeleton.Stray(rm)); ModUtilities.addRenderer(EntityWitherSkeleton.class, new RenderPonySkeleton.Wither(rm)); logger.info("Skeletons are now ponies."); } else { ModUtilities.addRenderer(EntitySkeleton.class, getRenderer(EntitySkeleton.class)); ModUtilities.addRenderer(EntityStray.class, getRenderer(EntityStray.class)); ModUtilities.addRenderer(EntityWitherSkeleton.class, getRenderer(EntityWitherSkeleton.class)); } if (this.config.illagers) { ModUtilities.addRenderer(EntityVex.class, new RenderPonyVex(rm)); ModUtilities.addRenderer(EntityEvoker.class, new RenderPonyEvoker(rm)); ModUtilities.addRenderer(EntityVindicator.class, new RenderPonyVindicator(rm)); ModUtilities.addRenderer(EntityIllusionIllager.class, new RenderPonyIllusionIllager(rm)); logger.info("Illagers are now ponies."); } else { ModUtilities.addRenderer(EntityVex.class, getRenderer(EntityVex.class)); ModUtilities.addRenderer(EntityEvoker.class, getRenderer(EntityEvoker.class)); ModUtilities.addRenderer(EntityVindicator.class, getRenderer(EntityVindicator.class)); ModUtilities.addRenderer(EntityIllusionIllager.class, getRenderer(EntityIllusionIllager.class)); } }
private boolean hasRoyalEffect(LivingUpdateEvent event) { return ((EntityZombieVillager) event.getEntity()).getActivePotionEffect(PotionRoyal.INSTANCE) != null; }
private boolean hasLoyalEffect(LivingUpdateEvent event) { return ((EntityZombieVillager) event.getEntity()).getActivePotionEffect(PotionLoyalty.INSTANCE) != null; }
protected void spawnZombieMob(EntityLivingBase entityLivingBase) { if (entityLivingBase instanceof EntityLiving) { EntityLiving entity = (EntityLiving) entityLivingBase; EntityLiving zombie = null; if (entity instanceof EntityVillager) { EntityVillager villager = (EntityVillager) entityLivingBase; EntityZombieVillager entityZombie = new EntityZombieVillager(this.getEntityWorld()); entityZombie.copyLocationAndAnglesFrom(entity); this.getEntityWorld().removeEntity(entity); entityZombie.onInitialSpawn(this.getEntityWorld().getDifficultyForLocation(new BlockPos(this)), null); entityZombie.setProfession(villager.getProfession()); entityZombie.setChild(entityLivingBase.isChild()); entityZombie.setNoAI(villager.isAIDisabled()); if (villager.hasCustomName()) { entityZombie.setCustomNameTag(villager.getCustomNameTag()); entityZombie.setAlwaysRenderNameTag(villager.getAlwaysRenderNameTag()); } this.getEntityWorld().spawnEntity(entityZombie); this.getEntityWorld().playEvent(null, 1026, new BlockPos(this), 0); zombie = entityZombie; } else if (entity instanceof EntityWolf) { EntityZombieDog zombieDog = new EntityZombieDog(this.getEntityWorld(), false); zombieDog.copyLocationAndAnglesFrom(entity); this.getEntityWorld().removeEntity(entity); this.getEntityWorld().spawnEntity(zombieDog); this.getEntityWorld().playEvent(null, 1026, new BlockPos(this), 0); zombie = zombieDog; } else if (entity instanceof EntityOcelot) { EntityZombieCat zombieCat = new EntityZombieCat(this.getEntityWorld(), false); zombieCat.copyLocationAndAnglesFrom(entity); if (((EntityOcelot) entity).isTamed()) { zombieCat.setSkin(((EntityOcelot) entity).getTameSkin()); } else { zombieCat.setSkin(0); } this.getEntityWorld().removeEntity(entity); zombieCat.onInitialSpawn(this.getEntityWorld().getDifficultyForLocation(new BlockPos(this)), null); this.getEntityWorld().spawnEntity(zombieCat); this.getEntityWorld().playEvent(null, 1026, new BlockPos(this), 0); zombie = zombieCat; } else if (entity instanceof EntityHorse) { EntityZombieHorse zombieHorse = new EntityZombieHorse(this.getEntityWorld()); zombieHorse.copyLocationAndAnglesFrom(entity); zombieHorse.setGrowingAge(((EntityHorse) entity).getGrowingAge()); this.getEntityWorld().removeEntity(entity); this.getEntityWorld().spawnEntity(zombieHorse); this.getEntityWorld().playEvent(null, 1026, new BlockPos(this), 0); zombie = zombieHorse; } if (zombie != null && entity.hasCustomName()) { zombie.setCustomNameTag(entity.getCustomNameTag()); } } }
private boolean doZombieVillager(ItemStack itemStack, EntityPlayer player, EntityZombieVillager entity) { if(!player.world.isRemote) return false; boolean power = false; int emeraldAt = -1; int appleAt = -1; InventoryPlayer inv = player.inventory; if(player.capabilities.isCreativeMode) power = true; else { int invElements = inv.getSizeInventory(); for(int i = 0; i < invElements; i++) { ItemStack stack = inv.getStackInSlot(i); if(stack == ItemStack.EMPTY) continue; Item item = stack.getItem(); if((item == Items.GOLDEN_APPLE) && (appleAt == -1)) if(stack.getItemDamage() == 0) appleAt = i; else if((item == Items.EMERALD) && (emeraldAt == -1)) emeraldAt = i; } if(appleAt == -1) return false; if(emeraldAt == -1) { int damage = itemStack.getItemDamage(); damage += 21; int maxDamage = itemStack.getMaxDamage(); if(damage <= maxDamage) { itemStack.setItemDamage(damage); power = true; } } else power = true; } if(!power) return false; if(!player.capabilities.isCreativeMode) { inv.decrStackSize(appleAt, 1); inv.decrStackSize(emeraldAt, 1); } entity.startConverting(player.getUniqueID(), 1); return true; }
@Override public float getOffsetPointVert(EntityLivingBase ent) { return ent instanceof EntityZombieVillager ? 10F/16F : 8F/16F; }