Jump to content

Draw pixels on top of a texture/block.


oyasunadev

Recommended Posts

Hey everyone. So my mod consists of a few blocks. Most of which are forms of machines. I want to have an indicator drawn over the texture on only one face. So for example, change the pixel of the texture to a different color when the machine is on. I really don't want to have textures for on and off, I want my code to be unique. Any ideas?

Link to comment
Share on other sites

> I really don't want to have textures for on and off, I want my code to be unique. Any ideas?

 

I don't understand what you mean there, but anyway the easiest method is probably to use a TileEntitySpecialRenderer.  You draw the underlying block with a Block Model, then use the TESR to draw your pixels on the top.

 

a working example is in this tutorial project

https://github.com/TheGreyGhost/MinecraftByExample

MBE21

 

-TGG

Link to comment
Share on other sites

> I really don't want to have textures for on and off, I want my code to be unique. Any ideas?

 

I don't understand what you mean there, but anyway the easiest method is probably to use a TileEntitySpecialRenderer.  You draw the underlying block with a Block Model, then use the TESR to draw your pixels on the top.

 

a working example is in this tutorial project

https://github.com/TheGreyGhost/MinecraftByExample

MBE21

 

-TGG

 

Sorry that was unclear. I mean that I don't want to have to have two different textures for the block, one on, and another off. I want to have one texture and then draw a pixel (green/red) at a certain spot on the face.

Link to comment
Share on other sites

Couldn't you just create a smart block model and draw baked quads on top and bind textures to those?

 

Yeah, I just did some research on the ISmartBlockModel class and alike. I had no previous knowledge of this class. I'm finding it very confusing. I can set it up properly with the event but how do I draw pixels over the face of the block?

Link to comment
Share on other sites

Hi

 

ISmartBlockModel just lets you generate a texture using code, instead of having to specify it in a block model file. 

Honestly, if you just need an on/off light on your block, and it's always in the same place on the block, you should just make two block textures, one for on, the other for off, and switch between them using the IBlockState, it's the most straightforward way.  If you want your light to blink or be animated, use a TESR.  You really don't need ISmartBlockModel unless you're trying to do fancy stuff like count the number of nearby blocks or put the light in different locations depending on what's connected to your machine, or you've got lots of lights that work independently.

 

That tutorial project has examples of ordinary blocks, blocks with variants (coloured signposts for example), also the more advanced ones that use ISmartBlockModel and such.

 

-TGG

Link to comment
Share on other sites

Hi

 

ISmartBlockModel just lets you generate a texture using code, instead of having to specify it in a block model file. 

Honestly, if you just need an on/off light on your block, and it's always in the same place on the block, you should just make two block textures, one for on, the other for off, and switch between them using the IBlockState, it's the most straightforward way.  If you want your light to blink or be animated, use a TESR.  You really don't need ISmartBlockModel unless you're trying to do fancy stuff like count the number of nearby blocks or put the light in different locations depending on what's connected to your machine, or you've got lots of lights that work independently.

 

That tutorial project has examples of ordinary blocks, blocks with variants (coloured signposts for example), also the more advanced ones that use ISmartBlockModel and such.

 

-TGG

 

EDIT: Figured it out. Used System.currentTimeMillis(). THANKS TO ALL THAT HELPED!

 

Thank you very much for your response. I think TESR is my way to go, but if I fail, I'll take your advice and just use textures. So is there an API way to animate? Or do I have to write a timer myself? The problem is that renderTileEntityAt is ran every tick for block existing in the world. So if I have two blocks then it will be ran 2 times per tick. I have something that I would like to turn on and off though. I want an animation similar to ComputerCraft's blinking placeholder. Any ideas?

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.