Posted March 21, 201411 yr I've been trying to get it so I can open a GUI from anywhere. I attach my itemstack to a chest or furnace or whatever and then have it go through blockList and do the onBlockActivated action. This should in theory open the GUI or do whatever is intended for the block to do but it doesn't. The only blocks that work are ones that do not open GUIs. So levers, switches, repeaters, etc... How would I go about opening the GUI of a block from any distance away? Some code from my Item: @Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { if(itemstack.getTagCompound() == null) { itemstack.setTagCompound(new NBTTagCompound()); return true; } else if(itemstack.getTagCompound().getBoolean("hasSet") == false) { itemstack.getTagCompound().setInteger("BlockX", x); itemstack.getTagCompound().setInteger("BlockY", y); itemstack.getTagCompound().setInteger("BlockZ", z); itemstack.getTagCompound().setBoolean("hasSet", true); itemstack.getTagCompound().setString("BlockName", Block.blocksList[world.getBlockId(x, y, z)].getLocalizedName()); return true; } else { if(Block.blocksList[world.getBlockId(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"))] != null) { if(world.getBlockTileEntity(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ")) != null && world.getBlockTileEntity(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ")) instanceof ISidedInventory) { ((ISidedInventory)world.getBlockTileEntity(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"))).openChest(); } if(Block.blocksList[world.getBlockId(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"))].onBlockActivated(world, itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"), player, par7, par8, par9, par10) == false) { itemstack.getTagCompound().setBoolean("hasSet", false); itemstack.getTagCompound().setInteger("BlockX", 0); itemstack.getTagCompound().setInteger("BlockY", 0); itemstack.getTagCompound().setInteger("BlockZ", 0); itemstack.getTagCompound().setString("BlockName", ""); return false; } } else itemstack.getTagCompound().setBoolean("hasSet", false); return true; } } public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if(itemstack.getTagCompound() != null) { if(Block.blocksList[world.getBlockId(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"))] != null) { if(Block.blocksList[world.getBlockId(itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"))].onBlockActivated(world, itemstack.getTagCompound().getInteger("BlockX"), itemstack.getTagCompound().getInteger("BlockY"), itemstack.getTagCompound().getInteger("BlockZ"), player, 0, 0.0F, 0.0F, 0.0F) == false) { itemstack.getTagCompound().setBoolean("hasSet", false); } } else itemstack.getTagCompound().setBoolean("hasSet", false); } return itemstack; } http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
March 22, 201411 yr Author Anyone have any ideas on how to go about this? http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
March 22, 201411 yr Vanilla blocks have a maximum distance for interaction, usually defined in the TileEntity#isUseableByPlayer(EntityPlayer), by a 64 distance squared. You would have to either patch this with a coremod, or use a FakePlayer placed accordingly and pass the block information to the real player entity. Also, it is recommended to cache the block information locally, instead of fetching the world data on every line of code.
March 22, 201411 yr Author Alright, I'll cache the block information. If on the TileEntity it detects this, then how come workbenches and anvils still won't let me use it? They do not have TileEntities attached. http://www.slothygaming.com/img/ota.png[/img] If your grammar is shit and you blatantly don't know what you're doing, I will not help you.
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.