package openblocks.common.entity;

import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import openblocks.OpenBlocks;
import openblocks.common.GenericInventory;
import openblocks.common.entity.ai.EntityAICollectItem;
import openblocks.utils.BlockUtils;

public class EntityLuggage extends EntityTameable {

	private GenericInventory inventory = new GenericInventory("luggage", false, 27);
	private boolean special;
	
	public int lastSound = 0;
	
	public EntityLuggage(World world) {
		super(world);
		this.texture = OpenBlocks.getTexturesPath("models/luggage.png");
		this.setSize(0.5F, 0.5F);
		this.moveSpeed = 0.4F;
		setTamed(true);
		this.getNavigator().setAvoidsWater(true);
		this.getNavigator().setCanSwim(true);
		this.tasks.addTask(1, new EntityAISwimming(this));
		this.tasks.addTask(2, new EntityAIFollowOwner(this, this.moveSpeed, 10.0F, 2.0F));
		this.tasks.addTask(3, new EntityAICollectItem(this));
	}
	
	protected void setSpecial() {
		if(special) return;
		special = true;
		this.texture = OpenBlocks.getTexturesPath("models/luggage_special.png");
		GenericInventory inventory = new GenericInventory("luggage", false, 54);
		inventory.copyFrom(this.inventory);
		this.inventory = inventory;
	}
	
	public boolean isSpecial() {
		return special;
	}
	
	public void onLivingUpdate() {
		super.onLivingUpdate();
		lastSound++;
	}

	public boolean isAIEnabled() {
		return true;
	}

	@Override
	public int getMaxHealth() {
		return 100;
	}

	public GenericInventory getInventory() {
		return inventory;
	}
	
	@Override
	public EntityAgeable createChild(EntityAgeable entityageable) {
		return null;
	}

	@Override
	public boolean interact(EntityPlayer player) {
		if (!worldObj.isRemote) {
			if (player.isSneaking()) {
				ItemStack luggageItem = new ItemStack(OpenBlocks.Items.luggage);
				NBTTagCompound tag = new NBTTagCompound();
				inventory.writeToNBT(tag);
				luggageItem.setTagCompound(tag);
				BlockUtils.dropItemStackInWorld(worldObj, posX, posY, posZ, luggageItem);
				setDead();
			} else {
				player.openGui(OpenBlocks.instance, OpenBlocks.Gui.Luggage.ordinal(), player.worldObj, entityId, 0, 0);
			}
		}
		return true;
	}
	
	public boolean canConsumeStackPartially(ItemStack stack) {
		return BlockUtils.testInventoryInsertion(inventory, stack) > 0;
	}
	
    protected void playStepSound(int par1, int par2, int par3, int par4) {
        this.playSound("openblocks.feet", 0.3F, 0.7F + (worldObj.rand.nextFloat() * 0.5f));
    }
	
	@Override
	public void writeEntityToNBT(NBTTagCompound tag) {
        super.writeEntityToNBT(tag);
        inventory.writeToNBT(tag);
    }

	@Override
	public void readEntityFromNBT(NBTTagCompound tag) {
        super.readEntityFromNBT(tag);
        inventory.readFromNBT(tag);
    }
	
	@Override
	public void onStruckByLightning(EntityLightningBolt lightning) {
		setSpecial();
	}

	@Override
	public boolean isEntityInvulnerable() {
		return true;
	}
}

@@ -3054,32 +3054,74 @@
 tityToNBT(tag);%0A
+        tag.setBoolean(%22shiny%22, special);%0A
         inventor
@@ -3240,32 +3240,105 @@
 tyFromNBT(tag);%0A
+        if(tag.hasKey(%22shiny%22) && tag.getBoolean(%22shiny%22)) setSpecial();%0A
         inventor

Add shiny to NBT