Jump to content

Controlling block orientation


Tallinu

Recommended Posts

I have created a block with an inventory, with the intent for it to interact with an adjacent block's inventory, and I'm having trouble figuring out two things: First, how to determine which direction it should face when placed or manipulated by a player, and second, how to store and retrieve that information, especially for the purpose of determining which texture index to specify for each side in public int getBlockTextureFromSide(int i). I'd like to be able to (eventually) animate certain sides as well. I assume information specific to each individual block's state needs to go into the tile entity along with the inventory contents and such, but I'm confused as to how you get AT that specific information from the aforementioned function, since it doesn't offer any way to know what world coordinates it's dealing with.

 

I suspect I may not be looking in the right places, but I don't know what else to look at. I don't need a custom render model like Buildcraft's engines. I'm perfectly happy with a standard cube like RedPower's machines and most other mods that make things face the same direction you are when placed. Any advice would be appreciated.

 

Edit: I've been looking at pistons, but the metadata approach doesn't appear to allow for texture animation or changing appearance based on tile entity state. There's only 4 bits available, 3 of which would be required for the orientation. Right?

Link to comment
Share on other sites

Right, first 3 bits are for orientation. I do have that working now, at least. (The code is at https://github.com/Tallinu/InventoryStocker if that's any help.) I could use bit 4 to switch between one of two states for the entire block, and control the state of bit 4 from the tile entity.

 

But I'd like to have more than two states, and if I'm going to animate them at all I'd like it to be based on their individual state, not just a global "flashy lights" or "spinny wheel" thing. :)

 

How do I get more than 1 additional bit of information from the tile entity, or get direct access to the tile entity, from the Block functions that are supposed to return the texture index? Even the 'with meta data' version doesn't appear to have any information regarding the block's location or the specific tile entity associated with the block at the location in question.

 

Link to comment
Share on other sites

Right, first 3 bits are for orientation. I do have that working now, at least. (The code is at https://github.com/Tallinu/InventoryStocker if that's any help.) I could use bit 4 to switch between one of two states for the entire block, and control the state of bit 4 from the tile entity.

 

But I'd like to have more than two states, and if I'm going to animate them at all I'd like it to be based on their individual state, not just a global "flashy lights" or "spinny wheel" thing. :)

 

How do I get more than 1 additional bit of information from the tile entity, or get direct access to the tile entity, from the Block functions that are supposed to return the texture index? Even the 'with meta data' version doesn't appear to have any information regarding the block's location or the specific tile entity associated with the block at the location in question.

 

To do that with texture based on side it is difficult, not designed for that.  At this point you are more looking toward a TESR, Tile Entity Special Renderer.

Link to comment
Share on other sites

they are not used by a lot of blocks

don't listen to him

 

Really?

 

TileEntitySignRenderer

TileEntityMobSpawnerRenderer

TileEntityRendererPiston

TileEntityChestRenderer

RenderEnchantmentTable

RenderEndPortal

 

All using TESR's.

Link to comment
Share on other sites

Thanks for the suggestion, Overmind, and the list, Methuselah. I'll have a look at what those are doing. The internal workings are coming together more or less smoothly, so we'll be at the "it does what we want it to, now how can we make it look great while doing it" stage soon enough. ;)

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.