-
Recently Browsing
- No registered users viewing this page.
-
Posts
-
By diesieben07 · Posted
Uh, yes you do. https://mvnrepository.com/artifact/org.web3j/core -
By diesieben07 · Posted
You have to keep track that you are currently calling back into render and then have your event handler bail out early. Otherwise your event handler will fire on your render call, too and result in an infinite recursion. You can just use a private static boolean for this that you reset in a try-finally block. Note also that you should definitely not be creating new entity instances every time you render, this happens once every frame for every entity. -
You need to use Java 17 for 1.18
-
Hello, I am trying to replace every rendered mob's model (not the mob itself) with the model of a custom entity, under certain conditions. This is how it would work: @SubscribeEvent public static void replaceMobModel(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { if (condition A is reached) { // replace every rendered mob's model with the model of a custom entity } else { // every rendered mob's model reverts back to normal (e.g. villagers start looking like villagers again) } } I was looking at this forum (https://forums.minecraftforge.net/topic/75986-114-how-to-change-rendered-entity/) and found out that I need to use EntityRenderManager::renderEntity. But since that is from a previous version, I assume it would be EntityRenderDispatcher::render. Here's what I tried to do so far: @SubscribeEvent public static void replaceMobModel(RenderLivingEvent.Pre<LivingEntity, EntityModel<LivingEntity>> event) { LocalPlayer localPlayer = Minecraft.getInstance().player; if (localPlayer != null && event.getEntity() instanceof Mob mob) { // I'll set up the conditions later once I get this working event.setCanceled(true); CustomEntity customEntity = ModEntities.CUSTOM_ENTITY.get().create(localPlayer.clientLevel); if (customEntity != null) { customEntity.setXRot(mob.getXRot()); customEntity.setYRot(mob.getYRot()); Minecraft.getInstance().getEntityRenderDispatcher().render( customEntity, mob.getX(), mob.getY(), mob.getZ(), mob.getViewYRot(event.getPartialTick()), event.getPartialTick(), event.getPoseStack(), event.getMultiBufferSource(), event.getPackedLight() ); } } } This results in a stack overflow (EntityRenderDispatcher::render seems to cause RenderLivingEvent to fire, causing an infinite recursion). Is this even the right thing to do? Or do I have to go to my CustomEntity renderer class and override render()? If that's the case, I don't know what I should put in that method.
-
By 31293812saWw1 · Posted
Above is the output I got when I tried to run run.bat
-
-
Topics
-
Who's Online (See full list)
Recommended Posts