Jump to content

[1.14.4] Rendering ProjectileItemEntity


Eisenpaulchen

Recommended Posts

I am trying to create a throwable object just like the snowball and was successfull with creating an item and the projectile entity as well as throwing it, referencing to the snowball. But I can not get my flying entity to be rendered.

The minecraft snowball seems to be rendered with a SpriteRenderer that seems to be made for things like the ProjectileItemEntity.

 

Here is my code to register the EntityType, renderer the render itself and the Entity class
As far as I can see I did everything like the snowball does except for the extra constructor in the renderer which is needed for registration.

In addition I figured out that no method of the renderer except for the constructor is ever called, but I can summon the entity and it flies and hits things but is just invisibile.

Has anyone an Idea what I am missing?

 

	public static final DeferredRegister<EntityType<?>> ENTITYTYPES = new DeferredRegister<>(ForgeRegistries.ENTITIES,
			MODID);
	
	public static final RegistryObject<EntityType<MelonShardEntity>> MELONSHARD_ENTITY = ENTITYTYPES
			.register("melonshardentity",
					() -> EntityType.Builder
							.<MelonShardEntity>create(MelonShardEntity::new, EntityClassification.MISC)
							.size(0.25f, 0.25f).build(new ResourceLocation(MODID + ":melonshardentity").toString()));

 

public void doClientSetup(final FMLClientSetupEvent event) {
		
		RenderingRegistry.registerEntityRenderingHandler(MelonShardEntity.class, MelonshardRenderer::new);
		
}

 

public class MelonShardEntity extends ProjectileItemEntity {

	public static final int DAMAGE = 1000;

	public MelonShardEntity(EntityType<? extends MelonShardEntity> p_i50159_1_, World p_i50159_2_) {
		super(p_i50159_1_, p_i50159_2_);
	}

	public MelonShardEntity(World worldIn, LivingEntity throwerIn) {
		super(learnMod.MELONSHARD_ENTITY.get(), throwerIn, worldIn);
	}

	public MelonShardEntity(World worldIn, double x, double y, double z) {
		super(learnMod.MELONSHARD_ENTITY.get(), x, y, z, worldIn);
	}

	@Override
	protected Item func_213885_i() {

		return learnMod.MELON_SHARD;
	}
	
	@Override
	protected void onImpact(RayTraceResult result) {

		if (result.getType() == RayTraceResult.Type.ENTITY) {

			Entity entity = ((EntityRayTraceResult) result).getEntity();

			entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float) DAMAGE);
		}

		if (!this.world.isRemote) {
			this.world.setEntityState(this, (byte) 3);
			this.remove();
		}
	}
}

 

@OnlyIn(Dist.CLIENT)
public class MelonshardRenderer extends SpriteRenderer<MelonShardEntity> {

	public MelonshardRenderer(EntityRendererManager p_i50957_1) {
		super(p_i50957_1,Minecraft.getInstance().getItemRenderer());
	}

	public MelonshardRenderer(EntityRendererManager p_i50957_1_, ItemRenderer p_i50957_2_) {
		super(p_i50957_1_,p_i50957_2_);

	}
}

 

Link to comment
Share on other sites

Wow ok 1 day of search. Thank you very much, but is this requirement new or relativly new? Was just asking because in every turorial I watched no one did that and it worked just fine.

Since the readthedocs documentation does not cover entitys as a whole thing I had to rely on those videos. 

Link to comment
Share on other sites

Hm ok this is pretty interesting since I watched what felt like  thousands of videos of the same thing to make sure not one of them just missed something and this was never mentioned or written. And one last thing I was not able to find a error logentry is there non (would be very helpful for others like me :) ) or did I just missed it?

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.