KururuLABO Posted March 21, 2014 Posted March 21, 2014 public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer entityplayer, int a, float b, float x, float y){ TileEntityiTrade tileEntity = (TileEntityiTrade) world.getBlockTileEntity(i, j, k); if (tileEntity == null) return false; entityplayer.openGui(iCraftMain.instance, 1, world, i, k, k); return true; } Gui Handler package iCraft.Gui; import iCraft.Client.EnumGui; import iCraft.Packet.Handler.TileEntityiTrade; 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 iGuiHandler 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(ID == 1) { if(tileEntity instanceof TileEntityiTrade) { return new ContaineriTrade(player.inventory, (TileEntityiTrade) tileEntity,ID,player); } } 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(ID == 1) { System.out.println("Tile : "+tileEntity); if(tileEntity instanceof TileEntityiTrade) { return new GuiiTradeOwner(player.inventory, (TileEntityiTrade) tileEntity,ID,player); } } return null; } } If player right click[ Player place the block ] Gui can open it But if !playerowner gui can't open it Quote
Wicked1 Posted March 22, 2014 Posted March 22, 2014 Just had a similar problem with Null TE in guihandler. I did register the TE, I did set MyTE as the block te, but I didnt set the blocks HasTileEntity... once I told the block HasTileEntity the nulls stopped for me Quote http://i1149.photobucket.com/albums/o583/battleaxe333/mcMML-objBanner.png[/img]
Master801 Posted March 22, 2014 Posted March 22, 2014 This should help. :\ if (tileEntity != null) } } Quote
sequituri Posted March 23, 2014 Posted March 23, 2014 This should help. :\ if (tileEntity != null) { } Fixed that for you. ;-) Quote -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
Recommended Posts
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.