@Override public boolean isItemValid(ItemStack itemstack) { if (itemstack.getItem().shiftedIndex == item.shiftedIndex) { if (damage == -1) return true; else return itemstack.getItemDamage() == damage; } else return false; }
public int compare(ItemStack o1, ItemStack o2) { if (o1 == null && o2 == null) { return 0; } if (o1 != null && o2 == null) { return o1.itemID; } if (o2 != null && o1 == null) { return -o2.itemID; } if (byName) { org.spoutcraft.api.material.Material other1 = MaterialData.getMaterial(o1.itemID, (short) (o1.getItemDamage())); org.spoutcraft.api.material.Material other2 = MaterialData.getMaterial(o2.itemID, (short) (o2.getItemDamage())); if (other1 == null && other2 == null) { return 0; } if (other1 != null && other2 == null) { return o1.itemID; } if (other2 != null && other1 == null) { return -o2.itemID; } return other1.getName().compareTo(other2.getName()); } else { int idDiff = o1.itemID - o2.itemID; int dataDiff = o1.getItemDamage() - o2.getItemDamage(); return idDiff * 1000 - dataDiff; } }
/** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor * sections). */ public void setContents(ItemStack par2ItemStack) { for (int x = 0; x < 27; x++) { if (this.poubelleContents[x] != null && this.poubelleContents[x].getItem().shiftedIndex == par2ItemStack.getItem().shiftedIndex) { int max = this.poubelleContents[x].stackSize + par2ItemStack.stackSize; if (par2ItemStack.getItem().getHasSubtypes()) { } else if (max > 64) { this.poubelleContents[x].stackSize = 64; par2ItemStack.stackSize = max - 64; this.onInventoryChanged(); } else { this.poubelleContents[x].stackSize += par2ItemStack.stackSize; this.onInventoryChanged(); break; } } else if (this.poubelleContents[x] == null) { this.poubelleContents[x] = par2ItemStack; if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit()) { par2ItemStack.stackSize = this.getInventoryStackLimit(); } this.onInventoryChanged(); break; } } }
public boolean hitEntity(ItemStack itemstack, EntityLiving mob, EntityLiving entityliving1) { World world = entityliving1.worldObj; if (type1 == type2) { attacks(itemstack, world, entityliving1, mob, type1); } else { if (random.nextInt(100) + 1 <= 80) { attacks(itemstack, world, entityliving1, mob, type1); } if (random.nextInt(100) + 1 <= 20) { attacks(itemstack, world, entityliving1, mob, type2); } } int i = itemstack.getItemDamage(); if (i >= dur) { itemstack.stackSize = 0; } if (type1 == 3 || type2 == 3 || type1 == 4 || type2 == 4 || type1 == 8 || type2 == 8) { if (random.nextInt(100) + 1 <= 90) { itemstack.damageItem(1, entityliving1); } } else { itemstack.damageItem(1, entityliving1); } return true; }
public boolean func_70431_c(ItemStack p_70431_1_) { ItemStack[] var2 = this.field_70460_b; int var3 = var2.length; int var4; ItemStack var5; for (var4 = 0; var4 < var3; ++var4) { var5 = var2[var4]; if (var5 != null && var5.func_77965_c(p_70431_1_)) { return true; } } var2 = this.field_70462_a; var3 = var2.length; for (var4 = 0; var4 < var3; ++var4) { var5 = var2[var4]; if (var5 != null && var5.func_77965_c(p_70431_1_)) { return true; } } return false; }
public int getPercentageCapacity() { ItemStack linkCard = getPowerLinkStack(); if (hasPowerSource()) { return ((IPowerLinkItem) linkCard.getItem()).getPercentageCapacity(linkCard, this, worldObj); } return 0; }
public int getMaximumPower() { ItemStack linkCard = getPowerLinkStack(); if (hasPowerSource()) { return ((IPowerLinkItem) linkCard.getItem()).getMaximumPower(linkCard, this, worldObj); } return 0; }
protected int func_187_a(EntityPlayer p_187_1_, int p_187_2_, float p_187_3_) { ItemStack var4 = p_187_1_.field_778_b.func_492_d(3 - p_187_2_); if (var4 != null) { Item var5 = var4.func_1091_a(); if (var5 instanceof ItemArmor) { ItemArmor var6 = (ItemArmor) var5; this.func_151_a( "/armor/" + field_206_i[var6.field_311_aZ] + "_" + (p_187_2_ == 2 ? 2 : 1) + ".png"); ModelBiped var7 = p_187_2_ == 2 ? this.field_207_h : this.field_208_g; var7.field_1286_a.field_1403_h = p_187_2_ == 0; var7.field_1285_b.field_1403_h = p_187_2_ == 0; var7.field_1284_c.field_1403_h = p_187_2_ == 1 || p_187_2_ == 2; var7.field_1283_d.field_1403_h = p_187_2_ == 1; var7.field_1282_e.field_1403_h = p_187_2_ == 1; var7.field_1281_f.field_1403_h = p_187_2_ == 2 || p_187_2_ == 3; var7.field_1280_g.field_1403_h = p_187_2_ == 2 || p_187_2_ == 3; this.func_4013_a(var7); if (var4.func_40711_u()) { return 15; } return 1; } } return -1; }
/** * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if * the item isn't fuel */ public static int getItemBurnTime(ItemStack par0ItemStack) { if (par0ItemStack == null) { return 0; } else { int var1 = par0ItemStack.getItem().shiftedIndex; Item var2 = par0ItemStack.getItem(); if (var1 < 256 && Block.blocksList[var1] != null) { Block var3 = Block.blocksList[var1]; if (var3 == Block.blockSnow) { return 300; } if (var3 == Block.ice) { return 800; } if (var3 == Block.oreRedstone) { return 500; } } return var1 == Item.emerald.shiftedIndex ? 1000 : 0; } }
/** Called when the player picks up an item from an inventory slot */ public void onPickupFromSlot(ItemStack par1ItemStack) { ModLoader.takenFromCrafting(this.thePlayer, par1ItemStack, this.craftMatrix); // ForgeHooks.onTakenFromCrafting(thePlayer, par1ItemStack, craftMatrix); TODO this.func_48434_c(par1ItemStack); for (int var2 = 0; var2 < this.craftMatrix.getSizeInventory(); ++var2) { ItemStack var3 = this.craftMatrix.getStackInSlot(var2); if (var3 != null) { this.craftMatrix.decrStackSize(var2, 1); if (var3.getItem().hasContainerItem()) { ItemStack var4 = new ItemStack(var3.getItem().getContainerItem()); if (!var3.getItem().doesContainerItemLeaveCraftingGrid(var3) || !this.thePlayer.inventory.addItemStackToInventory(var4)) { if (this.craftMatrix.getStackInSlot(var2) == null) { this.craftMatrix.setInventorySlotContents(var2, var4); } else { this.thePlayer.dropPlayerItem(var4); } } } } } }
@Override public int execute( EAI_Manager manager, EntityLiving entity, IInventory inventory, int slotnum, int maxcol) { super.execute(manager, entity, inventory, slotnum, maxcol); // 食べ物を持ってたら食べる。次へ進む // // ロジックをなるだけ壊さないように、検索は後ろから for (int i = inventory.getSizeInventory() - 1; i > 0; i--) { ItemStack stack = inventory.getStackInSlot(i); if (stack != null && stack.getItem() instanceof ItemFood) { UtilInventory.decrStackSize(inventory, i, 1); // アイテムを 1 つ減らす ItemFood food = (ItemFood) stack.getItem(); entity.worldObj.playSoundEffect( entity.posX, entity.posY, entity.posZ, "random.eat", 0.5F, entity.worldObj.rand.nextFloat() * 0.1F + 0.9F); entity.setEating(true); entity.setEntityHealth(entity.getHealth() + 1); // HP を 1 回復する EasyAIInterface.debugPrint("[EAI_TASK_eatFood] Eat Food " + stack + " " + slotnum); return this.returnTrue(); } } return this.returnFalse(); }
/** * Handles what should be done on right clicking the item. * * @param is The ItemStack which is right clicked. * @param world The world in which the player is. * @param player The player who right clicked the item. * @param Returns the ItemStack after the process. */ @Override public ItemStack onItemRightClick(ItemStack is, World world, EntityPlayer player) { // if world.isRemote than we are on the client side if (world.isRemote) { // display rename GUI if player is sneaking if (player.isSneaking() && is.getItemDamage() != ItemBackpack.ENDERBACKPACK) { FMLCommonHandler.instance().showGuiScreen(new BackpackGui(player)); } return is; } // when the player is not sneaking if (!player.isSneaking()) { // get the inventory IInventory inv; if (is.getItemDamage() == ItemBackpack.ENDERBACKPACK) { inv = player.getInventoryEnderChest(); } else { inv = new BackpackInventory(player, is); } // open the GUI for a chest based on the loaded inventory player.displayGUIChest(inv); } return is; }
public boolean func_70454_b(Block p_70454_1_) { if (p_70454_1_.field_72018_cp.func_76229_l()) { return true; } else { ItemStack var2 = this.func_70301_a(this.field_70461_c); return var2 != null ? var2.func_77987_b(p_70454_1_) : false; } }
public boolean usePower(int powerAmount, boolean simulation) { ItemStack linkCard = getPowerLinkStack(); if (hasPowerSource()) { return ((IPowerLinkItem) linkCard.getItem()) .consumePower(linkCard, powerAmount, simulation, this, worldObj); } return false; }
public void func_94095_a(DamageSource p_94095_1_) { this.func_70106_y(); ItemStack var2 = new ItemStack(Item.field_77773_az, 1); if (this.field_94102_c != null) { var2.func_82834_c(this.field_94102_c); } this.func_70099_a(var2, 0.0F); }
public boolean onBlockDestroyed( ItemStack itemstack, int i, int j, int k, int l, EntityLiving entityliving) { int i1 = itemstack.getItemDamage(); if (i1 >= dur) { itemstack.stackSize = 0; } itemstack.damageItem(2, entityliving); return true; }
public static ItemStack getBptItemStack(int id, int damage, String name) { ItemStack stack = new ItemStack(id, 1, damage); NBTTagCompound nbt = new NBTTagCompound(); if (name != null && !"".equals(name)) { nbt.setString("BptName", name); stack.setTagCompound(nbt); } return stack; }
public void func_70455_b(InventoryPlayer p_70455_1_) { int var2; for (var2 = 0; var2 < this.field_70462_a.length; ++var2) { this.field_70462_a[var2] = ItemStack.func_77944_b(p_70455_1_.field_70462_a[var2]); } for (var2 = 0; var2 < this.field_70460_b.length; ++var2) { this.field_70460_b[var2] = ItemStack.func_77944_b(p_70455_1_.field_70460_b[var2]); } }
@Override public String getItemNameIS(ItemStack itemstack) { int metadata = 0; if (itemstack.getItemDamage() >= BlockBasicMachine.ELECTRIC_FURNACE_METADATA) { metadata = 2; } else if (itemstack.getItemDamage() >= BlockBasicMachine.BATTERY_BOX_METADATA) { metadata = 1; } return Block.blocksList[this.getBlockID()].getBlockName() + "." + metadata; }
private int func_70452_e(ItemStack p_70452_1_) { int var2 = p_70452_1_.field_77993_c; int var3 = p_70452_1_.field_77994_a; int var4; if (p_70452_1_.func_77976_d() == 1) { var4 = this.func_70447_i(); if (var4 < 0) { return var3; } else { if (this.field_70462_a[var4] == null) { this.field_70462_a[var4] = ItemStack.func_77944_b(p_70452_1_); } return 0; } } else { var4 = this.func_70432_d(p_70452_1_); if (var4 < 0) { var4 = this.func_70447_i(); } if (var4 < 0) { return var3; } else { if (this.field_70462_a[var4] == null) { this.field_70462_a[var4] = new ItemStack(var2, 0, p_70452_1_.func_77960_j()); if (p_70452_1_.func_77942_o()) { this.field_70462_a[var4].func_77982_d( (NBTTagCompound) p_70452_1_.func_77978_p().func_74737_b()); } } int var5 = var3; if (var3 > this.field_70462_a[var4].func_77976_d() - this.field_70462_a[var4].field_77994_a) { var5 = this.field_70462_a[var4].func_77976_d() - this.field_70462_a[var4].field_77994_a; } if (var5 > this.func_70297_j_() - this.field_70462_a[var4].field_77994_a) { var5 = this.func_70297_j_() - this.field_70462_a[var4].field_77994_a; } if (var5 == 0) { return var3; } else { var3 -= var5; this.field_70462_a[var4].field_77994_a += var5; this.field_70462_a[var4].field_77992_b = 5; return var3; } } } }
public String getItemDisplayName(ItemStack par1ItemStack) { if (par1ItemStack.hasTagCompound()) { NBTTagCompound nbttagcompound = par1ItemStack.getTagCompound(); NBTTagString nbttagstring = (NBTTagString) nbttagcompound.getTag("title"); if (nbttagstring != null) { return nbttagstring.toString(); } } return super.getItemDisplayName(par1ItemStack); }
@Override public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix) { if (item.isItemEqual(new ItemStack(GreenTechnology.blockPulverizer))) { player.addStat(GEAchievements.squishy, 1); } else if (item.isItemEqual(new ItemStack(GreenTechnology.blockGeo))) { player.addStat(GEAchievements.hothothot, 1); } else if (item.isItemEqual(new ItemStack(GreenTechnology.blockSolar))) { player.addStat(GEAchievements.newgreen, 1); } else if (item.isItemEqual(new ItemStack(GreenTechnology.blockSolarArray))) { player.addStat(GEAchievements.bluer, 1); } }
@Override public void doAction(IInventory matrix, DaemonEnergy energy) { int size = DaemonMatrix.MATRIX_SIZE; int orb = -1; ItemOrb orbItem = null; int lastSlot = 0; // find 1st orb for (; lastSlot < size; lastSlot++) { ItemStack stack = matrix.getStackInSlot(lastSlot); if (stack != null && stack.getItem() instanceof ItemOrb) { orb = lastSlot; orbItem = (ItemOrb) stack.getItem(); break; } } if (orb < 0) return; // charge with glass shard if possible for (int i = 0; i < size; i++) { ItemStack stack = matrix.getStackInSlot(i); if (stack != null && stack.getItem() instanceof ItemShardGlass && stack.getItemDamage() >= ItemShardGlass.DAMAGE_CHARGED) { matrix.setInventorySlotContents(i, null); orbItem.chargeOrb(matrix.getStackInSlot(orb)); return; } } // charge with crystal for (int i = 0; i < size; i++) { ItemStack stack = matrix.getStackInSlot(i); if (stack != null && stack.getItem() instanceof ItemCrystal) { matrix.setInventorySlotContents(i, null); DaemonEnergy de = UtilItem.getDaemonEnergy(matrix.getStackInSlot(orb)); DaemonEnergy de2 = UtilItem.getDaemonEnergy(stack); de.merge(de2); UtilItem.setDaemonEnergy(matrix.getStackInSlot(orb), de); return; } } for (lastSlot++; lastSlot < size; lastSlot++) { ItemStack stack = matrix.getStackInSlot(lastSlot); if (stack != null && stack.getItem() instanceof ItemOrb) { matrix.setInventorySlotContents(orb, orbItem.mergeOrbs(matrix.getStackInSlot(orb), stack)); matrix.setInventorySlotContents(lastSlot, null); return; } } }
@Override public ItemStack decrStackSize(int slot, int amount) { if (isLocked()) return null; ItemStack stack = getStackInSlot(slot); if (stack == null) return null; ItemStack returnStack; if (stack.stackSize <= amount) { returnStack = stack; contents[slot] = null; } else returnStack = stack.splitStack(amount); onInventoryChanged(); return returnStack; }
protected void func_48434_c(ItemStack par1ItemStack) { par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_48436_g); this.field_48436_g = 0; if (Util.isWooden(par1ItemStack) || Util.isStone(par1ItemStack) || Util.isIron(par1ItemStack) || Util.isGold(par1ItemStack) || Util.isDiamond(par1ItemStack)) { ItemCrossbow item = (ItemCrossbow) par1ItemStack.getItem(); // this.thePlayer.addStat(mod_CrossbowMod.createCrossbow, 1); TODO } }
public void func_71852_a( World p_71852_1_, int p_71852_2_, int p_71852_3_, int p_71852_4_, int p_71852_5_, int p_71852_6_) { TileEntityChest var7 = (TileEntityChest) p_71852_1_.func_72796_p(p_71852_2_, p_71852_3_, p_71852_4_); if (var7 != null) { for (int var8 = 0; var8 < var7.func_70302_i_(); ++var8) { ItemStack var9 = var7.func_70301_a(var8); if (var9 != null) { float var10 = this.field_72293_a.nextFloat() * 0.8F + 0.1F; float var11 = this.field_72293_a.nextFloat() * 0.8F + 0.1F; EntityItem var14; for (float var12 = this.field_72293_a.nextFloat() * 0.8F + 0.1F; var9.field_77994_a > 0; p_71852_1_.func_72838_d(var14)) { int var13 = this.field_72293_a.nextInt(21) + 10; if (var13 > var9.field_77994_a) { var13 = var9.field_77994_a; } var9.field_77994_a -= var13; var14 = new EntityItem( p_71852_1_, (double) ((float) p_71852_2_ + var10), (double) ((float) p_71852_3_ + var11), (double) ((float) p_71852_4_ + var12), new ItemStack(var9.field_77993_c, var13, var9.func_77960_j())); float var15 = 0.05F; var14.field_70159_w = (double) ((float) this.field_72293_a.nextGaussian() * var15); var14.field_70181_x = (double) ((float) this.field_72293_a.nextGaussian() * var15 + 0.2F); var14.field_70179_y = (double) ((float) this.field_72293_a.nextGaussian() * var15); if (var9.func_77942_o()) { var14 .func_92059_d() .func_77982_d((NBTTagCompound) var9.func_77978_p().func_74737_b()); } } } } } super.func_71852_a(p_71852_1_, p_71852_2_, p_71852_3_, p_71852_4_, p_71852_5_, p_71852_6_); }
@Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); NBTTagList items = compound.getTagList("Items"); contents = new ItemStack[getSizeInventory()]; for (int i = 0; i < items.tagCount(); i++) { NBTTagCompound item = (NBTTagCompound) items.tagAt(i); int slot = item.getByte("Slot") & 255; if (slot >= 0 && slot < contents.length) contents[slot] = ItemStack.loadItemStackFromNBT(item); } if (compound.hasKey("lock")) lock = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("lock")); }
public void func_75142_b() { for (int var1 = 0; var1 < this.field_75151_b.size(); ++var1) { ItemStack var2 = ((Slot) this.field_75151_b.get(var1)).func_75211_c(); ItemStack var3 = (ItemStack) this.field_75153_a.get(var1); if (!ItemStack.func_77989_b(var3, var2)) { var3 = var2 == null ? null : var2.func_77946_l(); this.field_75153_a.set(var1, var3); for (int var4 = 0; var4 < this.field_75149_d.size(); ++var4) { ((ICrafting) this.field_75149_d.get(var4)).func_71111_a(this, var1, var3); } } } }
public int func_70430_l() { int var1 = 0; ItemStack[] var2 = this.field_70460_b; int var3 = var2.length; for (int var4 = 0; var4 < var3; ++var4) { ItemStack var5 = var2[var4]; if (var5 != null && var5.func_77973_b() instanceof ItemArmor) { int var6 = ((ItemArmor) var5.func_77973_b()).field_77879_b; var1 += var6; } } return var1; }
@Override public String getItemNameIS(ItemStack itemstack) { return "tile." + Block.blocksList[getBlockID()].getBlockName() + "." + itemstack.getItemDamage(); }