Jump to content

Tile Entity troubles...


luisc99

Recommended Posts

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  :D

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :P

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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