Jump to content

How would I set my blocks metadata depending on the players direction?


Flenix

Recommended Posts

Only easy way for is too make tileentity and rotate it's renderer... Hope there are more easy ways.

   

 

Please do not do this, it isn't worth the extra save file size cost. I would rather see you make a texture for the two separate possible directions and use the metadata to store the direction.

 

Here is how I would do it:

when deciding the icon for the face:

if nbt (metadata) = 0 > choose north/south icon

if nbt = 1 > choose east/west icon

 

when placing the block:

use the code above to tell if the player is facing north or south, if they are set the metadata to 0, otherwise set it to 1.

 

From what you have said so far, I would assume this block is strictly visual and has no intended functionality other than being a block.

 

There appears to be some code in the Minecraft source that handles icon face rotation, but I haven't played with that yet. maybe later, as I do see myself hitting a similar problem in the future.

Link to comment
Share on other sites

Only easy way for is too make tileentity and rotate it's renderer... Hope there are more easy ways.

   

 

Please do not do this, it isn't worth the extra save file size cost. I would rather see you make a texture for the two separate possible directions and use the metadata to store the direction.

 

Here is how I would do it:

when deciding the icon for the face:

if nbt (metadata) = 0 > choose north/south icon

if nbt = 1 > choose east/west icon

 

when placing the block:

use the code above to tell if the player is facing north or south, if they are set the metadata to 0, otherwise set it to 1.

 

From what you have said so far, I would assume this block is strictly visual and has no intended functionality other than being a block.

 

There appears to be some code in the Minecraft source that handles icon face rotation, but I haven't played with that yet. maybe later, as I do see myself hitting a similar problem in the future.

Link to comment
Share on other sites

Only easy way for is too make tileentity and rotate it's renderer... Hope there are more easy ways.

   

Please do not do this, it isn't worth the extra save file size cost. I would rather see you make a texture for the two separate possible directions and use the metadata to store the direction.

 

Do you mean the world size?

The mod is mainly designed for my server, which we have a 500gb drive dedicated just for minecraft (and a few small things like Jenkins.. if it ever bloody works.), so that's not an issue.

The only reason I avoided tile entity at all was because I heard it was more RAM-consuming. However I eventually wanted to make some of the blocks a custom shape, and from what I've seen if I did that, there's no avoiding a tile entity. Maybe I should look into that, but I'll try your NBT thing first.

 

The blocks are entirely cosmetic. It's just a set of road blocks like you'd see in the street; we have a modern server, and we have Flans, it was a huge gap and I'm learning Java to fill it :P

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

There is way to avoid TileEntities in custom renderes. I've coded a library that does. I have example code for it too. But it still have one bug: It won't render if there is no full block in chunk section which shouldn't be issue for you since it's road block. Take a look in here: https://github.com/skore13/renderLib

Creator of easy custom renderer library without tile entity. https://github.com/skore13/renderLib

Link to comment
Share on other sites

You should always strive to use the least space possible when it comes to saves/ram usage and minimize the footprint of these blocks as much as possible. To me, that is just good practice. And seeing that these blocks are strictly cosmetic, I highly suggest looking into the log code more, as it seems that the log code is closes to what you are trying to achieve (save leaf support and vertical axis alignment).

 

I will try to look into icon rotation later to see if it is easy to rotate the texture face on a block (just don't hold me to this please).

Link to comment
Share on other sites

There is way to avoid TileEntities in custom renderes. I've coded a library that does. I have example code for it too. But it still have one bug: It won't render if there is no full block in chunk section which shouldn't be issue for you since it's road block. Take a look in here: https://github.com/skore13/renderLib

 

Looks pretty useful! How exactly would I go about using this?

 

You should always strive to use the least space possible when it comes to saves/ram usage and minimize the footprint of these blocks as much as possible. To me, that is just good practice. And seeing that these blocks are strictly cosmetic, I highly suggest looking into the log code more, as it seems that the log code is closes to what you are trying to achieve (save leaf support and vertical axis alignment).

 

I know that in general it's good practice. However, I'm sure I mentioned earlier that eventually, these blocks are custom rendered anyway and I was just trying to get something basic together first to help me learn. However, if it's easier to just go tile entity (or the thing Skore mentioned) then that's probably for the best.

 

When the mod is done, the roads would look like this (The blocks are from Redpower as an example)

517beaf888a70.jpg

 

I'm also making road signs which obviously are more important to have rendered.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

This is all irrelevant;

I just realized that custom rendered tile entities (for example, a chest) don't get rendered after about 32 blocks. Which makes it totally useless for a road...

So unless anyone has an idea of how to force it to be rendered, it's impossible?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Link to comment
Share on other sites

How exactly would I go about using this?

Here is wiki I created:

https://github.com/skore13/renderLib/wiki

Now I'm working on rotation. But for your roads it's irrelevant. Also if you are missing anything rendering-related please tell me :)

Road signs: It's gonna be hard to create round signs... But I've idea (from vanilla code for rendering item in player's hand)

Also you have to override hitboxes for your road blocks but that's not as hard as custom renderers and I also want it in my library.

Creator of easy custom renderer library without tile entity. https://github.com/skore13/renderLib

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.