[1.7.10](Crash)Открытие ГУИ кастомной печи

Когда крашлог ругается на мой код, я примерно понимаю, что нужно делать, а когда вот так...
Код GuiRubberFactory:
Код:
package com.alternativemod.gui;

import org.lwjgl.opengl.GL11;
import com.alternativemod.blocks.RubberFactory;
import com.alternativemod.containers.RubberFactoryContainer;
import com.alternativemod.tile.entity.TileEntityRubberFactory;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.ForgeVersion.Status;

@SideOnly(Side.CLIENT)
public class GuiRubberFactory extends GuiContainer {
    
    private static final ResourceLocation furnaceGuiTextures = new ResourceLocation("textures/gui/container/furnace.png");
    private TileEntityRubberFactory tilefactory;

    public GuiRubberFactory(InventoryPlayer invPlayer, TileEntityRubberFactory tile) {
        super(new RubberFactoryContainer(invPlayer, tile));
        this.tilefactory = tile;
        
    }
    
    protected void drawGuiContainerForegroundLayer(int par1, int par2){
        String string = this.tilefactory.hasCustomInventoryName() ? this.tilefactory.getInventoryName() : I18n.format(this.tilefactory.getInventoryName(), new Object[0]);
        this.fontRendererObj.drawString(string, this.xSize / 2 - this.fontRendererObj.getStringWidth(string), 6, 4210752);
        this.fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, this.ySize - 94, 4210752);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {
         GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.getTextureManager().bindTexture(furnaceGuiTextures);
            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 (RubberFactory.isBurning)
            {
                i1 = this.tilefactory.getBurnTimeRemainingScaled(12);
                this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
            }

            i1 = this.tilefactory.getCookProgressScaled(24);
            this.drawTexturedModalRect(k + 79, l + 34, 176, 14, i1 + 1, 16);
    }
}

Краш  лог:
Код:
---- Minecraft Crash Report ----
// I let you down. Sorry :(

Time: 28.11.15 11:21
Description: Rendering screen

java.lang.NullPointerException: Rendering screen
    at net.minecraft.inventory.Slot.getStack(Slot.java:88)
    at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:219)
    at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114)
    at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1137)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067)
    at net.minecraft.client.Minecraft.run(Minecraft.java:962)
    at net.minecraft.client.main.Main.main(Main.java:164)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
    at GradleStart.main(Unknown Source)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
    at net.minecraft.inventory.Slot.getStack(Slot.java:88)
    at net.minecraft.client.gui.inventory.GuiContainer.func_146977_a(GuiContainer.java:219)
    at net.minecraft.client.gui.inventory.GuiContainer.drawScreen(GuiContainer.java:114)

-- Screen render details --
Details:
    Screen name: com.alternativemod.gui.GuiRubberBase
    Mouse location: Scaled: (213, 119). Absolute: (427, 240)
    Screen size: Scaled: (427, 240). Absolute: (854, 480). Scale factor of 2

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityClientPlayerMP['Player935'/171, l='MpServer', x=-241,96, y=5,62, z=-90,86]]
    Chunk stats: MultiplayerChunkCache: 289, 289
    Level seed: 0
    Level generator: ID 01 - flat, ver 0. Features enabled: false
    Level generator options: 
    Level spawn location: World: (-265,4,-139), Chunk: (at 7,0,5 in -17,-9; contains blocks -272,0,-144 to -257,255,-129), Region: (-1,-1; contains chunks -32,-32 to -1,-1, blocks -512,0,-512 to -1,255,-1)
    Level time: 290388 game time, 10944 day time
    Level dimension: 0
    Level storage version: 0x00000 - Unknown?
    Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false
    Forced entities: 17 total; [EntityCow['Cow'/64, l='MpServer', x=-292,94, y=4,00, z=-129,88], EntityBat['Bat'/160, l='MpServer', x=-166,59, y=4,71, z=-7,97], EntitySheep['Sheep'/65, l='MpServer', x=-289,50, y=4,00, z=-121,47], EntityBat['Bat'/161, l='MpServer', x=-168,83, y=14,77, z=-31,02], EntityHorse['Horse'/162, l='MpServer', x=-174,94, y=4,00, z=-15,06], EntityHorse['Horse'/67, l='MpServer', x=-281,28, y=4,00, z=-118,25], EntityHorse['Horse'/71, l='MpServer', x=-279,04, y=4,00, z=-41,90], EntityCow['Cow'/81, l='MpServer', x=-254,94, y=4,00, z=-159,88], EntityClientPlayerMP['Player935'/171, l='MpServer', x=-241,96, y=5,62, z=-90,86], EntityCow['Cow'/151, l='MpServer', x=-186,78, y=4,00, z=-168,34], EntityPig['Pig'/92, l='MpServer', x=-225,06, y=4,00, z=-164,97], EntityChicken['Chicken'/93, l='MpServer', x=-234,41, y=4,00, z=-151,59], EntityPig['Pig'/125, l='MpServer', x=-214,66, y=4,00, z=-169,81], EntityChicken['Chicken'/62, l='MpServer', x=-306,53, y=4,00, z=-152,97], EntityCow['Cow'/158, l='MpServer', x=-166,81, y=4,00, z=-158,19], EntityCow['Cow'/63, l='MpServer', x=-309,81, y=4,00, z=-81,81], EntityChicken['Chicken'/159, l='MpServer', x=-170,47, y=4,00, z=-124,44]]
    Retry entities: 0 total; []
    Server brand: fml,forge
    Server type: Integrated singleplayer server
Stacktrace:
    at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415)
    at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566)
    at net.minecraft.client.Minecraft.run(Minecraft.java:984)
    at net.minecraft.client.main.Main.main(Main.java:164)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
    at GradleStart.main(Unknown Source)

-- System Details --
Details:
    Minecraft Version: 1.7.10
    Operating System: Windows 7 (x86) version 6.1
    Java Version: 1.8.0_65, Oracle Corporation
    Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
    Memory: 947547160 bytes (903 MB) / 1046937600 bytes (998 MB) up to 1046937600 bytes (998 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1448 4 mods loaded, 4 mods active
    States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    UCHIJAAAA    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
    UCHIJAAAA    FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) 
    UCHIJAAAA    Forge{10.13.4.1448} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1448-1.7.10.jar) 
    UCHIJAAAA    alternativemod{0.0.1} [Alternative Mod] (bin) 
    GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.4.13283 Compatibility Profile Context 14.501.1003.0' Renderer: 'AMD Radeon HD 6520G'
    Launched Version: 1.7.10
    LWJGL: 2.9.1
    OpenGL: AMD Radeon HD 6520G GL version 4.4.13283 Compatibility Profile Context 14.501.1003.0, ATI Technologies Inc.
    GL Caps: Using GL 1.3 multitexturing.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Anisotropic filtering is supported and maximum anisotropy is 16.
Shaders are available because OpenGL 2.1 is supported.

    Is Modded: Definitely; Client brand changed to 'fml,forge'
    Type: Client (map_client.txt)
    Resource Packs: []
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
    Anisotropic Filtering: Off (1)
 

timaxa007

Модератор
5,831
409
672
ChooseLife написал(а):
Краш  лог:
Код:
java.lang.NullPointerException: Rendering screen
    at net.minecraft.inventory.Slot.getStack(Slot.java:88)
Не может от рендерить, предположительно слот. Предположение: - "Ты пытаешь использовать слот, которого нет у тебя в контейнере. Тем самым твой GuiContainer, пытается рендерить твой слот".
Хоть краш-лог - есть, но этого не достаточно, чтобы точно подсказать.
 
Мой Container

Код:
package com.alternativemod.containers;

import com.alternativemod.RubberFactoryRecipes;
import com.alternativemod.tile.entity.TileEntityRubberFactory;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;

public class RubberFactoryContainer extends Container {
    
    private TileEntityRubberFactory tileFactory;

    private int lastCookTime;
    private int lastBurnTime;
    private int lastItemBurnTime;
    
    public RubberFactoryContainer(InventoryPlayer player, TileEntityRubberFactory tileEntityFurnace){
        this.tileFactory = tileEntityFurnace;
        this.addSlotToContainer(new Slot(tileEntityFurnace, 0, 56, 17));
        this.addSlotToContainer(new Slot(tileEntityFurnace, 1, 56, 53));
        this.addSlotToContainer(new SlotFurnace(player.player, tileEntityFurnace, 2, 116, 35));
    }

    public void addCraftingToCrafters(ICrafting craft){
        super.addCraftingToCrafters(craft);
        craft.sendProgressBarUpdate(this, 0, this.tileFactory.furnaceCookTime);
        craft.sendProgressBarUpdate(this, 1, this.tileFactory.furnaceBurnTime);
        craft.sendProgressBarUpdate(this, 2, this.tileFactory.currentBurnTime);
    }
    
    public void detectAndSendChanges(){
        super.detectAndSendChanges();    
        for(int i = 0; i < this.crafters.size(); ++i){
            ICrafting craft = (ICrafting) this.crafters.get(i);
            
            if(this.lastCookTime != this.tileFactory.furnaceCookTime){
                craft.sendProgressBarUpdate(this, 0, this.tileFactory.furnaceCookTime);
            }
            
            if(this.lastBurnTime != this.tileFactory.furnaceBurnTime){
                craft.sendProgressBarUpdate(this, 1, this.tileFactory.furnaceBurnTime);
            }
            
            if(this.lastItemBurnTime != this.tileFactory.currentBurnTime){
                craft.sendProgressBarUpdate(this, 2, this.tileFactory.currentBurnTime);
            }
        }
        
        this.lastBurnTime = this.tileFactory.furnaceBurnTime;
        this.lastCookTime = this.tileFactory.furnaceCookTime;
        this.lastItemBurnTime = this.tileFactory.currentBurnTime;
    }
    
    @SideOnly(Side.CLIENT)
    public void updateProgressBar(int par1, int par2){
        if(par1 == 0){
            this.tileFactory.furnaceCookTime = par2;
        }
        
        if(par1 == 1){
            this.tileFactory.furnaceBurnTime = par2;
        }
        
        if(par1 == 2){
            this.tileFactory.currentBurnTime = par2;
        }
    }
    
    @Override
    public boolean canInteractWith(EntityPlayer player) {
        return this.tileFactory.isUseableByPlayer(player);
    }
    
    public ItemStack transferStackInSlot(EntityPlayer player, 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 == 2){
                if(!this.mergeItemStack(itemstack1, 3, 39, true)){
                    return null;
                }
                slot.onSlotChange(itemstack1, itemstack);
            }else if(par2 != 1 && par2 != 0){
                if(RubberFactoryRecipes.smelting().getSmeltingResult(itemstack1) != null){
                    if(!this.mergeItemStack(itemstack1, 0, 1, false)){
                        return null;
                    }
                }else if(TileEntityRubberFactory.isItemFuel(itemstack1)){
                    if(!this.mergeItemStack(itemstack1, 1, 2, false)){
                        return null;
                        }
                }else if(par2 >=3 && par2 < 30){
                    if(!this.mergeItemStack(itemstack1, 30, 39, false)){
                        return null;
                    }
                }else if(par2 >= 30 && par2 < 39 && !this.mergeItemStack(itemstack1, 3, 30, false)){
                    return null;
                }
            }else if(!this.mergeItemStack(itemstack1, 3, 39, false)){
                return null;
            }
            if(itemstack1.stackSize == 0){
                slot.putStack((ItemStack)null);
            }else{
                slot.onSlotChanged();
            }
            if(itemstack1.stackSize == itemstack.stackSize){
                return null;
            }
            slot.onPickupFromSlot(player, itemstack1);
        }
        return itemstack;
    }
}

Три слота добавляю, вроде все нормально(
 
После слотов печи добавил:
Код:
for (i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 9; ++j)
                {
                    this.addSlotToContainer(new Slot(p_i1812_1_, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
                }
            }

            for (i = 0; i < 9; ++i)
            {
                this.addSlotToContainer(new Slot(p_i1812_1_, i, 8 + i * 18, 142));
            }
        }

Результат тот же(

UPD: Весь класс контейнер скопировал из ванильной печки, поменял тайл на свой, то же самое(

UPD2: Еще, кстати, во всех крашлогах верхняя строка "at net.minecraft.inventory.Slot.getStack(Slot.java:88)" одинакова. А нижние могут изменятся, я так понимаю он вызывает эту ф-цию из разных мест, и все время не получается?

Метод в Slot.class:
/**
* Helper fnct to get the stack in the slot.
*/
public ItemStack getStack()
{
return this.inventory.getStackInSlot(this.slotIndex);
}

Что я могу не так делать? Разве что Индекс не правильный подавать... Или дело совсем не в этом
 

timaxa007

Модератор
5,831
409
672
Так-же ещё нужно будет смотреть инвентарь "TileEntityRubberFactory".
Делаешь "кастомной печи", но вот будешь добавлять слоты игрока?
[merge_posts_bbcode]Добавлено: 28.11.2015 14:24:12[/merge_posts_bbcode]

По #4 посту, и что ты пытался добавить? Слоты игрока? Если - да, то не понятно какие переменные ты используешь, я про "p_i1812_1_" (я догадываюсь, что это инвентарь игрока).
 
p_i1812_1_ = InventoryPlayer player из прошлого поста
[merge_posts_bbcode]Добавлено: 28.11.2015 15:29:42[/merge_posts_bbcode]

Мой TileEntityRubberFactory:

Код:
package com.alternativemod.tile.entity;

import com.alternativemod.AlternativeItems;
import com.alternativemod.RubberFactoryRecipes;
import com.alternativemod.blocks.RubberFactory;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemTool;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
public class TileEntityRubberFactory extends TileEntity  implements ISidedInventory{
    
    private static final int[] slotsTop = new int[]{0};
    private static final int[] slotsBottom = new int[]{2, 1};
    private static final int[] slotsSides = new int[]{1};
    
    private ItemStack[] furnaceItemStacks = new ItemStack [3];
    
    public int furnaceBurnTime;
    public int currentBurnTime;
    public int  furnaceCookTime;
    private String furnaceName;
    
    
    @Override
    public int getSizeInventory() {
        return this.furnaceItemStacks.length;    
    }

    @Override
    public ItemStack getStackInSlot(int slot) {
        return this.furnaceItemStacks[slot];
    }

    @Override
    public ItemStack decrStackSize(int slot, int par2) {
        if(this.furnaceItemStacks[slot]!= null){
            ItemStack itemstack;
            if (this.furnaceItemStacks[slot].stackSize <= par2)
            {
                itemstack = this.furnaceItemStacks[slot];
                this.furnaceItemStacks[slot] = null;
                return itemstack;
            }
            else
            {
                itemstack = this.furnaceItemStacks[slot].splitStack(par2);

                if (this.furnaceItemStacks[slot].stackSize == 0)
                {
                    this.furnaceItemStacks[slot] = null;
                }

                return itemstack;
            }
        }else{
            return null;
        }
    }
    
    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
        if(this.furnaceItemStacks[slot]!= null){
            ItemStack itemstack = this.furnaceItemStacks[slot];
            this.furnaceItemStacks[slot] = null;
            return itemstack;
        }else{
            return null;
        }
        
    }

    @Override
    public void setInventorySlotContents(int slot, ItemStack itemstack) {
        this.furnaceItemStacks[slot] = itemstack;

        if (itemstack != null && itemstack.stackSize > this.getInventoryStackLimit()) {
            itemstack.stackSize = this.getInventoryStackLimit();
        }

    }

    @Override
    public String getInventoryName() {
        return this.hasCustomInventoryName() ? this.furnaceName : "Tut Furnace";
    }

    @Override
    public boolean hasCustomInventoryName() {
        return this.furnaceName != null && this.furnaceName.length() > 0;
    }

    @Override
    public int getInventoryStackLimit() {
        return 64;
    }

    public void readFromNBT(NBTTagCompound tagCompound) {
        super.readFromNBT(tagCompound);
        NBTTagList tagList = tagCompound.getTagList("Items", 10);
        this.furnaceItemStacks = new ItemStack[this.getSizeInventory()];

        for (int i = 0; i < tagList.tagCount(); ++i) {
            NBTTagCompound tabCompound1 = tagList.getCompoundTagAt(i);
            byte byte0 = tabCompound1.getByte("Slot");

            if (byte0 >= 0 && byte0 < this.furnaceItemStacks.length) {
                this.furnaceItemStacks[byte0] = ItemStack.loadItemStackFromNBT(tabCompound1);
            }
        }

        this.furnaceBurnTime = tagCompound.getShort("BurnTime");
        this.furnaceCookTime = tagCompound.getShort("CookTime");
        this.currentBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

        if (tagCompound.hasKey("CustomName", 8)) {
            this.furnaceName = tagCompound.getString("CustomName");
        }
    }

    public void writeToNBT(NBTTagCompound tagCompound) {
        super.writeToNBT(tagCompound);
        tagCompound.setShort("BurnTime", (short) this.furnaceBurnTime);
        tagCompound.setShort("CookTime", (short) this.furnaceBurnTime);
        NBTTagList tagList = new NBTTagList();

        for (int i = 0; i < this.furnaceItemStacks.length; ++i) {
            if (this.furnaceItemStacks[i] != null) {
                NBTTagCompound tagCompound1 = new NBTTagCompound();
                tagCompound1.setByte("Slot", (byte) i);
                this.furnaceItemStacks[i].writeToNBT(tagCompound1);
                tagList.appendTag(tagCompound1);
            }
        }

        tagCompound.setTag("Items", tagList);

        if (this.hasCustomInventoryName()) {
            tagCompound.setString("CustomName", this.furnaceName);
        }
    }

    
    public int getCookProgressScaled(int par1) {
        return this.furnaceCookTime * par1 / 200;
    }

    
    public int getBurnTimeRemainingScaled(int par1) {
        if (this.currentBurnTime == 0) {
            this.currentBurnTime = 200;
        }

        return this.furnaceBurnTime * par1 / this.currentBurnTime;
    }

    public boolean isBurning() {
        return this.furnaceBurnTime > 0;
    }

    public void updateEntity() {
        boolean flag = this.furnaceBurnTime > 0;
        boolean flag1 = false;

        if (this.furnaceBurnTime > 0) {
            --this.furnaceBurnTime;
        }

        if (!this.worldObj.isRemote) {
            if (this.furnaceBurnTime == 0 && this.canSmelt()) {
                this.currentBurnTime = this.furnaceBurnTime = getItemBurnTime(this.furnaceItemStacks[1]);

                if (this.furnaceBurnTime > 0) {
                    flag1 = true;
                    if (this.furnaceItemStacks[1] != null) {
                        --this.furnaceItemStacks[1].stackSize;

                        if (this.furnaceItemStacks[1].stackSize == 0) {
                            this.furnaceItemStacks[1] = furnaceItemStacks[1].getItem().getContainerItem(this.furnaceItemStacks[1]);
                        }
                    }
                }
            }

            if (this.isBurning() && this.canSmelt()) {
                ++this.furnaceCookTime;
                if (this.furnaceCookTime == 200) {
                    this.furnaceCookTime = 0;
                    this.smeltItem();
                    flag1 = true;
                }
            } else {
                this.furnaceCookTime = 0;
            }
        }

        if (flag != this.furnaceBurnTime > 0) {
            flag1 = true;
            RubberFactory.updateBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
        }

        if (flag1) {
            this.markDirty();
        }
    }

    private boolean canSmelt() {
        if (this.furnaceItemStacks[0] == null) {
            return false;
        } else {
            ItemStack itemstack = RubberFactoryRecipes.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();
        }
    }

    public void smeltItem() {
        if (this.canSmelt()) {
            ItemStack itemstack = RubberFactoryRecipes.smelting().getSmeltingResult(this.furnaceItemStacks[0]);

            if (this.furnaceItemStacks[2] == null) {
                this.furnaceItemStacks[2] = itemstack.copy();
            } else if (this.furnaceItemStacks[2].getItem() == itemstack.getItem()) {
                this.furnaceItemStacks[2].stackSize += itemstack.stackSize;
            }
            
            --this.furnaceItemStacks[0].stackSize;
            
            if(this.furnaceItemStacks[0].stackSize >= 0){
                this.furnaceItemStacks[0] = null;
            }
        }
    }
    
    public static int getItemBurnTime(ItemStack itemstack){
        if(itemstack == null){
            return 0;
        }else{
            Item item = itemstack.getItem();
            
            if(item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.air){
                Block block = Block.getBlockFromItem(item);
                
                if(block.getMaterial() == Material.rock){
                    return 300;
                }//                                                                                    TODO
            }
            
            if(item == AlternativeItems.alternativeStick) return 1600;
            if(item instanceof ItemTool && ((ItemTool) item).getToolMaterialName().equals("EMERALD")) return 300;
            return GameRegistry.getFuelValue(itemstack);
        }
    }

    public static boolean isItemFuel(ItemStack itemstack){
        return getItemBurnTime(itemstack) > 0;
    }
    
    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
        return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : player.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
    }

    @Override
    public void openInventory() {

    }

    @Override
    public void closeInventory() {

    }

    @Override
    public boolean isItemValidForSlot(int par1, ItemStack itemstack) {
        return par1 == 2 ? false : (par1 == 1 ? isItemFuel(itemstack) : true);
    }

    @Override
    public int[] getAccessibleSlotsFromSide(int par1) {
        return par1 == 0 ? slotsBottom : (par1 == 1 ? slotsTop : slotsSides);
    }

    @Override
    public boolean canInsertItem(int par1, ItemStack itemstack, int par3) {
        return this.isItemValidForSlot(par1, itemstack);
    }

    @Override
    public boolean canExtractItem(int par1, ItemStack itemstack, int par3) {
        return par3 != 0 || par1 != 1 || itemstack.getItem() == Items.bucket;
    }

}
 
Сверху