Tallinu Posted May 2, 2012 Posted May 2, 2012 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? Quote
OvermindDL1 Posted May 2, 2012 Posted May 2, 2012 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. Quote
Tallinu Posted May 3, 2012 Author Posted May 3, 2012 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. Quote
OvermindDL1 Posted May 3, 2012 Posted May 3, 2012 On 5/3/2012 at 5:04 AM, Tallinu said: 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. Quote
Tallinu Posted May 4, 2012 Author Posted May 4, 2012 Okay, thanks. Is there any advice you can give or direct me to on working with and/or implementing that? Quote
OvermindDL1 Posted May 4, 2012 Posted May 4, 2012 TESR's are used by a *lot* of vanilla blocks. Quote
Tallinu Posted May 6, 2012 Author Posted May 6, 2012 Looking at the code, I can only find a few that appear to do so, at least calling it by that name. What am I missing? Quote
Methuselah96 Posted May 6, 2012 Posted May 6, 2012 they are not used by a lot of blocks don't listen to him Quote
Cloudy Posted May 6, 2012 Posted May 6, 2012 On 5/6/2012 at 12:56 AM, Methuselah96 said: 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. Quote
Methuselah96 Posted May 6, 2012 Posted May 6, 2012 that's not a lot that's like six out of like a hundred some blocks Quote
OvermindDL1 Posted May 7, 2012 Posted May 7, 2012 On 5/6/2012 at 7:27 PM, Methuselah96 said: 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. Quote
Methuselah96 Posted May 7, 2012 Posted May 7, 2012 Tallinu had said there were only a few and i agree with him. Quote
Tallinu Posted May 9, 2012 Author Posted May 9, 2012 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. Quote
Recommended Posts
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.