Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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_);

	}
}

 

  • Author

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. 

  • Author

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?

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.