Posted June 22, 201312 yr Hey! For a section of my mod that I am working on at the moment, I need to be able to apply tile entities to a block upon clicking with an item. However, in the onItemUse function, whenever I try to call world.setBlockTileEntity(x, y, z, TileEntityBlockCover) it claims that the final variable is undefined, and I do not know what/how it should be defined as it is a tile entity. Also, if it is useful, I aim to be able to click on any block with this item, and if the block I click on does not already have a TE, I want my TE applied to it to render/use NBT/ do whatever. Thanks in advance! Luis
June 24, 201312 yr I'm not sure about this but don't u have to add .class to TileEntityBlockCover? Like this: world.setBlockTileEntity(x, y, z, TileEntityBlockCover.class)
June 24, 201312 yr The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are.
June 24, 201312 yr I have made a block with a tileentity, etc. I will upload my code for u to see as soon as I can.
June 24, 201312 yr Author I have made a block with a tileentity, etc. I will upload my code for u to see as soon as I can. Thanks but I know how tile entities on blocks work. What I am trying to achieve here is when an item is used on any block, vanilla or modded, it creates my TileEntityBlockCover which I can later use in rendering... Thanks anyway! The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are. Thanks! I will try this tomorrow and see if it does what I need
June 25, 201312 yr Author The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are. I tried this method, but the TE gets removed from the world after a tick, when I want it to stay. I am unsure if this is a problem with the fact this TE is not assigned to any block, and that I just want it placed upon an item clicking on a block. Also, using some System.out.println I know that the TE is being placed, just not staying in the world at all...
June 25, 201312 yr The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are. I tried this method, but the TE gets removed from the world after a tick, when I want it to stay. I am unsure if this is a problem with the fact this TE is not assigned to any block, and that I just want it placed upon an item clicking on a block. Also, using some System.out.println I know that the TE is being placed, just not staying in the world at all... You shouldn't need to be doing that. Instead, set the block to BlockCover and watch as the TE is created automatically. BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
June 25, 201312 yr Author The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are. I tried this method, but the TE gets removed from the world after a tick, when I want it to stay. I am unsure if this is a problem with the fact this TE is not assigned to any block, and that I just want it placed upon an item clicking on a block. Also, using some System.out.println I know that the TE is being placed, just not staying in the world at all... You shouldn't need to be doing that. Instead, set the block to BlockCover and watch as the TE is created automatically. I want the block to stay as its original block, and keep all its old features, just look different. Essentially an item that changes the look of any block it is clicked on...
June 25, 201312 yr The method takes a tile entity object, not the class itself. Meaning, you need to instatiate (create) a new object of your tile entity. Like this: world.setBlockTileEntity(x, y, z, new TileEntityBlockCover(parameters)); Replace parameters with whatever your TileEntityBlockCover's constructor's parameters are. I tried this method, but the TE gets removed from the world after a tick, when I want it to stay. I am unsure if this is a problem with the fact this TE is not assigned to any block, and that I just want it placed upon an item clicking on a block. Also, using some System.out.println I know that the TE is being placed, just not staying in the world at all... You shouldn't need to be doing that. Instead, set the block to BlockCover and watch as the TE is created automatically. I want the block to stay as its original block, and keep all its old features, just look different. Essentially an item that changes the look of any block it is clicked on... You can't do that without modifying the block. Which means you'd have to modify every block. Just create your own block/TE, put the ID/metadata in an NBT tag, and redefine all the block functions to emulate whichever block. (like return Block.blocksList[((myTE) w.getTileEntity(x,y,z)).theID].whateverFunction(...). Unfortunately most functions will then not work because the coords are not passed in and you can't access your TE without coords.) BEWARE OF GOD --- Co-author of Pentachoron Labs' SBFP Tech.
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.