示例#1
0
 public String getItemNameIS(ItemStack itemstack) {
   return (new StringBuilder())
       .append(super.getItemName())
       .append(".")
       .append(ItemDye.dyeColorNames[BlockCloth.getBlockFromDye(itemstack.getItemDamage())])
       .toString();
 }
示例#2
0
 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);
  }
示例#7
0
 /** Gets an icon index based on an item's damage value */
 public Icon getIconFromDamage(int par1) {
   return Block.cloth.getBlockTextureFromSideAndMetadata(2, BlockCloth.getBlockFromDye(par1));
 }