[1.7.10](Crash)Краш при открытии гуи

Код:
---- Minecraft Crash Report ----
// I'm sorry, Dave.

Time: 05.09.15 19:52
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
    at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
    at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
    at com.alternativemod.blocks.RubberBase.onBlockActivated(RubberBase.java:50)
    at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
    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 cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
    at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
    at com.alternativemod.blocks.RubberBase.onBlockActivated(RubberBase.java:50)
    at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityClientPlayerMP['Player359'/169, l='MpServer', x=-157,10, y=5,62, z=-221,92]]
    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: 231763 game time, 155435 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: 68 total; [EntityCow['Cow'/128, l='MpServer', 
x=-206,66, y=4,00, z=-251,25], EntityHorse['Horse'/129, l='MpServer', 
x=-206,97, y=4,00, z=-225,88], EntitySheep['Sheep'/130, l='MpServer', 
x=-205,46, y=4,00, z=-234,56], EntityHorse['Horse'/131, l='MpServer', 
x=-199,28, y=4,00, z=-221,59], EntityCow['Cow'/132, l='MpServer', 
x=-207,13, y=4,00, z=-190,81], EntityChicken['Chicken'/133, 
l='MpServer', x=-199,19, y=4,00, z=-162,31], EntityCow['Cow'/134, 
l='MpServer', x=-193,34, y=4,00, z=-165,13], EntityPig['Pig'/135, 
l='MpServer', x=-203,84, y=4,00, z=-158,78], EntitySheep['Sheep'/137, 
l='MpServer', x=-180,91, y=4,00, z=-275,06], EntitySheep['Sheep'/138, 
l='MpServer', x=-178,81, y=4,00, z=-267,13], EntityPig['Pig'/139, 
l='MpServer', x=-184,59, y=4,00, z=-269,81], EntityCow['Cow'/140, 
l='MpServer', x=-184,88, y=4,00, z=-259,84], EntityPig['Pig'/141, 
l='MpServer', x=-180,19, y=4,00, z=-258,22], EntityPig['Pig'/142, 
l='MpServer', x=-190,44, y=4,00, z=-258,88], EntityPig['Pig'/143, 
l='MpServer', x=-175,95, y=4,00, z=-235,75], EntityCow['Cow'/144, 
l='MpServer', x=-190,22, y=4,00, z=-246,81], EntityHorse['Horse'/145, 
l='MpServer', x=-190,91, y=4,00, z=-251,03], EntityPig['Pig'/146, 
l='MpServer', x=-180,97, y=4,00, z=-248,94], EntityCow['Cow'/147, 
l='MpServer', x=-187,16, y=4,00, z=-238,16], EntityHorse['Horse'/148, 
l='MpServer', x=-178,06, y=4,00, z=-232,00], 
EntityChicken['Chicken'/149, l='MpServer', x=-184,81, y=4,00, 
z=-235,28], EntityChicken['Chicken'/150, l='MpServer', x=-180,56, 
y=4,00, z=-215,44], EntityCow['Cow'/151, l='MpServer', x=-177,31, 
y=4,00, z=-164,59], EntityCow['Cow'/153, l='MpServer', x=-172,84, 
y=4,00, z=-269,06], EntityHorse['Horse'/154, l='MpServer', x=-171,91, 
y=4,00, z=-250,34], EntityPig['Pig'/155, l='MpServer', x=-167,81, 
y=4,00, z=-231,09], EntityCow['Cow'/156, l='MpServer', x=-175,21, 
y=4,00, z=-237,59], EntityPig['Pig'/159, l='MpServer', x=-145,94, 
y=4,00, z=-260,88], EntityHorse['Horse'/160, l='MpServer', x=-156,00, 
y=4,00, z=-248,81], EntitySheep['Sheep'/161, l='MpServer', x=-147,47, 
y=4,00, z=-213,69], EntitySheep['Sheep'/162, l='MpServer', x=-133,91, 
y=4,00, z=-253,91], EntityCow['Cow'/163, l='MpServer', x=-141,47, 
y=4,00, z=-161,16], 
EntityMinecartEmpty['entity.MinecartRideable.name'/164, l='MpServer', 
x=-130,91, y=4,50, z=-145,21], EntityPig['Pig'/165, l='MpServer', 
x=-122,97, y=4,00, z=-268,06], EntityChicken['Chicken'/166, 
l='MpServer', x=-121,53, y=4,00, z=-247,41], EntityHorse['Horse'/167, 
l='MpServer', x=-121,00, y=4,00, z=-214,19], 
EntityChicken['Chicken'/168, l='MpServer', x=-83,91, y=4,00, z=-221,19],
 EntityClientPlayerMP['Player359'/169, l='MpServer', x=-157,10, y=5,62, 
z=-221,92], EntitySheep['Sheep'/80, l='MpServer', x=-229,09, y=4,00, 
z=-284,09], EntitySheep['Sheep'/81, l='MpServer', x=-228,84, y=4,00, 
z=-276,25], EntityChicken['Chicken'/82, l='MpServer', x=-232,22, y=4,00,
 z=-279,11], EntityPig['Pig'/83, l='MpServer', x=-229,97, y=4,00, 
z=-253,88], EntitySheep['Sheep'/84, l='MpServer', x=-232,69, y=4,00, 
z=-225,95], EntityPig['Pig'/85, l='MpServer', x=-230,91, y=4,00, 
z=-237,94], EntityCow['Cow'/86, l='MpServer', x=-225,09, y=4,00, 
z=-214,91], EntityHorse['Horse'/87, l='MpServer', x=-227,11, y=4,00, 
z=-205,94], EntityChicken['Chicken'/89, l='MpServer', x=-235,34, y=4,00,
 z=-159,56], EntitySheep['Sheep'/106, l='MpServer', x=-220,38, y=4,00, 
z=-259,72], EntitySheep['Sheep'/107, l='MpServer', x=-221,28, y=4,00, 
z=-253,81], EntityChicken['Chicken'/108, l='MpServer', x=-209,56, 
y=4,00, z=-248,56], EntitySheep['Sheep'/109, l='MpServer', x=-217,78, 
y=4,00, z=-242,84], EntityPig['Pig'/110, l='MpServer', x=-208,69, 
y=4,00, z=-235,80], EntityChicken['Chicken'/111, l='MpServer', 
x=-224,65, y=4,00, z=-221,14], EntityPig['Pig'/112, l='MpServer', 
x=-221,84, y=4,00, z=-209,59], EntityHorse['Horse'/113, l='MpServer', 
x=-211,81, y=4,00, z=-209,03], EntityCow['Cow'/114, l='MpServer', 
x=-223,69, y=4,00, z=-202,50], EntityPig['Pig'/115, l='MpServer', 
x=-215,50, y=4,00, z=-205,94], EntityChicken['Chicken'/116, 
l='MpServer', x=-210,44, y=4,00, z=-195,47], EntityPig['Pig'/117, 
l='MpServer', x=-219,98, y=4,00, z=-176,94], EntityPig['Pig'/118, 
l='MpServer', x=-218,25, y=4,00, z=-178,24], EntitySheep['Sheep'/119, 
l='MpServer', x=-208,76, y=4,00, z=-168,67], EntitySheep['Sheep'/121, 
l='MpServer', x=-202,56, y=4,00, z=-261,31], EntityPig['Pig'/122, 
l='MpServer', x=-206,25, y=4,00, z=-262,84], EntityCow['Cow'/123, 
l='MpServer', x=-200,28, y=4,00, z=-259,69], EntitySheep['Sheep'/124, 
l='MpServer', x=-195,25, y=4,00, z=-255,41], EntityPig['Pig'/125, 
l='MpServer', x=-200,09, y=4,00, z=-245,78], EntitySheep['Sheep'/126, 
l='MpServer', x=-200,13, y=4,00, z=-252,44], EntityPig['Pig'/127, 
l='MpServer', x=-207,97, y=4,00, z=-252,50]]
    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:991)
    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_45, Oracle Corporation
    Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
    Memory: 936165288 bytes (892 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)

RubberBase:

Код:
package com.alternativemod.blocks;


import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

import com.alternativemod.AlternativeBlocks;
import com.alternativemod.AlternativeMod;
import com.alternativemod.gui.GuiRubberBase;
import com.alternativemod.tile.entity.TileEntityRubberBase;

public class RubberBase extends BlockContainer {
    
    public RubberBase(Material material) {
        super(material);
        setHardness(2.0F);
        setResistance(5.0F);
        setBlockName("RubberBase");
        setCreativeTab(AlternativeMod.tabAlternative);
}
    
     @Override
     public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int metadata, float what, float these, float are) {
             TileEntityRubberBase tileEntity =(TileEntityRubberBase) world.getTileEntity(x, y, z);
             if (tileEntity == null || player.isSneaking()) {
                     return false;
             }
             
             
     player.openGui(new GuiRubberBase(player.inventory, tileEntity), 0, world, x, y, z);
             return true;
     }
     @Override
     public void breakBlock(World world, int x, int y, int z, Block block, int par6)
        {
            super.breakBlock(world, x, y, z, block, par6);
            world.removeTileEntity(x, y, z);
        }    

     private void dropItems(World world, int x, int y, int z){
         Random rand = new Random();

         TileEntity tileEntity = world.getTileEntity(x, y, z);
         if (!(tileEntity instanceof IInventory)) {
                 return;
         }
         IInventory inventory = (IInventory) tileEntity;

         for (int i = 0; i < inventory.getSizeInventory(); i++) {
                 ItemStack item = inventory.getStackInSlot(i);

                 if (item != null && item.stackSize > 0) {
                         float rx = rand.nextFloat() * 0.8F + 0.1F;
                         float ry = rand.nextFloat() * 0.8F + 0.1F;
                         float rz = rand.nextFloat() * 0.8F + 0.1F;

                         EntityItem entityItem = new EntityItem(world, x + rx, y + ry, z + rz,
                                         item); //Странно

                         if (item.hasTagCompound()) {
                                 entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
                         }

                         float factor = 0.05F;
                         entityItem.motionX = rand.nextGaussian() * factor;
                         entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
                         entityItem.motionZ = rand.nextGaussian() * factor;
                         world.spawnEntityInWorld(entityItem);
                         item.stackSize = 0;
                 }
         }
 }
     /**
     * Returns a new instance of a block's tile entity class. Called on placing the block.
     */
     @Override
     public TileEntity createNewTileEntity(World world, int h) {
             return new TileEntityRubberBase();
     }
    
}


TileEntityRubberBase:

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

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;

public class TileEntityRubberBase extends TileEntity implements IInventory  {
    
    private ItemStack[] inv;
    
     public TileEntityRubberBase(){
         inv = new ItemStack[9];
     }
     
     @Override
     public int getSizeInventory() {
         return inv.length;
     }
     @Override
     public ItemStack getStackInSlot(int slot) {
         return inv[slot];
     }
     
     @Override
     public void setInventorySlotContents(int slot, ItemStack stack) {
         inv[slot] = stack;
         if (stack != null && stack.stackSize > getInventoryStackLimit()) {
                 stack.stackSize = getInventoryStackLimit();
         }              
     }
     
     @Override
     public ItemStack decrStackSize(int slot, int amt) {
         ItemStack stack = getStackInSlot(slot);
         if (stack != null) {
                 if (stack.stackSize <= amt) {
                         setInventorySlotContents(slot, null);
                 } else {
                         stack = stack.splitStack(amt);
                         if (stack.stackSize == 0) {
                                 setInventorySlotContents(slot, null);
                         }
                 }
         }
         return stack;
     }
     
     @Override
     public ItemStack getStackInSlotOnClosing(int slot) {
              ItemStack stack = getStackInSlot(slot);
              if (stack != null) {
                      setInventorySlotContents(slot, null);
             }
             return stack;
      }
      
      @Override
     public int getInventoryStackLimit() {
             return 64;
      }
      
      @Override
     public boolean isUseableByPlayer(EntityPlayer player) {
             return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this &&
             player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
     }
      

     
      @Override
      public void openInventory() {}
      
     @Override
     public void closeInventory() {}
     
     @Override
     public void readFromNBT(NBTTagCompound tagCompound) {
             super.readFromNBT(tagCompound);
            
             NBTTagList tagList = tagCompound.getTagList("Inventory", 1);
             for (int i = 0; i < tagList.tagCount(); i++) {
                     NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
                     byte slot = tag.getByte("Slot");
                     if (slot >= 0 && slot < inv.length) {
                             inv[slot] = ItemStack.loadItemStackFromNBT(tag);
                 }
         }
     }
     
     @Override
     public void writeToNBT(NBTTagCompound tagCompound) {
              super.writeToNBT(tagCompound);
                             
              NBTTagList itemList = new NBTTagList();
             for (int i = 0; i < inv.length; i++) {
                     ItemStack stack = inv[i];
                      if (stack != null) {
                              NBTTagCompound tag = new NBTTagCompound();
                              tag.setByte("Slot", (byte) i);
                             stack.writeToNBT(tag);
                             itemList.appendTag(tag);
                      }
              }
              tagCompound.setTag("Inventory", itemList);
     }
     
             @Override
             public String getInventoryName() {
                     return "tco.tileentityRubberBase";
              }


            @Override
            public boolean hasCustomInventoryName() {
                // TODO Auto-generated method stub
                return false;
            }
            @Override
            public boolean isItemValidForSlot(int p_94041_1_,
                    ItemStack p_94041_2_) {
                // TODO Auto-generated method stub
                return false;
            }
      
}     
    


RubberBaseContainer:

Код:
package com.alternativemod.containers;

import com.alternativemod.tile.entity.TileEntityRubberBase;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class RubberBaseContainer extends Container{
    
    protected TileEntityRubberBase tileEntity;

    public RubberBaseContainer (InventoryPlayer inventoryPlayer, TileEntityRubberBase te){
            tileEntity = te;

            //the Slot constructor takes the IInventory and the slot number in that it binds to
            //and the x-y coordinates it resides on-screen
            for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                            addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
                    }
            }

            //commonly used vanilla code that adds the player's inventory
            bindPlayerInventory(inventoryPlayer);
    }

    @Override
    public boolean canInteractWith(EntityPlayer player) {
            return tileEntity.isUseableByPlayer(player);
    }


    protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
            for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 9; j++) {
                            addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
                                            8 + j * 18, 84 + i * 18));
                    }
            }

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

    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
            ItemStack stack = null;
            Slot slotObject = (Slot) inventorySlots.get(slot);

            //null checks and checks if the item can be stacked (maxStackSize > 1)
            if (slotObject != null && slotObject.getHasStack()) {
                    ItemStack stackInSlot = slotObject.getStack();
                    stack = stackInSlot.copy();

                    //merges the item into player inventory since its in the tileEntity
                    if (slot < tileEntity.getSizeInventory()) {
                            if (!this.mergeItemStack(stackInSlot, tileEntity.getSizeInventory(), 36+tileEntity.getSizeInventory(), true)) {
                                    return null;
                            }
                    }
                    //places it into the tileEntity is possible since its in the player inventory
                    else if (!this.mergeItemStack(stackInSlot, 0, tileEntity.getSizeInventory(), false)) {
                            return null;
                    }

                    if (stackInSlot.stackSize == 0) {
                            slotObject.putStack(null);
                    } else {
                            slotObject.onSlotChanged();
                    }

                    if (stackInSlot.stackSize == stack.stackSize) {
                            return null;
                    }
                    slotObject.onPickupFromSlot(player, stackInSlot);
            }
            return stack;
    }
}


GuiRubberBase:

Код:
package com.alternativemod.gui;

import org.lwjgl.input.Keyboard;
import com.alternativemod.AlternativeMod;
import com.alternativemod.containers.RubberBaseContainer;
import com.alternativemod.tile.entity.TileEntityRubberBase;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerFurnace;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;

public class GuiRubberBase extends GuiContainer  {
    
    int guiWidth = 175;
    int guiHeight = 165;
//    public static final int GUI_ID = 20;
    int guiX = (width - guiWidth)/2;
    int guiY = (height - guiHeight)/2;
    
    public GuiRubberBase(InventoryPlayer inventoryPlayer,
            TileEntityRubberBase tileEntity) {
    //the container is instanciated and passed to the superclass for handling
    super(new RubberBaseContainer(inventoryPlayer, tileEntity));      
    }
    public GuiRubberBase GetGuiRubberBase(){
        return this;
    }
    
    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2) {
            //draw text and stuff here
            //the parameters for drawString are: string, x, y, color
   //       FontRenderer.drawString("Tiny", 8, 6, 4210752);
            //draws "Inventory" or your regional equivalent
            fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
    }

    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2,
                    int par3) {
        
            
            //draw your Gui here, only thing you need to change is the path
            mc.renderEngine.bindTexture(new ResourceLocation(AlternativeMod.MODID, "textures/gui/RubberBase.png"));
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            int x = (width - xSize) / 2;
            int y = (height - ySize) / 2;
            this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    }
    
    
    
    
    @Override
    protected void keyTyped(char c, int key){
        switch(key){
        case Keyboard.KEY_E: Minecraft.getMinecraft().displayGuiScreen(null);
        }
        super.keyTyped(c, key);
    }
}


GuiHandler:

Код:
package com.alternativemod.gui;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

import com.alternativemod.containers.RubberBaseContainer;
import com.alternativemod.tile.entity.TileEntityRubberBase;

import cpw.mods.fml.common.network.IGuiHandler;

public class GuiHandler implements IGuiHandler {
    //returns an instance of the Container you made earlier
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,
                    int x, int y, int z) {
            TileEntity tileEntity = world.getTileEntity(x, y, z);
            if(tileEntity instanceof TileEntityRubberBase){
                    return new RubberBaseContainer(player.inventory, (TileEntityRubberBase) tileEntity);
            }
            return null;
    }

    //returns an instance of the Gui you made earlier
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,
                    int x, int y, int z) {
            TileEntity tileEntity = world.getTileEntity(x, y, z);
            if(tileEntity instanceof TileEntityRubberBase){
                    return new GuiRubberBase(player.inventory, (TileEntityRubberBase) tileEntity);
            }
            return null;

    }

}

Не понимаю в чем может быть проблема((. Второй день не могу разобраться. В эклипсе ошибок нет. Намекните, пожалуйста, где проблема.
 
1,087
2
Your Code написал(а):
Код:
cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
    at com.alternativemod.blocks.RubberBase.onBlockActivated(RubberBase.java:50)
Найди эту строчку и исправь метод или строку... Я с мобилы. Еле разберёшь.
 

timaxa007

Модератор
5,831
409
672
ChooseLife, а где ты регистрировал твой "GuiHandler"?
 
Код:
public void init(FMLInitializationEvent event) {
        NetworkRegistry network = NetworkRegistry.INSTANCE;
network.registerGuiHandler(this, new GuiHandler());
Если делать как в гайде:

Код:
 NetworkRegistry.instance().registerGuiHandler(this, new GuiHandler());
instance() подчеркивает, Не понимаю, как можно создать объект перечисления
 

timaxa007

Модератор
5,831
409
672
ChooseLife, ты смотрел на 1.6.х урок? Так как там использовалось "instance()", на 1.7.х "INSTANCE". И нужно типа этого:
Код:
NetworkRegistry.INSTANCE.registerGuiHandler(AlternativeMod.instance, new HandlerGui());
Код:
player.openGui(new GuiRubberBase(player.inventory, tileEntity), 0, world, x, y, z);
И в каком уроке используется объект окна, место "instance" мода?
Код:
player.openGui(AlternativeMod.instance, 0, world, x, y, z);
 
Гайд
Да я понимаю что там написано outdated, но если правильно, как ты говоришь:
Код:
NetworkRegistry.INSTANCE.registerGuiHandler(AlternativeMod.instance, new HandlerGui());
То ошибка где-то еще.
(Насчет openGui, я сам так подумал потому, что в суперклассе написано mod, поэтому пробую и так, и так.)
Все еще вылет при открытии.  Новый крашлог:

Код:
---- Minecraft Crash Report ----
// Don't be sad. I'll do better next time, I promise!

Time: 05.09.15 22:04
Description: Unexpected error

java.lang.NullPointerException: Unexpected error
    at cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
    at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
    at com.alternativemod.blocks.RubberBase.onBlockActivated(RubberBase.java:50)
    at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)
    at net.minecraft.client.Minecraft.runTick(Minecraft.java:2044)
    at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1039)
    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 cpw.mods.fml.common.network.NetworkRegistry.getLocalGuiContainer(NetworkRegistry.java:265)
    at cpw.mods.fml.common.network.internal.FMLNetworkHandler.openGui(FMLNetworkHandler.java:93)
    at net.minecraft.entity.player.EntityPlayer.openGui(EntityPlayer.java:2501)
    at com.alternativemod.blocks.RubberBase.onBlockActivated(RubberBase.java:50)
    at net.minecraft.client.multiplayer.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:376)
    at net.minecraft.client.Minecraft.func_147121_ag(Minecraft.java:1529)

-- Affected level --
Details:
    Level name: MpServer
    All players: 1 total; [EntityClientPlayerMP['Player137'/169, l='MpServer', x=-157,10, y=5,62, z=-221,92]]
    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: 231866 game time, 155538 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: 67 total; [EntityPig['Pig'/128, l='MpServer', x=-207,97, y=4,00, z=-252,50], EntityCow['Cow'/129, l='MpServer', x=-206,66, y=4,00, z=-251,25], EntityHorse['Horse'/130, l='MpServer', x=-206,97, y=4,00, z=-225,88], EntitySheep['Sheep'/131, l='MpServer', x=-205,84, y=4,00, z=-235,19], EntityHorse['Horse'/132, l='MpServer', x=-199,28, y=4,00, z=-221,59], EntityCow['Cow'/133, l='MpServer', x=-207,13, y=4,00, z=-190,81], EntityChicken['Chicken'/134, l='MpServer', x=-199,19, y=4,00, z=-162,31], EntityCow['Cow'/135, l='MpServer', x=-198,86, y=4,00, z=-163,35], EntityPig['Pig'/136, l='MpServer', x=-203,86, y=4,00, z=-158,75], EntitySheep['Sheep'/137, l='MpServer', x=-180,35, y=4,00, z=-277,49], EntitySheep['Sheep'/138, l='MpServer', x=-178,81, y=4,00, z=-267,13], EntityPig['Pig'/139, l='MpServer', x=-184,59, y=4,00, z=-269,81], EntityCow['Cow'/140, l='MpServer', x=-184,88, y=4,00, z=-259,84], EntityPig['Pig'/141, l='MpServer', x=-180,19, y=4,00, z=-258,22], EntityPig['Pig'/142, l='MpServer', x=-190,44, y=4,00, z=-258,88], EntityCow['Cow'/143, l='MpServer', x=-190,22, y=4,00, z=-246,81], EntityHorse['Horse'/144, l='MpServer', x=-190,91, y=4,00, z=-251,03], EntityPig['Pig'/145, l='MpServer', x=-180,97, y=4,00, z=-248,94], EntityCow['Cow'/146, l='MpServer', x=-187,16, y=4,00, z=-238,16], EntityHorse['Horse'/147, l='MpServer', x=-178,09, y=4,00, z=-232,00], EntityChicken['Chicken'/148, l='MpServer', x=-185,03, y=4,00, z=-235,01], EntityChicken['Chicken'/149, l='MpServer', x=-180,56, y=4,00, z=-215,44], EntityCow['Cow'/150, l='MpServer', x=-177,31, y=4,00, z=-164,59], EntityCow['Cow'/152, l='MpServer', x=-172,84, y=4,00, z=-269,06], EntityHorse['Horse'/153, l='MpServer', x=-171,91, y=4,00, z=-250,34], EntityPig['Pig'/154, l='MpServer', x=-167,81, y=4,00, z=-231,09], EntityCow['Cow'/155, l='MpServer', x=-175,16, y=4,00, z=-237,63], EntityPig['Pig'/156, l='MpServer', x=-175,50, y=4,00, z=-235,03], EntityClientPlayerMP['Player137'/169, l='MpServer', x=-157,10, y=5,62, z=-221,92], EntityPig['Pig'/159, l='MpServer', x=-146,22, y=4,00, z=-261,05], EntityHorse['Horse'/160, l='MpServer', x=-156,00, y=4,00, z=-248,81], EntitySheep['Sheep'/161, l='MpServer', x=-147,47, y=4,00, z=-213,69], EntitySheep['Sheep'/162, l='MpServer', x=-133,91, y=4,00, z=-253,91], EntityCow['Cow'/163, l='MpServer', x=-146,23, y=4,00, z=-155,25], EntityMinecartEmpty['entity.MinecartRideable.name'/164, l='MpServer', x=-129,57, y=4,50, z=-145,31], EntityPig['Pig'/165, l='MpServer', x=-122,97, y=4,00, z=-268,06], EntityChicken['Chicken'/166, l='MpServer', x=-121,53, y=4,00, z=-247,41], EntityHorse['Horse'/167, l='MpServer', x=-121,00, y=4,00, z=-214,19], EntityChicken['Chicken'/168, l='MpServer', x=-83,34, y=4,00, z=-220,59], EntitySheep['Sheep'/79, l='MpServer', x=-229,09, y=4,00, z=-284,09], EntitySheep['Sheep'/80, l='MpServer', x=-233,32, y=4,00, z=-275,23], EntityPig['Pig'/82, l='MpServer', x=-229,01, y=4,00, z=-260,13], EntitySheep['Sheep'/83, l='MpServer', x=-234,94, y=4,00, z=-228,97], EntityPig['Pig'/84, l='MpServer', x=-230,91, y=4,00, z=-237,94], EntityCow['Cow'/85, l='MpServer', x=-225,10, y=4,00, z=-214,84], EntityChicken['Chicken'/86, l='MpServer', x=-225,03, y=4,00, z=-216,03], EntityHorse['Horse'/87, l='MpServer', x=-227,47, y=4,00, z=-206,19], EntityChicken['Chicken'/89, l='MpServer', x=-235,34, y=4,00, z=-159,56], EntitySheep['Sheep'/107, l='MpServer', x=-220,38, y=4,00, z=-259,72], EntitySheep['Sheep'/108, l='MpServer', x=-221,28, y=4,00, z=-253,81], EntityChicken['Chicken'/109, l='MpServer', x=-209,56, y=4,00, z=-248,56], EntitySheep['Sheep'/110, l='MpServer', x=-217,78, y=4,00, z=-242,84], EntityPig['Pig'/111, l='MpServer', x=-208,66, y=4,00, z=-234,91], EntityPig['Pig'/112, l='MpServer', x=-221,84, y=4,00, z=-209,59], EntityHorse['Horse'/113, l='MpServer', x=-210,05, y=4,00, z=-209,24], EntityCow['Cow'/114, l='MpServer', x=-223,69, y=4,00, z=-202,50], EntityPig['Pig'/115, l='MpServer', x=-209,18, y=4,00, z=-212,16], EntityChicken['Chicken'/116, l='MpServer', x=-215,69, y=4,00, z=-201,41], EntityPig['Pig'/117, l='MpServer', x=-225,81, y=4,00, z=-173,75], EntityPig['Pig'/118, l='MpServer', x=-218,68, y=4,00, z=-178,44], EntitySheep['Sheep'/119, l='MpServer', x=-208,72, y=4,00, z=-167,94], EntitySheep['Sheep'/122, l='MpServer', x=-202,56, y=4,00, z=-261,31], EntityPig['Pig'/123, l='MpServer', x=-211,20, y=4,00, z=-266,70], EntityCow['Cow'/124, l='MpServer', x=-200,28, y=4,00, z=-259,69], EntitySheep['Sheep'/125, l='MpServer', x=-193,91, y=4,00, z=-248,91], EntityPig['Pig'/126, l='MpServer', x=-200,06, y=4,00, z=-245,75], EntitySheep['Sheep'/127, l='MpServer', x=-200,13, y=4,00, z=-252,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:991)
    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_45, Oracle Corporation
    Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Oracle Corporation
    Memory: 892876032 bytes (851 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)
 
Сверху