[1.7.10] GUI open crash (Печка)

Не знаешь почему у меня вот это http://joxi.ru/Vrwp6X9Sbo9bmX подчеркивается? 
Dovakin написал(а):
Приятно видеть код на пастебине. Дай 61 строку TutFurnace
[merge_posts_bbcode]Добавлено: 16.03.2015 21:22:43[/merge_posts_bbcode]

Код:
package com.thegrovesyproject.block;

import java.util.Random;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
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.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;

import com.thegrovesyproject.lib.Strings;
import com.thegrovesyproject.main.MainRegistry;
import com.thegrovesyproject.tile_entity.TileEntityTutFurnace;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class TutFurnace extends BlockContainer {

    @SideOnly(Side.CLIENT)
    private IIcon top;
    @SideOnly(Side.CLIENT)
    private IIcon front;

    private static boolean isBurning;
    private final boolean isBurning2;
    private final Random random = new Random();

    protected TutFurnace(boolean isActive) {
        super(Material.rock);
        isBurning2 = isActive;
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconregister) {
        this.blockIcon = iconregister.registerIcon(Strings.MODID + ":TutFurnaceSide");
        this.front = iconregister.registerIcon(this.isBurning2 ? Strings.MODID + ":TutFurnaceActive" : Strings.MODID + ":TutFurnaceInactive");
        this.top = iconregister.registerIcon(Strings.MODID + ":TutFurnaceTop");
    }

    public IIcon getIcon(int side, int meta) {
        if (side == 1) {
            return top;
        } else if (side == 3) {
            return front;
        } else {
            return this.blockIcon;
        }
    }

    public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
        player.openGui(MainRegistry.modInstance, 0, world, x, y, z);
        return true;
    }

    public Item getItemDropped(int par1, Random random, int par3) {
        return Item.getItemFromBlock(TMBlock.tutFurnace);
    }

    public Item getItem(World world, int par2, int par3, int par4) {
        return Item.getItemFromBlock(TMBlock.tutFurnace);
    }
    
    /**
     * Returns a new instance of a block's tile entity class. Called on placing the block.
     */
    public TileEntity createNewTileEntity(World world, int par2)
    {
        return new TileEntityTutFurnace();
    }

    
    @SideOnly(Side.CLIENT)
    public void onBlockAdded(World world, int x, int y, int z) {
        super.onBlockAdded(world, x, y, z);
        this.direction(world, x, y, z);
    }

    private void direction(World world, int x, int y, int z) {
        if (!world.isRemote) {
            Block direction = world.getBlock(x, y, z - 1);
            Block direction1 = world.getBlock(x, y, z + 1);
            Block direction2 = world.getBlock(x - 1, y, z);
            Block direction3 = world.getBlock(x + 1, y, z);
            byte byte0 = 3;

            if (direction.func_149730_j() && direction.func_149730_j()) {
                byte0 = 3;
            }

            if (direction1.func_149730_j() && direction1.func_149730_j()) {
                byte0 = 2;
            }

            if (direction2.func_149730_j() && direction2.func_149730_j()) {
                byte0 = 5;
            }

            if (direction3.func_149730_j() && direction3.func_149730_j()) {
                byte0 = 4;
            }

            world.setBlockMetadataWithNotify(x, y, z, byte0, 2);
        }
    }

    public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack itemstack) {
        int direction = MathHelper.floor_double((double) (entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        if (direction == 0) {
            world.setBlockMetadataWithNotify(x, y, z, 2, 2);
        }

        if (direction == 1) {
            world.setBlockMetadataWithNotify(x, y, z, 5, 2);
        }

        if (direction == 2) {
            world.setBlockMetadataWithNotify(x, y, z, 3, 2);
        }

        if (direction == 3) {
            world.setBlockMetadataWithNotify(x, y, z, 4, 2);
        }

        if (itemstack.hasDisplayName()) {
            ((TileEntityTutFurnace) world.getTileEntity(x, y, z)).furnaceName(itemstack.getDisplayName());
        }
    }

    public static void updateBlockState(boolean burning, World world, int x, int y, int z) {
        int direction = world.getBlockMetadata(x, y, z);
        TileEntity tileentity = world.getTileEntity(x, y, z);
        isBurning = true;

        if (burning) {
            world.setBlock(x, y, z, TMBlock.tutFurnaceActive);
        } else {
            world.setBlock(x, y, z, TMBlock.tutFurnace);
        }

        isBurning = false;
        world.setBlockMetadataWithNotify(x, y, z, direction, 2);

        if (tileentity != null) {
            tileentity.validate();
            world.setTileEntity(x, y, z, tileentity);
        }
    }

    public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
        if (!isBurning) {
            TileEntityTutFurnace tileentitytutfurnace = (TileEntityTutFurnace) world.getTileEntity(x, y, z);

            if (tileentitytutfurnace != null) {
                for (int i = 0; i < tileentitytutfurnace.getSizeInventory(); ++i) {
                    ItemStack itemstack = tileentitytutfurnace.getStackInSlot(i);

                    if (itemstack != null) {
                        float f = this.random.nextFloat() * 0.6F + 0.1F;
                        float f1 = this.random.nextFloat() * 0.6F + 0.1F;
                        float f2 = this.random.nextFloat() * 0.6F + 0.1F;

                        while (itemstack.stackSize > 0) {
                            int j = this.random.nextInt(21) + 10;

                            if (j > itemstack.stackSize) {
                                j = itemstack.stackSize;
                            }

                            itemstack.stackSize -= j;
                            EntityItem entityitem = new EntityItem(world, (double) ((float) x + f), (double) ((float) y + f1), (double) ((float) z + f2), new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

                            if (itemstack.hasTagCompound()) {
                                entityitem.getEntityItem().setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
                            }

                            float f3 = 0.025F;
                            entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
                            entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);
                            entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3);
                            world.spawnEntityInWorld(entityitem);
                        }
                    }
                }
                world.func_147453_f(x, y, z, block);
            }
        }
        super.breakBlock(world, x, y, z, block, meta);
    }

    @SideOnly(Side.CLIENT)
    public void randomDisplayTick(World world, int x, int y, int z, Random random) {
        if (this.isBurning2) {
            int direction = world.getBlockMetadata(x, y, z);

            float xx = (float) x + 0.5F, yy = (float) y + random.nextFloat() * 6.0F / 16.0F, zz = (float) z + 0.5F, xx2 = random.nextFloat() * 0.3F - 0.2F, zz2 = 0.5F;

            if (direction == 4) {
                world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
                world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
            } else if (direction == 5) {
                world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
                world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
            } else if (direction == 3) {
                world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
                world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
            } else if (direction == 2) {
                world.spawnParticle("smoke", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
                world.spawnParticle("flame", (double) (xx - zz2), (double) yy, (double) (zz + xx2), 0.0F, 0.0F, 0.0F);
            }
        }
    }

}
Dovakin написал(а):
 
Полностью главный класс мода скинь. Хочу видеть аннотацию @Instance, переменную под ней и modid.
К слову, открывать гуи надо только на сервере - он сам клиенту даст знать.

Код:
if(!world.isRemote)
     openGui(...);
 
Код:
package com.thegrovesyproject.main;

import com.thegrovesyproject.block.TMBlock;
import com.thegrovesyproject.creativetabs.TMCreativeTabs;
import com.thegrovesyproject.entity.TMEntity;
import com.thegrovesyproject.handler.CraftingManager;
import com.thegrovesyproject.handler.TMGuiHandler;
import com.thegrovesyproject.item.TMItem;
import com.thegrovesyproject.lib.Strings;
import com.thegrovesyproject.world.TMWorld;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;

@Mod(modid = Strings.MODID, name = Strings.name, version = Strings.version)

public class MainRegistry {
    
    @SidedProxy(clientSide = "com.thegrovesyproject.main.ClientProxy", serverSide = "com.thegrovesyproject.main.ServerProxy") 
    public static ServerProxy proxy;
    
    
    @Instance(Strings.MODID)
    public static MainRegistry modInstance;
    
    /**
     * Loads before
     * @param PreEvent
     */
    @EventHandler
    public static void PreLoad(FMLPreInitializationEvent PreEvent){
        TMCreativeTabs.initialiseTabs();
        TMBlock.mainRegistry();
        TMItem.mainRegistry();
        TMEntity.mainRegistry();
        CraftingManager.mainRegistry();
        TMWorld.mainRegistry();
        TMHooks.mainRegistry();
        
        proxy.registerTileEntities();
        proxy.registerRenderThings();
    }
    
    /**
     * Loads during
     * @param event
     */
    @EventHandler
    public static void load(FMLInitializationEvent event){
        proxy.registerNetworkStuff();
    }
    
    /**
     * Loads after
     * @param PostEvent
     */
    @EventHandler
    public static void PostLoad(FMLPostInitializationEvent PostEvent){
        
    }
    
}
Oldestkon написал(а):
Полностью главный класс мода скинь. Хочу видеть аннотацию @Instance, переменную под ней и modid.
К слову, открывать гуи надо только на сервере - он сам клиенту даст знать.

Код:
if(!world.isRemote)
     openGui(...);
 
Где GuiHandler (NetworkRegistry.INSTANCE.registerGuiHandler)?
[merge_posts_bbcode]Добавлено: 16.03.2015 21:34:25[/merge_posts_bbcode]

И что написано в твоём GuiHandler'е?
 
Выкинь всё из preload в load. Есть подозрение, что инстанс к этому времени ещё не меняется рефлексией из форджа. 
Фигню сказал. Там же всё вызывается из события активации блока. Тем не менее, совет остается в силе.
Вообще не понимаю, нафига ты всё в preload запихал, ни в одном туторе такого нет.
 
GuiHandler
Код:
package com.thegrovesyproject.handler;

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

import com.thegrovesyproject.gui.GuiTutFurnace;
import com.thegrovesyproject.inventory.ContainerTutFurnace;
import com.thegrovesyproject.tile_entity.TileEntityTutFurnace;

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

public class TMGuiHandler implements IGuiHandler {

    public TMGuiHandler (){
        
    }
    
    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        if(ID == 0){
            TileEntityTutFurnace tileEntityFurnace = (TileEntityTutFurnace) world.getTileEntity(x, y, z);
            return new ContainerTutFurnace(player.inventory, tileEntityFurnace);
        }
        return null;
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
        if(ID == 0){
            TileEntityTutFurnace tileEntityTestContainer = (TileEntityTutFurnace) world.getTileEntity(x, y, z);
            return new GuiTutFurnace(player.inventory, tileEntityTestContainer);
        }
        return null;
    }

}


timaxa007 написал(а):
Где GuiHandler (NetworkRegistry.INSTANCE.registerGuiHandler)?
[merge_posts_bbcode]Добавлено: 16.03.2015 21:34:25[/merge_posts_bbcode]

И что написано в твоём GuiHandler'е?
 
Вобще везде заменить preload На load или только в главном классе?
Oldestkon написал(а):
Выкинь всё из preload в load. Есть подозрение, что инстанс к этому времени ещё не меняется рефлексией из форджа. 
Фигню сказал. Там же всё вызывается из события активации блока. Тем не менее, совет остается в силе.
Вообще не понимаю, нафига ты всё в preload запихал, ни в одном туторе такого нет.
 
В главном классе содержимое метода PreLoad в метод load перенеси же, ну.
 
Кого?
Dovakin написал(а):
[merge_posts_bbcode]Добавлено: 16.03.2015 22:01:35[/merge_posts_bbcode]

Всем спасибо,решено.Можно закрывать.Кому нужен полный код  печки стучитесь в лс.
 
Лучше выложи решение проблемы сюда. Вероятность, что тебе кто-то будет стучать в ЛС:
13319512014e19d1de2c59a.jpg

А так другие смогут увидеть решение сразу, просто погуглив и наткнувшись на форум.
 
Назад
Сверху