Jump to content

Recommended Posts

Posted

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?

Posted

If you want to allow for texture animation, you need to limit it to 2 possible states if you are both using metadata to store this and your machine can point in any of the six directions.  Else you can use a TileEntity, which is what RP2 does.

Posted

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.

 

Posted

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.

Posted

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.

Posted

that's not a lot

that's like six out of like a hundred some blocks

A 'lot' in this context means there there are more examples in the vanilla codebase then is actually needed to demonstrate what to do.  ;)

Posted

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

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.