From 8f1bd46081db70e5f920101306fae95419e63ba3 Mon Sep 17 00:00:00 2001 From: mcrcortex <{ID}+{username}@users.noreply.github.com> Date: Sat, 16 Mar 2024 15:25:31 +1000 Subject: [PATCH] Fixes for quotations, free translucent, fix boss bar --- .../me/cortex/voxy/client/core/VoxelCore.java | 14 +++++++++++--- .../core/rendering/Gl46FarWorldRenderer.java | 18 ++++++++---------- .../core/rendering/NvMeshFarWorldRenderer.java | 1 + .../client/terrain/WorldImportCommand.java | 5 ++++- src/main/resources/voxy.accesswidener | 2 ++ 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java index 3e4de223..021aa201 100644 --- a/src/main/java/me/cortex/voxy/client/core/VoxelCore.java +++ b/src/main/java/me/cortex/voxy/client/core/VoxelCore.java @@ -13,6 +13,8 @@ import me.cortex.voxy.client.saver.ContextSelectionSystem; import me.cortex.voxy.common.world.WorldEngine; import me.cortex.voxy.client.importers.WorldImporter; import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.hud.BossBarHud; +import net.minecraft.client.gui.hud.ClientBossBar; import net.minecraft.client.render.Camera; import net.minecraft.client.render.Frustum; import net.minecraft.client.util.math.MatrixStack; @@ -20,6 +22,7 @@ import net.minecraft.entity.boss.BossBar; import net.minecraft.entity.boss.ServerBossBar; import net.minecraft.registry.RegistryKeys; import net.minecraft.text.Text; +import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.chunk.WorldChunk; import org.joml.Matrix4f; @@ -239,15 +242,20 @@ public class VoxelCore { return false; } var importer = new WorldImporter(this.world, mcWorld); - var bossBar = new ServerBossBar(Text.of("Voxy world importer"), BossBar.Color.GREEN, BossBar.Style.PROGRESS); - bossBar.addPlayer(MinecraftClient.getInstance().getServer().getPlayerManager().getPlayer(MinecraftClient.getInstance().player.getUuid())); + var bossBar = new ClientBossBar(MathHelper.randomUuid(), Text.of("Voxy world importer"), 0.0f, BossBar.Color.GREEN, BossBar.Style.PROGRESS, false, false, false); + MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.put(bossBar.getUuid(), bossBar); importer.importWorldAsyncStart(worldPath, 4, (a,b)-> MinecraftClient.getInstance().executeSync(()-> { bossBar.setPercent(((float) a)/((float) b)); bossBar.setName(Text.of("Voxy import: "+ a+"/"+b + " region files")); }), ()-> { - MinecraftClient.getInstance().executeSync(bossBar::clearPlayers); + MinecraftClient.getInstance().executeSync(()-> { + MinecraftClient.getInstance().inGameHud.getBossBarHud().bossBars.remove(bossBar.getUuid()); + String msg = "Voxy world import finished"; + MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(Text.literal(msg)); + System.err.println(msg); + }); this.importer = null; }); this.importer = importer; diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java index 3507ae4b..931f69ff 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/Gl46FarWorldRenderer.java @@ -60,9 +60,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer } protected void bindResources(Gl46Viewport viewport) { - glBindBuffer(GL_DRAW_INDIRECT_BUFFER, this.glCommandBuffer.id); - glBindBuffer(GL_PARAMETER_BUFFER_ARB, this.glCommandCountBuffer.id); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, SharedIndexBuffer.INSTANCE.id()); glBindBufferBase(GL_UNIFORM_BUFFER, 0, this.uniformBuffer.id); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, this.geometry.geometryId()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, this.glCommandBuffer.id); @@ -72,6 +69,13 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 6, this.models.getBufferId()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 7, this.models.getColourBufferId()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 8, this.lightDataBuffer.id);//Lighting LUT + glBindBuffer(GL_DRAW_INDIRECT_BUFFER, this.glCommandBuffer.id); + glBindBuffer(GL_PARAMETER_BUFFER_ARB, this.glCommandCountBuffer.id); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, SharedIndexBuffer.INSTANCE.id()); + + //Bind the texture atlas + glBindSampler(0, this.models.getSamplerId()); + glBindTextureUnit(0, this.models.getTextureId()); } //FIXME: dont do something like this as it breaks multiviewport mods @@ -127,11 +131,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer UploadStream.INSTANCE.commit(); glBindVertexArray(AbstractFarWorldRenderer.STATIC_VAO); - - //Bind the texture atlas - glBindSampler(0, this.models.getSamplerId()); - glBindTextureUnit(0, this.models.getTextureId()); - glClearNamedBufferData(this.glCommandCountBuffer.id, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, new int[1]); this.commandGen.bind(); this.bindResources(viewport); @@ -143,7 +142,7 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer glDisable(GL_CULL_FACE); //glPointSize(10); //TODO: replace glMultiDrawElementsIndirectCountARB with glMultiDrawElementsIndirect on intel gpus, since it performs so much better - //glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, (int) (this.geometry.getSectionCount()*0.9), 0); + //glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, drawCnt, 0); glMultiDrawElementsIndirectCountARB(GL_TRIANGLES, GL_UNSIGNED_SHORT, 0, 0, (int) (this.geometry.getSectionCount()*4.4), 0); glEnable(GL_CULL_FACE); @@ -155,7 +154,6 @@ public class Gl46FarWorldRenderer extends AbstractFarWorldRenderer System.out.println(cnt); }); DownloadStream.INSTANCE.commit(); - DownloadStream.INSTANCE.tick(); */ diff --git a/src/main/java/me/cortex/voxy/client/core/rendering/NvMeshFarWorldRenderer.java b/src/main/java/me/cortex/voxy/client/core/rendering/NvMeshFarWorldRenderer.java index 29784183..24507d2d 100644 --- a/src/main/java/me/cortex/voxy/client/core/rendering/NvMeshFarWorldRenderer.java +++ b/src/main/java/me/cortex/voxy/client/core/rendering/NvMeshFarWorldRenderer.java @@ -184,6 +184,7 @@ public class NvMeshFarWorldRenderer extends AbstractFarWorldRenderer