@Override public void writeEntityToNBT(NBTTagCompound par1NBTTagCompound) { super.writeEntityToNBT(par1NBTTagCompound); par1NBTTagCompound.setTag("Inventory", this.inventory.writeToNBT(new NBTTagList())); par1NBTTagCompound.setInteger("SelectedItemSlot", this.inventory.currentItem); par1NBTTagCompound.setString("zombieName", getPigZombieName()); par1NBTTagCompound.setBoolean("dropItems", dropItems); }
protected void setEntityAttackTarget( EntityCreature creatureIn, EntityLivingBase entityLivingBaseIn) { super.setEntityAttackTarget(creatureIn, entityLivingBaseIn); if (creatureIn instanceof EntityPigZombie) { ((EntityPigZombie) creatureIn).becomeAngryAt(entityLivingBaseIn); } }
@Override public void readEntityFromNBT(NBTTagCompound par1NBTTagCompound) { super.readEntityFromNBT(par1NBTTagCompound); NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); this.inventory.readFromNBT(nbttaglist); this.inventory.currentItem = par1NBTTagCompound.getInteger("SelectedItemSlot"); this.setPigZombieName(par1NBTTagCompound.getString("zombieName")); this.dropItems = par1NBTTagCompound.getBoolean("dropItems"); }
/** Called when a lightning bolt hits the entity. */ public void onStruckByLightning(EntityLightningBolt lightningBolt) { if (!this.worldObj.isRemote && !this.isDead) { EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj); entitypigzombie.setItemStackToSlot( EntityEquipmentSlot.MAINHAND, new ItemStack(Items.GOLDEN_SWORD)); entitypigzombie.setLocationAndAngles( this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); entitypigzombie.setNoAI(this.isAIDisabled()); if (this.hasCustomName()) { entitypigzombie.setCustomNameTag(this.getCustomNameTag()); entitypigzombie.setAlwaysRenderNameTag(this.getAlwaysRenderNameTag()); } this.worldObj.spawnEntityInWorld(entitypigzombie); this.setDead(); } }