public void drainRCBattery(int slot) { ItemStack itemstack = this.batterySlots[slot - this.getLengthOfInventory()]; if (itemstack != null && this.RCStorage < this.MAXRCSTORAGE) { this.RCStorage += ((IRedstoneCurrentBattery) itemstack.getItem()).drainRC(itemstack, this.MAXTXRX); } }
public boolean onBlockActivated( World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return false; } else { ItemStack currentItem = player.inventory.getCurrentItem(); if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, "customnpcs.editblocks")) { TileEntity tile = par1World.getTileEntity(i, j, k); NBTTagCompound compound = new NBTTagCompound(); tile.writeToNBT(compound); Server.sendData( (EntityPlayerMP) player, EnumPacketClient.GUI_WAYPOINT, new Object[] {compound}); return true; } else { return false; } } }
/** Check if the stack is a valid item for this slot. Always true beside for the armor slots. */ @Override public boolean isItemValid(ItemStack is) { return (is.itemID == RotaryCraft.extracts.itemID && is.getItemDamage() < 8) || (ExtractorModOres.isModOreIngredient(is) && ExtractorModOres.isDust( ModOreList.getEntryFromDamage(is.getItemDamage() / 4), is.getItemDamage())); }
@Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2) { ItemStack itemstack = null; Slot slot = (Slot) this.inventorySlots.get(par2); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (par2 == 0) { if (!this.mergeItemStack(itemstack1, 1, 37, true)) { return null; } } else if (par2 != 0) { if (par2 >= 1 && par2 < 37) { if (!this.mergeItemStack(itemstack1, 0, 1, false)) { return null; } } } slot.onSlotChanged(); if (itemstack1.stackSize == 0) { slot.putStack((ItemStack) null); } slot.onPickupFromSlot(par1EntityPlayer, itemstack1); } return itemstack; }
public static void spawnEntityItem(World world, ItemStack stack, double x, double y, double z) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; stack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if (j1 > stack.stackSize) j1 = stack.stackSize; stack.stackSize -= j1; entityitem = new EntityItem( world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(stack.getItem(), j1, stack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double) ((float) world.rand.nextGaussian() * f3); entityitem.motionY = (double) ((float) world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double) ((float) world.rand.nextGaussian() * f3); if (stack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound) stack.getTagCompound().copy()); } } }
public static void givePlayerItem( EntityPlayerMP player, ItemStack stack, boolean infinite, boolean doGive) { if (stack.getItem() == null) { player.addChatComponentMessage( setColour( new ChatComponentTranslation("nei.chat.give.noitem"), EnumChatFormatting.WHITE)); return; } int given = stack.stackSize; if (doGive) { if (infinite) { player.inventory.addItemStackToInventory(stack); } else { given -= InventoryUtils.insertItem(player.inventory, stack, false); } } sendNotice( player, new ChatComponentTranslation( "commands.give.success", stack.getChatComponent(), infinite ? "\u221E" : Integer.toString(given), player.getName()), "notify-item"); player.openContainer.detectAndSendChanges(); }
public ItemStack getCraftingResult() { this.cost = 0; ItemStack output = this.tool.getStack().copy(); NBTTagList toolList = getEnchantmentTagList(output); NBTTagList bookList = getEnchantmentTagList(this.enchantedBook.copy()); boolean changed = false; for (int iBook = 0; iBook < bookList.tagCount(); iBook++) { boolean found = false; NBTTagCompound bookEnchant = bookList.getCompoundTagAt(iBook); // Check the tool for allowed enchants if (!this.tool .getItem() .getAllowedEnchantments() .contains(Enchantment.enchantmentsList[bookEnchant.getShort("id")].type)) continue; // Check if the enchant already exists for (int iTool = 0; iTool < toolList.tagCount(); iTool++) { NBTTagCompound toolEnchant = toolList.getCompoundTagAt(iTool); if (toolEnchant.getShort("id") == bookEnchant.getShort("id")) { found = true; if (toolEnchant.getShort("lvl") < bookEnchant.getShort("lvl")) { changed = true; toolEnchant.setShort("lvl", bookEnchant.getShort("lvl")); } continue; } } // It doesn't exist yet, just add it if (!found) { boolean allowed = true; for (int iTool = 0; iTool < toolList.tagCount(); iTool++) { int toolEnchant = toolList.getCompoundTagAt(iTool).getShort("id"); if (!Enchantment.enchantmentsList[toolEnchant].canApplyTogether( Enchantment.enchantmentsList[bookEnchant.getShort("id")])) { allowed = false; } } if (allowed) { changed = true; toolList.appendTag(bookEnchant); int lvl = bookEnchant.getShort("lvl") + 1; int cost = lvl * lvl * 2 / (this.tool.getHeadMaterial().arcaneLevel + 1); this.cost += cost; } } } if ((output.getEnchantmentTagList() == null || output.getEnchantmentTagList().tagCount() == 0) && toolList.tagCount() > 0) { output.getTagCompound().setTag("ench", toolList); } return changed ? output : null; }
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotNum) { ItemStack itemCopy = null; Slot slot = (Slot) this.inventorySlots.get(slotNum); if (slot != null && slot.getHasStack()) { ItemStack item = slot.getStack(); itemCopy = item.copy(); if (slotNum < 9) { if (!this.mergeItemStack(item, 9, this.inventorySlots.size(), true)) { return null; } } else if (!this.mergeItemStack(item, 0, 9, false)) { return null; } if (item.stackSize == 0) { slot.putStack((ItemStack) null); } else { slot.onSlotChanged(); } } return itemCopy; }
/** * Input list must be ItemStack array with 5 elements, contain null if no item is used in the * slot. * * <p>0 - Crystal slot 1 - Silicon slot 2 - Silicon slot 3 - Redstone slot 4 - Optional slot * * @param output * @param inputList ItemStack array with length 5. Fill with stacks as explained above * @return */ public static void addRecipe(ItemStack output, ItemStack[] inputList) { if (inputList.length != 5) { throw new RuntimeException("Invalid circuit fabricator recipe!"); } CircuitFabricatorRecipes.recipes.put(inputList, output); // Add the recipe ingredients to the valid items for each slot // First initialise the ArrayList if this is the first time it's used if (CircuitFabricatorRecipes.slotValidItems.size() == 0) { for (int i = 0; i < 5; i++) { ArrayList<ItemStack> entry = new ArrayList<ItemStack>(); CircuitFabricatorRecipes.slotValidItems.add(entry); } } // Now see if the recipe items are already valid for their slots, if not add them for (int i = 0; i < 5; i++) { ItemStack inputStack = inputList[i]; if (inputStack == null) continue; ArrayList<ItemStack> validItems = CircuitFabricatorRecipes.slotValidItems.get(i); boolean found = false; for (int j = 0; j < validItems.size(); j++) { if (inputStack.isItemEqual(validItems.get(j))) { found = true; break; } } if (!found) { validItems.add(inputStack.copy()); } } }
public static int getDye(ItemStack stack) { if (stack == null) return -1; if (stack.getItem().equals(Items.dye)) return stack.getItemDamage(); for (int dye = 0; dye < dyeNames.length; dye++) if (compareToOreName(stack, "dye" + dyeNames[dye])) return dye; return -1; }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer player, int idk, float what, float these, float are) { ItemStack playerItem = player.getCurrentEquippedItem(); if (playerItem != null) { if (playerItem.getItem() instanceof TelepositionFocus) { SoulNetworkHandler.checkAndSetItemPlayer(playerItem, player); if (playerItem.getTagCompound() == null) { playerItem.setTagCompound(new NBTTagCompound()); } NBTTagCompound itemTag = playerItem.getTagCompound(); itemTag.setInteger("xCoord", x); itemTag.setInteger("yCoord", y); itemTag.setInteger("zCoord", z); itemTag.setInteger("dimensionId", world.provider.dimensionId); return true; } } player.openGui(AlchemicalWizardry.instance, 1, world, x, y, z); return true; }
public static ItemStack insertStackIntoInventory( IInventory inventory, ItemStack stack, int side) { if (stack == null || inventory == null) return null; int stackSize = stack.stackSize; if (inventory instanceof ISidedInventory) { ISidedInventory sidedInv = (ISidedInventory) inventory; int slots[] = sidedInv.getAccessibleSlotsFromSide(side); if (slots == null) return stack; for (int i = 0; i < slots.length && stack != null; i++) { if (sidedInv.canInsertItem(slots[i], stack, side)) { ItemStack existingStack = inventory.getStackInSlot(slots[i]); if (OreDictionary.itemMatches(existingStack, stack, true) && ItemStack.areItemStackTagsEqual(stack, existingStack)) stack = addToOccupiedSlot(sidedInv, slots[i], stack, existingStack); } } for (int i = 0; i < slots.length && stack != null; i++) if (inventory.getStackInSlot(slots[i]) == null && sidedInv.canInsertItem(slots[i], stack, side)) stack = addToEmptyInventorySlot(sidedInv, slots[i], stack); } else { int invSize = inventory.getSizeInventory(); for (int i = 0; i < invSize && stack != null; i++) { ItemStack existingStack = inventory.getStackInSlot(i); if (OreDictionary.itemMatches(existingStack, stack, true) && ItemStack.areItemStackTagsEqual(stack, existingStack)) stack = addToOccupiedSlot(inventory, i, stack, existingStack); } for (int i = 0; i < invSize && stack != null; i++) if (inventory.getStackInSlot(i) == null) stack = addToEmptyInventorySlot(inventory, i, stack); } if (stack == null || stack.stackSize != stackSize) inventory.markDirty(); return stack; }
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex) { ItemStack newItemStack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { ItemStack itemStack = slot.getStack(); newItemStack = itemStack.copy(); if (slotIndex < chestInventoryRows * chestInventoryColumns) { if (!this.mergeItemStack( itemStack, chestInventoryRows * chestInventoryColumns, inventorySlots.size(), false)) { return null; } } else if (!this.mergeItemStack( itemStack, 0, chestInventoryRows * chestInventoryColumns, false)) { return null; } if (itemStack.stackSize == 0) { slot.putStack(null); } else { slot.onSlotChanged(); } } return newItemStack; }
@Optional.Method(modid = Mods.OpenComputers) private boolean isUpgrade(ItemStack stack) { return stack != null && stack.getItem() != null && stack.getItem() instanceof ItemOpenComputers && upgrades.contains(stack.getItemDamage()); }
public void sellProperty() { ArrayList<ItemStack> addedStacks = new ArrayList<ItemStack>(); for (ItemStack stack : price) { if (owner.inventory.addItemStackToInventory(stack)) addedStacks.add(stack); else { for (ItemStack addedStack : addedStacks) for (int i = 0; i < addedStack.stackSize; i++) owner.inventory.consumeInventoryItem( addedStack.itemID); // Abrar's PR: ,addedStack.getItemDamage()); break; } } ArrayList<ItemStack> takenStacks = new ArrayList<ItemStack>(); for (ItemStack stack : price) { ItemStack copyStack = stack.copy(); copyStack.stackSize = 0; do { if (!buyer.inventory.consumeInventoryItem(stack.itemID)) for (ItemStack takenStack : takenStacks) owner.inventory.addItemStackToInventory(copyStack); copyStack.stackSize++; } while (copyStack.stackSize < stack.stackSize); if (copyStack.stackSize == stack.stackSize) takenStacks.add(copyStack); } }
@Override public void onPickupFromSlot(EntityPlayer player, ItemStack stack) { if (stack.getItem() instanceof ItemPotion && stack.getItemDamage() > 0) player.addStat(AchievementList.potion, 1); super.onPickupFromSlot(player, stack); }
@Override public boolean onBlockActivated( World world, int x, int y, int z, EntityPlayer entityplayer, int par6, float par7, float par8, float par9) { if (!canBlockStay(world, x, y, z)) { world.setBlockToAir(x, y, z); world.spawnEntityInWorld(new EntityItem(world, x, y, z, new ItemStack(this, 1))); } else if ((TEBloomery) world.getTileEntity(x, y, z) != null) { TEBloomery te = (TEBloomery) world.getTileEntity(x, y, z); ItemStack is = entityplayer.getCurrentEquippedItem(); if (is != null && (is.getItem() == TFCItems.FireStarter || is.getItem() == TFCItems.FlintSteel)) { if (te.canLight()) entityplayer.getCurrentEquippedItem().damageItem(1, entityplayer); } else { world.playAuxSFXAtEntity(entityplayer, 1003, x, y, z, 0); if (isOpen(world.getBlockMetadata(x, y, z))) world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) - 8, 3); else world.setBlockMetadataWithNotify(x, y, z, world.getBlockMetadata(x, y, z) + 8, 3); } } return true; }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { ItemStack itemstack = null; Slot slot = (Slot) inventorySlots.get(slotIndex); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if ((slotIndex < 0 || slotIndex > 2) && slotIndex != 3) { if (!ingredientSlot.getHasStack() && ingredientSlot.isItemValid(itemstack1)) { if (!mergeItemStack(itemstack1, 3, 4, false)) return null; } else if (PotionSlot.canHoldPotion(itemstack)) { if (!mergeItemStack(itemstack1, 0, 3, false)) return null; } else if (slotIndex >= 4 && slotIndex < 31) { if (!mergeItemStack(itemstack1, 31, 40, false)) return null; } else if (slotIndex >= 31 && slotIndex < 40) { if (!mergeItemStack(itemstack1, 4, 31, false)) return null; } else if (!mergeItemStack(itemstack1, 4, 40, false)) return null; } else { if (!mergeItemStack(itemstack1, 4, 40, true)) return null; slot.onSlotChange(itemstack1, itemstack); } if (itemstack1.stackSize == 0) slot.putStack((ItemStack) null); else slot.onSlotChanged(); if (itemstack1.stackSize == itemstack.stackSize) return null; slot.onPickupFromSlot(player, itemstack1); } return itemstack; }
/** Used to check if a recipe matches current crafting inventory */ @Override public boolean matches(InventoryCrafting par1InventoryCrafting, World par2World) { this.enchantedBook = null; this.tool = null; for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) { ItemStack itemstack = par1InventoryCrafting.getStackInRowAndColumn(j, i); if (itemstack != null) { if (Item.getIdFromItem(itemstack.getItem()) == Item.getIdFromItem(Items.enchanted_book)) { if (this.enchantedBook != null) return false; this.enchantedBook = itemstack; } if (itemstack.getItem() instanceof ToolBase) { if (this.tool != null) return false; this.tool = ((ToolBase) itemstack.getItem()).getToolProperties(itemstack); } } } } return this.enchantedBook != null && this.tool != null; }
@Override public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slot) { Slot slotObject = (Slot) inventorySlots.get(slot); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); ItemStack stack = stackInSlot.copy(); if (slot >= 0 && slot < kDecomposerInventoryEnd) { if (!mergeItemStack(stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true)) return null; } else if (stackInSlot.itemID == MinechemItems.testTube.itemID) { if (!mergeItemStack( stackInSlot, decomposer.kEmptyTestTubeSlotStart, decomposer.kEmptyTestTubeSlotEnd + 1, false)) return null; } else if (slot >= kPlayerInventorySlotStart) { if (!mergeItemStack(stackInSlot, decomposer.kInputSlot, decomposer.kInputSlot + 1, false)) return null; } else if (!mergeItemStack( stackInSlot, kPlayerInventorySlotStart, inventorySlots.size(), true)) return null; if (stackInSlot.stackSize == 0) slotObject.putStack(null); else slotObject.onSlotChanged(); return stack; } return null; }
private static void doPlayer(EntityPlayerMP player, VoteEvent vote) { if (!ConfigServerVote.msgAll.equals("")) { player.playerNetServerHandler.sendPacket( new S02PacketChat( new ChatComponentText( ChatOutputHandler.formatColors( ConfigServerVote.msgAll .replaceAll("%service", vote.serviceName) .replaceAll("%player", vote.player))))); } if (!ConfigServerVote.msgVoter.equals("")) { ChatOutputHandler.sendMessage( player, ChatOutputHandler.formatColors( ConfigServerVote.msgAll .replaceAll("%service", vote.serviceName) .replaceAll("%player", vote.player))); } if (!ConfigServerVote.freeStuff.isEmpty()) { for (ItemStack stack : ConfigServerVote.freeStuff) { LoggingHandler.felog.debug(stack.toString()); player.inventory.addItemStackToInventory(stack.copy()); } } }
@Override public void onBlockPlacedBy( World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) { if (world.isRemote) return; if (stack.hasTagCompound()) { TileEntity te = world.getTileEntity(x, y, z); if (te instanceof TileVendorBlock) { TileVendorBlock tentity = (TileVendorBlock) te; NBTTagCompound tagCompound = stack.getTagCompound(); if (tagCompound == null) { return; } NBTTagList tagList = tagCompound.getTagList("Inventory", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i); byte slot = tag.getByte("Slot"); if (slot >= 0 && slot < tentity.getSizeInventory()) { tentity.setInventorySlotContents(slot, ItemStack.loadItemStackFromNBT(tag)); } } tentity.coinSum = tagCompound.getInteger("CoinSum"); tentity.userCoinSum = tagCompound.getInteger("UserCoinSum"); tentity.itemPrice = tagCompound.getInteger("ItemPrice"); tentity.blockOwner = tagCompound.getString("BlockOwner"); tentity.infiniteMode = tagCompound.getBoolean("Infinite"); } world.markBlockForUpdate(x, y, z); } else { // item has no owner so we'll set one and get out of here ((TileVendorBlock) world.getTileEntity(x, y, z)).blockOwner = entity.getCommandSenderName(); } int meta = stack.getItemDamage(); world.setBlockMetadataWithNotify(x, y, z, meta, 2); }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slot) { ItemStack stack = null; Slot slotObject = (Slot) inventorySlots.get(slot); int machInvSize = _ncw.getSizeInventory(); if (slotObject != null && slotObject.getHasStack()) { ItemStack stackInSlot = slotObject.getStack(); stack = stackInSlot.copy(); if (slot < machInvSize) { if (!mergeItemStack(stackInSlot, machInvSize, inventorySlots.size(), true)) { return null; } } else if (!mergeItemStack(stackInSlot, 0, machInvSize, false)) { return null; } if (stackInSlot.stackSize == 0) { slotObject.putStack(null); } else { slotObject.onSlotChanged(); } if (stackInSlot.stackSize == stack.stackSize) { return null; } slotObject.onPickupFromSlot(player, stackInSlot); } return stack; }
public ItemStack getItemStackWithData(World world, int x, int y, int z) { ItemStack stack = new ItemStack(world.getBlock(x, y, z), 1, 0); TileEntity tentity = world.getTileEntity(x, y, z); if (tentity instanceof TileVendorBlock) { TileVendorBlock te = (TileVendorBlock) tentity; NBTTagList itemList = new NBTTagList(); NBTTagCompound tagCompound = new NBTTagCompound(); for (int i = 0; i < te.getSizeInventory(); i++) { ItemStack invStack = te.getStackInSlot(i); if (invStack != null) { NBTTagCompound tag = new NBTTagCompound(); tag.setByte("Slot", (byte) i); invStack.writeToNBT(tag); itemList.appendTag(tag); } } tagCompound.setTag("Inventory", itemList); tagCompound.setInteger("CoinSum", te.coinSum); tagCompound.setInteger("UserCoinSum", te.userCoinSum); tagCompound.setInteger("ItemPrice", te.itemPrice); tagCompound.setString("BlockOwner", te.blockOwner); tagCompound.setBoolean("Infinite", te.infiniteMode); stack.setTagCompound(tagCompound); return stack; } else return stack; }
@Override public void drawScreen(int mouseX, int mouseY, float ticks) { super.drawScreen(mouseX, mouseY, ticks); int i = 0; if (prevHover.checkHover(mouseX, mouseY)) { i = -1; } else if (nextHover.checkHover(mouseX, mouseY)) { i = 1; } if (container.isRecipes() && i != 0) { ItemStack stack = container.getNextRecipe(i); drawCreativeTabHoveringText(stack.getDisplayName(), mouseX, mouseY); } if (container.isRecipes() && mouseX >= guiLeft + recipesX - 5 && mouseX <= guiLeft + xSize - 5 && mouseY >= guiTop + recipesY - 4 && mouseY <= guiTop + recipesY + 10) { tooltips.clear(); for (ItemStack stack : container.getRecipes()) { tooltips.add(stack.getDisplayName()); } drawHoveringText(tooltips, mouseX, mouseY); } }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack var1, EntityPlayer var2, List var3, boolean var4) { if (var1.getItem().equals(RioVItems.axeOfAunTun)) { var3.add("The most valuable and powerful weapon."); var3.add("Fully fused. Fully usable."); var3.add("Fusion: 100%"); } if (var1.getItem().equals(RioVItems.unfusedAxeOfAunTun)) { var3.add(StatCollector.translateToLocal("Unfused. Not usable.")); var3.add(StatCollector.translateToLocal("Fusion: 0%")); } if (var1.getItem().equals(RioVItems.halfFusedAxeOfAunTun)) { var3.add(StatCollector.translateToLocal("Half fused. Still not usable.")); var3.add(StatCollector.translateToLocal("Fusion: 50%")); } if (Config.showToolInfo) { var3.add(Color.GOLD + (var1.getMaxDamage() - var1.getItemDamage()) + " Uses"); var3.add(Color.DARK_PURPLE + "Damage: " + toolMaterial.getDamageVsEntity()); } }
@Override public ActionResult<ItemStack> onItemRightClick( ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { if (!playerIn.capabilities.isCreativeMode) { itemStackIn.damageItem(1, playerIn); if (itemStackIn.getItemDamage() == 0) { itemStackIn = new ItemStack(ModItems.staff); } } worldIn.playSound( (EntityPlayer) null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!worldIn.isRemote) { EntityLargeSnowBall snowball = new EntityLargeSnowBall(worldIn, playerIn); snowball.setHeadingFromThrower( playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F); worldIn.spawnEntityInWorld(snowball); } return new ActionResult(EnumActionResult.SUCCESS, itemStackIn); }
public float checkTemps(IInventory inv) { float temp = 0; float[] temp1 = new float[inv.getSizeInventory()]; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack is = inv.getStackInSlot(i); if (is != null && is.hasTagCompound() && !is.getItem().getUnlocalizedName(is).contains("Clay")) { if (is.getTagCompound().hasKey("temperature")) { temp1[i] = is.getTagCompound().getFloat("temperature"); if (temp1[i] < TFC_ItemHeat.getMeltingPoint(is)) { return (float) -1; } } else { return (float) -1; } } else if (is == null) { temp1[i] = -1; } } int temp2 = 0; for (int i = 0; i < inv.getSizeInventory(); i++) { if (temp1[i] >= 0) { temp += temp1[i]; temp2++; } } if (temp2 > 0) { temp /= temp2; } return temp; }
@Override protected void drawSlot(int id, int x, int y, int var4, int var5, int var6) { Block block = blocks.get(id); ItemStack itemStack = new ItemStack(Item.getItemFromBlock(block)); GlStateManager.enableRescaleNormal(); GlStateManager.enableBlend(); RenderHelper.enableGUIStandardItemLighting(); GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); if (itemStack.getItem() != null) try { Minecraft.getMinecraft() .getRenderItem() .renderItemAndEffectIntoGUI(itemStack, x + 4, y + 4); } catch (Exception e) { e.printStackTrace(); } else mc.fontRendererObj.drawString("?", x + 10, y + 9, 10526880); Minecraft.getMinecraft() .getRenderItem() .func_175030_a(Minecraft.getMinecraft().fontRendererObj, itemStack, x + 4, y + 4); RenderHelper.disableStandardItemLighting(); GlStateManager.disableRescaleNormal(); GlStateManager.disableBlend(); glDisable(GL_LIGHTING); mc.fontRendererObj.drawString( "Name: " + (itemStack.getItem() == null ? block.getLocalizedName() : itemStack.getDisplayName()), x + 31, y + 3, 10526880); int blockID = Block.getIdFromBlock(block); mc.fontRendererObj.drawString("ID: " + blockID, x + 31, y + 15, 10526880); }
@Override public EnumRarity getRarity(ItemStack is) { if (is.getItem() == ModBase.magicApple) return EnumRarity.uncommon; if (is.getItem() == ModBase.magicGoodApple) return EnumRarity.rare; if (is.getItem() == ModBase.magicSuperApple) return EnumRarity.epic; return EnumRarity.common; }