Jump to content

Gui not opening


BlueGhast90

Recommended Posts

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;

    }
}

Link to comment
Share on other sites

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");


}
}

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • rp.crazyheal.xyz mods  
    • I'm developing a dimension, but it's kinda resource intensive so some times during player teleporting it lags behind making the player phase down into the void, so im trying to implement some kind of pregeneration to force the game loading a small set of chunks in the are the player will teleport to. Some of the things i've tried like using ServerLevel and ServerChunkCache methods like getChunk() dont actually trigger chunk generation if the chunk isn't already on persistent storage (already generated) or placing tickets, but that doesn't work either. Ideally i should be able to check when the task has ended too. I've peeked around some pregen engines, but they're too complex for my current understanding of the system of which I have just a basic understanding (how ServerLevel ,ServerChunkCache  and ChunkMap work) of. Any tips or other classes I should be looking into to understand how to do this correctly?
    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
  • Topics

×
×
  • Create New...

Important Information

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