@Override protected Optional<Boolean> getVal(EntityTameable container) { return Optional.of(container.isSitting()); }
@Override public boolean interact(EntityPlayer player) { ItemStack itemstack = player.inventory.getCurrentItem(); if (!this.worldObj.isRemote) { // Allow taming in creative mode without items if (!this.isTamed() && player.capabilities.isCreativeMode) { this.func_152115_b(player.getUniqueID().toString()); // Set owner UUID this.setTamed(true); } // If tamed if (this.isTamed()) { // If player has item if (itemstack != null) { // If armour, equip it if (itemstack.getItem() instanceof ItemArmor && !player.isSneaking()) { int i = EntityLiving.getArmorPosition(itemstack) - 1; if (this.getEquipmentInSlot(i + 1) == null) { this.setCurrentItemOrArmor(i + 1, itemstack.copy()); if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); } else { EntityItem entityItem = new EntityItem( this.worldObj, this.posX, this.posY, this.posZ, this.getEquipmentInSlot(i + 1)); this.worldObj.spawnEntityInWorld(entityItem); this.setCurrentItemOrArmor(i + 1, null); } return true; } // If lead and mounted, unmount else if (itemstack.getItem() == Items.lead && this.isRiding() && !player.isSneaking()) this.mountEntity(null); // If entity is holding something and player is holding a stick, drop current item else if (itemstack.getItem() == Items.stick && this.getHeldItem() != null) { EntityItem entityItem = new EntityItem( player.worldObj, this.posX, this.posY, this.posZ, this.getHeldItem().copy()); player.worldObj.spawnEntityInWorld(entityItem); this.setCarrying(null); // Drop chest contents for (int i = 0; i < inventory.getSizeInventory(); i++) { ItemStack itemStackToDrop = inventory.getStackInSlot(i); if (itemStackToDrop != null) { entityItem = new EntityItem( player.worldObj, this.posX, this.posY, this.posZ, itemStackToDrop); player.worldObj.spawnEntityInWorld(entityItem); } inventory.setInventorySlotContents(i, null); } } else if (this.getHeldItem() == null) { ItemStack newItemStack = itemstack.copy(); newItemStack.stackSize = 1; this.setCarrying(newItemStack); player.playSound( "mob.chickenplop", 1.0F, (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0) player.inventory.setInventorySlotContents(player.inventory.currentItem, null); } } // If entity is holding something and player isn't, open GUI if (this.getHeldItem() != null && !player.isSneaking()) { if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.chest) player.openGui(MiniCreatures.instance, 0, player.worldObj, this.getEntityId(), 0, 0); else if (Block.getBlockFromItem(this.getHeldItem().getItem()) == Blocks.anvil) player.openGui( MiniCreatures.instance, 1, player.worldObj, (int) this.posX, (int) this.posY, (int) this.posZ); } else if (player.isEntityEqual(this.getOwner()) && !this.worldObj.isRemote) { if (this.isRiding()) { EntityTameable ridingEntity = (EntityTameable) this.ridingEntity; ridingEntity.func_70907_r().setSitting(!ridingEntity.isSitting()); ridingEntity.setSitting(!ridingEntity.isSitting()); ridingEntity.setJumping(false); ridingEntity.setPathToEntity(null); ridingEntity.setTarget(null); ridingEntity.setAttackTarget(null); } else { this.aiSit.setSitting(!this.isSitting()); this.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity(null); this.setTarget(null); this.setAttackTarget(null); } } } } return super.interact(player); }