Hey guys.
I'm working on a mod. There are two new blocks. Each block should open a GUI with a right mouse button.
Problem: The GUI don't open. No Errors. No messages in the console in eclipse.
Each block have an onBlockActivated like this, only the ID in par5EntityPlayer.opengui are different(0-1).
public boolean onBlockActivated(World par1World, int par2, int par3,
int par4, EntityPlayer par5EntityPlayer, int par6, float par7,
float par8, float par9) {
if (par1World.isRemote) {
return true;
} else if (!par5EntityPlayer.isSneaking()) {
TileEntity var10 = (TileEntity) par1World.getBlockTileEntity(par2,
par3, par4);
if (var10 != null) {
par5EntityPlayer.openGui(Basis.instance, 0, par1World, par2,
par3, par4);
}
return true;
} else {
return false;
}
}
Also I have an GuiHandler class with the methods getServerGuiElement and getClientGuiElement
getClientGuiElement:
public Object getClientGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity == null) {
switch (ID) {
case 0:
return new GuiBlock1(player.inventory,
((TileEntityBlock1) entity));
case 1:
return new GuiFlock2(player.inventory,
((TileEntityBlock2) entity));
}
}
return null;
}
getServerGuiElement:
public Object getServerGuiElement(int ID, EntityPlayer player, World world,
int x, int y, int z) {
TileEntity entity = world.getBlockTileEntity(x, y, z);
if (entity == null) {
switch (ID) {
case 0:
return new ContainerBlock1(player.inventory,
((TileEntityBlock1) entity));
case 1:
return new ContainerBlock2(player.inventory,
((TileEntityBlock2) entity));
}
}
return null;
}
And in the main class I added this:
public static GuiHandler handler;
NetworkRegistry.instance().registerGuiHandler(instance, handler);