Fix vanishing minecarts

This commit is contained in:
Jozufozu 2021-12-12 22:30:46 -08:00
parent a3ee39099a
commit 56150b2645
2 changed files with 13 additions and 1 deletions

View file

@ -12,6 +12,7 @@ import com.jozufozu.flywheel.event.BeginFrameEvent;
import com.jozufozu.flywheel.event.RenderLayerEvent;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.block.entity.BlockEntity;
@ -100,4 +101,14 @@ public class InstanceWorld {
public void renderLayer(RenderLayerEvent event) {
engine.render(event, event.buffers.bufferSource());
}
/**
* Instantiate all the necessary instances to render the given world.
*/
public void loadEntities(ClientLevel world) {
// Block entities are loaded while chunks are baked.
// Entities are loaded with the world, so when chunks are reloaded they need to be re-added.
world.entitiesForRendering()
.forEach(entityInstanceManager::add);
}
}

View file

@ -93,7 +93,8 @@ public class InstancedRenderDispatcher {
}
public static void resetInstanceWorld(ClientLevel world) {
instanceWorlds.replace(world, InstanceWorld::delete);
instanceWorlds.replace(world, InstanceWorld::delete)
.loadEntities(world);
}
}