public static ItemStack getSmelt(ItemStack smelt, ItemStack itemStack) { if (!itemStack.hasTagCompound() || !itemStack.getTagCompound().getBoolean("Smelt")) return smelt; NBTTagList items = itemStack.getTagCompound().getTagList("ItemsSmelt", Constants.NBT.TAG_COMPOUND); for (int i = 0; i < items.tagCount(); ++i) { NBTTagCompound item = /*(NBTTagCompound)*/ items.getCompoundTagAt(i); byte slot = item.getByte("Slot"); // Just double-checking that the saved slot index is within our inventory array bounds if (slot >= 0 && slot < 9) { if (!itemStack.getTagCompound().getBoolean("Invert") && ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt)) return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null ? getOneSmelt(smelt) : smelt; else if (itemStack.getTagCompound().getBoolean("Invert") && !ItemStack.loadItemStackFromNBT(item).isItemEqual(smelt)) return FurnaceRecipes.smelting().getSmeltingResult(smelt) != null ? getOneSmelt(smelt) : smelt; } } return smelt; }
public static void initBlockSmelting() { FurnaceRecipes furnaceRecipes = FurnaceRecipes.smelting(); /* Harmonon Ore Smelting. */ furnaceRecipes.addSmelting( ModBlocks.HarmonionOre.blockID, new ItemStack(ModItems.Refinedsoundstone), 5.0F); }
private static void registerVanillaImprovements() { FurnaceRecipes.smelting() .addSmelting( MineFactoryReloadedCore.rawRubberItem.itemID, 0, new ItemStack(MineFactoryReloadedCore.rubberBarItem), 0.1F); FurnaceRecipes.smelting() .addSmelting( MineFactoryReloadedCore.rubberWoodBlock.blockID, 0, new ItemStack(Item.coal, 1, 1), 0.1F); GameRegistry.addShapelessRecipe( new ItemStack(Block.planks, 3, 3), new ItemStack(MineFactoryReloadedCore.rubberWoodBlock)); GameRegistry.addRecipe( new ItemStack(Block.torchWood, 4), new Object[] { "R", "S", Character.valueOf('R'), MineFactoryReloadedCore.rawRubberItem, Character.valueOf('S'), Item.stick }); GameRegistry.addRecipe( new ItemStack(Block.pistonStickyBase), new Object[] { "R", "P", Character.valueOf('R'), MineFactoryReloadedCore.rawRubberItem, Character.valueOf('P'), Block.pistonBase }); if (MineFactoryReloadedCore.vanillaOverrideIce.getBoolean(true)) { GameRegistry.addShapelessRecipe( new ItemStack(Block.ice, 1, 1), new ItemStack(Block.ice, 1, 0), new ItemStack(MineFactoryReloadedCore.rawPlasticItem, 1)); } if (MineFactoryReloadedCore.enableMossyCobbleRecipe.getBoolean(true)) { GameRegistry.addShapelessRecipe( new ItemStack(Block.cobblestoneMossy), new Object[] {Block.cobblestone, Item.bucketWater, Item.wheat}); } GameRegistry.addShapelessRecipe( new ItemStack(MineFactoryReloadedCore.milkBottleItem), new Object[] {Item.bucketMilk, Item.glassBottle}); }
public static void smeltBlockInWorld(World world, int posX, int posY, int posZ) { FurnaceRecipes recipes = FurnaceRecipes.smelting(); Block block = Block.blocksList[world.getBlockId(posX, posY, posZ)]; if (block == null) { return; } int meta = world.getBlockMetadata(posX, posY, posZ); ItemStack smeltedStack = recipes.getSmeltingResult(new ItemStack(block, 1, meta)); if (smeltedStack != null && smeltedStack.getItem() instanceof ItemBlock) { world.setBlock(posX, posY, posZ, smeltedStack.itemID, smeltedStack.getItemDamage(), 3); } }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) { ItemStack result = null; Slot slot = getSlot(slotIndex); if (slot != null && slot.getHasStack()) { ItemStack stack = slot.getStack(); result = stack.copy(); if (slotIndex == 1) { if (!mergeItemStack(stack, 2, 38, true)) return null; slot.onSlotChange(stack, result); } else if (slotIndex != 0) { if (FurnaceRecipes.smelting().getSmeltingResult(stack) != null) { if (!this.mergeItemStack(stack, 0, 1, false)) return null; } else if (slotIndex >= 2 && slotIndex < 29) { if (!this.mergeItemStack(stack, 29, 38, false)) return null; } else if (slotIndex >= 29 && slotIndex < 38) { if (!this.mergeItemStack(stack, 2, 29, false)) return null; } } else if (!this.mergeItemStack(stack, 2, 38, false)) return null; if (stack.stackSize <= 0) slot.putStack(null); else slot.onSlotChanged(); if (stack.stackSize == result.stackSize) return null; slot.onPickupFromSlot(player, stack); } return result; }
@Override public void onPoweredCycleEnd() { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this._inventories[0]); if (destroyInputs(this.xCoord, this.yCoord, this.zCoord, this.worldObj)) { consumeInputs(); } else if (Utils.isChestAvailable( this.xCoord, this.yCoord, this.zCoord, this.worldObj, itemstack)) { consumeInputs(); } else if (_inventories[1] != null) { if (consumeInputs()) { _inventories[1].stackSize += itemstack.stackSize; } } else { if (consumeInputs()) { _inventories[1] = itemstack.copy(); _inventories[1].stackSize = itemstack.stackSize; } } active = 0; markDirty(); }
/** * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't * full, etc. */ private boolean canSmelt() { if (furnaceItemStacks[0] == null) { return false; } ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(furnaceItemStacks[0].getItem().itemID); if (itemstack == null) { return false; } if (furnaceItemStacks[2] == null) { return true; } if (!furnaceItemStacks[2].isItemEqual(itemstack)) { return false; } if (furnaceItemStacks[2].stackSize < getInventoryStackLimit() && furnaceItemStacks[2].stackSize < furnaceItemStacks[2].getMaxStackSize()) { return true; } else { return furnaceItemStacks[2].stackSize < itemstack.getMaxStackSize(); } }
/** Philosopher's stone smelting recipes, EE3 style */ public static void registerPhiloStoneSmelting() { for (Entry<ItemStack, ItemStack> entry : (((HashMap<ItemStack, ItemStack>) FurnaceRecipes.smelting().getSmeltingList()) .entrySet())) { if (entry.getKey() == null || entry.getValue() == null) { continue; } ItemStack input = entry.getKey(); ItemStack output = entry.getValue().copy(); output.stackSize *= 7; GameRegistry.addShapelessRecipe( output, philosStone, input, input, input, input, input, input, input, new ItemStack(Items.coal, 1, OreDictionary.WILDCARD_VALUE)); } }
@Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { if (itemstack != null && FurnaceRecipes.smelting().getSmeltingResult(itemstack) != null && i == 0) return true; return false; }
@Override public float getExperienceForOutput(ItemStack output) { if (output == null) { return 0; } float result = FurnaceRecipes.smelting().func_151398_b(output); return result * output.stackSize; }
private ItemStack getInputForOutput(ItemStack output) { for (Object o : FurnaceRecipes.smelting().getSmeltingList().entrySet()) { ItemStack stack = (ItemStack) ((Map.Entry) o).getValue(); if (stack.isItemEqual(output)) { return (ItemStack) ((Map.Entry) o).getKey(); } } return null; }
public static void registerRecipes() { // Uncooked walrus meat GameRegistry.addShapedRecipe( new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 0), "mmm", "mmm", "mmm", 'm', new ItemStack(ModMahMeat.meat, 1, 0)); GameRegistry.addShapelessRecipe( new ItemStack(ModMahMeat.meat, 9, 0), new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 0)); // Cooked walrus meat GameRegistry.addShapedRecipe( new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 1), "mmm", "mmm", "mmm", 'm', new ItemStack(ModMahMeat.meat, 1, 1)); GameRegistry.addShapelessRecipe( new ItemStack(ModMahMeat.meat, 9, 1), new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 1)); Item walrus = Item.getByNameOrId("extracells:walrus"); if (walrus != null) { // Allow for equal conversion rates between walri and walrus meat GameRegistry.addShapedRecipe( new ItemStack(walrus), " m ", "MMm", " m ", 'm', new ItemStack(ModMahMeat.meat, 1, 0), 'M', (new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 0))); GameRegistry.addShapelessRecipe(new ItemStack(ModMahMeat.meat, 21, 0), new ItemStack(walrus)); } else { // Add a different recipe for raw walrus GameRegistry.addShapedRecipe( new ItemStack(Item.getItemFromBlock(ModMahMeat.walrusMeat), 1, 0), "fff", "fbf", "fff", 'f', Items.fish, 'b', Items.bone); } // Furnace recipes FurnaceRecipes.instance() .addSmeltingRecipe( new ItemStack(ModMahMeat.meat, 1, 0), new ItemStack(ModMahMeat.meat, 1, 1), 0.35F); }
private boolean smeltBlock(Coord4D block) { ItemStack stack = block.getStack(worldObj); if (stack == null) { return false; } ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj)); if (result != null) { if (!worldObj.isRemote) { Block b = block.getBlock(worldObj); int meta = block.getMetadata(worldObj); if (Block.getBlockFromItem(result.getItem()) != Blocks.air) { worldObj.setBlock( block.xCoord, block.yCoord, block.zCoord, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 3); } else { worldObj.setBlockToAir(block.xCoord, block.yCoord, block.zCoord); EntityItem item = new EntityItem( worldObj, block.xCoord + 0.5, block.yCoord + 0.5, block.zCoord + 0.5, result.copy()); item.motionX = 0; item.motionY = 0; item.motionZ = 0; worldObj.spawnEntityInWorld(item); } worldObj.playAuxSFXAtEntity( null, 2001, block.xCoord, block.yCoord, block.zCoord, Block.getIdFromBlock(b) + (meta << 12)); } spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5)); return true; } return false; }
private boolean canSmelt() { if (this.inventory[0] == null) { return false; } else { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]); if (itemstack == null) return false; if (this.inventory[1] == null) return true; if (!this.inventory[1].isItemEqual(itemstack)) return false; int result = inventory[1].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } }
private boolean canSmelt() { if (contents[0] == null) { return false; } else { ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(contents[0]); if (stack == null) return false; if (contents[2] == null) return true; if (!contents[2].isItemEqual(stack)) return false; int result = contents[2].stackSize + stack.stackSize; return result <= getInventoryStackLimit() && result <= contents[2].getMaxStackSize(); } }
private boolean canSmelt() { if (this.furnaceItemStacks[INPUT] == null || this.waterLevel == 0) { return false; } else { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[INPUT]); if (itemstack == null) return false; if (this.furnaceItemStacks[OUTPUT] == null) return true; if (!this.furnaceItemStacks[OUTPUT].isItemEqual(itemstack)) return false; int result = furnaceItemStacks[OUTPUT].stackSize + itemstack.stackSize; return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); } }
@SubscribeEvent public void modifyDrops(LivingDropsEvent event) { if (event.source == STEAM) for (EntityItem entityItem : event.drops) { ItemStack drop = entityItem.getEntityItem(); ItemStack cooked = FurnaceRecipes.smelting().getSmeltingResult(drop); if (cooked != null && MiscTools.RANDOM.nextDouble() < 0.5) { cooked = cooked.copy(); cooked.stackSize = drop.stackSize; entityItem.setEntityItemStack(cooked); } } }
@Override public boolean isRecipe(MachineRecipeInput... inputs) { if (!enabled) { return false; } ItemStack output = null; for (MachineRecipeInput ri : inputs) { if (ri != null && ri.item != null && !isExcluded(ri.item)) { if (output == null) { output = FurnaceRecipes.smelting().getSmeltingResult(ri.item); if (output == null) { return false; } } else { ItemStack newOutput = FurnaceRecipes.smelting().getSmeltingResult(ri.item); if (newOutput == null || !newOutput.isItemEqual(output)) { return false; } } } } return output != null; }
@Override public boolean canBeginCycle() { if (_inventories[0] != null && _inventories[0].stackSize >= 1) { if (_inventories[1] != null && _inventories[1].stackSize >= getInventoryStackLimit()) { return false; } if (FurnaceRecipes.smelting().getSmeltingResult(this._inventories[0]) != null) return true; } return false; }
@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if (stack == null) { return false; } if (slot == 0) { return TileEntityFurnace.isItemFuel(stack) || stack.getItem() == ObjHandler.kleinStars; } else if (slot >= 1 && slot <= 13) { return FurnaceRecipes.smelting().getSmeltingResult(stack) != null; } return false; }
@Override public boolean isValidInput(MachineRecipeInput input) { if (!enabled) { return false; } if (input == null || input.item == null) { return false; } if (isExcluded(input.item)) { return false; } ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(input.item); return itemstack != null; }
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */ @Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1) { ItemStack var2 = null; final Slot var3 = (Slot) inventorySlots.get(par1); if (var3 != null && var3.getHasStack()) { final ItemStack var4 = var3.getStack(); var2 = var4.copy(); if (par1 == 1) { if (!mergeItemStack(var4, 2, 38, true)) { return null; } var3.onSlotChange(var4, var2); } else if (par1 != 1 && par1 != 0) { if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null) { if (!mergeItemStack(var4, 0, 1, false)) { return null; } } else if (TileEntityFurnace.isItemFuel(var4)) { if (!mergeItemStack(var4, 0, 1, false)) { return null; } } else if (par1 >= 2 && par1 < 29) { if (!mergeItemStack(var4, 29, 38, false)) { return null; } } else if (par1 >= 29 && par1 < 38 && !mergeItemStack(var4, 2, 29, false)) { return null; } } else if (!mergeItemStack(var4, 2, 38, false)) { return null; } if (var4.stackSize == 0) { var3.putStack((ItemStack) null); } else { var3.onSlotChanged(); } if (var4.stackSize == var2.stackSize) { return null; } var3.onPickupFromSlot(par1EntityPlayer, var4); } return var2; }
public void smeltItem() { if (this.canSmelt()) { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.inventory[0]); if (this.inventory[1] == null) { this.inventory[1] = itemstack.copy(); } else if (this.inventory[1].isItemEqual(itemstack)) { inventory[1].stackSize += itemstack.stackSize; } --this.inventory[0].stackSize; if (this.inventory[0].stackSize <= 0) { this.inventory[0] = null; } } }
@Override public boolean onItemUse( ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing facing, float fx, float fy, float fz) { // TODO Auto-generated method stub if (!world.isRemote) { ItemStack block = new ItemStack(world.getBlockState(pos).getBlock()); if (FurnaceRecipes.instance().getSmeltingResult(block) != null) { ItemStack temp = FurnaceRecipes.instance().getSmeltingResult(block); world.spawnEntityInWorld( new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), temp.copy())); world.setBlockToAir(pos); } } return true; }
/** * Returns true if the furnace can smelt an item, i.e. has a source item, destination stack isn't * full, etc. */ private boolean canSmelt() { if (this.furnaceItemStacks[0] == null) { return false; } else { ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]); if (itemstack == null) return false; if (this.furnaceItemStacks[2] == null) return true; if (!this.furnaceItemStacks[2].isItemEqual(itemstack)) return false; int result = furnaceItemStacks[2].stackSize + itemstack.stackSize; return result <= getInventoryStackLimit() && result <= this.furnaceItemStacks[2] .getMaxStackSize(); // Forge BugFix: Make it respect stack sizes properly. } }
private boolean smeltItem(EntityItem item) { ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(item.getEntityItem()); if (result != null) { item.setEntityItemStack(StackUtils.size(result, item.getEntityItem().stackSize)); item.ticksExisted = 0; spawnParticlesAt(new Pos3D(item)); worldObj.playSoundAtEntity(item, "random.fizz", 1.0F, 1.0F); return true; } return false; }
@Override public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { ItemStack stack = null; Slot currentSlot = (Slot) inventorySlots.get(slotID); if (currentSlot != null && currentSlot.getHasStack()) { ItemStack slotStack = currentSlot.getStack(); stack = slotStack.copy(); if (slotID == 2) { if (!mergeItemStack(slotStack, 3, 39, true)) { return null; } } else if (slotID != 1 && slotID != 0) { if (FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) { if (!mergeItemStack(slotStack, 0, 1, false)) { return null; } } else if (TileEntityFurnace.isItemFuel(slotStack)) { if (!mergeItemStack(slotStack, 1, 2, false)) { return null; } } else if (slotID >= 3 && slotID < 30) { if (!mergeItemStack(slotStack, 30, 39, false)) { return null; } } else if (slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) { return null; } } else if (!mergeItemStack(slotStack, 3, 39, false)) { return null; } if (slotStack.stackSize == 0) { currentSlot.putStack((ItemStack) null); } else { currentSlot.onSlotChanged(); } if (slotStack.stackSize == stack.stackSize) { return null; } currentSlot.onPickupFromSlot(player, slotStack); } return stack; }
public ItemStack func_82846_b(EntityPlayer p_82846_1_, int p_82846_2_) { ItemStack var3 = null; Slot var4 = (Slot) this.field_75151_b.get(p_82846_2_); if (var4 != null && var4.func_75216_d()) { ItemStack var5 = var4.func_75211_c(); var3 = var5.func_77946_l(); if (p_82846_2_ == 2) { if (!this.func_75135_a(var5, 3, 39, true)) { return null; } var4.func_75220_a(var5, var3); } else if (p_82846_2_ != 1 && p_82846_2_ != 0) { if (FurnaceRecipes.func_77602_a().func_77603_b(var5.func_77973_b().field_77779_bT) != null) { if (!this.func_75135_a(var5, 0, 1, false)) { return null; } } else if (TileEntityFurnace.func_70401_b(var5)) { if (!this.func_75135_a(var5, 1, 2, false)) { return null; } } else if (p_82846_2_ >= 3 && p_82846_2_ < 30) { if (!this.func_75135_a(var5, 30, 39, false)) { return null; } } else if (p_82846_2_ >= 30 && p_82846_2_ < 39 && !this.func_75135_a(var5, 3, 30, false)) { return null; } } else if (!this.func_75135_a(var5, 3, 39, false)) { return null; } if (var5.field_77994_a == 0) { var4.func_75215_d((ItemStack) null); } else { var4.func_75218_e(); } if (var5.field_77994_a == var3.field_77994_a) { return null; } var4.func_82870_a(p_82846_1_, var5); } return var3; }
@Override protected void onCrafting(ItemStack par1ItemStack) { par1ItemStack.onCrafting(this.thePlayer.worldObj, this.thePlayer, this.field_75228_b); if (!this.thePlayer.worldObj.isRemote) { int i = this.field_75228_b; // 経験値なぁ…うーん float f = FurnaceRecipes.smelting().func_151398_b(par1ItemStack); int j; if (f == 0.0F) { i = 0; } else if (f < 1.0F) { j = MathHelper.floor_float((float) i * f); if (j < MathHelper.ceiling_float_int((float) i * f) && (float) Math.random() < (float) i * f - (float) j) { ++j; } i = j; } while (i > 0) { j = EntityXPOrb.getXPSplit(i); i -= j; this.thePlayer.worldObj.spawnEntityInWorld( new EntityXPOrb( this.thePlayer.worldObj, this.thePlayer.posX, this.thePlayer.posY + 0.5D, this.thePlayer.posZ + 0.5D, j)); } } this.field_75228_b = 0; FMLCommonHandler.instance().firePlayerSmeltedEvent(thePlayer, par1ItemStack); if (par1ItemStack.getItem() == Items.iron_ingot) { this.thePlayer.addStat(AchievementList.acquireIron, 1); } if (par1ItemStack.getItem() == Items.cooked_fished) { this.thePlayer.addStat(AchievementList.cookFish, 1); } }
public String getVariantNameForCookingItem(ItemStack input) { if (input == null) { return null; } ItemStack output = FurnaceRecipes.instance().getSmeltingResult(input); if (output == null) { return null; } String[] fallbacks = output.getItem() == Items.coal ? new String[] {"generic_wood"} : new String[] {}; return ModelHelpers.getStringIDInSetForStack(input, cookingItemModels, fallbacks); }