net.minecraft.tileentity.TileEntityFurnace Java Examples
The following examples show how to use
net.minecraft.tileentity.TileEntityFurnace.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Furnace.java From minecraft-roguelike with GNU General Public License v3.0 | 6 votes |
public static void generate(IWorldEditor editor, ItemStack fuel, boolean lit, Cardinal dir, Coord pos){ if(!RogueConfig.getBoolean(RogueConfig.FURNITURE)) return; MetaBlock furnace; if(lit){ furnace = new MetaBlock(Blocks.LIT_FURNACE); } else { furnace = new MetaBlock(Blocks.FURNACE); } furnace.withProperty(BlockFurnace.FACING, Cardinal.facing(Cardinal.reverse(dir))); furnace.set(editor, pos); if(fuel == null) return; TileEntity te = editor.getTileEntity(pos); if(te == null) return; if(!(te instanceof TileEntityFurnace)) return; TileEntityFurnace teFurnace = (TileEntityFurnace)te; teFurnace.setInventorySlotContents(FUEL_SLOT, fuel); }
Example #2
Source File: MachineManager.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
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); }
Example #3
Source File: MachineManager.java From customstuff4 with GNU General Public License v3.0 | 6 votes |
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; }
Example #4
Source File: FurnaceRecipeHandler.java From NotEnoughItems with MIT License | 6 votes |
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)); } } }
Example #5
Source File: TickHandler.java From GokiStats with MIT License | 6 votes |
private void handleFurnace(EntityPlayer player) { if (DataHelper.getPlayerStatLevel(player, Stats.FURNACE_FINESSE) > 0) { ArrayList<TileEntityFurnace> furnacesAroundPlayer = new ArrayList<>(); for (TileEntity listEntity : player.world.loadedTileEntityList) { if (listEntity != null) { TileEntity tileEntity = listEntity; BlockPos pos = tileEntity.getPos(); if (tileEntity instanceof TileEntityFurnace && MathHelper.sqrt(player.getDistanceSq(pos)) < 4.0D) { // TODO work out alter way to do tileEntity furnacesAroundPlayer.add((TileEntityFurnace) tileEntity); } } } // FIXME Laggy for (TileEntityFurnace furnace : furnacesAroundPlayer) if (furnace.isBurning()) for (int i = 0; i < Stats.FURNACE_FINESSE.getBonus(player); i++) // Intend to "mount" ticks, same as Torcherino. furnace.update(); } }
Example #6
Source File: TileEntityEngine.java From archimedes-ships with MIT License | 6 votes |
public boolean consumeFuel(int f) { if (burnTime >= f) { burnTime -= f; return true; } for (int i = 0; i < getSizeInventory(); i++) { ItemStack is = decrStackSize(i, 1); if (is != null && is.stackSize > 0) { burnTime += TileEntityFurnace.getItemBurnTime(is); return consumeFuel(f); } } return false; }
Example #7
Source File: UpgradeFueled.java From BetterChests with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void update(IUpgradableBlock chest, ItemStack stack) { if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 64) != 0) { return; } IEnergyStorage storage = chest.getEnergyStorage(); if (storage.getEnergyStored() >= storage.getMaxEnergyStored()) { return; } IBetterChest inv = (IBetterChest) chest; IFilter filter = inv.getFilterFor(stack); int slot = InvUtil.findInInvInternal(inv, null, test -> TileEntityFurnace.getItemBurnTime(test) > 0 && filter.matchesStack(test)); if (slot != -1) { ItemStack current = inv.getStackInSlot(slot); int provided = TileEntityFurnace.getItemBurnTime(current) * Config.INSTANCE.energyFueled; if (storage.receiveEnergy(provided, true) == provided) { storage.receiveEnergy(provided, false); current.setCount(current.getCount() - 1); inv.markDirty(); } } }
Example #8
Source File: HeatBehaviourFurnace.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
@Override public void update(){ TileEntityFurnace furnace = getTileEntity(); if(getHeatExchanger().getTemperature() > 373) { if(furnace.furnaceBurnTime < 190 && furnace.getStackInSlot(0) != null) { if(furnace.furnaceBurnTime == 0) BlockFurnace.updateFurnaceBlockState(true, furnace.getWorldObj(), furnace.xCoord, furnace.yCoord, furnace.zCoord); furnace.currentItemBurnTime = 200; furnace.furnaceBurnTime += 10; getHeatExchanger().addHeat(-1); } if(furnace.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.updateEntity(); } } } }
Example #9
Source File: GuiAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void addPressureStatInfo(List<String> pressureStatText){ super.addPressureStatInfo(pressureStatText); if(te.getBurnTimeRemainingScaled(12) > 0 || TileEntityFurnace.isItemFuel(te.getStackInSlot(0)) && te.redstoneAllows()) { pressureStatText.add("\u00a77Currently producing:"); pressureStatText.add("\u00a70" + (double)Math.round(te.getBaseProduction() * te.getEfficiency() * te.getSpeedMultiplierFromUpgrades(te.getUpgradeSlots()) / 100) + " mL/tick."); } }
Example #10
Source File: GuiAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override protected void addProblems(List<String> textList){ super.addProblems(textList); if(te.burnTime <= 0 && !TileEntityFurnace.isItemFuel(te.getStackInSlot(0))) { textList.add("\u00a77No fuel!"); textList.add("\u00a70Insert any burnable item."); } List<Pair<ForgeDirection, IAirHandler>> teSurrounding = te.getConnectedPneumatics(); if(teSurrounding.isEmpty()) { textList.add("\u00a77Air leaking!"); textList.add("\u00a70Add pipes / machines"); textList.add("\u00a70to the output."); } }
Example #11
Source File: FurnaceRecipeHandler.java From NotEnoughItems with MIT License | 5 votes |
private static void findFuels() { afuels = new ArrayList<FuelPair>(); 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)); } }
Example #12
Source File: ContainerAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
/** * @param itemStack * ItemStack to merge into inventory * @param start * minimum slot to attempt fill * @param end * maximum slot to attempt fill * @param backwards * go backwards * @return true if stacks merged successfully public boolean * mergeItemStack(itemStack, start, end, backwards) */ @Override public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2){ ItemStack var3 = null; Slot var4 = (Slot)inventorySlots.get(par2); if(var4 != null && var4.getHasStack()) { ItemStack var5 = var4.getStack(); var3 = var5.copy(); if(par2 < 5) { if(!mergeItemStack(var5, 5, 41, false)) return null; var4.onSlotChange(var5, var3); } else { if(var5.getItem() == Itemss.machineUpgrade) { if(!mergeItemStack(var5, 1, 5, false)) return null; } else if(TileEntityFurnace.isItemFuel(var5) && !mergeItemStack(var5, 0, 1, false)) return null; var4.onSlotChange(var5, var3); } if(var5.stackSize == 0) { var4.putStack((ItemStack)null); } else { var4.onSlotChanged(); } if(var5.stackSize == var3.stackSize) return null; var4.onPickupFromSlot(par1EntityPlayer, var5); } return var3; }
Example #13
Source File: CraftingHelper.java From malmo with MIT License | 5 votes |
/** * Consume fuel from the player's inventory.<br> * Take it first from their cache, if present, and then from their inventory, starting * at the first slot and working upwards. * * @param player * @param burnAmount amount of fuel to burn, in ticks. */ public static void burnInventory(EntityPlayerMP player, int burnAmount, ItemStack input) { if (!fuelCaches.containsKey(player)) fuelCaches.put(player, -burnAmount); else fuelCaches.put(player, fuelCaches.get(player) - burnAmount); int index = 0; while (fuelCaches.get(player) < 0 && index < player.inventory.mainInventory.size()) { ItemStack is = player.inventory.mainInventory.get(index); if (is != null) { int burnTime = TileEntityFurnace.getItemBurnTime(is); if (burnTime != 0) { // Consume item: if (is.getCount() > 1) is.setCount(is.getCount() - 1); else { // If this is a bucket of lava, we need to consume the lava but leave the bucket. if (is.getItem() == Items.LAVA_BUCKET) { // And if we're cooking wet sponge, we need to leave the bucket filled with water. if (input.getItem() == Item.getItemFromBlock(Blocks.SPONGE) && input.getMetadata() == 1) player.inventory.mainInventory.set(index, new ItemStack(Items.WATER_BUCKET)); else player.inventory.mainInventory.set(index, new ItemStack(Items.BUCKET)); } else player.inventory.mainInventory.get(index).setCount(0); index++; } fuelCaches.put(player, fuelCaches.get(player) + burnTime); } else index++; } else index++; } }
Example #14
Source File: CraftingHelper.java From malmo with MIT License | 5 votes |
/** * Go through player's inventory and see how much fuel they have. * * @param player * @return the amount of fuel available in ticks */ public static int totalBurnTimeInInventory(EntityPlayerMP player) { Integer fromCache = fuelCaches.get(player); int total = (fromCache != null) ? fromCache : 0; for (int i = 0; i < player.inventory.mainInventory.size(); i++) { ItemStack is = player.inventory.mainInventory.get(i); total += is.getCount() * TileEntityFurnace.getItemBurnTime(is); } return total; }
Example #15
Source File: TileEntityAirCompressor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public void updateEntity(){ if(!worldObj.isRemote) { if(burnTime < curFuelUsage && inventory[0] != null && TileEntityFurnace.isItemFuel(inventory[0]) && redstoneAllows()) { burnTime += TileEntityFurnace.getItemBurnTime(inventory[0]); maxBurnTime = burnTime; inventory[0].stackSize--; if(inventory[0].stackSize == 0) { inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); } } curFuelUsage = (int)(getBaseProduction() * getSpeedUsageMultiplierFromUpgrades(getUpgradeSlots()) / 10); if(burnTime >= curFuelUsage) { burnTime -= curFuelUsage; if(!worldObj.isRemote) { addAir((int)(getBaseProduction() * getSpeedMultiplierFromUpgrades(getUpgradeSlots()) * getEfficiency() / 100D), ForgeDirection.UNKNOWN); onFuelBurn(curFuelUsage); } } isActive = burnTime > curFuelUsage; } else if(isActive) spawnBurningParticle(); super.updateEntity(); }
Example #16
Source File: CapabilityMinecartDestination.java From Signals with GNU General Public License v3.0 | 5 votes |
/** * Tries to use fuel and returns true if succeeded. * @return */ public boolean useFuel(EntityMinecart cart){ if(motorized) { if(fuelLeft == 0) { for(int i = 0; i < fuelInv.getSizeInventory(); i++) { ItemStack fuel = fuelInv.getStackInSlot(i); if(!fuel.isEmpty()) { int fuelValue = TileEntityFurnace.getItemBurnTime(fuel); if(fuelValue > 0) { fuel.shrink(1); if(fuel.isEmpty()) { fuelInv.setInventorySlotContents(i, fuel.getItem().getContainerItem(fuel)); } fuelLeft += fuelValue; totalBurnTime = fuelValue; break; } } } } if(fuelLeft > 0) { fuelLeft--; double randX = cart.getPositionVector().x + (cart.world.rand.nextDouble() - 0.5) * 0.5; double randY = cart.getPositionVector().y + (cart.world.rand.nextDouble() - 0.5) * 0.5; double randZ = cart.getPositionVector().z + (cart.world.rand.nextDouble() - 0.5) * 0.5; NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.SMOKE_LARGE, randX, randY, randZ, 0, 0, 0), cart.world); return true; } } return false; }
Example #17
Source File: StorageESPMod.java From ForgeHax with MIT License | 5 votes |
private int getTileEntityColor(TileEntity tileEntity) { if (tileEntity instanceof TileEntityChest || tileEntity instanceof TileEntityDispenser || tileEntity instanceof TileEntityShulkerBox) { return Colors.ORANGE.toBuffer(); } else if (tileEntity instanceof TileEntityEnderChest) { return Colors.PURPLE.toBuffer(); } else if (tileEntity instanceof TileEntityFurnace) { return Colors.GRAY.toBuffer(); } else if (tileEntity instanceof TileEntityHopper) { return Colors.DARK_RED.toBuffer(); } else { return -1; } }
Example #18
Source File: CraftFurnace.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void applyTo(TileEntityFurnace furnace) { super.applyTo(furnace); if (!this.getSnapshot().hasCustomName()) { furnace.setCustomInventoryName(null); } }
Example #19
Source File: TileEntitySaltFurnace.java From TofuCraftReload with MIT License | 5 votes |
@Override public boolean isItemValidForSlot(int i, ItemStack itemstack) { switch (i) { case 0: return TileEntityFurnace.isItemFuel(itemstack); case 2: return itemstack.isItemEqual(new ItemStack(Items.GLASS_BOTTLE, 1)) || itemstack.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); } return false; }
Example #20
Source File: BlockCampfirePot.java From Sakura_mod with MIT License | 5 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) { return true; } ItemStack stack = playerIn.getHeldItem(hand); TileEntity tile = worldIn.getTileEntity(pos); if (hand == EnumHand.MAIN_HAND) { if (tile instanceof TileEntityCampfirePot) { TileEntityCampfirePot tileEntityCampfire = (TileEntityCampfirePot) tile; IFluidHandlerItem handler = FluidUtil.getFluidHandler(ItemHandlerHelper.copyStackWithSize(stack, 1)); if (handler != null) { FluidUtil.interactWithFluidHandler(playerIn, hand, tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)); return true; } if (WorldUtil.isItemFuel(stack)) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + TileEntityFurnace.getItemBurnTime(stack)); setState(true, worldIn, pos); if(stack.getItem().hasContainerItem(stack)) stack = stack.getItem().getContainerItem(stack); else stack.shrink(1); return true; } if (stack.getItem() == Items.FLINT_AND_STEEL) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + 10000); setState(true, worldIn, pos); stack.damageItem(1, playerIn); return true; } playerIn.openGui(SakuraMain.instance, SakuraGuiHandler.ID_CAMPFIREPOT, worldIn, pos.getX(), pos.getY(), pos.getZ()); return true; } } return true; }
Example #21
Source File: SteamCoalBoiler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void tryConsumeNewFuel() { ItemStack fuelInSlot = importItems.extractItem(0, 1, true); if (fuelInSlot.isEmpty()) return; int burnTime = TileEntityFurnace.getItemBurnTime(fuelInSlot); if (burnTime <= 0) return; importItems.extractItem(0, 1, false); ItemStack remainderAsh = ModHandler.getBurningFuelRemainder(getWorld().rand, fuelInSlot); if (!remainderAsh.isEmpty()) { //we don't care if we can't insert ash - it's chanced anyway exportItems.insertItem(0, remainderAsh, false); } setFuelMaxBurnTime(burnTime); }
Example #22
Source File: SteamCoalBoiler.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public IItemHandlerModifiable createImportItemHandler() { return new ItemStackHandler(1) { @Nonnull @Override public ItemStack insertItem(int slot, @Nonnull ItemStack stack, boolean simulate) { if (TileEntityFurnace.getItemBurnTime(stack) <= 0) return stack; return super.insertItem(slot, stack, simulate); } }; }
Example #23
Source File: BW_TileEntity_HeatedWaterPump.java From bartworks with MIT License | 5 votes |
private void handleRefuel() { if (this.fuelstack != null && this.fuel == 0) { this.fuel = this.maxfuel = TileEntityFurnace.getItemBurnTime(this.fuelstack); --this.fuelstack.stackSize; if (this.fuelstack.stackSize <= 0) this.fuelstack = null; } }
Example #24
Source File: TileEntitySaltFurnace.java From TofuCraftReload with MIT License | 4 votes |
/** * Like the old updateEntity(), except more generic. */ @Override public void update() { boolean wasBurning = isBurning(); if (isBurning()) furnaceBurnTime--; int cauldron = this.getCauldronStatus(); boolean isDirty = false; if (!world.isRemote) { if (furnaceBurnTime == 0 && this.canBoil(cauldron)) { ItemStack fuel = furnaceItemStacks.get(0); furnaceBurnTime = TileEntityFurnace.getItemBurnTime(fuel); if (furnaceBurnTime > 0) { isDirty = true; fuel.shrink(1); if (fuel.getCount() == 0) { furnaceItemStacks.set(0, fuel.getItem().getContainerItem(fuel)); } } } if (isBurning() && canBoil(cauldron) && cauldron >= 1) { cookTime++; if (cookTime == 200) { cookTime = 0; boilDown(); isDirty = true; } } else cookTime = 0; if (wasBurning != isBurning()) { isDirty = true; BlockSaltFurnace.setState(isBurning(), world, pos); } if (this.isBurning()) { if (cauldron == -1) { this.world.setBlockState(this.pos.up(), Blocks.FIRE.getDefaultState().withProperty(BlockFire.AGE, 0)); } else if (cauldron == -2) { if (this.world.rand.nextInt(200) == 0) { this.world.setBlockState(this.pos.up(2), Blocks.FIRE.getDefaultState().withProperty(BlockFire.AGE, 0)); } } } // Output nigari this.outputNigari(); } updateCauldronStatus(); if (isDirty) markDirty(); }
Example #25
Source File: CraftInventoryFurnace.java From Kettle with GNU General Public License v3.0 | 4 votes |
public CraftInventoryFurnace(TileEntityFurnace inventory) { super(inventory); }
Example #26
Source File: BlockCampfire.java From Sakura_mod with MIT License | 4 votes |
@Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) return true; ItemStack stack = playerIn.getHeldItem(hand); TileEntity tile = worldIn.getTileEntity(pos); if (hand == EnumHand.MAIN_HAND) { if (tile instanceof TileEntityCampfire) { TileEntityCampfire tileEntityCampfire = (TileEntityCampfire) tile; if(tileEntityCampfire.getInventory().isItemValid(0,stack)&& tileEntityCampfire.getInventory().getStackInSlot(0).getCount() < 16){ ItemStack campfireStack=new ItemStack(stack.getItem(),1,stack.getMetadata()); stack.shrink(1); tileEntityCampfire.getInventory().insertItem(0,campfireStack,false); return true; } if(stack.getItem()==ItemLoader.POT){ worldIn.setBlockToAir(pos); worldIn.removeTileEntity(pos); worldIn.setBlockState(pos, BlockLoader.CAMPFIRE_POT_IDLE.getDefaultState()); stack.shrink(1); return true; } if (WorldUtil.isItemFuel(stack)) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + TileEntityFurnace.getItemBurnTime(stack)); setState(true, worldIn, pos); if(stack.getItem().hasContainerItem(stack)) stack = stack.getItem().getContainerItem(stack); else stack.shrink(1); return true; } if (stack.getItem() == Items.FLINT_AND_STEEL) { tileEntityCampfire.setBurningTime(tileEntityCampfire.getBurningTime() + 10000); setState(true, worldIn, pos); stack.damageItem(1, playerIn); return true; } if(stack.isEmpty()){ Block.spawnAsEntity(worldIn, pos, ((TileEntityCampfire) tile).getInventory().getStackInSlot(0)); ((TileEntityCampfire) tile).getInventory().setStackInSlot(0, ItemStack.EMPTY); return true; } } } return true; }
Example #27
Source File: HeatBehaviourFurnace.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public boolean isApplicable(){ return getTileEntity() instanceof TileEntityFurnace; }
Example #28
Source File: BW_FuelSlot.java From bartworks with MIT License | 4 votes |
@Override public boolean isItemValid(ItemStack itemStack) { return TileEntityFurnace.getItemBurnTime(itemStack) > 0; }
Example #29
Source File: SlotFuel.java From archimedes-ships with MIT License | 4 votes |
@Override public boolean isItemValid(ItemStack itemstack) { return TileEntityFurnace.isItemFuel(itemstack); }
Example #30
Source File: TileEntityEngine.java From archimedes-ships with MIT License | 4 votes |
@Override public boolean isItemValidForSlot(int i, ItemStack is) { return i >= 0 && i < 4 && TileEntityFurnace.isItemFuel(is); }