public boolean a(ItemStack itemstack, EntityLiving entityliving) { if (entityliving instanceof EntitySheep) { EntitySheep entitysheep = (EntitySheep) entityliving; int i = BlockCloth.e_(itemstack.getData()); if (!entitysheep.isSheared() && entitysheep.getColor() != i) { // CraftBukkit start byte bColor = (byte) i; SheepDyeWoolEvent event = new SheepDyeWoolEvent( (org.bukkit.entity.Sheep) entitysheep.getBukkitEntity(), org.bukkit.DyeColor.getByData(bColor)); entitysheep.world.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } i = (byte) event.getColor().getData(); // CraftBukkit end entitysheep.setColor(i); --itemstack.count; } return true; } else { return false; } }
public String getItemNameIS(ItemStack itemstack) { return (new StringBuilder()) .append(super.getItemName()) .append(".") .append(ItemDye.dyeColorNames[BlockCloth.getBlockFromDye(itemstack.getItemDamage())]) .toString(); }
public boolean interact(EntityPlayer entityplayer) { ItemStack itemstack = entityplayer.inventory.getCurrentItem(); if (itemstack != null && itemstack.itemID == Item.shears.shiftedIndex && !getSheared()) { if (!worldObj.multiplayerWorld) { if (getPuffed()) { setPuffed(false); int i = 2 + rand.nextInt(3); for (int l = 0; l < i; l++) { EntityItem entityitem = entityDropItem(new ItemStack(Block.cloth.blockID, 1, getFleeceColor()), 1.0F); entityitem.motionY += rand.nextFloat() * 0.05F; entityitem.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; entityitem.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; } } else { setSheared(true); int j = 2 + rand.nextInt(3); for (int i1 = 0; i1 < j; i1++) { EntityItem entityitem1 = entityDropItem(new ItemStack(Block.cloth.blockID, 1, getFleeceColor()), 1.0F); entityitem1.motionY += rand.nextFloat() * 0.05F; entityitem1.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F; entityitem1.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F; } } } itemstack.damageItem(1, entityplayer); } if (itemstack != null && itemstack.itemID == Item.dyePowder.shiftedIndex && !getSheared()) { int k = BlockCloth.func_21034_c(itemstack.getItemDamage()); if (getFleeceColor() != k) { if (getPuffed() && itemstack.stackSize >= 2) { setFleeceColor(k); itemstack.stackSize -= 2; } else if (!getPuffed()) { setFleeceColor(k); itemstack.stackSize--; } } } return false; }
public int getIconFromDamage(int i) { return Block.cloth.getBlockTextureFromSideAndMetadata(2, BlockCloth.getBlockFromDye(i)); }
/** * Returns the unlocalized name of this item. This version accepts an ItemStack so different * stacks can have different names based on their damage or NBT. */ public String getUnlocalizedName(ItemStack par1ItemStack) { return super.getUnlocalizedName() + "." + ItemDye.dyeColorNames[BlockCloth.getBlockFromDye(par1ItemStack.getItemDamage())]; }
/** Gets an icon index based on an item's damage value */ public Icon getIconFromDamage(int par1) { return Block.cloth.getIcon(2, BlockCloth.getBlockFromDye(par1)); }
protected void entityInit() { super.entityInit(); this.dataWatcher.addObject(18, new Integer(this.getHealth())); this.dataWatcher.addObject(19, new Byte((byte) 0)); this.dataWatcher.addObject(20, new Byte((byte) BlockCloth.getBlockFromDye(1))); }
/** * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a * pig. */ public boolean interact(EntityPlayer par1EntityPlayer) { ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem(); if (this.isTamed()) { if (var2 != null) { if (Item.itemsList[var2.itemID] instanceof ItemFood) { ItemFood var3 = (ItemFood) Item.itemsList[var2.itemID]; if (var3.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectInt(18) < 20) { if (!par1EntityPlayer.capabilities.isCreativeMode) { --var2.stackSize; } this.heal(var3.getHealAmount()); if (var2.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents( par1EntityPlayer.inventory.currentItem, (ItemStack) null); } return true; } } else if (var2.itemID == Item.dyePowder.shiftedIndex) { int var4 = BlockCloth.getBlockFromDye(var2.getItemDamage()); if (var4 != this.getCollarColor()) { this.setCollarColor(var4); if (!par1EntityPlayer.capabilities.isCreativeMode && --var2.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents( par1EntityPlayer.inventory.currentItem, (ItemStack) null); } return true; } } } if (par1EntityPlayer.username.equalsIgnoreCase(this.getOwnerName()) && !this.worldObj.isRemote && !this.isBreedingItem(var2)) { this.aiSit.setSitting(!this.isSitting()); this.isJumping = false; this.setPathToEntity((PathEntity) null); } } else if (var2 != null && var2.itemID == Item.bone.shiftedIndex && !this.isAngry()) { if (!par1EntityPlayer.capabilities.isCreativeMode) { --var2.stackSize; } if (var2.stackSize <= 0) { par1EntityPlayer.inventory.setInventorySlotContents( par1EntityPlayer.inventory.currentItem, (ItemStack) null); } if (!this.worldObj.isRemote) { if (this.rand.nextInt(3) == 0) { this.setTamed(true); this.setPathToEntity((PathEntity) null); this.setAttackTarget((EntityLiving) null); this.aiSit.setSitting(true); this.setEntityHealth(20); this.setOwner(par1EntityPlayer.username); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } return true; } return super.interact(par1EntityPlayer); }
/** Gets an icon index based on an item's damage value */ public Icon getIconFromDamage(int par1) { return Block.cloth.getBlockTextureFromSideAndMetadata(2, BlockCloth.getBlockFromDye(par1)); }