/** * Called frequently so the entity can update its state every tick as required. For example, * zombies and skeletons use this to react to sunlight and start to burn. */ public void onLivingUpdate() { if (this.worldObj.isDaytime() && !this.worldObj.isRemote && !this.isChild()) { float f = this.getBrightness(1.0F); if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.worldObj.canBlockSeeTheSky( MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ))) { boolean flag = true; ItemStack itemstack = this.getCurrentItemOrArmor(4); if (itemstack != null) { if (itemstack.isItemStackDamageable()) { itemstack.setItemDamage(itemstack.getItemDamageForDisplay() + this.rand.nextInt(2)); if (itemstack.getItemDamageForDisplay() >= itemstack.getMaxDamage()) { this.renderBrokenItemStack(itemstack); this.setCurrentItemOrArmor(4, (ItemStack) null); } } flag = false; } if (flag) { this.setFire(8); } } } super.onLivingUpdate(); }
public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) { int var3 = 0; ItemStack var4 = null; ItemStack var5 = null; for (int var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6) { ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6); if (var7 != null) { if (var3 == 0) { var4 = var7; } if (var3 == 1) { var5 = var7; } ++var3; } } if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable()) { Item var13 = Item.itemsList[var4.itemID]; int var14 = var13.getMaxDamage() - var4.getItemDamageForDisplay(); int var8 = var13.getMaxDamage() - var5.getItemDamageForDisplay(); int var9 = var14 + var8 + var13.getMaxDamage() * 5 / 100; int var10 = var13.getMaxDamage() - var9; if (var10 < 0) { var10 = 0; } return new ItemStack(var4.itemID, 1, var10); } else { Iterator var11 = this.recipes.iterator(); IRecipe var12; do { if (!var11.hasNext()) { return null; } var12 = (IRecipe) var11.next(); } while (!var12.matches(par1InventoryCrafting, par2World)); return var12.getCraftingResult(par1InventoryCrafting); } }
public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World) { int i = 0; ItemStack itemstack = null; ItemStack itemstack1 = null; int j; for (j = 0; j < par1InventoryCrafting.getSizeInventory(); ++j) { ItemStack itemstack2 = par1InventoryCrafting.getStackInSlot(j); if (itemstack2 != null) { if (i == 0) { itemstack = itemstack2; } if (i == 1) { itemstack1 = itemstack2; } ++i; } } if (i == 2 && itemstack.getItem() == itemstack1.getItem() && itemstack.stackSize == 1 && itemstack1.stackSize == 1 && itemstack.getItem().isRepairable()) { Item item = itemstack.getItem(); int j1 = item.getMaxDamage() - itemstack.getItemDamageForDisplay(); int k = item.getMaxDamage() - itemstack1.getItemDamageForDisplay(); int l = j1 + k + item.getMaxDamage() * 5 / 100; int i1 = item.getMaxDamage() - l; if (i1 < 0) { i1 = 0; } return new ItemStack(itemstack.getItem(), 1, i1); } else { for (j = 0; j < this.recipes.size(); ++j) { IRecipe irecipe = (IRecipe) this.recipes.get(j); if (irecipe.matches(par1InventoryCrafting, par2World)) { return irecipe.getCraftingResult(par1InventoryCrafting); } } return null; } }
public void renderItemStack( FontRenderer par1FontRenderer, RenderEngine par2RenderEngine, ItemStack par3ItemStack, int par4, int par5, String par6Str) { if (par3ItemStack != null) { if (par3ItemStack.stackSize > 1 || par6Str != null) { String s1 = par6Str == null ? String.valueOf(par3ItemStack.stackSize) : par6Str; GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); par1FontRenderer.drawStringWithShadow( s1, par4 + 19 - 2 - par1FontRenderer.getStringWidth(s1), par5 + 6 + 3, 16777215); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); } if (par3ItemStack.isItemDamaged()) { int k = (int) Math.round( 13.0D - (double) par3ItemStack.getItemDamageForDisplay() * 13.0D / (double) par3ItemStack.getMaxDamage()); int l = (int) Math.round( 255.0D - (double) par3ItemStack.getItemDamageForDisplay() * 255.0D / (double) par3ItemStack.getMaxDamage()); GL11.glDisable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_TEXTURE_2D); Tessellator tessellator = Tessellator.instance; int i1 = 255 - l << 16 | l << 8; int j1 = (255 - l) / 4 << 16 | 16128; this.renderQuad(tessellator, par4 + 2, par5 + 13, 13, 2, 0); this.renderQuad(tessellator, par4 + 2, par5 + 13, 12, 1, j1); this.renderQuad(tessellator, par4 + 2, par5 + 13, k, 1, i1); GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); } } }
@SuppressWarnings({"rawtypes", "unchecked"}) @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List info, boolean par4) { NBTTagCompound c = stack.getTagCompound(); if (getBlockID() == Machine.DeepStorageUnit.getBlockId() && stack.getItemDamage() == Machine.DeepStorageUnit.getMeta() && c != null) { if (c.hasKey("storedStack")) { ItemStack storedItem = ItemStack.loadItemStackFromNBT(c.getCompoundTag("storedStack")); int storedQuantity = c.getInteger("storedQuantity"); if (storedItem != null & storedQuantity > 0) { info.add( "Contains " + storedQuantity + " " + storedItem.getDisplayName() + " (" + storedItem.itemID + ":" + storedItem.getItemDamageForDisplay() + ")"); } else { // info.add("Empty"); } } } else if (getBlockID() == Machine.BioFuelGenerator.getBlockId() && stack.getItemDamage() == Machine.BioFuelGenerator.getMeta()) { info.add("Produces MJ only."); } }
/** * Called frequently so the entity can update its state every tick as required. For example, * zombies and skeletons use this to react to sunlight and start to burn. */ public void onLivingUpdate() { boolean var2 = true; ItemStack var3 = this.getCurrentItemOrArmor(4); if (var3 != null) { if (var3.isItemStackDamageable()) { var3.setItemDamage(var3.getItemDamageForDisplay() + this.rand.nextInt(2)); if (var3.getItemDamageForDisplay() >= var3.getMaxDamage()) { this.renderBrokenItemStack(var3); this.setCurrentItemOrArmor(4, (ItemStack) null); } } } super.onLivingUpdate(); }