Jump to content

Recommended Posts

Posted

So I am trying to get my GUI to open and its not and I'm not sure why can someone please help me other thanks.

 

My main mod class

 

package com.robertcars.generaltech.core;

import com.robertcars.generaltech.blocks.ModBlocks;
import com.robertcars.generaltech.gui.GuiHandler;
import com.robertcars.generaltech.items.ModItems;
import com.robertcars.generaltech.lib.Reference;
import com.robertcars.generaltech.proxy.CommonProxy;
import com.robertcars.generaltech.tileentity.ModTileEntitys;

import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; // used in 1.6.2
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=Reference.MOD_ID, name=Reference.MOD_NAME, version=Reference.VERSION)

public class GeneralTech {

@Instance(value = Reference.MOD_ID)
        public static GeneralTech instance;
        
        @SidedProxy(clientSide="com.robertcars.generaltech.proxy.ClientProxy", serverSide="com.robertcars.generaltech.proxy.CommonProxy")
        public static CommonProxy proxy;
        
        @EventHandler
        public void preInit(FMLPreInitializationEvent event) {
        	ModItems.init();
        	ModBlocks.init();
        	ModTileEntitys.init();
        }
        
        @EventHandler
        public void load(FMLInitializationEvent event) {
                proxy.registerRenderers();
            	NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
        }
        
        @EventHandler
        public void postInit(FMLPostInitializationEvent event) {

        }
}

 

 

GuiHandler

 

 

package com.robertcars.generaltech.gui;

import com.robertcars.generaltech.container.ContainerTeleporter;
import com.robertcars.generaltech.lib.GuiIDS;
import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

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 GuiHandler implements IGuiHandler {

public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch (ID) {
		case GuiIDS.guiIDTeleporter:
			if(entity instanceof TileEntityTeleporter) {
				return new ContainerTeleporter(player.inventory, (TileEntityTeleporter) entity);
			}
		}
	}

	return null;
}

public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch (ID) {
		case GuiIDS.guiIDTeleporter:
			if(entity instanceof TileEntityTeleporter) {
				return new GuiTeleporter(player.inventory, (TileEntityTeleporter) entity);
			}
		}
	}

	return null;
}

}

 

 

Gui class

 

 

package com.robertcars.generaltech.gui;

import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;

import com.robertcars.generaltech.container.ContainerTeleporter;
import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

public class GuiTeleporter extends GuiContainer {

public TileEntityTeleporter teleporter;

public GuiTeleporter(InventoryPlayer inventoryPlayer, TileEntityTeleporter entity) {
	super(new ContainerTeleporter(inventoryPlayer, entity));

	this.teleporter = entity;
}

//draw text
public void drawGuiContainerForegroundLayer(int par1, int par2) {

}

//draw images
public void drawGuiContainerBackgroundLayer(float f, int i, int j) {

	this.drawDefaultBackground();

}

}

 

 

Container

 

 

package com.robertcars.generaltech.container;


import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;

import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

public class ContainerTeleporter extends Container{

private TileEntityTeleporter teleporter;


public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tileentity) {
	this.teleporter = tileentity;

}

public boolean canInteractWith(EntityPlayer var1) {
	return this.teleporter.isUseableByPlayer(var1);
}

}

 

 

TileEntity

 

 

package com.robertcars.generaltech.tileentity;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

public class TileEntityTeleporter extends TileEntity {

public String pass;
public int pa;

    public void readFromNBT(NBTTagCompound p_145839_1_) {
        super.readFromNBT(p_145839_1_);
    }

    public void writeToNBT(NBTTagCompound p_145841_1_){
    }

public boolean isUseableByPlayer(EntityPlayer entityplayer) {
	return this.worldObj.getTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5F, (double)this.zCoord + 0.5D) <= 64.0D;
}
}

 

 

Block

 

 

package com.robertcars.generaltech.blocks;

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

import com.robertcars.generaltech.core.GeneralTech;
import com.robertcars.generaltech.lib.GuiIDS;
import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;


public class BlockTeleporter extends BasicBlock {

    public BlockTeleporter() {
        super();
    }
    
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {

	if(!world.isRemote) {
		FMLNetworkHandler.openGui(player, GeneralTech.instance, GuiIDS.guiIDTeleporter, world, x, y, z);
	}

	return true;
}

    
    public TileEntity createTileEntity(World world, int metadata) {
       return new TileEntityTeleporter();
    }
}

 

Posted

I think you are missing the IGuiHandler.

 

Im sorry I must have messed up putting my code in.

here is my guihandler

package com.robertcars.generaltech.gui;

 

import com.robertcars.generaltech.container.ContainerTeleporter;

import com.robertcars.generaltech.lib.GuiIDS;

import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

 

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 GuiHandler implements IGuiHandler {

 

public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

 

TileEntity entity = world.getTileEntity(x, y, z);

 

if(entity != null) {

switch (ID) {

case GuiIDS.guiIDTeleporter:

if(entity instanceof TileEntityTeleporter) {

return new ContainerTeleporter(player.inventory, (TileEntityTeleporter) entity);

}

}

}

 

return null;

}

 

public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

 

TileEntity entity = world.getTileEntity(x, y, z);

 

if(entity != null) {

switch (ID) {

case GuiIDS.guiIDTeleporter:

if(entity instanceof TileEntityTeleporter) {

return new GuiTeleporter(player.inventory, (TileEntityTeleporter) entity);

}

}

}

 

return null;

}

 

}

 

Posted

if you are what you may want to do is change

 

FMLNetworkHandler.openGui(player, GeneralTech.instance, GuiIDS.guiIDTeleporter, world, x, y, z);

 

to

 

player.openGui(GeneralTech.instance, GuiIDS.guiIDTeleporter, world, x, y, z

Posted

Yes right here

 

 

package com.robertcars.generaltech.tileentity;

import cpw.mods.fml.common.registry.GameRegistry;

public class ModTileEntitys {

public static void init() {
	GameRegistry.registerTileEntity(TileEntityTeleporter.class, "tileEntityTeleporter");
}

}

 

 

I did notice i don't know if this helps but when I put System.out.println("test"); in my Guihandler in the getClientGuiElement and try to open the GUI it doesn't print. But im not sure if even if it was working if it would print either.

Posted

if you are what you may want to do is change

 

FMLNetworkHandler.openGui(player, GeneralTech.instance, GuiIDS.guiIDTeleporter, world, x, y, z);

 

to

 

player.openGui(GeneralTech.instance, GuiIDS.guiIDTeleporter, world, x, y, z

it still didnt work after changing that
Posted

Yes right here

 

 

package com.robertcars.generaltech.tileentity;

import cpw.mods.fml.common.registry.GameRegistry;

public class ModTileEntitys {

public static void init() {
	GameRegistry.registerTileEntity(TileEntityTeleporter.class, "tileEntityTeleporter");
}

}

 

 

I did notice i don't know if this helps but when I put System.out.println("test"); in my Guihandler in the getClientGuiElement and try to open the GUI it doesn't print. But im not sure if even if it was working if it would print either.

 

it should work it is usually just very hard to see in the console

Posted

Yes right here

 

 

package com.robertcars.generaltech.tileentity;

import cpw.mods.fml.common.registry.GameRegistry;

public class ModTileEntitys {

public static void init() {
	GameRegistry.registerTileEntity(TileEntityTeleporter.class, "tileEntityTeleporter");
}

}

 

 

I did notice i don't know if this helps but when I put System.out.println("test"); in my Guihandler in the getClientGuiElement and try to open the GUI it doesn't print. But im not sure if even if it was working if it would print either.

 

it should work it is usually just very hard to see in the console

Well it doesnt atleast not here

 

package com.robertcars.generaltech.gui;

import com.robertcars.generaltech.container.ContainerTeleporter;
import com.robertcars.generaltech.lib.GuiIDS;
import com.robertcars.generaltech.tileentity.TileEntityTeleporter;

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 GuiHandler implements IGuiHandler {

public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch (ID) {
		case GuiIDS.guiIDTeleporter:
			if(entity instanceof TileEntityTeleporter) {
				return new ContainerTeleporter(player.inventory, (TileEntityTeleporter) entity);
			}
		}
	}

	return null;
}

public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
	System.out.println("Test");
	TileEntity entity = world.getTileEntity(x, y, z);

	if(entity != null) {
		switch (ID) {
		case GuiIDS.guiIDTeleporter:
			if(entity instanceof TileEntityTeleporter) {
				return new GuiTeleporter(player.inventory, (TileEntityTeleporter) entity);
			}
		}
	}

	return null;
}

}

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been using this modpack for a few days now with no issues, it was working properly just an hour or two ago and now all of a sudden when I try to load it I get this error: 'The game crashed: exception in server tick loop Error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $' debug log: https://pastebin.com/1htBuhsP crash report: https://pastebin.com/QggHKYDg
    • Everything worked fine until I decided to install supplementaries squared, amendments and a couple other mods like artifacts, and compats for it. I'm having a hard time fixing this, and I get this crash whenever I try to enter a world. Not even a new world is feasible. Any help would be highly appreciated!! https://pastebin.com/7KXYZ6fM
    • Internal Exception: com.google.gson.JsonParseException: Error loading registry data: Unknown element: ResourceKey[minecraft:worldgen/configured_feature / minecraft:crimson_forest_vegetation]   This error is there when i try to join my friends server. We had some mods and it was okay but after 3 days i cant join.
    • It just says the mod i had but i dont have now.. and i didnt even use these mods and it still was crashing with the mods  
    • Hello,   I've been back and forth in emails with some CurseForge support staff on the issue but there's been no progress. In the CurseForge app, I have custom profiles and some public modpacks that will not load no matter what. I've goen through every link sent to me, I've reinstalled Minecraft, reinstalled the launcher, repaired the installations individually, uninstalled and reinstalled the public modpacks, downloaded the latest Java--all of it. But each time, I'm always met with either "java runtime exception", "exit code 1" on the rare occasions Minecraft does launch, or "java is out of date" (which literally cannot be possible since I reinstalled the latest version a few different times.) Making a new profile works, but I want to be able to play the ones I had before.  I had gotten one of the old public Minecraft modpacks to work, the prehistoric one about dinosaurs being featured right now, but then it only worked once. I've tried to retrace my steps and it just would not work. I have genuinely no clue what's going on.
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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