diff --git a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java index b1cc5b1a..c30fb455 100644 --- a/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java +++ b/src/main/java/me/cortex/voxy/client/core/model/ModelBakerySubsystem.java @@ -28,15 +28,30 @@ public class ModelBakerySubsystem { private final AtomicInteger blockIdCount = new AtomicInteger(); private final ConcurrentLinkedDeque blockIdQueue = new ConcurrentLinkedDeque<>();//TODO: replace with custom DS + private final Thread processingThread; + private volatile boolean isRunning = true; public ModelBakerySubsystem(Mapper mapper) { this.mapper = mapper; this.factory = new ModelFactory(mapper, this.storage); + this.processingThread = new Thread(()->{ + while (this.isRunning) { + this.factory.processAllThings(); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + }, "Model factory processor"); + this.processingThread.start(); } public void tick(long totalBudget) { - if (this.blockIdCount.get() != 0) { - //Always do 1 iteration minimum - Integer i = this.blockIdQueue.poll(); + long start = System.nanoTime(); + this.factory.tickAndProcessUploads(); + //Always do 1 iteration minimum + Integer i = this.blockIdQueue.poll(); + if (i != null) { int j = 0; if (i != null) { int fbBinding = glGetInteger(GL_FRAMEBUFFER_BINDING); @@ -44,7 +59,7 @@ public class ModelBakerySubsystem { do { this.factory.addEntry(i); j++; - if (24