Posted May 2, 201213 yr 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?
May 2, 201213 yr 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.
May 3, 201213 yr Author 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.
May 3, 201213 yr 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.
May 4, 201213 yr Author Okay, thanks. Is there any advice you can give or direct me to on working with and/or implementing that?
May 6, 201213 yr Author 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?
May 6, 201213 yr 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.
May 7, 201213 yr 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.
May 9, 201213 yr Author 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.