Eisenpaulchen Posted April 28, 2020 Share Posted April 28, 2020 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_); } } Quote Link to comment Share on other sites More sharing options...
Eisenpaulchen Posted April 28, 2020 Author Share Posted April 28, 2020 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. Quote Link to comment Share on other sites More sharing options...
Eisenpaulchen Posted April 28, 2020 Author Share Posted April 28, 2020 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? Quote Link to comment Share on other sites More sharing options...
Eisenpaulchen Posted April 28, 2020 Author Share Posted April 28, 2020 Ok thanks for the quick answeres helped a lot. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.