Posted June 13, 20214 yr I am trying to make a custom minecart whose model is just the same as vanilla minecart. Here is MyMinecartEntity class: public class MyMinecartEntity extends AbstractMinecartEntity { public MyMinecartEntity(EntityType<?> entityType, World world) { super(entityType, world); } public MyMinecartEntity(World world, double xin, double yin, double zin) { super(RegisterEntities.Entities.MY_MINECART.get(), world, xin, yin, zin); } @Override @Nonnull public IPacket<?> getAddEntityPacket() { return NetworkHooks.getEntitySpawningPacket(this); } @Nonnull public AbstractMinecartEntity.Type getMinecartType() { return Type.RIDEABLE; } } and the renderer is: @OnlyIn(Dist.CLIENT) public class MyMinecartRenderer<T extends MyMinecartEntity> extends MinecartRenderer<T> { private static final ResourceLocation MY_MINECART_LOCATION = new ResourceLocation(MYMOD.MOD_ID,"textures/entity/my_minecart.png"); public MyMinecartRenderer(EntityRendererManager manager) { super(manager); } @Override @Nonnull public ResourceLocation getTextureLocation(@Nonnull T entity) { return MY_MINECART_LOCATION; } } I intend to use vanilla MinecartModel class, so I did not create new model class. To register the entity and the renderer, I made a class like: public class RegisterEntities { public static class Entities { public static final RegistryObject<EntityType<?>> MY_MINECART; private static final DeferredRegister<EntityType<?>> ENTITIES; static { ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, MYMOD.MOD_ID); MY_MINECART = ENTITIES.register("my_minecart", () -> EntityType.Builder.of(MyMinecartEntity::new, EntityClassification.MISC) .sized(0.98F, 0.7F) .setTrackingRange(8) .build("my_minecart")); } public static void register(IEventBus eventBus) { ENTITIES.register(eventBus); } public static void registerRenderer() { RenderingRegistry.registerEntityRenderingHandler((EntityType<MyMinecartEntity>)MY_MINECART.get(), MyMinecartRenderer::new); } } } and called the registering procedures from my main mod as: public MYMOD() { IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); RegisterItems.Items.register(modEventBus); RegisterBlocks.Blocks.register(modEventBus); RegisterEntities.Entities.register(modEventBus); MinecraftForge.EVENT_BUS.addListener(EventPriority.HIGH, GenerateOres::generateOres); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientSetup); MinecraftForge.EVENT_BUS.register(this); } private void clientSetup(final FMLClientSetupEvent event) { RegisterEntities.Entities.registerRenderer(); } I tried to summon a MyMinecart entity by world.getChunk(i, j).addEntity(entity), and it seems that Minecraft tried to summon the cart (because something transparent prevented me from interacting with the rail below), but the cart was never rendered. How can I get the carts rendered? Thank you. Edited June 13, 20214 yr by Sabotember The problem has been solved
June 13, 20214 yr Author 3 hours ago, diesieben07 said: That is not how you spawn entities. You have to use World#addFreshEntity on the server. Also, do not use @OnlyIn. Now the problem has been solved. Thank you. I mistook (!world.isClientSide) in the vanilla MinecartItem class for (world.isClientSide).
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.