Jump to content

[1.6.2][SOLVED] Custom crafting table problems


bdkuhman

Recommended Posts

My custom crafting table GUI is opening, but immediately closing:

BlockDeconstructionTable:

 

package deconstruction.common;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class BlockDeconstructionTable extends Block{
         @SideOnly(Side.CLIENT)
            private Icon workbenchIconTop;
            @SideOnly(Side.CLIENT)
            private Icon workbenchIconFront;


           
public BlockDeconstructionTable(int par1){
         super(par1, Material.wood);

   
         this.setCreativeTab(CreativeTabs.tabDecorations);
}
@SideOnly(Side.CLIENT)

/**
* From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
*/
public Icon getIcon(int par1, int par2)
{
    return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront));
}

@SideOnly(Side.CLIENT)

/**
* When this method is called, your block should register all the icons it needs with the given IconRegister. This
* is the only chance you get to register icons.
*/
@Override
public void registerIcons(IconRegister par1IconRegister)
{
    this.blockIcon = par1IconRegister.registerIcon("deconstruction:Decon_Side");
    this.workbenchIconTop = par1IconRegister.registerIcon("deconstruction:Decon_Top");
    this.workbenchIconFront = this.blockIcon;
}

public boolean onBlockActivated(World par1World, int x, int y, int z, EntityPlayer player, int var6, float var7, float var8, float var9){
        if (!player.isSneaking()){
                player.openGui(mod_Deconstruction.instance, 1, par1World, x, y, z);
                return true;
        }else{
                return false;
        }
}
}

 

 

Gui Handler:

 

package deconstruction.common;


import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

import deconstruction.deconTable.ContainerDeconstructionTable;
import deconstruction.deconTable.GuiDeconstruction;

public class GuiHandler implements IGuiHandler
{

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{

TileEntity tile_entity = world.getBlockTileEntity(x, y, z);


switch(id)
{

case 1: return id == 1 && world.getBlockId(x, y, z) == mod_Deconstruction.deconstructionTable.blockID ? new ContainerDeconstructionTable(player.inventory, world, x, y, z) : null;
//case 2: return id == 2 && world.getBlockId(x, y, z) == mod_Deconstruction.alchemyStation.blockID ? new ContainerAlchemy(player.inventory, (TileEntityStationAlchemy)tile_entity) : null;
}
return null;
}

@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z)
{

TileEntity tile_entity = world.getBlockTileEntity(x, y, z);

switch(id)
{

case 1: return id == 1 && world.getBlockId(x, y, z) == mod_Deconstruction.deconstructionTable.blockID ? new GuiDeconstruction(player.inventory, world, x, y, z) : null;
//case 2: return id == 2 && world.getBlockId(x, y, z) == mod_Deconstruction.alchemyStation.blockID ? new ContainerAlchemy(player.inventory, (TileEntityStationAlchemy)tile_entity): null;
}

return null;

}
}

 

mod_Deconstruction:

 

package deconstruction.common;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStone;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemReed;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
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.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
//import deconstruction.alchemy.BlockAlchemy;
//import deconstruction.alchemy.TileEntityStationAlchemy;
import deconstruction.deconTable.DeconstructionManager;

@Mod(modid="deconstruction", name="The Deconstruction Mod", version="1.2.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class mod_Deconstruction {
public static Block deconstructionTable;



public static void RegisterBlocks(){
	GameRegistry.registerBlock(deconstructionTable, "deconstructionTable");
}

public static void RegisterNames(){
	LanguageRegistry.addName(deconstructionTable, "Deconstruction Table");
	}

public static void RegisterRecipes(){

	GameRegistry.addRecipe(new ItemStack(deconstructionTable, 1), "BDB", "ACA", "AAA", 'A', Block.planks, 'B', Item.ingotIron, 'C', Block.workbench, 'D', Item.diamond);
	DeconstructionManager.getInstance().addRecipe(new ItemStack(deconstructionTable, 1), new Object[]{"BDB", "ACA", "AAA", 'A', Block.planks, 'B', Item.ingotIron, 'C', Block.workbench, 'D', Item.diamond});
        

}




// The instance of your mod that Forge uses.
@Instance("deconstruction")
public static mod_Deconstruction instance;

private GuiHandler guiHandler = new GuiHandler();
// Says where the client and server 'proxy' code is loaded.
@SidedProxy(clientSide="deconstruction.client.ClientProxy", serverSide="deconstruction.common.CommonProxy")
public static CommonProxy proxy;

@PreInit
public void preInit(FMLPreInitializationEvent event) {

}

@Init
public void load(FMLInitializationEvent event) {

	//alchemyStation = new BlockAlchemy(601).setHardness(2.5F).setStepSound(Block.soundStoneFootstep);
	deconstructionTable = new BlockDeconstructionTable(600).setHardness(2.5F).setStepSound(Block.soundWoodFootstep);
	//GameRegistry.registerTileEntity(TileEntityStationAlchemy.class, "tileEntityStationAlchemy");
	//itemAlchemyStation =(new ItemReed(650, alchemyStation)).setUnlocalizedName("brewingStand").setCreativeTab(CreativeTabs.tabBrewing);
	RegisterBlocks();
	RegisterNames();
	RegisterRecipes();


	NetworkRegistry.instance().registerGuiHandler(this, guiHandler);

}


@PostInit
public void postInit(FMLPostInitializationEvent event) {
	// Stub Method
}
}




 

 

ContainerDeconstructionTable:

 

package deconstruction.deconTable;

import java.util.Random;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import cpw.mods.fml.client.FMLClientHandler;
import deconstruction.common.mod_Deconstruction;


public class ContainerDeconstructionTable extends Container{

public ContainerDeconstructionTable(InventoryPlayer par1InventoryPlayer,
		World par2World, int par3, int par4, int par5) {
	// TODO Auto-generated constructor stub
}

@Override
public boolean canInteractWith(EntityPlayer entityplayer) {
	// TODO Auto-generated method stub
	return false;
}

 

Common and Client proxies:

 

package deconstruction.common;

public class CommonProxy{
public void registerRenderers(){

}
}

 

 

package deconstruction.client;

import deconstruction.common.CommonProxy;

public class ClientProxy extends CommonProxy{
@Override
public void registerRenderers(){

}
}

 

EDIT:

GuiDeconstruction:

 

package deconstruction.deconTable;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;

import org.lwjgl.opengl.GL11;

public class GuiDeconstruction extends GuiContainer{

        public GuiDeconstruction(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) {
                super(new ContainerDeconstructionTable(par1InventoryPlayer, par2World, par3, par4, par5));
                // TODO Auto-generated constructor stub
        }
        /**
     * Draw the foreground layer for the GuiContainer (everything in front of the items)
     */
        protected void drawGuiContainerForegroundLayer(int par1, int par2)
        {
                this.fontRenderer.drawString("Deconstruction", 28, 6, 4210752);
        this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
        }

/**
     * Draw the background layer for the GuiContainer (everything behind the items)
     */
        protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
        {
                //int var4 = this.mc.renderEngine.getTexture("/mods/deconstruction/textures/gui/deconstruction.png");
                GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
                //this.mc.renderEngine.bindTexture("/mods/deconstruction/textures/gui/deconstruction.png");
                this.mc.renderEngine.func_110577_a(new ResourceLocation("/mods/deconstruction/textures/gui/deconstruction.png"));
                int var5 = (this.width - this.xSize) / 2;
        int var6 = (this.height - this.ySize) / 2;
        this.drawTexturedModalRect(var5, var6, 0, 0, this.xSize, this.ySize);
        }

        
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.