Jump to content

[1.16.3] SpriteRenderer Overlay Texture


Peerius
 Share

Recommended Posts

Hello,

 

I already asked this question a while ago for 1.15, but I think I can ask more specificially now. 

I want to implement a falling star similar to the one in the LegendGear mod. So it's basically a ProjectileItemEntity falling from the sky but overlayed with a spinning, color changing star-shaped texture.

I already implemented the entity and it works fine, but I struggle with the renderer. I looked at the SpriteRenderer to get some information on how to use MatrixStacks and so on and this is what I currently have:

	@Override
	public void render(ShootingStarEntity entity, float f1, float f2, MatrixStack stack, IRenderTypeBuffer buffer, int i1) {
		super.render(entity, f1, f2, stack, buffer, i1);
		IVertexBuilder builder = buffer.getBuffer(RenderType.getCutout());
		if(!entity.collidedVertically) {
		}else {
			stack.push();
			stack.rotate(this.renderManager.getCameraOrientation());
			stack.rotate(Vector3f.YP.rotationDegrees(180.0F));
	    		this.itemRenderer.renderItem(entity.getItem(), ItemCameraTransforms.TransformType.GROUND, i1, 0, stack, buffer);
	    		stack.pop();
		}
	}

(The renderItem call has currently no further use)
And this code is, as far as I got it basically used to make the ProjectileItemEntity (e.g. snowball) appear and look at the player.

My texture for the overlay is just a white, star-shaped texture with some transperancy.

I hope someone can give me a hint on how to overlay a texture and how to rotate and color it. I found many methods in many classes, but I don't know which to use here.

 

Thank you in advance and stay healthy :) 

Link to comment
Share on other sites

1 hour ago, Peerius said:

So it's basically a ProjectileItemEntity falling from the sky but overlayed with a spinning, color changing star-shaped texture.

If this is a texture for an item (as it seems to be), you could easily animate it using an mcmeta and change the colors within the texture itself or using ColorHandlerEvent$Item. If that's the case, then you would just need to register the factory with the SpriteRenderer instead of recreating it. If you wish to stay on your line of thinking, you will most likely have to reconstruct the ItemRenderer methods with some additional parameters in the correct RenderType.

Link to comment
Share on other sites

On 10/25/2020 at 5:07 PM, ChampionAsh5357 said:

If this is a texture for an item (as it seems to be)

Not exactly. The texture for the item shall be handled as always and then I want to add a layer with another texture with the things mentioned above. 

But I guess the things you told me should help, so I'm going to try it. Thank you for now - I write again, if I have more problems :D

Link to comment
Share on other sites

4 hours ago, Peerius said:

Not exactly. The texture for the item shall be handled as always and then I want to add a layer with another texture with the things mentioned above. 

But I guess the things you told me should help, so I'm going to try it. Thank you for now - I write again, if I have more problems :D

To clarify what I mean:

 

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.