Jump to content

Recommended Posts

Posted

Hello :) 

So, I wanted to make a shooting star similar to the one from the LegendGear Mod by NMcCoy.

If someone doesn't know, how those look like, you can see it for example in this video: https://youtu.be/PSIjNFwPDfk?t=565 at 9:25.

 

Now, I created a new ProjectileItemEntity, which works perfectly fine and renders as normal. I got only two issues left:

The first one is, that my entity doesn't have a beam and this star looking spinning thing around my entity yet. I came across TileEntities, but those are only for blocks if I got that right. So, I thought of implementing it with extending the SpriteRenderer, overriding the render(...) method, calling super.render(...); and adding this there. But since those classes and methods for rendering don't seem like they are self-explanatory, I don't know how to do it. For now, I only have a white texture for the beam and the star, which I would like to switch colors.

 

And my second one is naturally spawning my entity. I came across EntitySpawnPlacementRegistry.register(...) but I don't know how to create an EntitySpawnPlacementRegistry.IPlacementPredicate and it looked like in vanilla this code is only used for MobEntities. Obviously, I also want to make my entity spawn in the air, maybe like 30 blocks above ground level.

 

I am grateful for any help. Thank you in advance. xD

 

 

 

Posted (edited)

For now, I have this:

public class ShootingStarRenderer extends SpriteRenderer<ShootingStarEntity> {

	protected ShootingStarRenderer(EntityRendererManager renderManager, ItemRenderer itemRenderer) {
		super(renderManager, itemRenderer);
	}

	@Override
	public ResourceLocation getEntityTexture(ShootingStarEntity entity) {
		return DeepAffection.RegistryEvents.location("textures/entity/star.png");
	}
	
	private void add(IVertexBuilder renderer, MatrixStack stack, float x, float y, float z, float u, float v) {
		renderer.pos(stack.getLast().getMatrix(), x, y, z)
		.color(1.0f, 1.0f, 1.0f, 1.0f)
		.tex(u, v)
		.normal(1, 0, 0)
		.endVertex();
	}
	
	@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.getEntityGlint());
		if(!entity.collided) {
		}else {
			stack.push();
			AtlasTexture star = new AtlasTexture(DeepAffection.RegistryEvents.location("textures/entity/star"));
			TextureAtlasSprite sprite = star.getSprite(DeepAffection.RegistryEvents.location("textures/entity/star"));
			stack.translate(0.5, 0.5, 0.5);
			add(builder, stack, 0.0f, 0.0f, 0.0f, sprite.getMinU(), sprite.getMinV());
			add(builder, stack, 1.0f, 0.0f, 0.0f, sprite.getMaxU(), sprite.getMinV());
			add(builder, stack, 0.0f, 1.0f, 0.0f, sprite.getMinU(), sprite.getMaxV());
			add(builder, stack, 1.0f, 1.0f, 0.0f, sprite.getMaxU(), sprite.getMaxV());
			stack.pop();
			}
	}

I just picked some floats for the add method, so that I could look how it looks like. But when summoning the entity, the game crashes after it collided because of a NullPointerException from the line where the add method get's called the first time. I would guess that sprite equals null, but I don't know how to fix that.

Edited by Peerius

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.