Jump to content

Recommended Posts

Posted

I have tried for days to get this to work, but I cant seem to make it work. Help would be appreciated I have tried this but It doesnt seem to help http://www.minecraftforge.net/wiki/Containers_and_GUIs

 

Block Class

import java.util.Random;

import AeroMod.Tutorial.AeroMod;
import AeroMod.Tutorial.TileEntity.TileEntityGrinder;

import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.src.ModLoader;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class GUIBlock extends Block {

public GUIBlock(int par1, String texture) {
super(par1, Material.rock);
setCreativeTab(CreativeTabs.tabBlock); 

}

public int idDropped(int par1, Random par2Random, int par3)
{
return AeroMod.GUIBlock.blockID;
}
public int quantityDropped(Random random)
{
return 1;
}

public String getTextureFile(){
return "/textures/blocks/GUIBlock.png";
}

@Override
        public boolean onBlockActivated(World world, int x, int y, int z,
                        EntityPlayer player, int idk, float what, float these, float are) {
                TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
                if (tileEntity == null || player.isSneaking()) {
                        return true;
                }
                
                		player.openGui(AeroMod.instance, 0, world, x, y, z);
                		return true;
        	}

        @Override
        public void breakBlock(World world, int x, int y, int z, int par5, int par6) {
                dropItems(world, x, y, z);
                super.breakBlock(world, x, y, z, par5, par6);
        }
        public TileEntity createNewTileEntity(World world) {
                return new TileEntityGrinder();
        }
        
        private void dropItems(World world, int x, int y, int z){
                Random rand = new Random();

                TileEntity tileEntity = world.getBlockTileEntity(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,
                                                new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));

                                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;
                        }
                }
        }
}

 




Tile Entity Class
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 TileEntityGrinder extends TileEntity implements IInventory {

        private ItemStack[] inv;

        public TileEntityGrinder(){
                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.getBlockTileEntity(xCoord, yCoord, zCoord) == this &&
                player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
        }

        @Override
        public void openChest() {}

        @Override
        public void closeChest() {}
        
        @Override
        public void readFromNBT(NBTTagCompound tagCompound) {
                super.readFromNBT(tagCompound);
                
                NBTTagList tagList = tagCompound.getTagList("Inventory");
                for (int i = 0; i < tagList.tagCount(); i++) {
                        NBTTagCompound tag = (NBTTagCompound) tagList.tagAt(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 getInvName() {
                        return "AeroMod.TileEntityGrinder";
                }

			@Override
			public boolean isInvNameLocalized() {

				return false;
			}

			@Override
			public boolean isStackValidForSlot(int i, ItemStack itemstack) {

				return false;
			}
}

 

Container Class

import cpw.mods.fml.common.FMLLog;
import AeroMod.Tutorial.TileEntity.TileEntityGrinder;
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.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.FurnaceRecipes;
import net.minecraft.tileentity.TileEntityFurnace;

public class ContainerGrinder extends Container {

        protected TileEntityGrinder tileEntity;

        public ContainerGrinder (InventoryPlayer inventoryPlayer, TileEntityGrinder 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 par1EntityPlayer){
    		return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
    	}

    
        
        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 par1EntityPlayer, 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 (FurnaceRecipes.smelting().getSmeltingResult(itemstack1) != null)
                    {
                        if (!this.mergeItemStack(itemstack1, 0, 1, false))
                        {
                            return null;
                        }
                    }
                    else if (TileEntityFurnace.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(par1EntityPlayer, itemstack1);
            }

            return itemstack;
        }
        
}

 

Gui Class

import org.lwjgl.opengl.GL11;

import AeroMod.Tutorial.Container.ContainerGrinder;
import AeroMod.Tutorial.TileEntity.TileEntityGrinder;

import cpw.mods.fml.relauncher.*;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.util.StatCollector;
import net.minecraft.client.gui.inventory.*;

@SideOnly(Side.CLIENT)
public class GuiGrinder extends GuiContainer {

    public GuiGrinder (InventoryPlayer inventoryPlayer, TileEntityGrinder tileEntity) {
            super(new ContainerGrinder(inventoryPlayer, tileEntity));
    }

    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2) {
            fontRenderer.drawString("Ore Grinder", 8, 6, 4210752);
    }

    
    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            this.mc.renderEngine.bindTexture("/gui/grinder.png");
            int posX = (this.width - this.xSize) / 2;
            int posY = (this.height - this.ySize) / 2;
            this.drawTexturedModalRect(posX, posY, 0, 0, this.xSize, this.ySize);
            int i1;
            
            if (this.furnaceInventory.isBurning())
            {
                i1 = this.furnaceInventory.getBurnTimeRemainingScaled(12);
                this.drawTexturedModalRect(posX + 56, posY + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
            }

            i1 = this.furnaceInventory.getCookProgressScaled(24);
            this.drawTexturedModalRect(posX + 79, posY + 34, 176, 14, i1 + 1, 16);
    }

    private TileEntityFurnace furnaceInventory;
}

 

Guihandler Class

import AeroMod.Tutorial.Container.ContainerGrinder;
import AeroMod.Tutorial.Gui.GuiGrinder;
import AeroMod.Tutorial.TileEntity.TileEntityGrinder;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import cpw.mods.fml.common.network.IGuiHandler;

public class AeroModGuiHandler implements IGuiHandler {

    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,
                    int x, int y, int z) {
            TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
            if(tileEntity instanceof TileEntityGrinder){
                    return new ContainerGrinder(player.inventory, (TileEntityGrinder) tileEntity);
            }
            return null;
    }


    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,
                    int x, int y, int z) {
            TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
            if(tileEntity instanceof TileEntityGrinder){
                    return new GuiGrinder(player.inventory, (TileEntityGrinder) tileEntity);
            }
            return null;

    }
}

Posted

Sorry, my mistake

 

import java.util.List;

import org.lwjgl.input.Keyboard;

import AeroMod.common.blocks.AquaBlueBlock;
import AeroMod.common.blocks.BrightYellowBlock;
import AeroMod.common.blocks.CoalBlock;
import AeroMod.common.blocks.EmeraldGreenBlock;
import AeroMod.common.blocks.GUIBlock;
import AeroMod.common.blocks.WaterstoneBlock;

import AeroMod.Entity.EntityGrenade;

import AeroMod.Ore.RubyOre;
import AeroMod.Ore.WaterStoneOre;
import AeroMod.Tutorial.TileEntity.TileEntityGrinder;

import AeroMod.common.AeroModFuelHandler;
import AeroMod.common.AeroModGuiHandler;
import AeroMod.common.WorldGeneration.WaterStoneOreWorldGeneration;

import AeroMod.common.tools.EnumToolMaterials;
import AeroMod.common.tools.ItemWaterStoneAxe;
import AeroMod.common.tools.ItemWaterStoneHoe;
import AeroMod.common.tools.ItemWaterStonePickaxe;
import AeroMod.common.tools.ItemWaterStoneShovel;
import AeroMod.common.tools.ItemWaterStoneSword;
import AeroMod.common.tools.ItemWaterStoneBow;

import com.google.common.collect.Lists;
import net.minecraft.block.Block;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.client.registry.KeyBindingRegistry;
import cpw.mods.fml.common.IFuelHandler;
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.PreInit;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;


@Mod(modid="AeroMod",name="Tutorial Mod",version="v1")
@NetworkMod(clientSideRequired=true,serverSideRequired=false)

public class AeroMod {


public static CreativeTabs DecorativeBlocksTab = new DecorativeBlocksTab(CreativeTabs.getNextID(), "Decorative Blocks Tab");
public static WaterStoneOreWorldGeneration GenWorld = new WaterStoneOreWorldGeneration();

public static Item ItemWaterStone;	
public static Item ItemWaterStoneBow;
public static Item ItemGrenade;
public static Item IngotSteel;
public static Item ItemWaterStonePickaxe;
public static Item ItemWaterStoneSword;
public static Item ItemWaterStoneAxe;
public static Item ItemWaterStoneShovel;
public static Item ItemWaterStoneHoe;

public static Block RubyOre;
public static Block CoalBlock;
public static Block WaterStoneBlock;
public static Block AquaBlueBlock;
public static Block BrightYellowBlock;
public static Block EmeraldGreenBlock;
public static Block WaterStoneOre;
public static Block GUIBlock;


@Instance("AeroMod")
public static AeroMod instance;


@Init
public void load(FMLInitializationEvent event){

// items     Skip |ID Numbers 2256 - 2267|
ItemWaterStone = new WaterstoneItem(2014).setUnlocalizedName("WaterStone");
ItemGrenade = new GrenadeItem(2019).setUnlocalizedName("ItemGrenade");
IngotSteel = new IngotSteel(2020).setUnlocalizedName("IngotSteel");


//blocks
WaterStoneBlock = new WaterstoneBlock(2015, "WaterStoneBlock").setUnlocalizedName("WaterStoneBlock").setHardness(2.0F).setStepSound(Block.soundStoneFootstep).setResistance(10.0F);
CoalBlock = new CoalBlock(2016, "CoalBlock").setUnlocalizedName("CoalBlock").setHardness(3.0F).setStepSound(Block.soundStoneFootstep).setResistance(10.0F);
AquaBlueBlock = new AquaBlueBlock(2026, "AquaBlueBlock").setUnlocalizedName("AquaBlueBlock").setHardness(2.0F).setStepSound(Block.soundStoneFootstep).setResistance(10.0F);
BrightYellowBlock = new BrightYellowBlock(2027, "BrightYellowBLock").setUnlocalizedName("BrightYellowBlock").setHardness(2.0F).setStepSound(Block.soundStoneFootstep).setResistance(10.0F);
EmeraldGreenBlock = new EmeraldGreenBlock(2028, "EmeraldGreenBlock").setUnlocalizedName("EmeraldGreenBlock").setHardness(2.0F).setStepSound(Block.soundStoneFootstep).setResistance(10.0F);
GUIBlock = new GUIBlock(2031, "GUIBlock").setUnlocalizedName("GUIBlock").setHardness(2.0F).setStepSound(Block.soundMetalFootstep);

//Ore
WaterStoneOre = new WaterStoneOre(2029, "WaterStoneOre").setUnlocalizedName("WaterStoneOre").setCreativeTab(CreativeTabs.tabBlock).setHardness(10.0F).setResistance(10.0F).setLightValue(1.0F);
MinecraftForge.setBlockHarvestLevel(WaterStoneOre, "pickaxe", 1);
RubyOre = new RubyOre(2030, "RubyOre").setUnlocalizedName("RubyOre").setCreativeTab(CreativeTabs.tabBlock).setHardness(10.0F).setResistance(10.0F).setLightValue(1.0F);
MinecraftForge.setBlockHarvestLevel(RubyOre, "pickaxe", 1);

//Tools
ItemWaterStonePickaxe = new ItemWaterStonePickaxe(2021, EnumToolMaterials.WaterStone).setUnlocalizedName("ItemWaterStonePickaxe").setCreativeTab(CreativeTabs.tabTools);
ItemWaterStoneSword = new ItemWaterStoneSword(2022, EnumToolMaterials.WaterStone).setUnlocalizedName("ItemWaterStoneSword").setCreativeTab(CreativeTabs.tabCombat);
ItemWaterStoneAxe = new ItemWaterStoneAxe(2023, EnumToolMaterials.WaterStone).setUnlocalizedName("ItemWaterStoneAxe").setCreativeTab(CreativeTabs.tabTools);
ItemWaterStoneShovel = new ItemWaterStoneShovel(2024, EnumToolMaterials.WaterStone).setUnlocalizedName("ItemWaterStoneShovel").setCreativeTab(CreativeTabs.tabTools);
ItemWaterStoneHoe = new ItemWaterStoneHoe(2025, EnumToolMaterials.WaterStone).setUnlocalizedName("ItemWaterStoneHoe").setCreativeTab(CreativeTabs.tabTools);	
ItemWaterStoneBow = new ItemWaterStoneBow(2017).setUnlocalizedName("WaterStoneBow");


//adding names
LanguageRegistry.addName(ItemWaterStone, "Water Stone");
LanguageRegistry.addName(WaterStoneBlock, "Waterstone Block");
LanguageRegistry.addName(CoalBlock, "Coal Block");
LanguageRegistry.addName(ItemWaterStoneBow, "Waterstone Bow");
LanguageRegistry.addName(IngotSteel, "Steel Ingot");
LanguageRegistry.addName(ItemGrenade, "Grenade");
LanguageRegistry.addName(ItemWaterStonePickaxe, "WaterStone Pickaxe");
LanguageRegistry.addName(ItemWaterStoneSword, "WaterStone Sword");
LanguageRegistry.addName(ItemWaterStoneAxe, "WaterStone Axe");
LanguageRegistry.addName(ItemWaterStoneShovel, "WaterStone Shovel");
LanguageRegistry.addName(ItemWaterStoneHoe, "WaterStone Hoe");
LanguageRegistry.addName(AquaBlueBlock, "AquaBlue Block");
LanguageRegistry.addName(BrightYellowBlock, "BrightYellow Block");
LanguageRegistry.addName(EmeraldGreenBlock, "EmeraldGreen Block");
LanguageRegistry.addName(WaterStoneOre, "WaterStone Ore");
LanguageRegistry.addName(RubyOre, "Ruby Ore");
LanguageRegistry.addName(GUIBlock, "GUI Block");

//Blocks
GameRegistry.registerBlock(WaterStoneBlock, "Waterstone Block");
GameRegistry.registerBlock(CoalBlock, "Coal Block");
GameRegistry.registerBlock(AquaBlueBlock, "AquaBlue Block");
GameRegistry.registerBlock(BrightYellowBlock, "BrightYellow Block");
GameRegistry.registerBlock(EmeraldGreenBlock, "EmeraldGreen Block");
GameRegistry.registerBlock(WaterStoneOre, "WaterStone Ore");
GameRegistry.registerBlock(RubyOre, "Ruby Ore");
GameRegistry.registerBlock(GUIBlock, "GUI Block");


GameRegistry.registerWorldGenerator(GenWorld);
GameRegistry.registerFuelHandler(new AeroModFuelHandler());
GameRegistry.registerTileEntity(TileEntityGrinder.class, "containergrinder");

NetworkRegistry.instance().registerGuiHandler(this, new AeroModGuiHandler());



//Recipes
GameRegistry.addRecipe(new ItemStack(WaterStoneBlock,1), new Object[]
	{ "TTT","TTT","TTT",'T',ItemWaterStone});
GameRegistry.addRecipe(new ItemStack(ItemWaterStoneBow, 1), new Object[]
	{ " TX", "T X", " TX",'T',ItemWaterStone, 'X',Item.silk});
GameRegistry.addRecipe(new ItemStack(ItemGrenade,1), new Object[]
	{ "XTX","XTX","XXX",'T',Item.gunpowder, 'X', IngotSteel});
GameRegistry.addRecipe(new ItemStack(ItemWaterStonePickaxe, 1), new Object[]
	{"TTT"," X "," X ",'T',ItemWaterStone, 'X',Item.stick});
GameRegistry.addRecipe(new ItemStack(ItemWaterStoneSword, 1), new Object[]
	{"TTT"," X "," X ",'T',ItemWaterStone, 'X',Item.stick});
GameRegistry.addRecipe(new ItemStack(ItemWaterStoneAxe, 1), new Object[]
	{"TTT"," X "," X ",'T',ItemWaterStone, 'X',Item.stick});
GameRegistry.addRecipe(new ItemStack(ItemWaterStoneShovel, 1), new Object[]
	{"TTT"," X "," X ",'T',ItemWaterStone, 'X',Item.stick});
GameRegistry.addRecipe(new ItemStack(ItemWaterStoneHoe, 1), new Object[]
	{"TTT"," X "," X ",'T',ItemWaterStone, 'X',Item.stick});
GameRegistry.addRecipe(new ItemStack(AquaBlueBlock, 1), new Object[]
	{"TTT","TTT","TTT",'T', Item.stick,}); //MultiBlock + Dye
GameRegistry.addRecipe(new ItemStack(GUIBlock, 1), new Object[]
	{"TTT","SRS","TTT", 'T', Item.ingotIron, 'S', IngotSteel, 'R',Item.redstone });

//Smelting
GameRegistry.addSmelting(Item.ingotIron.itemID, new ItemStack(IngotSteel, 1), 2F);
GameRegistry.addSmelting(WaterStoneOre.blockID, new ItemStack(ItemWaterStone, 4), 2F);


//Entitys
EntityRegistry.registerModEntity(EntityGrenade.class, "Grenade", EntityRegistry.findGlobalUniqueEntityId(), this, 128, 1, true);
	LanguageRegistry.instance().addStringLocalization("entity.Grenade.name", "Grenade");


}
}

Posted

Any updates on this?

 

I'm having a similar issue.  Things seem to be set up correctly, but the GUI never opens (no crash).  getClientGuiElement in the IGuiHandler never gets called.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I figured I'd poke this thread as it's the same issue.

 

Instead of, I don't know, creating a duplicate.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

I figured I'd poke this thread as it's the same issue.

 

Instead of, I don't know, creating a duplicate.

No, I meant did you have another thread *before* this one was started, so I could look at your code there. I don't know if you have the same problem; as it it I haven't the faintest idea what's wrong with his code. @OP: can you check if getClientGUIElement() is getting called?

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Posted

I am still learning but with code which is working I have a couple of differences, not sure if these are just different ways to do the same as you have

 

First I would try changing

 

NetworkRegistry.instance().registerGuiHandler(this, new AeroModGuiHandler());

 

to

 

NetworkRegistry.instance().registerGuiHandler(instance, new AeroModGuiHandler());

 

Other then that the only other difference I have is that I have my

 

registerTileEntities(), getServerGuiElement(), and getClientGuiElement() in the CommonProxy and

 

I am loading in this order

 

NetworkRegistry.instance().registerGuiHandler(instance, proxy);

   

proxy.registerTileEntities();

 

Again not sure if it helps but other then those changes your code looks almost the same as mine, and my Gui's are working.

Neoublie

Author of Codename: Project Shadow

 

if you do models and textures pm me. looking for some assistance.

Posted

I figured I'd poke this thread as it's the same issue.

 

Instead of, I don't know, creating a duplicate.

No, I meant did you have another thread *before* this one was started, so I could look at your code there. I don't know if you have the same problem; as it it I haven't the faintest idea what's wrong with his code. @OP: can you check if getClientGUIElement() is getting called?

 

I hadn't, because this thread existed.

 

In any case, I solved my own problem by pulling up another GUI mod I'd made and literally copy-pasting code in until I had my new mod.

 

I still have no idea why one works and the other doesn't.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.