@Override public void update() { TileEntityFurnace furnace = getTileEntity(); if (getHeatExchanger().getTemperature() > 373) { int furnaceBurnTime = furnace.getField(0); int furnaceCookTime = furnace.getField(2); if (furnaceBurnTime < 190 && !furnace.getStackInSlot(0).isEmpty()) { if (furnaceBurnTime == 0) BlockFurnace.setState(true, furnace.getWorld(), furnace.getPos()); furnace.setField(1, 200); // currentItemBurnTime furnace.setField(0, furnaceBurnTime + 10); // furnaceBurnTime getHeatExchanger().addHeat(-1); } if (furnaceCookTime > 0) { // Easy performance saver, the Furnace won't be ticked unnecessary when there's nothing to // cook (or when just started cooking). int progress = Math.max(0, ((int) getHeatExchanger().getTemperature() - 343) / 30); progress = Math.min(5, progress); for (int i = 0; i < progress; i++) { furnace.update(); } } } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { playerIn.displayGUIChest((TileEntityFurnace)tileentity); playerIn.triggerAchievement(StatList.field_181741_Y); } return true; } }
/** * Args : renderPartialTicks, mouseX, mouseY */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(furnaceGuiTextures); int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize); if (TileEntityFurnace.isBurning(this.tileFurnace)) { int k = this.getBurnLeftScaled(13); this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1); } int l = this.getCookProgressScaled(24); this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16); }
public static MachineFuel findMatchingFuel(ResourceLocation list, NonNullList<ItemStack> input) { if (list.toString().equals("minecraft:vanilla")) { if (input.size() == 1 && !input.get(0).isEmpty()) { ItemStack stack = input.get(0); int burnTime = TileEntityFurnace.getItemBurnTime(stack); if (burnTime > 0) return new VanillaFurnaceFuel(stack, burnTime); } return MachineFuel.EMPTY; } return findMatchingFuel(getInstance(list).fuels, input); }
public static boolean isPartOfFuel(ResourceLocation list, ItemStack stack) { if (stack.isEmpty()) return false; if (list.toString().equals("minecraft:vanilla")) { return TileEntityFurnace.getItemBurnTime(stack) > 0; } for (MachineFuel fuel : getInstance(list).fuels) { if (fuel.getFuelInput().stream() .anyMatch(input -> ItemHelper.stackMatchesRecipeInput(stack, input, false))) return true; } return false; }
private boolean isStackValidForSlot(int index, @Nonnull ItemStack stack) { if (!slotChecksEnabled) return true; if (type.isOutputSlot(index)) { return false; } else if (type.isInputSlot(index)) { return true; } else { return TileEntityFurnace.isItemFuel(stack) || SlotFurnaceFuel.isBucket(stack); } }
private boolean useOnVanillaFurnace(EntityPlayer playerIn, World world, BlockPos pos, ItemStack stack, Upgrades upgrade) { TileEntity te = world.getTileEntity(pos); if (te != null && te instanceof TileEntityFurnace) { TileEntityFurnace furnace = (TileEntityFurnace) te; boolean upgraded = upgradeVanillaFurnace(world, pos, furnace, upgrade.getUpgradedType()); if (upgraded && !playerIn.capabilities.isCreativeMode) { stack.shrink(1); } return true; } return false; }
private boolean upgradeVanillaFurnace(World world, BlockPos pos, TileEntityFurnace furnace, FurnaceType to) { byte facing = (byte) world.getBlockState(pos).getValue(BlockFurnace.FACING).ordinal(); TileEntityIronFurnace newFurnace = FurnaceType.makeEntity(to.ordinal()); if (newFurnace != null) { int[][] fromSlotIds = new int[][] {new int[] {0}, new int[] {1}, new int[] {2}}; copyInventory(furnace, fromSlotIds, newFurnace); world.setBlockState(pos, MoreFurnaces.blockFurnaces.getDefaultState().withProperty(BlockMoreFurnaces.VARIANT, to)); world.setTileEntity(pos, newFurnace); newFurnace.copyStateFrom(furnace, facing); return true; } else { return false; } }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { playerIn.displayGUIChest((TileEntityFurnace)tileentity); playerIn.addStat(StatList.FURNACE_INTERACTION); } return true; } }
/** * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated */ public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!keepInventory) { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { InventoryHelper.dropInventoryItems(worldIn, pos, (TileEntityFurnace)tileentity); worldIn.updateComparatorOutputLevel(pos, this); } } super.breakBlock(worldIn, pos, state); }
/** * Draws the background layer of this container (behind the items). */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(FURNACE_GUI_TEXTURES); int i = (this.width - this.xSize) / 2; int j = (this.height - this.ySize) / 2; this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize); if (TileEntityFurnace.isBurning(this.tileFurnace)) { int k = this.getBurnLeftScaled(13); this.drawTexturedModalRect(i + 56, j + 36 + 12 - k, 176, 12 - k, 14, k + 1); } int l = this.getCookProgressScaled(24); this.drawTexturedModalRect(i + 79, j + 34, 176, 14, l + 1, 16); }
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } else { TileEntity tileentity = worldIn.getTileEntity(pos); if (tileentity instanceof TileEntityFurnace) { playerIn.displayGUIChest((TileEntityFurnace)tileentity); playerIn.addStat(StatList.FURNACE_INTERACTION); } return true; } }
public static void initialize() { NonNullList<ItemStack> stacks = NonNullList.create(); for (Item i : ForgeRegistries.ITEMS) { CreativeTabs tab = i.getCreativeTab(); if(tab != null) { i.getSubItems(tab, stacks); } } List<ItemStack> out = new LinkedList<>(); for (ItemStack stack : stacks) { int burn = TileEntityFurnace.getItemBurnTime(stack); //Respects vanilla values. if(burn > 0) { out.add(stack); } } knownFuelStacks = ImmutableList.copyOf(out); }
@Override public boolean handleEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) { if(entity.ticksExisted()%FUEL_EAT_TICKS==0 && !worldIn.isRemote){ if(entityIn instanceof EntityItem){ ItemStack stack = ((EntityItem)entityIn).getItem(); //find the furnace burn time. if not hardcoded in vanilla furnace, it will check Forge's registered fuelHandlers int burnTime = TileEntityFurnace.getItemBurnTime(stack); if(burnTime!=0){ this.addFuel(burnTime*stack.getCount()); worldIn.playSound(null,entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1, 1); worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, entityIn.posX, entityIn.posY, entityIn.posZ, 0, 0, 0); entityIn.setDead(); IBlockState bstate = worldIn.getBlockState(getPos()); worldIn.notifyBlockUpdate(getPos(), bstate, bstate, 3); } } } return true; }
private boolean ignite() { ItemStack stackInSlot = furnace.getStackInSlot(fuel_slot); int burnTime = TileEntityFurnace.getItemBurnTime(stackInSlot); if (burnTime > 0) { furnace.setField(currentItemBurnTime_field, burnTime); furnace.setField(furnaceBurnTime_field, burnTime - 1); stackInSlot.stackSize--; if (stackInSlot.stackSize <= 0) { stackInSlot = stackInSlot.getItem().getContainerItem(stackInSlot); } furnace.setInventorySlotContents(fuel_slot, stackInSlot); BlockFurnace.setState(furnace.isBurning(), furnace.getWorld(), furnace.getPos()); furnace.markDirty(); return true; } return false; }
@Override public boolean isItemValidForSlot(int slotID, ItemStack itemStack) { if (slotID == 0) { return TileEntityFurnace.getItemBurnTime(itemStack) > 0; } else if (slotID >= 2) { if (this.producingStack != null) { ItemStack stackInSlot = this.getStackInSlot(slotID); return stackInSlot != null && stackInSlot.isItemEqual(itemStack); } return TileEntityIngotCompressor.isItemCompressorInput(itemStack); } return false; }
private static void findFuels() { IngotCompressorRecipeHandler.afuels = new ArrayList<FuelPair>(); for (ItemStack item : ItemList.items) { if (!IngotCompressorRecipeHandler.efuels.contains(Item.getIdFromItem(item.getItem()))) { int burnTime = TileEntityFurnace.getItemBurnTime(item); if (burnTime > 0) { FuelPair fuelPair = new FuelPair(item.copy(), burnTime); fuelPair.stack.relx = 57; fuelPair.stack.rely = 83; IngotCompressorRecipeHandler.afuels.add(fuelPair); } } } }
public static int getItemEnergyValue(ItemStack fuel) { if (!ItemStackTools.isValid(fuel)) { return 0; } int amt = GameRegistry.getFuelValue(fuel); if(amt == 0)amt = TileEntityFurnace.getItemBurnTime(fuel); //{ 10000, 400000, 2000000, 10000000} /*TE * (COAL)1600 * (VALUE)1600*10*3/2 = 24000 * (LEADSTONE)24000/10000=2.4 * (HARD)24000/400000=0.06 * (REDSTONE)24000/2000000=0.012 * (RESONENT)24000/10000000=0.0024 * */ /*CU * (NEW)24000/5=4800 * (BLUE)4800/10000=0.48 (+ADV) = 0.96 * (RED)4800/400000=0.012 (+ADV) = 0.024 * (GREEN)4800/2000000=0.0024 (+ADV) = 0.0048 * (DARK)4800/10000000=0.00048 (+ADV) = 0.00096 */ return amt; }
@SubscribeEvent public void onRenderTick(TickEvent.RenderTickEvent event) { EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().thePlayer; if (player != null) { if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().toString().contains("tile.air")) { ItemStack held = player.getHeldItemMainhand(); InventoryPlayer playerInv = player.inventory; if (held.getItem() instanceof ItemPickaxe) { if(held.serializeNBT().getInteger("BurnTimeLeft") == 0){ for (int i = 0; i < playerInv.getSizeInventory(); i++) { if (playerInv.getStackInSlot(i).getItem() == Items.COAL) { held.serializeNBT().setInteger("BurnTimeLeft", TileEntityFurnace.getItemBurnTime(playerInv.getStackInSlot(i))); break; } } } } } } }
public ContainerSourceLight(EntityPlayer player, IItemHandler burningSlot, TileEntitySourceLight tileEntity) { this.tileEntity = Optional.fromNullable(tileEntity); this.burningSlot = Preconditions.checkNotNull(burningSlot); this.addSlotToContainer(new SlotItemHandler(this.burningSlot, 0, 56, 51) { @Override public boolean isItemValid(ItemStack stack) { return TileEntityFurnace.isItemFuel(stack) && super.isItemValid(stack); } }); for (int i = 0; i < 3; ++i) { for (int j = 0; j < 9; ++j) { this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); } } for (int i = 0; i < 9; ++i) { this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142)); } }
private void heatLogic() { if (this.heat > this.getMinimumTemp()) this.heat -= 0.5f; if (this.heat < this.getMinimumTemp()) this.heat = this.getMinimumTemp(); if (this.heat >= this.maxHeat) return; if (!this.getStackInSlot(4).isEmpty() && this.maxBurnTime == 0) this.maxBurnTime = TileEntityFurnace.getItemBurnTime(this.decrStackSize(4, 1)); if (this.maxBurnTime != 0) { this.currentBurnTime++; this.heat++; } if (this.currentBurnTime >= this.maxBurnTime) { this.currentBurnTime = 0; this.maxBurnTime = 0; } }
private static void findFuels() { afuels = new ArrayList<>(); Set<Item> efuels = excludedFuels(); for (ItemStack item : ItemList.items) { Block block = Block.getBlockFromItem(item.getItem()); if (block instanceof BlockDoor) { continue; } if (efuels.contains(item.getItem())) { continue; } int burnTime = TileEntityFurnace.getItemBurnTime(item); if (burnTime > 0) { afuels.add(new FuelPair(item.copy(), burnTime)); } } }
public void tryDistill() { if (this.amIBottom()) { if (this.getFluidAmount() > 0 && this.getFluid().isFluidEqual(new FluidStack(ModBlocks.fluidOil, 0))) { // WE have oil. if (remainBurnTime > 0) { // we have fuel distill(); } else { // consume more fuel // only if it has mash to process // use the furnace's default burn times remainBurnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0)); if (remainBurnTime > 0) { // found fuel reduce item stack (AKA consume /brun the item) decrStackSize(0, 1); } } } } }
@Override public void update() { if (!world.isRemote) { // LogHelper.info("TE update entity called"); if (remainBurnTime > 0) { remainBurnTime--; transferFuel(); } else { // consume more fuel // only if it has mash to process if (fuelStorage > 0) { // use the furnace's default burn times remainBurnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(0)); if (remainBurnTime > 0) { // found fuel reduce item stack (AKA consume /brun the item) decrStackSize(0, 1); } } } } }
@Override protected void drawGuiContainerBackgroundLayer(float var1, int mouseX, int mouseY) { GL11.glEnable(GL11.GL_BLEND); this.mc.getTextureManager().bindTexture(new ResourceLocation("exoticpower", "textures/gui/container/elementgenerator.png")); int k = (this.width - this.xSize) / 2; int l = (this.height - this.ySize) / 2; this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); int i1; if (TileEntityFurnace.isBurning(this.tile)) { i1 = this.func_175382_i(13); this.drawTexturedModalRect(k + 61, l + 38 + 12 - i1, 176, 12 - i1, 18, i1 + 1); } i1 = this.tile.energy * 53 / this.tile.capacity; this.drawTexturedModalRect(k + 97, (int) l + 18 + 53 - i1, 176, (int) 13 + 53 - i1, 18, (int) i1 + 1); if (mouseX > k + 97 && mouseX < k + 114 && mouseY > l + 18 && mouseY < l + 70) { drawHoveringText(Arrays.asList(new String[]{this.tile.energy + "/" + this.tile.capacity}), mouseX, mouseY, fontRendererObj); } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onItemTooltipEvent(ItemTooltipEvent event) { if (Keyboard.isCreated() && (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))) { // https://www.reddit.com/r/minecraftsuggestions/comments/3brh7v/when_hovering_over_a_food_it_shows_how_many_food/ ItemStack itemStack = event.getItemStack(); if (itemStack == null || itemStack.getItem() == null) { return; } if (foodDetails && itemStack.getItem() instanceof ItemFood) { ItemFood food = (ItemFood) itemStack.getItem(); int hunger = food.getHealAmount(itemStack); float satur = food.getSaturationModifier(itemStack); if (hunger > 0 || satur > 0) { event.getToolTip().add(hunger + " (" + satur + ")"); } } if (fuelDetails) { int burnTime = TileEntityFurnace.getItemBurnTime(itemStack); if (burnTime > 0) { event.getToolTip().add(UtilChat.lang("tooltip.burntime") + burnTime); } } } }
/** * Args : renderPartialTicks, mouseX, mouseY */ protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) { GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); this.mc.getTextureManager().bindTexture(furnaceGuiTextures); int x = (this.width - this.xSize) / 2; int y = (this.height - this.ySize) / 2; this.drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize); if (TileEntityFurnace.isBurning(this.tileFurnace)) { int cookTime = this.getCookTimeScaled(13); this.drawTexturedModalRect(x + 45, y + 36 + 12 - cookTime, 176, 12 - cookTime, 14, cookTime + 1); } int burnTime = this.getBurnTimeScaled(24); this.drawTexturedModalRect(x + 79, y + 34, 176, 14, burnTime + 1, 16); }
@Override public void update() { if (burnTime <= 0) { if (machineCore.isMachineOn() && power < MAX_POWER) { burnTime = TileEntityFurnace.getItemBurnTime(getInventory().getStackInSlot(0)); } } else { burnTime--; if (power < MAX_POWER) { power += POWER_PER_TICK; } } }
@Override public boolean canStore(ItemStack stack, int slot, ForgeDirection side) { if (slot == 0 || slot == 1) { if (BasicIndustry.doInputSlotValidationChecks) { return MachineRecipeType.ITEM_SMELTER.getHandler().getRecipe(new Object[]{stack}, 0, 0) instanceof ItemStack; } return true; } else if (slot == 4) { return TileEntityFurnace.isItemFuel(stack); } return false; }
@Override public boolean isItemValidForSlot( int slot, ItemStack item ) { if ( item == null ) { return true; } if ( slot == FUEL_SLOT ) { return ( TileEntityFurnace.getItemBurnTime( item ) > 0 ); } else if ( slot == BLOCK_SLOT ) { return ( item.getItem() == Item.getItemFromBlock( ComponentEquipment.blocks.ingot ) && item.getItemDamage() == IngotItem.PERSISTIUM ); } else if ( slot == TOOL_SLOT ) { return ( item.getItem() instanceof EquipmentItem ); } return true; }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { if (p_149727_1_.isClient) { return true; } else { TileEntityFurnace var10 = (TileEntityFurnace)p_149727_1_.getTileEntity(p_149727_2_, p_149727_3_, p_149727_4_); if (var10 != null) { p_149727_5_.func_146101_a(var10); } return true; } }
public ContainerFurnace(InventoryPlayer par1InventoryPlayer, TileEntityFurnace par2TileEntityFurnace) { this.furnace = par2TileEntityFurnace; this.addSlotToContainer(new Slot(par2TileEntityFurnace, 0, 56, 17)); this.addSlotToContainer(new Slot(par2TileEntityFurnace, 1, 56, 53)); this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, par2TileEntityFurnace, 2, 116, 35)); int var3; for (var3 = 0; var3 < 3; ++var3) { for (int var4 = 0; var4 < 9; ++var4) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18)); } } for (var3 = 0; var3 < 9; ++var3) { this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142)); } }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return true; } else { TileEntityFurnace tileentityfurnace = (TileEntityFurnace)par1World.getBlockTileEntity(par2, par3, par4); if (tileentityfurnace != null) { par5EntityPlayer.displayGUIFurnace(tileentityfurnace); } return true; } }