]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Update to 1.17.1 (#124)
authorishland <ishlandmc@yeah.net>
Fri, 30 Jul 2021 02:12:43 +0000 (10:12 +0800)
committerGitHub <noreply@github.com>
Fri, 30 Jul 2021 02:12:43 +0000 (19:12 -0700)
* Setup for 1.15.2-Fabric

* Setup for 1.16.3 Fabric

* Initial port to 1.17.1

* Fix some crashes on client

* Reimplement some rendering functions

* todo

* Migrate apis

* It now render things but very cursed

* Rewrite cuboid renderer

* Finish cuboid renderer (still have some small issues)

* Replace filled faces with cuboid

* Rewrite line renderer

* Sphere rendering

* Some fixes

- Don't add borders when delegating rendering faces to cuboid rendering
- Fix weird settings screen background

* Fix shader color

happens when you get RGR instead of RGB

* Frustum culling

* Depth testing is mostly working

* Depth test is working

Co-authored-by: Irtimaled <irtimaled@gmail.com>
54 files changed:
build.gradle
gradle/wrapper/gradle-wrapper.properties
src/main/java/com/irtimaled/bbor/client/ClientProxy.java
src/main/java/com/irtimaled/bbor/client/ClientRenderer.java
src/main/java/com/irtimaled/bbor/client/RenderCulling.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/commands/Arguments.java
src/main/java/com/irtimaled/bbor/client/config/Configuration.java
src/main/java/com/irtimaled/bbor/client/gui/AbstractControl.java
src/main/java/com/irtimaled/bbor/client/gui/BoolSettingButton.java
src/main/java/com/irtimaled/bbor/client/gui/ControlList.java
src/main/java/com/irtimaled/bbor/client/gui/IntSettingSlider.java
src/main/java/com/irtimaled/bbor/client/gui/ListScreen.java
src/main/java/com/irtimaled/bbor/client/gui/LoadSavesScreen.java
src/main/java/com/irtimaled/bbor/client/gui/SelectableControlList.java
src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
src/main/java/com/irtimaled/bbor/client/gui/SettingsScreenButton.java
src/main/java/com/irtimaled/bbor/client/gui/WorldSaveRow.java
src/main/java/com/irtimaled/bbor/client/interop/ClientInterop.java
src/main/java/com/irtimaled/bbor/client/interop/NBTStructureLoader.java
src/main/java/com/irtimaled/bbor/client/interop/TileEntitiesHelper.java
src/main/java/com/irtimaled/bbor/client/providers/BeaconProvider.java
src/main/java/com/irtimaled/bbor/client/providers/BedrockCeilingProvider.java
src/main/java/com/irtimaled/bbor/client/renderers/AbstractRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/BeaconRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/BiomeBorderRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/ConduitRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/CuboidRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/FlowerForestRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/LineRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/MobSpawnerRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/OffsetBox.java
src/main/java/com/irtimaled/bbor/client/renderers/OffsetPoint.java
src/main/java/com/irtimaled/bbor/client/renderers/RenderHelper.java
src/main/java/com/irtimaled/bbor/client/renderers/Renderer.java
src/main/java/com/irtimaled/bbor/client/renderers/SlimeChunkRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/SpawnableBlocksRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/SpawningSphereRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/SphereRenderer.java
src/main/java/com/irtimaled/bbor/client/renderers/WorldSpawnRenderer.java
src/main/java/com/irtimaled/bbor/common/CommonProxy.java
src/main/java/com/irtimaled/bbor/common/StructureProcessor.java
src/main/java/com/irtimaled/bbor/common/interop/CommonInterop.java
src/main/java/com/irtimaled/bbor/mixin/access/IBeaconBlockEntity.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/access/IStructureStart.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManager.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManagerClientChunkMap.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/client/gui/screen/MixinOptionsScreen.java
src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinDebugHud.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinGameRenderer.java
src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinWorldRenderer.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/mixin/resource/MixinResourcePackManager.java
src/main/resources/bbor.accesswidener [new file with mode: 0644]
src/main/resources/fabric.mod.json
src/main/resources/mixins.bbor.json

index 05c2fea285dff075930ea8836c8e224c2c7fe511..eba553db66e82b7b23057de1d94e761a0d8a2e23 100644 (file)
@@ -35,10 +35,14 @@ tasks.withType(JavaCompile).configureEach {
 
 dependencies {
     minecraft 'com.mojang:minecraft:' + project.mcVersion
-    mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.1:v2'
+    mappings 'net.fabricmc:yarn:' + project.mcVersion + '+build.29'
     modImplementation 'net.fabricmc:fabric-loader:0.11.6'
 }
 
+loom {
+    accessWidener "src/main/resources/bbor.accesswidener"
+}
+
 minecraft {
     refmapName = 'mixins.bbor.refmap.json'
 }
index c4c1514bbdeea96077f96f5c2440dc49f89e4347..9927d0c97f5da6cdc25adda2d966e1049bcf4b53 100644 (file)
@@ -1,5 +1,5 @@
 #Tue May 26 09:16:06 PDT 2020
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStorePath=wrapper/dists
index 2716d124c1bbb6715c351c242d62634f34335120..8a5d4bf1dd7a63d1b7499a2420640a39c7e0500b 100644 (file)
@@ -1,7 +1,11 @@
 package com.irtimaled.bbor.client;
 
 import com.irtimaled.bbor.client.config.ConfigManager;
-import com.irtimaled.bbor.client.events.*;
+import com.irtimaled.bbor.client.events.AddBoundingBoxReceived;
+import com.irtimaled.bbor.client.events.DisconnectedFromRemoteServer;
+import com.irtimaled.bbor.client.events.InitializeClientReceived;
+import com.irtimaled.bbor.client.events.SaveLoaded;
+import com.irtimaled.bbor.client.events.UpdateWorldSpawnReceived;
 import com.irtimaled.bbor.client.gui.LoadSavesScreen;
 import com.irtimaled.bbor.client.gui.SettingsScreen;
 import com.irtimaled.bbor.client.interop.FlowerForestHelper;
index 7cf1418775fcfe294712da71612306eb5d87ab06..c8121788c800ea29c7246a4b9f43c6d86bca9bdc 100644 (file)
@@ -1,16 +1,62 @@
 package com.irtimaled.bbor.client;
 
 import com.irtimaled.bbor.client.interop.ClientInterop;
-import com.irtimaled.bbor.client.models.*;
-import com.irtimaled.bbor.client.providers.*;
-import com.irtimaled.bbor.client.renderers.*;
+import com.irtimaled.bbor.client.models.BoundingBoxBeacon;
+import com.irtimaled.bbor.client.models.BoundingBoxBedrockCeiling;
+import com.irtimaled.bbor.client.models.BoundingBoxBiomeBorder;
+import com.irtimaled.bbor.client.models.BoundingBoxConduit;
+import com.irtimaled.bbor.client.models.BoundingBoxFlowerForest;
+import com.irtimaled.bbor.client.models.BoundingBoxLine;
+import com.irtimaled.bbor.client.models.BoundingBoxMobSpawner;
+import com.irtimaled.bbor.client.models.BoundingBoxSlimeChunk;
+import com.irtimaled.bbor.client.models.BoundingBoxSpawnableBlocks;
+import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
+import com.irtimaled.bbor.client.models.BoundingBoxSphere;
+import com.irtimaled.bbor.client.models.BoundingBoxWorldSpawn;
+import com.irtimaled.bbor.client.models.Point;
+import com.irtimaled.bbor.client.providers.BeaconProvider;
+import com.irtimaled.bbor.client.providers.BedrockCeilingProvider;
+import com.irtimaled.bbor.client.providers.BiomeBorderProvider;
+import com.irtimaled.bbor.client.providers.ConduitProvider;
+import com.irtimaled.bbor.client.providers.CustomBeaconProvider;
+import com.irtimaled.bbor.client.providers.CustomBoxProvider;
+import com.irtimaled.bbor.client.providers.CustomLineProvider;
+import com.irtimaled.bbor.client.providers.CustomSphereProvider;
+import com.irtimaled.bbor.client.providers.FlowerForestProvider;
+import com.irtimaled.bbor.client.providers.IBoundingBoxProvider;
+import com.irtimaled.bbor.client.providers.ICachingProvider;
+import com.irtimaled.bbor.client.providers.MobSpawnerProvider;
+import com.irtimaled.bbor.client.providers.SlimeChunkProvider;
+import com.irtimaled.bbor.client.providers.SpawnableBlocksProvider;
+import com.irtimaled.bbor.client.providers.SpawningSphereProvider;
+import com.irtimaled.bbor.client.providers.WorldSpawnProvider;
+import com.irtimaled.bbor.client.renderers.AbstractRenderer;
+import com.irtimaled.bbor.client.renderers.BeaconRenderer;
+import com.irtimaled.bbor.client.renderers.BiomeBorderRenderer;
+import com.irtimaled.bbor.client.renderers.ConduitRenderer;
+import com.irtimaled.bbor.client.renderers.CuboidRenderer;
+import com.irtimaled.bbor.client.renderers.FlowerForestRenderer;
+import com.irtimaled.bbor.client.renderers.LineRenderer;
+import com.irtimaled.bbor.client.renderers.MobSpawnerRenderer;
+import com.irtimaled.bbor.client.renderers.RenderHelper;
+import com.irtimaled.bbor.client.renderers.RenderQueue;
+import com.irtimaled.bbor.client.renderers.SlimeChunkRenderer;
+import com.irtimaled.bbor.client.renderers.SpawnableBlocksRenderer;
+import com.irtimaled.bbor.client.renderers.SpawningSphereRenderer;
+import com.irtimaled.bbor.client.renderers.SphereRenderer;
+import com.irtimaled.bbor.client.renderers.WorldSpawnRenderer;
 import com.irtimaled.bbor.common.MathHelper;
 import com.irtimaled.bbor.common.TypeHelper;
 import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
 import com.irtimaled.bbor.common.models.DimensionId;
+import net.minecraft.client.util.math.MatrixStack;
 
-import java.util.*;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 import java.util.stream.Stream;
 
 public class ClientRenderer {
@@ -84,17 +130,19 @@ public class ClientRenderer {
         return boundingBox.intersectsBounds(minX, minZ, maxX, maxZ);
     }
 
-    public static void render(DimensionId dimensionId) {
+    public static void render(MatrixStack matrixStack, DimensionId dimensionId) {
         if (!active) return;
 
+        matrixStack.push();
         RenderHelper.beforeRender();
 
         getBoundingBoxes(dimensionId).forEach(key -> {
             AbstractRenderer renderer = boundingBoxRendererMap.get(key.getClass());
-            if (renderer != null) renderer.render(key);
+            if (renderer != null) renderer.render(matrixStack, key);
         });
 
         RenderHelper.afterRender();
+        matrixStack.pop();
     }
 
     public static void renderDeferred() {
@@ -131,4 +179,6 @@ public class ClientRenderer {
             TypeHelper.doIfType(provider, ICachingProvider.class, ICachingProvider::clearCache);
         }
     }
+
+
 }
diff --git a/src/main/java/com/irtimaled/bbor/client/RenderCulling.java b/src/main/java/com/irtimaled/bbor/client/RenderCulling.java
new file mode 100644 (file)
index 0000000..c76a923
--- /dev/null
@@ -0,0 +1,64 @@
+package com.irtimaled.bbor.client;
+
+import net.minecraft.client.render.Frustum;
+import net.minecraft.util.math.Box;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class RenderCulling {
+
+    private static volatile Frustum frustum = null;
+    private static final Object mutex = new Object();
+    private static final AtomicInteger culledCount = new AtomicInteger();
+    private static final AtomicInteger totalCount = new AtomicInteger();
+    private static final AtomicInteger culledCountLast = new AtomicInteger();
+    private static final AtomicInteger totalCountLast = new AtomicInteger();
+
+    public static void setFrustum(Frustum frustum) {
+        RenderCulling.frustum = frustum;
+    }
+
+    public static void flushStats() {
+        synchronized (mutex) {
+            culledCountLast.set(culledCount.get());
+            totalCountLast.set(totalCount.get());
+            culledCount.set(0);
+            totalCount.set(0);
+        }
+    }
+
+    public static String debugString() {
+        final int culledCountLast;
+        final int totalCountLast;
+        synchronized (mutex) {
+            culledCountLast = RenderCulling.culledCountLast.get();
+            totalCountLast = RenderCulling.totalCountLast.get();
+        }
+        if (totalCountLast != 0) {
+            return String.format("[BBOR] Rendering culling: %d / %d (%.1f%%)", culledCountLast, totalCountLast, (culledCountLast / (float) totalCountLast) * 100.0);
+        } else {
+            return "[BBOR] Rendering not enabled";
+        }
+    }
+
+    private static boolean cullFrustum(Box box) {
+        final Frustum frustum = RenderCulling.frustum;
+        if (frustum != null) {
+            return frustum.isVisible(box);
+        } else {
+            return true;
+        }
+    }
+
+    public static boolean cullRayTrace(Box box) {
+        return true;
+    }
+
+    public static boolean isVisibleCulling(Box box) {
+        final boolean cullResult = cullFrustum(box);
+        totalCount.incrementAndGet();
+        if (!cullResult) culledCount.incrementAndGet();
+        return cullResult;
+    }
+
+}
index 737b2edaee531ee28920570b649350b2a7bc36ca..6d3524e93b624dcebe63028daf1ca54fda433abf 100644 (file)
@@ -3,7 +3,11 @@ package com.irtimaled.bbor.client.commands;
 import com.irtimaled.bbor.client.config.HexColor;
 import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.models.Coords;
-import com.mojang.brigadier.arguments.*;
+import com.mojang.brigadier.arguments.ArgumentType;
+import com.mojang.brigadier.arguments.BoolArgumentType;
+import com.mojang.brigadier.arguments.DoubleArgumentType;
+import com.mojang.brigadier.arguments.IntegerArgumentType;
+import com.mojang.brigadier.arguments.StringArgumentType;
 import com.mojang.brigadier.context.CommandContext;
 import com.mojang.brigadier.exceptions.CommandSyntaxException;
 import net.minecraft.command.argument.BlockPosArgumentType;
index af4e09cf5583bd6aa750b71d7c8c339f6dc8922c..4dd36692769aa894f1bab963466a003a8e61015f 100644 (file)
@@ -2,7 +2,12 @@ package com.irtimaled.bbor.client.config;
 
 import com.google.common.io.Files;
 
-import java.io.*;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.List;
index df1a538b5349a0903985a162f9090efda7874e25..3dc6996e22c1ceebcded088fff62dac8e7c59353 100644 (file)
@@ -1,7 +1,6 @@
 package com.irtimaled.bbor.client.gui;
 
 import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
 import net.minecraft.client.gui.widget.ClickableWidget;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.text.LiteralText;
@@ -66,8 +65,4 @@ abstract class AbstractControl extends ClickableWidget implements IControl {
     public void clearFocus() {
         this.setFocused(false);
     }
-
-    @Override
-    public void appendNarrations(NarrationMessageBuilder builder) {
-    }
 }
index e4f7bb69ca7fac81cc72e6cddaf5947139a486e4..20542247b53729a0e5c8293899dccf289ab41b3b 100644 (file)
@@ -2,6 +2,7 @@ package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.config.Setting;
+import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
 
 public class BoolSettingButton extends BoolButton {
     private final Setting<Boolean> setting;
@@ -20,4 +21,10 @@ public class BoolSettingButton extends BoolButton {
     protected boolean getValue() {
         return this.setting.get();
     }
+
+    @Override
+    public void appendNarrations(NarrationMessageBuilder narrationMessageBuilder) {
+        // TODO
+        this.appendDefaultNarrations(narrationMessageBuilder);
+    }
 }
index b031531d1c7ec1bd7ff4932fae920796da4b4a84..f27e394c750d2732466008cdb91b10bc141aeb52 100644 (file)
@@ -3,7 +3,15 @@ package com.irtimaled.bbor.client.gui;
 import com.irtimaled.bbor.client.renderers.RenderHelper;
 import com.irtimaled.bbor.client.renderers.Renderer;
 import com.irtimaled.bbor.common.MathHelper;
+import com.mojang.blaze3d.platform.GlStateManager;
+import com.mojang.blaze3d.systems.RenderSystem;
+import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.GameRenderer;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
+import net.minecraft.client.render.VertexFormats;
 import net.minecraft.client.util.math.MatrixStack;
 
 import java.util.ArrayList;
@@ -153,10 +161,6 @@ public class ControlList extends DrawableHelper implements IControlSet {
     public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
         this.amountScrolled = MathHelper.clamp(this.amountScrolled, 0.0D, this.getMaxScroll());
 
-        RenderHelper.disableLighting();
-        // RenderHelper.disableFog();
-        if (!transparentBackground) drawListBackground();
-
         int listTop = this.top + PADDING - (int) this.amountScrolled;
 
         drawEntries(matrixStack, mouseX, mouseY, listTop);
@@ -170,8 +174,7 @@ public class ControlList extends DrawableHelper implements IControlSet {
         RenderHelper.disableDepthTest();
         RenderHelper.enableBlend();
         RenderHelper.blendFuncGui();
-        RenderHelper.disableAlphaTest();
-        RenderHelper.shadeModelSmooth();
+        // RenderHelper.shadeModelSmooth();
         RenderHelper.disableTexture();
         drawOverlayShadows();
 
@@ -181,14 +184,14 @@ public class ControlList extends DrawableHelper implements IControlSet {
         }
 
         RenderHelper.enableTexture();
-        RenderHelper.shadeModelFlat();
-        RenderHelper.enableAlphaTest();
+        // RenderHelper.shadeModelFlat();
         RenderHelper.disableBlend();
     }
 
-    private void drawListBackground() {
-        RenderHelper.setTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
+    private void drawListBackground(MatrixStack matrixStack) {
+        MinecraftClient.getInstance().getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
         Renderer.startTextured()
+                .setMatrixStack(matrixStack)
                 .setColor(32, 32, 32)
                 .setAlpha(255)
                 .addPoint(0, this.bottom, 0.0D, (float) 0 / 32.0F, (float) (this.bottom + (int) this.amountScrolled) / 32.0F)
@@ -219,15 +222,33 @@ public class ControlList extends DrawableHelper implements IControlSet {
     }
 
     private void overlayBackground(int top, int bottom) {
-        RenderHelper.setTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
-        Renderer.startTextured()
-                .setColor(64, 64, 64)
-                .setAlpha(255)
-                .addPoint(0, bottom, -100.0D, 0.0D, (float) bottom / 32.0F)
-                .addPoint(this.width, bottom, -100.0D, (float) this.width / 32.0F, (float) bottom / 32.0F)
-                .addPoint(this.width, top, -100.0D, (float) this.width / 32.0F, (float) top / 32.0F)
-                .addPoint(0, top, -100.0D, 0.0D, (float) top / 32.0F)
-                .render();
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder bufferBuilder = tessellator.getBuffer();
+        RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
+        RenderSystem.setShaderTexture(0, DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
+
+        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
+        bufferBuilder
+                .vertex(0, bottom, -100.0D)
+                .texture(0.0F, (float) bottom / 32.0F)
+                .color(64, 64, 64, 255)
+                .next();
+        bufferBuilder
+                .vertex(this.width, bottom, -100.0D)
+                .texture((float) this.width / 32.0F, (float) bottom / 32.0F)
+                .color(64, 64, 64, 255)
+                .next();
+        bufferBuilder
+                .vertex(this.width, top, -100.0D)
+                .texture((float) this.width / 32.0F, (float) top / 32.0F)
+                .color(64, 64, 64, 255)
+                .next();
+        bufferBuilder
+                .vertex(0, top, -100.0D)
+                .texture(0.0f, (float) top / 32.0F)
+                .color(64, 64, 64, 255)
+                .next();
+        tessellator.draw();
     }
 
     private void drawScrollBar(int maxScroll) {
@@ -237,48 +258,56 @@ public class ControlList extends DrawableHelper implements IControlSet {
             scrollBarTop = this.top;
         }
 
-        Renderer.startTextured()
-                .setAlpha(255)
-                .addPoint(this.scrollBarLeft, this.bottom, 0.0D, 0.0D, 1.0D)
-                .addPoint(this.width, this.bottom, 0.0D, 1.0D, 1.0D)
-                .addPoint(this.width, this.top, 0.0D, 1.0D, 0.0D)
-                .addPoint(this.scrollBarLeft, this.top, 0.0D, 0.0D, 0.0D)
-                .render();
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder bufferBuilder = tessellator.getBuffer();
+        RenderSystem.disableTexture();
+        RenderSystem.setShader(GameRenderer::getPositionColorShader);
 
-        Renderer.startTextured()
-                .setColor(128, 128, 128)
-                .setAlpha(255)
-                .addPoint(this.scrollBarLeft, scrollBarTop + scrollBarHeight, 0.0D, 0.0D, 1.0D)
-                .addPoint(this.width, scrollBarTop + scrollBarHeight, 0.0D, 1.0D, 1.0D)
-                .addPoint(this.width, scrollBarTop, 0.0D, 1.0D, 0.0D)
-                .addPoint(this.scrollBarLeft, scrollBarTop, 0.0D, 0.0D, 0.0D)
-                .render();
+        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
 
-        Renderer.startTextured()
-                .setColor(192, 192, 192)
-                .setAlpha(255)
-                .addPoint(this.scrollBarLeft, scrollBarTop + scrollBarHeight - 1, 0.0D, 0.0D, 1.0D)
-                .addPoint(this.width - 1, scrollBarTop + scrollBarHeight - 1, 0.0D, 1.0D, 1.0D)
-                .addPoint(this.width - 1, scrollBarTop, 0.0D, 1.0D, 0.0D)
-                .addPoint(this.scrollBarLeft, scrollBarTop, 0.0D, 0.0D, 0.0D)
-                .render();
+        bufferBuilder.vertex(this.scrollBarLeft, this.bottom, 0.0D).color(0, 0, 0, 255).next();
+        bufferBuilder.vertex(this.width, this.bottom, 0.0D).color(0, 0, 0, 255).next();
+        bufferBuilder.vertex(this.width, this.top, 0.0D).color(0, 0, 0, 255).next();
+        bufferBuilder.vertex(this.scrollBarLeft, this.top, 0.0D).color(0, 0, 0, 255).next();
+
+        bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight, 0.0D).color(128, 128, 128, 255).next();
+        bufferBuilder.vertex(this.width, scrollBarTop + scrollBarHeight, 0.0D).color(128, 128, 128, 255).next();
+        bufferBuilder.vertex(this.width, scrollBarTop, 0.0D).color(128, 128, 128, 255).next();
+        bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0D).color(128, 128, 128, 255).next();
+
+        bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop + scrollBarHeight - 1, 0.0D).color(192, 192, 192, 255).next();
+        bufferBuilder.vertex(this.width - 1, scrollBarTop + scrollBarHeight - 1, 0.0D).color(192, 192, 192, 255).next();
+        bufferBuilder.vertex(this.width - 1, scrollBarTop, 0.0D).color(192, 192, 192, 255).next();
+        bufferBuilder.vertex(this.scrollBarLeft, scrollBarTop, 0.0D).color(192, 192, 192, 255).next();
+
+        tessellator.draw();
+        RenderSystem.enableTexture();
     }
 
     private void drawOverlayShadows() {
-        Renderer.startTextured()
-                .addPoint(0, this.top + 4, 0.0D, 0.0D, 1.0D)
-                .addPoint(this.width, this.top + 4, 0.0D, 1.0D, 1.0D)
-                .setAlpha(255)
-                .addPoint(this.width, this.top, 0.0D, 1.0D, 0.0D)
-                .addPoint(0, this.top, 0.0D, 0.0D, 0.0D)
-                .render();
-        Renderer.startTextured()
-                .addPoint(this.width, this.bottom - 4, 0.0D, 1.0D, 0.0D)
-                .addPoint(0, this.bottom - 4, 0.0D, 0.0D, 0.0D)
-                .setAlpha(255)
-                .addPoint(0, this.bottom, 0.0D, 0.0D, 1.0D)
-                .addPoint(this.width, this.bottom, 0.0D, 1.0D, 1.0D)
-                .render();
+        RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
+        RenderSystem.enableBlend();
+        RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ZERO, GlStateManager.DstFactor.ONE);
+        RenderSystem.disableTexture();
+        RenderSystem.setShader(GameRenderer::getPositionColorShader);
+        Tessellator tessellator = Tessellator.getInstance();
+        BufferBuilder bufferBuilder = tessellator.getBuffer();
+
+        bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
+
+        bufferBuilder.vertex(0, this.top + 4, 0.0D).color(0, 0, 0, 0).next();
+        bufferBuilder.vertex(this.width, this.top + 4, 0.0D).color(0, 0, 0, 0).next();
+        bufferBuilder.vertex(this.width, this.top, 0.0D).color(0, 0, 0, 255).next();
+        bufferBuilder.vertex(0, this.top, 0.0D).color(0, 0, 0, 255).next();
+
+        bufferBuilder.vertex(this.width, this.bottom - 4, 0.0D).color(0, 0, 0, 0).next();
+        bufferBuilder.vertex(0, this.bottom - 4, 0.0D).color(0, 0, 0, 0).next();
+        bufferBuilder.vertex(0, this.bottom, 0.0D).color(0, 0, 0, 255).next();
+        bufferBuilder.vertex(this.width, this.bottom, 0.0D).color(0, 0, 0, 255).next();
+
+        tessellator.draw();
+        RenderSystem.enableTexture();
+        RenderSystem.disableBlend();
     }
 
     ControlList section(String title, CreateControl... createControls) {
index a5f73b5f43ea2c72693e383bd71cecf9595f9084..a681e6d2e8cf1ac5bd9315751b2b77fdf4da6919 100644 (file)
@@ -1,6 +1,7 @@
 package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.client.config.Setting;
+import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
 import net.minecraft.client.resource.language.I18n;
 import net.minecraft.text.LiteralText;
 
@@ -49,4 +50,9 @@ class IntSettingSlider extends AbstractSlider {
         this.setting.set(this.getSettingValue());
         updateText();
     }
+
+    @Override
+    public void appendNarrations(NarrationMessageBuilder narrationMessageBuilder) {
+        this.appendDefaultNarrations(narrationMessageBuilder);
+    }
 }
index d97b546182b179b2e5bef69da6983292f38b17ed..e455896dbbd9ef9acd7483063b57739fb14455f4 100644 (file)
@@ -2,11 +2,13 @@ package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.Versions;
 import com.irtimaled.bbor.client.interop.ClientInterop;
+import com.mojang.blaze3d.systems.RenderSystem;
 import net.minecraft.client.gui.Element;
 import net.minecraft.client.gui.screen.Screen;
-import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.gui.widget.ButtonWidget;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.text.LiteralText;
+import net.minecraft.text.TranslatableText;
 
 import java.util.List;
 
@@ -14,7 +16,7 @@ public abstract class ListScreen extends Screen {
     private final Screen lastScreen;
     private static final String version = Versions.build;
 
-    private AbstractButton doneButton;
+    private ButtonWidget doneButton;
     private ControlList controlList;
     private SearchField searchField;
 
@@ -35,15 +37,10 @@ public abstract class ListScreen extends Screen {
     protected void init() {
         this.controlList = this.buildList(48, this.height - 28);
         this.searchField = new SearchField(this.textRenderer, this.width / 2 - 100, 22, 200, 20, this.controlList);
-        this.doneButton = new AbstractButton(this.width / 2 - 100, this.height - 24, 200, I18n.translate("gui.done")) {
-            @Override
-            public void onPressed() {
-                onDoneClicked();
-            }
-        };
+        this.doneButton = new ButtonWidget(this.width / 2 - 100, this.height - 24, 200, 20, new TranslatableText("gui.done"), buttonWidget -> onDoneClicked());
 
         this.addDrawableChild(this.searchField);
-        ((List<Element>)this.children()).add(controlList);
+        ((List<Element>) this.children()).add(this.controlList);
         this.addDrawableChild(this.doneButton);
     }
 
@@ -55,11 +52,13 @@ public abstract class ListScreen extends Screen {
     }
 
     protected void render(MatrixStack matrixStack, int mouseX, int mouseY) {
+        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+        this.renderBackground(matrixStack);
         this.controlList.render(matrixStack, mouseX, mouseY);
 
         this.drawCenteredText(matrixStack, this.textRenderer, this.title.asString(), this.width / 2, 8, 16777215);
         this.searchField.render(matrixStack, mouseX, mouseY);
-        this.doneButton.render(matrixStack, mouseX, mouseY);
+        this.doneButton.render(matrixStack, mouseX, mouseY, 0f);
 
         int left = this.width - this.textRenderer.getWidth(version) - 2;
         int top = this.height - 10;
index 7198838a7fac703e38bfd06a52430e351c3e3bff..ed3b5d17ed37c1f2cfd3036dca17c905cc170423 100644 (file)
@@ -1,6 +1,8 @@
 package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.client.interop.ClientInterop;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.gui.screen.Screen;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.world.level.storage.LevelStorage;
 import net.minecraft.world.level.storage.LevelStorageException;
@@ -12,7 +14,11 @@ public class LoadSavesScreen extends ListScreen {
     private SelectableControlList controlList;
 
     public static void show() {
-        ClientInterop.displayScreen(new LoadSavesScreen());
+        ClientInterop.displayScreen(new LoadSavesScreen(MinecraftClient.getInstance().currentScreen));
+    }
+
+    public LoadSavesScreen(Screen lastScreen) {
+        super(lastScreen);
     }
 
     @Override
index ad3fc827e48af195c24f654927b2efdeab029da2..1c1e7032ee9ebf5452ad87b629da62d8d05005ed 100644 (file)
@@ -83,9 +83,9 @@ public class SelectableControlList extends ControlList {
     protected void drawEntry(MatrixStack matrixStack, int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
         if (this.selectedElement == entry.index) {
             RenderHelper.disableTexture();
-            RenderHelper.resetShader();
             int color = this.isFocused ? 255 : 128;
             Renderer.startQuads()
+                    .setMatrixStack(matrixStack)
                     .setAlpha(255)
                     .setColor(color, color, color)
                     .addPoint((double) this.listLeft - 2, (double) (top + height) - 2, 0.0D)
index 27b7dafe90b8558fa58c24e138b435a66ee46cc6..49e5e6828b228e00d9c2db2298113929bc1d851a 100644 (file)
@@ -6,6 +6,7 @@ import com.irtimaled.bbor.client.interop.ClientInterop;
 import com.irtimaled.bbor.common.BoundingBoxType;
 import net.minecraft.SharedConstants;
 import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
 import net.minecraft.client.resource.language.I18n;
 
 public class SettingsScreen extends ListScreen {
@@ -36,6 +37,11 @@ public class SettingsScreen extends ListScreen {
         controlList
                 .section(null,
                         width -> new BoolButton(width, I18n.translate("bbor.options.active"), this.client.world != null) {
+                            @Override
+                            public void appendNarrations(NarrationMessageBuilder narrationMessageBuilder) {
+                                this.appendDefaultNarrations(narrationMessageBuilder);
+                            }
+
                             @Override
                             public void onPressed() {
                                 ClientRenderer.toggleActive();
index 9587ab8a8271db968c7f8f8c1290cb00629602ef..864eddeeabd2de44894719245378f81aa068a482 100644 (file)
@@ -2,6 +2,7 @@ package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.client.interop.ClientInterop;
 import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.narration.NarrationMessageBuilder;
 
 public class SettingsScreenButton extends AbstractButton {
     private final SettingsScreen screen;
@@ -15,4 +16,10 @@ public class SettingsScreenButton extends AbstractButton {
     public void onPressed() {
         ClientInterop.displayScreen(screen);
     }
+
+    @Override
+    public void appendNarrations(NarrationMessageBuilder narrationMessageBuilder) {
+        // TODO
+        this.appendDefaultNarrations(narrationMessageBuilder);
+    }
 }
index 9db539c0c1c3d3f3ccd8e2f5e24e514e21796c37..3c8aca227e191840dd12cfa5ab7f0bb5c851e2c1 100644 (file)
@@ -121,7 +121,7 @@ public class WorldSaveRow extends ControlListEntry implements Comparable<WorldSa
         int y = this.getY();
         this.client.textRenderer.draw(matrixStack, displayName, (float) (x + ICON_SIZE + 3), (float) (y + 1), 16777215);
         this.client.textRenderer.draw(matrixStack, details, (float) (x + ICON_SIZE + 3), (float) (y + 1 + this.client.textRenderer.fontHeight + 1), 8421504);
-        RenderHelper.setTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
+        this.client.getTextureManager().bindTexture(this.icon != null ? this.iconLocation : ICON_MISSING);
         RenderHelper.enableBlend();
         DrawableHelper.drawTexture(matrixStack, x, y, 0.0F, 0.0F, ICON_SIZE, ICON_SIZE, 32, 32);
         RenderHelper.disableBlend();
index 7588003b0fd48acdc8233dbc0070d35b04538c0a..bbc29ce6abc7926698572caac051b62ba1e7e31b 100644 (file)
@@ -1,8 +1,11 @@
 package com.irtimaled.bbor.client.interop;
 
 import com.irtimaled.bbor.client.ClientRenderer;
-import com.irtimaled.bbor.client.Player;
-import com.irtimaled.bbor.client.commands.*;
+import com.irtimaled.bbor.client.commands.ConfigCommand;
+import com.irtimaled.bbor.client.commands.CustomCommand;
+import com.irtimaled.bbor.client.commands.SeedCommand;
+import com.irtimaled.bbor.client.commands.SpawningSphereCommand;
+import com.irtimaled.bbor.client.commands.StructuresCommand;
 import com.irtimaled.bbor.client.events.DisconnectedFromRemoteServer;
 import com.irtimaled.bbor.client.events.SaveLoaded;
 import com.irtimaled.bbor.client.events.UpdateWorldSpawnReceived;
@@ -16,9 +19,15 @@ import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.screen.Screen;
 import net.minecraft.client.network.ClientPlayNetworkHandler;
 import net.minecraft.client.network.ClientPlayerEntity;
+import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.command.CommandSource;
 import net.minecraft.server.command.ServerCommandSource;
-import net.minecraft.text.*;
+import net.minecraft.text.ClickEvent;
+import net.minecraft.text.LiteralText;
+import net.minecraft.text.MutableText;
+import net.minecraft.text.Text;
+import net.minecraft.text.Texts;
+import net.minecraft.text.TranslatableText;
 import net.minecraft.util.Formatting;
 import net.minecraft.util.math.BlockPos;
 
@@ -28,9 +37,8 @@ public class ClientInterop {
         EventBus.publish(new DisconnectedFromRemoteServer());
     }
 
-    public static void render(float partialTicks, ClientPlayerEntity player) {
-        Player.setPosition(partialTicks, player);
-        ClientRenderer.render(DimensionId.from(player.getEntityWorld().getRegistryKey()));
+    public static void render(MatrixStack matrixStack, ClientPlayerEntity player) {
+        ClientRenderer.render(matrixStack, DimensionId.from(player.getEntityWorld().getRegistryKey()));
     }
 
     public static void renderDeferred() {
@@ -121,7 +129,7 @@ public class ClientInterop {
     }
 
     public static void displayScreen(Screen screen) {
-        MinecraftClient.getInstance().openScreen(screen);
+        MinecraftClient.getInstance().setScreen(screen);
     }
 
     public static long getGameTime() {
index b0c76ec3582e7760650a5fc097fb5e9b17c03423..6e3f5c8ada645b7f79f71b974f9db9ee86d652ba 100644 (file)
@@ -15,7 +15,11 @@ import net.minecraft.util.math.BlockBox;
 import net.minecraft.util.math.BlockPos;
 import net.minecraft.util.math.ChunkPos;
 import net.minecraft.util.registry.DynamicRegistryManager;
-import net.minecraft.world.*;
+import net.minecraft.world.FeatureUpdater;
+import net.minecraft.world.HeightLimitView;
+import net.minecraft.world.PersistentStateManager;
+import net.minecraft.world.StructureWorldAccess;
+import net.minecraft.world.World;
 import net.minecraft.world.biome.Biome;
 import net.minecraft.world.dimension.DimensionType;
 import net.minecraft.world.gen.StructureAccessor;
@@ -26,7 +30,11 @@ import net.minecraft.world.storage.RegionBasedStorage;
 
 import java.io.File;
 import java.io.IOException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
 import java.util.function.BiFunction;
 
 class NBTStructureLoader {
@@ -115,10 +123,15 @@ class NBTStructureLoader {
     }
 
     private static class SimpleStructureStart extends StructureStart<FeatureConfig> {
+        private final BlockBox parsedBoundingBox;
+
         SimpleStructureStart(NbtCompound compound) {
             super(null,
-                    null,
-                    0, 0);
+                    new ChunkPos(0, 0),
+                    0,
+                    0);
+
+            this.parsedBoundingBox = create(compound.getIntArray("BB"));
 
             NbtList children = compound.getList("Children", 10);
             for (int index = 0; index < children.size(); ++index) {
@@ -127,9 +140,20 @@ class NBTStructureLoader {
             }
         }
 
+        private static BlockBox create(int[] compound) {
+            if (compound.length == 6)
+                return new BlockBox(compound[0], compound[1], compound[2], compound[3], compound[4], compound[5]);
+            else
+                return new BlockBox(0, 0, 0, 0, 0, 0);
+        }
+
         @Override
-        public void init(DynamicRegistryManager registryManager, ChunkGenerator chunkGenerator, StructureManager manager, ChunkPos pos, Biome biome, FeatureConfig config, HeightLimitView world) {
+        public void init(DynamicRegistryManager dynamicRegistryManager, ChunkGenerator chunkGenerator, StructureManager structureManager, ChunkPos chunkPos, Biome biome, FeatureConfig featureConfig, HeightLimitView heightLimitView) {
+        }
 
+        @Override
+        protected BlockBox calculateBoundingBox() {
+            return this.parsedBoundingBox;
         }
     }
 
@@ -139,8 +163,7 @@ class NBTStructureLoader {
         }
 
         @Override
-        protected void writeNbt(ServerWorld world, NbtCompound nbt) {
-
+        protected void writeNbt(ServerWorld serverWorld, NbtCompound nbtCompound) {
         }
 
         @Override
index ba54e38ded969164b00b5c675762ef85486c30b1..1119146640125bed6e534a6eac87d6f7e038b0a4 100644 (file)
@@ -2,20 +2,30 @@ package com.irtimaled.bbor.client.interop;
 
 import com.irtimaled.bbor.common.TypeHelper;
 import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.irtimaled.bbor.mixin.client.access.IClientChunkManager;
+import com.irtimaled.bbor.mixin.client.access.IClientChunkManagerClientChunkMap;
 import net.minecraft.block.entity.BlockEntity;
 import net.minecraft.client.MinecraftClient;
+import net.minecraft.world.chunk.WorldChunk;
 
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicReferenceArray;
 import java.util.function.Function;
 
 public class TileEntitiesHelper {
     public static <T extends BlockEntity, S extends AbstractBoundingBox> Iterable<S> map(Class<T> clazz, Function<T, S> map) {
-        //Collection<BlockEntity> tileEntities = MinecraftClient.getInstance().world.blockEntities;
+        @SuppressWarnings("ConstantConditions") final AtomicReferenceArray<WorldChunk> chunks = ((IClientChunkManagerClientChunkMap) (Object) ((IClientChunkManager) MinecraftClient.getInstance().world.getChunkManager()).getChunks()).getChunks();
+        Collection<BlockEntity> tileEntities = new HashSet<>();
+        for (int i = 0; i < chunks.length(); i ++) {
+            final WorldChunk worldChunk = chunks.get(i);
+            if(worldChunk == null) continue;
+            tileEntities.addAll(worldChunk.getBlockEntities().values());
+        }
 
         Set<S> results = new HashSet<>();
-        /*for (BlockEntity tileEntity : tileEntities) {
+        for (BlockEntity tileEntity : tileEntities) {
             T typed = TypeHelper.as(tileEntity, clazz);
             if (typed == null) {
                 continue;
@@ -24,7 +34,7 @@ public class TileEntitiesHelper {
             if (result != null) {
                 results.add(result);
             }
-        }*/
+        }
         return results;
     }
 }
index 8c9fb3fa359c762d68a494387ecf637cb0ddda90..33b3a2d2060ae0de7385f15b2079c2913113c4d3 100644 (file)
@@ -8,7 +8,6 @@ import com.irtimaled.bbor.common.models.Coords;
 import com.irtimaled.bbor.common.models.DimensionId;
 import net.minecraft.block.entity.BeaconBlockEntity;
 
-
 public class BeaconProvider implements IBoundingBoxProvider<BoundingBoxBeacon> {
     @Override
     public boolean canProvide(DimensionId dimensionId) {
index b7c5a37f4a0d07998802980b68f18867cc4f2669..46438801d255c474be19527b9c2269ca2d2d7e7a 100644 (file)
@@ -10,7 +10,12 @@ import com.irtimaled.bbor.common.MathHelper;
 import com.irtimaled.bbor.common.models.Coords;
 import com.irtimaled.bbor.common.models.DimensionId;
 
-import java.util.*;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
 
 public class BedrockCeilingProvider implements IBoundingBoxProvider<BoundingBoxBedrockCeiling>, ICachingProvider {
     private static final double CHUNK_SIZE = 16d;
index d7f220f4dde2caf1a6916fb5a31828b67cd89ffa..98e8a919938f9ad4c8a2feac336fbf56c885fbff 100644 (file)
@@ -1,15 +1,29 @@
 package com.irtimaled.bbor.client.renderers;
 
+import com.irtimaled.bbor.client.Camera;
+import com.irtimaled.bbor.client.RenderCulling;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.MathHelper;
 import com.irtimaled.bbor.common.models.AbstractBoundingBox;
+import com.mojang.blaze3d.systems.RenderSystem;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.font.TextRenderer;
+import net.minecraft.client.gl.VertexBuffer;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.BufferRenderer;
+import net.minecraft.client.render.GameRenderer;
+import net.minecraft.client.render.Shader;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
+import net.minecraft.client.render.VertexFormats;
 import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Box;
+import net.minecraft.util.math.Matrix4f;
+import org.lwjgl.opengl.GL11;
 
 import java.awt.*;
-import java.util.function.Supplier;
 
 public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
     private static final double TAU = 6.283185307179586D;
@@ -17,125 +31,122 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
     private static final double PI = TAU / 2D;
     public static final double THETA_SEGMENT = PHI_SEGMENT / 2D;
 
-    public abstract void render(T boundingBox);
+    private final VertexBuffer solidBox = new VertexBuffer();
+    private final VertexBuffer outlinedBox = new VertexBuffer();
 
-    void renderCuboid(OffsetBox bb, Color color) {
-        OffsetBox nudge = bb.nudge();
-        renderOutlinedCuboid(nudge, color);
-        renderFilledFaces(nudge.getMin(), nudge.getMax(), color);
+    {
+        final Box box = new Box(BlockPos.ORIGIN);
+        RenderHelper.drawSolidBox(box, solidBox);
+        RenderHelper.drawOutlinedBox(box, outlinedBox);
     }
 
-    void renderOutlinedCuboid(OffsetBox bb, Color color) {
-        RenderHelper.polygonModeLine();
-        OffsetPoint min = bb.getMin();
-        OffsetPoint max = bb.getMax();
-        renderFaces(min, max, color, 255, min.getY() == max.getY() ? Renderer::startLineLoop : Renderer::startLines);
-    }
+    public abstract void render(MatrixStack matrixStack, T boundingBox);
+
+    void renderCuboid(MatrixStack matrixStack, OffsetBox bb, Color color, boolean fillOnly) {
+        OffsetBox nudge = bb.nudge();
+
+        GL11.glEnable(GL11.GL_LINE_SMOOTH);
+        GL11.glEnable(GL11.GL_CULL_FACE);
+        RenderHelper.polygonModeFill();
+        matrixStack.push();
 
-    private void renderFaces(OffsetPoint min, OffsetPoint max, Color color, int alpha, Supplier<Renderer> rendererSupplier) {
-        double minX = min.getX();
-        double minY = min.getY();
-        double minZ = min.getZ();
+        RenderHelper.applyRegionalRenderOffset(matrixStack);
+        renderCuboid0(matrixStack, nudge, color, fillOnly);
 
-        double maxX = max.getX();
-        double maxY = max.getY();
-        double maxZ = max.getZ();
+        matrixStack.pop();
+        GL11.glDisable(GL11.GL_LINE_SMOOTH);
+        RenderSystem.setShaderColor(1, 1, 1, 1);
+    }
 
+    private void renderCuboid0(MatrixStack stack, OffsetBox nudge, Color color, boolean fillOnly) {
+        if (!RenderCulling.isVisibleCulling(nudge.toBox())) return;
         if (ConfigManager.invertBoxColorPlayerInside.get() &&
-                playerInsideBoundingBox(minX, minY, minZ, maxX, maxY, maxZ)) {
+                playerInsideBoundingBox(nudge)) {
             color = new Color(255 - color.getRed(), 255 - color.getGreen(), 255 - color.getBlue());
         }
-
-        Renderer renderer = rendererSupplier.get()
-                .setColor(color)
-                .setAlpha(alpha);
-
-        if (minX != maxX && minZ != maxZ) {
-            renderer.addPoint(minX, minY, minZ)
-                    .addPoint(maxX, minY, minZ)
-                    .addPoint(maxX, minY, maxZ)
-                    .addPoint(minX, minY, maxZ);
-
-            if (minY != maxY) {
-                renderer.addPoint(minX, maxY, minZ)
-                        .addPoint(maxX, maxY, minZ)
-                        .addPoint(maxX, maxY, maxZ)
-                        .addPoint(minX, maxY, maxZ);
-            }
-        }
-
-        if (minX != maxX && minY != maxY) {
-            renderer.addPoint(minX, minY, maxZ)
-                    .addPoint(minX, maxY, maxZ)
-                    .addPoint(maxX, maxY, maxZ)
-                    .addPoint(maxX, minY, maxZ);
-
-            if (minZ != maxZ) {
-                renderer.addPoint(minX, minY, minZ)
-                        .addPoint(minX, maxY, minZ)
-                        .addPoint(maxX, maxY, minZ)
-                        .addPoint(maxX, minY, minZ);
-            }
+        stack.push();
+        int regionX = (((int) Camera.getX()) >> 9) << 9;
+        int regionZ = (((int) Camera.getZ()) >> 9) << 9;
+        RenderSystem.setShader(GameRenderer::getPositionShader);
+        stack.translate(nudge.getMin().getX() - regionX, nudge.getMin().getY(), nudge.getMin().getZ() - regionZ);
+        stack.scale((float) (nudge.getMax().getX() - nudge.getMin().getX()),
+                (float) (nudge.getMax().getY() - nudge.getMin().getY()),
+                (float) (nudge.getMax().getZ() - nudge.getMin().getZ()));
+
+        Matrix4f viewMatrix = stack.peek().getModel();
+        Matrix4f projMatrix = RenderSystem.getProjectionMatrix();
+        Shader shader = RenderSystem.getShader();
+        if (fillOnly || ConfigManager.fill.get()) {
+            RenderSystem.setShaderColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 30 / 255F);
+            solidBox.setShader(viewMatrix, projMatrix, shader);
         }
-        if (minY != maxY && minZ != maxZ) {
-            renderer.addPoint(minX, minY, minZ)
-                    .addPoint(minX, minY, maxZ)
-                    .addPoint(minX, maxY, maxZ)
-                    .addPoint(minX, maxY, minZ);
-
-            if (minX != maxX) {
-                renderer.addPoint(maxX, minY, minZ)
-                        .addPoint(maxX, minY, maxZ)
-                        .addPoint(maxX, maxY, maxZ)
-                        .addPoint(maxX, maxY, minZ);
-            }
+        if (!fillOnly) {
+            RenderSystem.setShaderColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 1F);
+            outlinedBox.setShader(viewMatrix, projMatrix, shader);
         }
-        renderer.render();
-    }
-
-    private boolean playerInsideBoundingBox(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
-        return minX < 0 && maxX > 0 && minY < 0 && maxY > 0 && minZ < 0 && maxZ > 0;
-    }
 
-    void renderLine(OffsetPoint startPoint, OffsetPoint endPoint, Color color) {
-        RenderHelper.polygonModeLine();
-        Renderer.startLines()
-                .setColor(color)
-                .addPoint(startPoint)
-                .addPoint(endPoint)
-                .render();
+        stack.pop();
     }
 
-    void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color) {
-        renderFilledFaces(min, max, color, 30);
+    private boolean playerInsideBoundingBox(OffsetBox nudge) {
+        return nudge.getMin().getX() < 0 && nudge.getMax().getX() > 0 &&
+                nudge.getMin().getY() < 0 && nudge.getMax().getY() > 0 &&
+                nudge.getMin().getZ() < 0 && nudge.getMax().getZ() > 0;
     }
 
-    void renderFilledFaces(OffsetPoint min, OffsetPoint max, Color color, int alpha) {
-        if (!ConfigManager.fill.get()) return;
-        RenderQueue.deferRendering(() -> renderFaces(min, max, color, alpha, Renderer::startQuads));
+    void renderLine(MatrixStack matrixStack, OffsetPoint startPoint, OffsetPoint endPoint, Color color) {
+        if (!RenderCulling.isVisibleCulling(new OffsetBox(startPoint, endPoint).toBox())) return; // TODO better culling
+        matrixStack.push();
+
+        RenderHelper.applyRegionalRenderOffset(matrixStack);
+        RenderSystem.setShader(GameRenderer::getPositionShader);
+        RenderSystem.setShaderColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 0.55f);
+        int regionX = (((int) Camera.getX()) >> 9) * 512;
+        int regionZ = (((int) Camera.getZ()) >> 9) * 512;
+
+        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
+        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
+                VertexFormats.POSITION);
+        bufferBuilder
+                .vertex(matrixStack.peek().getModel(),
+                        (float) startPoint.getX() - regionX,
+                        (float) startPoint.getY(),
+                        (float) startPoint.getZ() - regionZ)
+                .next();
+        bufferBuilder
+                .vertex(matrixStack.peek().getModel(),
+                        (float) endPoint.getX() - regionX,
+                        (float) endPoint.getY(),
+                        (float) endPoint.getZ() - regionZ)
+                .next();
+        bufferBuilder.end();
+        BufferRenderer.draw(bufferBuilder);
+
+        matrixStack.pop();
     }
 
-    void renderText(OffsetPoint offsetPoint, String... texts) {
+    void renderText(MatrixStack matrixStack, OffsetPoint offsetPoint, String... texts) {
         TextRenderer fontRenderer = MinecraftClient.getInstance().textRenderer;
-        RenderHelper.beforeRenderFont(offsetPoint);
+        RenderHelper.beforeRenderFont(matrixStack, offsetPoint);
         float top = -(fontRenderer.fontHeight * texts.length) / 2f;
         for (String text : texts) {
             float left = fontRenderer.getWidth(text) / 2f;
             fontRenderer.draw(new MatrixStack(), text, -left, top, -1);
             top += fontRenderer.fontHeight;
         }
-        RenderHelper.afterRenderFont();
+        RenderHelper.afterRenderFont(matrixStack);
     }
 
-    void renderSphere(Point center, double radius, Color color) {
+    void renderSphere(MatrixStack matrixStack, Point center, double radius, Color color) {
         if (ConfigManager.renderSphereAsDots.get()) {
-            renderDotSphere(center, radius, color);
+            renderDotSphere(matrixStack, center, radius, color);
         } else {
-            renderLineSphere(center, radius, color);
+            renderLineSphere(matrixStack, center, radius, color);
         }
     }
 
-    private void renderLineSphere(Point center, double radius, Color color) {
+    private void renderLineSphere(MatrixStack matrixStack, Point center, double radius, Color color) {
+        if (!RenderCulling.isVisibleCulling(new Box(new BlockPos(center.getX(), center.getY(), center.getZ())).expand(radius))) return;
         RenderHelper.lineWidth2();
 
         double offset = ((radius - (int) radius) == 0) ? center.getY() - (int) center.getY() : 0;
@@ -143,26 +154,58 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
         for (double dy = offset - radius; dy <= radius + 1; dy += dyStep) {
             double circleRadius = Math.sqrt((radius * radius) - (dy * dy));
             if (circleRadius == 0) circleRadius = Math.sqrt(2) / 2;
-            renderCircle(center, circleRadius, color, dy + 0.001F);
+            renderCircle(matrixStack, center, circleRadius, color, dy + 0.001F);
         }
     }
 
-    private void renderCircle(Point center, double radius, Color color, double dy) {
-        Renderer renderer = Renderer.startLineLoop()
-                .setColor(color);
+    private void renderCircle(MatrixStack matrixStack, Point center, double radius, Color color, double dy) {
+        matrixStack.push();
+
+        RenderHelper.applyRegionalRenderOffset(matrixStack);
+        RenderSystem.setShader(GameRenderer::getPositionShader);
+        RenderSystem.setShaderColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 0.55f);
+        int regionX = (((int) Camera.getX()) >> 9) * 512;
+        int regionZ = (((int) Camera.getZ()) >> 9) * 512;
+
+        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
+        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINE_STRIP,
+                VertexFormats.POSITION);
+
+        Point firstPoint = null;
 
         for (double phi = 0.0D; phi < TAU; phi += PHI_SEGMENT) {
-            renderer.addPoint(new OffsetPoint(center.offset(Math.cos(phi) * radius, dy, Math.sin(phi) * radius)));
+            final Point point = center.offset(Math.cos(phi) * radius, dy, Math.sin(phi) * radius);
+            if (firstPoint == null) firstPoint = point;
+            bufferBuilder.vertex(matrixStack.peek().getModel(),
+                    (float) point.getX() - regionX,
+                    (float) point.getY(),
+                    (float) point.getZ() - regionZ)
+                    .next();
         }
 
-        renderer.render();
+        bufferBuilder.vertex(matrixStack.peek().getModel(),
+                (float) firstPoint.getX() - regionX,
+                (float) firstPoint.getY(),
+                (float) firstPoint.getZ() - regionZ)
+                .next();
+
+        bufferBuilder.end();
+        BufferRenderer.draw(bufferBuilder);
+        matrixStack.pop();
     }
 
-    private void renderDotSphere(Point center, double radius, Color color) {
-        RenderHelper.enablePointSmooth();
-        RenderHelper.pointSize5();
-        Renderer renderer = Renderer.startPoints()
-                .setColor(color);
+    private void renderDotSphere(MatrixStack matrixStack, Point center, double radius, Color color) {
+        if (!RenderCulling.isVisibleCulling(new Box(new BlockPos(center.getX(), center.getY(), center.getZ())).expand(radius))) return;
+        matrixStack.push();
+        RenderHelper.applyRegionalRenderOffset(matrixStack);
+        RenderSystem.setShader(GameRenderer::getPositionShader);
+        RenderSystem.setShaderColor(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, 0.55f);
+        int regionX = (((int) Camera.getX()) >> 9) * 512;
+        int regionZ = (((int) Camera.getZ()) >> 9) * 512;
+
+        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
+        bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
+                VertexFormats.POSITION);
 
         for (double phi = 0.0D; phi < TAU; phi += PHI_SEGMENT) {
             double dy = radius * Math.cos(phi);
@@ -171,9 +214,17 @@ public abstract class AbstractRenderer<T extends AbstractBoundingBox> {
                 double dx = radiusBySinPhi * Math.cos(theta);
                 double dz = radiusBySinPhi * Math.sin(theta);
 
-                renderer.addPoint(new OffsetPoint(center.offset(dx, dy, dz)));
+                final Point point = center.offset(dx, dy, dz);
+                bufferBuilder
+                        .vertex(matrixStack.peek().getModel(),
+                                (float) point.getX() - regionX,
+                                (float) point.getY(),
+                                (float) point.getZ() - regionZ)
+                        .next();
             }
         }
-        renderer.render();
+        bufferBuilder.end();
+        BufferRenderer.draw(bufferBuilder);
+        matrixStack.pop();
     }
 }
index 1afbc9df41ec545b63b7244c8b6ce716b01c8bc5..e1ee127db24b2ab867b4984f37730beeed2dcb4f 100644 (file)
@@ -3,17 +3,18 @@ package com.irtimaled.bbor.client.renderers;
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.models.BoundingBoxBeacon;
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class BeaconRenderer extends AbstractRenderer<BoundingBoxBeacon> {
     @Override
-    public void render(BoundingBoxBeacon boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxBeacon boundingBox) {
         Coords coords = boundingBox.getCoords();
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
-        renderCuboid(new OffsetBox(coords, coords), color);
+        renderCuboid(matrixStack, new OffsetBox(coords, coords), color, false);
         if (boundingBox.getLevel() != 0) {
-            renderCuboid(new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords()), color);
+            renderCuboid(matrixStack, new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords()), color, false);
         }
     }
 }
index 444edbce1ab91a44f99f248ab9b167189c509711..c957690d88aa42b92f525e660063a8bc9b678e40 100644 (file)
@@ -4,12 +4,13 @@ import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxBiomeBorder;
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class BiomeBorderRenderer extends AbstractRenderer<BoundingBoxBiomeBorder> {
     @Override
-    public void render(BoundingBoxBiomeBorder boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxBiomeBorder boundingBox) {
         Coords coords = boundingBox.getCoords();
         OffsetPoint northWest = new OffsetPoint(coords).offset(0, 0.001F, 0);
         OffsetPoint northEast = northWest.offset(1, 0, 0);
@@ -17,23 +18,23 @@ public class BiomeBorderRenderer extends AbstractRenderer<BoundingBoxBiomeBorder
 
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
         if (boundingBox.renderNorth()) {
-            render(northWest, northEast, color);
+            render(matrixStack, northWest, northEast, color);
         }
         if (boundingBox.renderWest()) {
-            render(northWest, southWest, color);
+            render(matrixStack, northWest, southWest, color);
         }
         if (ConfigManager.renderOnlyCurrentBiome.get()) {
             OffsetPoint southEast = southWest.offset(1, 0, 0);
             if (boundingBox.renderSouth()) {
-                render(southWest, southEast, color);
+                render(matrixStack, southWest, southEast, color);
             }
             if (boundingBox.renderEast()) {
-                render(northEast, southEast, color);
+                render(matrixStack, northEast, southEast, color);
             }
         }
     }
 
-    private void render(OffsetPoint topCorner1, OffsetPoint topCorner2, Color color) {
+    private void render(MatrixStack matrixStack, OffsetPoint topCorner1, OffsetPoint topCorner2, Color color) {
         double xOffset = 0d;
         double zOffset = 0d;
         if (topCorner1.getX() == topCorner2.getX()) {
@@ -45,11 +46,11 @@ public class BiomeBorderRenderer extends AbstractRenderer<BoundingBoxBiomeBorder
         topCorner1 = topCorner1.offset(xOffset, 0, zOffset);
         topCorner2 = topCorner2.offset(xOffset, 0, zOffset);
 
-        renderLine(topCorner1, topCorner2, color);
+        renderLine(matrixStack, topCorner1, topCorner2, color);
         OffsetPoint bottomCorner2 = topCorner2.offset(0, 1, 0);
-        renderFilledFaces(topCorner1, bottomCorner2, color);
+        renderCuboid(matrixStack, new OffsetBox(topCorner1, bottomCorner2), color, true);
         OffsetPoint bottomCorner1 = topCorner1.offset(0, 1, 0);
-        renderLine(bottomCorner1, bottomCorner2, color);
+        renderLine(matrixStack, bottomCorner1, bottomCorner2, color);
     }
 
     private double getOffset(double value) {
index 51954f8c2a9a0174da145a8e588061a7099a4017..93dda6602abc68e54754635625fe33c83acf236a 100644 (file)
@@ -5,26 +5,27 @@ import com.irtimaled.bbor.client.config.ColorHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxConduit;
 import com.irtimaled.bbor.client.models.Point;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class ConduitRenderer extends AbstractRenderer<BoundingBoxConduit> {
     @Override
-    public void render(BoundingBoxConduit boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxConduit boundingBox) {
         int level = boundingBox.getLevel();
         Point point = boundingBox.getPoint();
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
 
         if (level != 0) {
-            renderSphere(point, boundingBox.getRadius() + 0.5, color);
+            renderSphere(matrixStack, point, boundingBox.getRadius() + 0.5, color);
         }
 
         OffsetPoint center = new OffsetPoint(point);
         OffsetBox centerBox = new OffsetBox(center, center).grow(0.5, 0.5, 0.5);
-        renderCuboid(centerBox, color);
+        renderCuboid(matrixStack, centerBox, color, false);
         if (level == 6 && ConfigManager.renderConduitMobHarmArea.get()) {
-            renderCuboid(centerBox.grow(8, 8, 8),
-                    ColorHelper.getColor(ConfigManager.colorConduitMobHarmArea));
+            renderCuboid(matrixStack, centerBox.grow(8, 8, 8),
+                    ColorHelper.getColor(ConfigManager.colorConduitMobHarmArea), false);
         }
     }
 }
index 7042c402827e14755d9d0bf214e7e4b1cce69395..094c63e41060e032fc76007148ecbb2ed3d1734c 100644 (file)
@@ -2,11 +2,12 @@ package com.irtimaled.bbor.client.renderers;
 
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
+import net.minecraft.client.util.math.MatrixStack;
 
 public class CuboidRenderer extends AbstractRenderer<BoundingBoxCuboid> {
     @Override
-    public void render(BoundingBoxCuboid boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxCuboid boundingBox) {
         OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
-        renderCuboid(bb, BoundingBoxTypeHelper.getColor(boundingBox.getType()));
+        renderCuboid(matrixStack, bb, BoundingBoxTypeHelper.getColor(boundingBox.getType()), false);
     }
 }
index 570e202fa7f23b63349ee95f76b9aa189541f7ae..fd81328ab8ee6f8e36559e13d89bbdd1f78dadc0 100644 (file)
@@ -2,16 +2,17 @@ package com.irtimaled.bbor.client.renderers;
 
 import com.irtimaled.bbor.client.models.BoundingBoxFlowerForest;
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.client.util.math.MatrixStack;
 
 public class FlowerForestRenderer extends AbstractRenderer<BoundingBoxFlowerForest> {
     @Override
-    public void render(BoundingBoxFlowerForest boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxFlowerForest boundingBox) {
         Coords coords = boundingBox.getCoords();
         int x = coords.getX();
         int y = coords.getY();
         int z = coords.getZ();
-        renderFilledFaces(new OffsetPoint(x, y + 0.01d, z),
-                new OffsetPoint(x + 1, y + 0.01d, z + 1),
-                boundingBox.getColor(), 127);
+        renderCuboid(matrixStack, new OffsetBox(new OffsetPoint(x, y + 0.01d, z),
+                        new OffsetPoint(x + 1, y + 0.01d, z + 1)),
+                boundingBox.getColor()/*, 127 alpha*/, true);
     }
 }
index a769ebfe6ac8aa34abf7b44942a6cce8f743ad9d..2e3cdd1f697da3db0d9428fcb2d580e6b93ef2a8 100644 (file)
@@ -3,19 +3,20 @@ package com.irtimaled.bbor.client.renderers;
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxLine;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 import java.util.Arrays;
 
 public class LineRenderer extends AbstractRenderer<BoundingBoxLine> {
     @Override
-    public void render(BoundingBoxLine boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxLine boundingBox) {
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
 
         if (boundingBox.getWidth() == 0) {
             OffsetPoint startPoint = new OffsetPoint(boundingBox.getMinPoint()).offset(0, 0.001f, 0);
             OffsetPoint endPoint = new OffsetPoint(boundingBox.getMaxPoint()).offset(0, 0.001f, 0);
-            renderLine(startPoint, endPoint, color);
+            renderLine(matrixStack, startPoint, endPoint, color);
             return;
         }
 
@@ -25,12 +26,14 @@ public class LineRenderer extends AbstractRenderer<BoundingBoxLine> {
 
         RenderHelper.polygonModeLine();
         Renderer.startQuads()
+                .setMatrixStack(matrixStack)
                 .setColor(color)
                 .addPoints(cornerPoints)
                 .render();
 
         if (!ConfigManager.fill.get()) return;
         RenderQueue.deferRendering(() -> Renderer.startQuads()
+                .setMatrixStack(matrixStack)
                 .setColor(color)
                 .setAlpha(30)
                 .addPoints(cornerPoints)
index 9b345805a218c993226fb62458c857634d8da4e4..7cdd89ca8ec3a235d383a50ffa705678bb639970 100644 (file)
@@ -6,34 +6,35 @@ import com.irtimaled.bbor.client.config.ColorHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxMobSpawner;
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class MobSpawnerRenderer extends AbstractRenderer<BoundingBoxMobSpawner> {
     @Override
-    public void render(BoundingBoxMobSpawner boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxMobSpawner boundingBox) {
         Coords coords = boundingBox.getCoords();
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
 
-        renderCuboid(new OffsetBox(coords, coords), color);
+        renderCuboid(matrixStack, new OffsetBox(coords, coords), color, false);
 
         if (ConfigManager.renderMobSpawnerActivationLines.get()) {
-            renderActivationLine(new OffsetPoint(coords).offset(0.5, 0.5, 0.5));
+            renderActivationLine(matrixStack, new OffsetPoint(coords).offset(0.5, 0.5, 0.5));
         }
 
         if (ConfigManager.renderMobSpawnerSpawnArea.get()) {
             OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
-            renderCuboid(bb, color);
+            renderCuboid(matrixStack, bb, color, false);
         }
     }
 
-    private void renderActivationLine(OffsetPoint centerPoint) {
+    private void renderActivationLine(MatrixStack matrixStack, OffsetPoint centerPoint) {
         OffsetPoint playerPos = new OffsetPoint(Player.getPoint());
         double distance = centerPoint.getDistance(playerPos);
         if (distance <= 20) {
 
             OffsetPoint playerPoint = playerPos.offset(0, 0.1, 0);
-            renderLine(centerPoint, playerPoint, getColor(distance));
+            renderLine(matrixStack, centerPoint, playerPoint, getColor(distance));
         }
     }
 
index e2f1050e462a505465f8549f909bcf13ef9120af..ce1d8923f7a678ac5f8e067ec2a5405a71bf2c1a 100644 (file)
@@ -1,6 +1,7 @@
 package com.irtimaled.bbor.client.renderers;
 
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.util.math.Box;
 
 class OffsetBox {
     private final OffsetPoint min;
@@ -40,4 +41,8 @@ class OffsetBox {
     OffsetPoint getMax() {
         return max;
     }
+
+    public Box toBox() {
+        return new Box(getMin().getX(), getMin().getY(), getMin().getZ(), getMax().getX(), getMax().getY(), getMax().getZ());
+    }
 }
index 76c1dc70f5d6ea8f81b84a30a0de97d2ed4182a9..6230d8db44e72602639418acdb25f23f525db1de 100644 (file)
@@ -1,6 +1,5 @@
 package com.irtimaled.bbor.client.renderers;
 
-import com.irtimaled.bbor.client.Camera;
 import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.models.Coords;
 
@@ -20,15 +19,15 @@ class OffsetPoint {
     }
 
     double getX() {
-        return point.getX() - Camera.getX();
+        return point.getX();
     }
 
     double getY() {
-        return point.getY() - Camera.getY();
+        return point.getY();
     }
 
     double getZ() {
-        return point.getZ() - Camera.getZ();
+        return point.getZ();
     }
 
     OffsetPoint offset(double x, double y, double z) {
index 5747fd680673bbaea75aa7f57aef15e48f663d8a..8826c4b94f7f40c8b7544da7c29f064cb180bf9e 100644 (file)
 package com.irtimaled.bbor.client.renderers;
 
+import com.irtimaled.bbor.client.Camera;
 import com.irtimaled.bbor.client.config.ConfigManager;
+import com.mojang.blaze3d.platform.GlStateManager;
 import com.mojang.blaze3d.systems.RenderSystem;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.GameRenderer;
-import net.minecraft.util.Identifier;
+import net.minecraft.client.gl.VertexBuffer;
+import net.minecraft.client.render.BufferBuilder;
+import net.minecraft.client.render.Tessellator;
+import net.minecraft.client.render.VertexFormat;
+import net.minecraft.client.render.VertexFormats;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.math.Box;
+import net.minecraft.util.math.Quaternion;
 import org.lwjgl.opengl.GL11;
 
 public class RenderHelper {
-    public static final int QUADS = GL11.GL_QUADS;
-    public static final int LINES = GL11.GL_LINES;
-    public static final int LINE_LOOP = GL11.GL_LINE_LOOP;
-    public static final int POINTS = GL11.GL_POINTS;
 
-    //public static final VertexFormat.DrawMode CUSTOM = ReflectionHelper.getPrivateInstanceBuilder(VertexFormat.DrawMode.class,)
     public static void beforeRender() {
         enableBlend();
-        RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
-        lineWidth2();
-        disableTexture();
+        GlStateManager._blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
+        GL11.glEnable(GL11.GL_LINE_SMOOTH);
         RenderSystem.disableCull();
         enableDepthTest();
+        RenderSystem.depthMask(false);
+        RenderSystem.depthFunc(GL11.GL_LEQUAL);
 
         if (ConfigManager.alwaysVisible.get()) {
-            RenderSystem.clear(GL11.GL_DEPTH_BUFFER_BIT, MinecraftClient.IS_SYSTEM_MAC);
+            RenderSystem.disableDepthTest();
         }
     }
 
-    public static void setTexture(Identifier texture) {
-        RenderSystem.setShader(GameRenderer::getPositionTexColorShader);
-        RenderSystem.setShaderTexture(0, texture);
-    }
-
-    public static void resetShader() {
-        RenderSystem.setShader(GameRenderer::getPositionColorShader);
-    }
-
     public static void afterRender() {
-        polygonModeFill();
         RenderSystem.enableCull();
-        enableTexture();
+        GL11.glDisable(GL11.GL_LINE_SMOOTH);
+        RenderSystem.setShaderColor(1, 1, 1, 1);
     }
 
-    public static void beforeRenderFont(OffsetPoint offsetPoint) {
-       // RenderSystem.pushMatrix();
+    public static void beforeRenderFont(MatrixStack matrixStack, OffsetPoint offsetPoint) {
+        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+        matrixStack.push();
         polygonModeFill();
-        //RenderSystem.translated(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
-        //RenderSystem.normal3f(0.0F, 1.0F, 0.0F);
-        //RenderSystem.rotatef(0.0F, 0.0F, 1.0F, 0.0F);
-        //RenderSystem.rotatef(90.0F, 1.0F, 0.0F, 0.0F);
-        //RenderSystem.scalef(-0.0175F, -0.0175F, 0.0175F);
+        matrixStack.translate(offsetPoint.getX(), offsetPoint.getY() + 0.002D, offsetPoint.getZ());
+        // GL11.glNormal3f(0.0F, 1.0F, 0.0F);
+        matrixStack.multiply(new Quaternion(0.0F, 0.0F, 0.0F, 1.0F));
+        matrixStack.multiply(new Quaternion(0.0F, 90.0F, 1.0F, 0.0F));
+        matrixStack.scale(-0.0175F, -0.0175F, 0.0175F);
         enableTexture();
         enableBlend();
-        RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
+        GlStateManager._blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
 
         depthMaskTrue();
     }
 
-    public static void afterRenderFont() {
+    public static void afterRenderFont(MatrixStack matrixStack) {
         disableTexture();
         disableBlend();
-        //RenderSystem.popMatrix();
+        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+        matrixStack.pop();
         enableDepthTest();
     }
 
-    public static void disableLighting() {
-        //RenderSystem.disableLighting();
-    }
+//    public static void disableLighting() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+//        GL11.glDisable(GL11.GL_LIGHTING);
+//    }
 
     public static void disableDepthTest() {
-        RenderSystem.disableDepthTest();
+        GlStateManager._disableDepthTest();
     }
 
     public static void enableDepthTest() {
-        RenderSystem.enableDepthTest();
+        GlStateManager._enableDepthTest();
     }
 
+//    public static void disableFog() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+//        GL11.glDisable(GL11.GL_FOG);
+//    }
+
     public static void disableBlend() {
-        RenderSystem.disableBlend();
+        GlStateManager._disableBlend();
     }
 
     public static void enableBlend() {
-        RenderSystem.enableBlend();
-    }
-
-    public static void disableAlphaTest() {
-        //RenderSystem.disableAlphaTest();
+        GlStateManager._enableBlend();
     }
 
-    public static void enableAlphaTest() {
-        //RenderSystem.enableAlphaTest();
-    }
+//    public static void disableAlphaTest() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+//        GL11.glDisable(GL32.GL_ALPHA_TEST);
+//    }
+//
+//    public static void enableAlphaTest() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+//        GL11.glEnable(GL11.GL_ALPHA_TEST);
+//    }
 
     public static void disableTexture() {
-        RenderSystem.disableTexture();
+        GlStateManager._disableTexture();
     }
 
     public static void enableTexture() {
-        RenderSystem.enableTexture();
-    }
-
-    public static void shadeModelSmooth() {
-        //RenderSystem.shadeModel(GL11.GL_SMOOTH);
+        GlStateManager._enableTexture();
     }
 
-    public static void shadeModelFlat() {
-        //RenderSystem.shadeModel(GL11.GL_FLAT);
-    }
+//    public static void shadeModelSmooth() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
+//        GL11.glShadeModel(GL11.GL_SMOOTH);
+//    }
+//
+//    public static void shadeModelFlat() {
+//        RenderSystem.assertThread(RenderSystem::isOnRenderThreadOrInit);
+//        GL11.glShadeModel(GL11.GL_FLAT);
+//    }
 
-    public static void enablePointSmooth() {
-        GL11.glEnable(GL11.GL_POINT_SMOOTH);
-    }
+//    public static void enablePointSmooth() {
+//        GL11.glEnable(GL11.GL_POINT_SMOOTH);
+//    }
 
     public static void lineWidth2() {
+        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
         RenderSystem.lineWidth(2f);
     }
 
     public static void polygonModeLine() {
-        RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+        GlStateManager._polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
     }
 
     public static void polygonModeFill() {
-        RenderSystem.polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+        GlStateManager._polygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
     }
 
     public static void polygonOffsetMinusOne() {
-        RenderSystem.polygonOffset(-1.f, -1.f);
+        GlStateManager._polygonOffset(-1.f, -1.f);
     }
 
     public static void enablePolygonOffsetLine() {
-        //RenderSystem.enableLineOffset();
+        RenderSystem.assertThread(RenderSystem::isOnRenderThread);
+        GL11.glEnable(GL11.GL_POLYGON_OFFSET_LINE);
     }
 
     public static void depthMaskTrue() {
-        RenderSystem.depthMask(true);
-    }
-
-    public static void pointSize5() {
-        GL11.glPointSize(5);
+        GlStateManager._depthMask(true);
     }
 
     public static void blendFuncGui() {
-        RenderSystem.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
+        GlStateManager._blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ZERO, GL11.GL_ONE);
     }
 
     public static void depthFuncAlways() {
-        RenderSystem.depthFunc(GL11.GL_ALWAYS);
+        GlStateManager._depthFunc(GL11.GL_ALWAYS);
     }
 
     public static void depthFuncLessEqual() {
-        RenderSystem.depthFunc(GL11.GL_LEQUAL);
+        GlStateManager._depthFunc(GL11.GL_LEQUAL);
+    }
+
+    public static void drawSolidBox(Box box, VertexBuffer vertexBuffer) {
+        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
+        bufferBuilder.begin(VertexFormat.DrawMode.QUADS,
+                VertexFormats.POSITION);
+
+        bufferBuilder.vertex(box.minX, box.minY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.minY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.minY, box.maxZ).next();
+        bufferBuilder.vertex(box.minX, box.minY, box.maxZ).next();
+
+        bufferBuilder.vertex(box.minX, box.maxY, box.minZ).next();
+        bufferBuilder.vertex(box.minX, box.maxY, box.maxZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.maxZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.minZ).next();
+
+        bufferBuilder.vertex(box.minX, box.minY, box.minZ).next();
+        bufferBuilder.vertex(box.minX, box.maxY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.minY, box.minZ).next();
+
+        bufferBuilder.vertex(box.maxX, box.minY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.minZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.maxZ).next();
+        bufferBuilder.vertex(box.maxX, box.minY, box.maxZ).next();
+
+        bufferBuilder.vertex(box.minX, box.minY, box.maxZ).next();
+        bufferBuilder.vertex(box.maxX, box.minY, box.maxZ).next();
+        bufferBuilder.vertex(box.maxX, box.maxY, box.maxZ).next();
+        bufferBuilder.vertex(box.minX, box.maxY, box.maxZ).next();
+
+        bufferBuilder.vertex(box.minX, box.minY, box.minZ).next();
+        bufferBuilder.vertex(box.minX, box.minY, box.maxZ).next();
+        bufferBuilder.vertex(box.minX, box.maxY, box.maxZ).next();
+        bufferBuilder.vertex(box.minX, box.maxY, box.minZ).next();
+
+        bufferBuilder.end();
+        vertexBuffer.upload(bufferBuilder);
+    }
+
+    public static void drawOutlinedBox(Box bb, VertexBuffer vertexBuffer) {
+        BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer();
+        bufferBuilder.begin(VertexFormat.DrawMode.DEBUG_LINES,
+                VertexFormats.POSITION);
+
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next();
+
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.minZ).next();
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.minZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.minY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.minX, bb.minY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.minZ).next();
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.maxX, bb.maxY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next();
+
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.maxZ).next();
+        bufferBuilder.vertex(bb.minX, bb.maxY, bb.minZ).next();
+
+        bufferBuilder.end();
+        vertexBuffer.upload(bufferBuilder);
+    }
+
+    public static void applyRegionalRenderOffset(MatrixStack matrixStack)
+    {
+
+        int regionX = (((int) Camera.getX()) >> 9) << 9;
+        int regionZ = (((int) Camera.getZ()) >> 9) << 9;
+
+        matrixStack.translate(regionX - Camera.getX(), -Camera.getY(),
+                regionZ - Camera.getZ());
     }
 }
index 92479973ed4c4bd7ac0dbdef9831544119c5ded5..8c354f1581f2e159c9df0c99547435ba2f10271f 100644 (file)
@@ -5,43 +5,47 @@ import net.minecraft.client.render.BufferBuilder;
 import net.minecraft.client.render.Tessellator;
 import net.minecraft.client.render.VertexFormat;
 import net.minecraft.client.render.VertexFormats;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class Renderer {
-    private final int glMode;
+    private final VertexFormat.DrawMode glMode;
 
     static Renderer startLines() {
         return new Renderer(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR);
     }
 
     static Renderer startLineLoop() {
-        return new Renderer(VertexFormat.DrawMode.LINES, VertexFormats.POSITION_COLOR);
+        return new Renderer(VertexFormat.DrawMode.DEBUG_LINE_STRIP, VertexFormats.POSITION_COLOR);
     }
 
     public static Renderer startQuads() {
         return new Renderer(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR);
     }
 
-    static Renderer startPoints() {
-        return new Renderer(VertexFormat.DrawMode.DEBUG_LINES, VertexFormats.POSITION_COLOR);
-    }
-
     public static Renderer startTextured() {
         return new Renderer(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR);
     }
 
-    private static final Tessellator tessellator = new Tessellator(2097152);
+    private static final Tessellator tessellator = Tessellator.getInstance();
     private static final BufferBuilder bufferBuilder = tessellator.getBuffer();
 
     private int red;
     private int green;
     private int blue;
     private int alpha;
+    private MatrixStack matrixStack;
 
     private Renderer(VertexFormat.DrawMode glMode, VertexFormat vertexFormat) {
         bufferBuilder.begin(glMode, vertexFormat);
-        this.glMode = glMode.mode;
+        this.glMode = glMode;
+    }
+
+    public Renderer setMatrixStack(MatrixStack stack) {
+        this.matrixStack = stack;
+        matrixStack.push();
+        return this;
     }
 
     public Renderer setColor(Color color) {
@@ -74,9 +78,11 @@ public class Renderer {
     }
 
     public Renderer addPoint(double x, double y, double z) {
+        matrixStack.push();
         pos(x, y, z);
         color();
         end();
+        matrixStack.pop();
         return this;
     }
 
@@ -89,14 +95,15 @@ public class Renderer {
     }
 
     public void render() {
-        if (glMode == RenderHelper.QUADS) {
+        if (glMode == VertexFormat.DrawMode.QUADS) {
             bufferBuilder.setCameraPosition((float) Camera.getX(), (float) Camera.getY(), (float) Camera.getZ());
         }
         tessellator.draw();
+        matrixStack.pop();
     }
 
     private void pos(double x, double y, double z) {
-        bufferBuilder.vertex(x, y, z);
+        bufferBuilder.vertex(matrixStack.peek().getModel(), (float) x, (float) y, (float) z);
     }
 
     private void tex(double u, double v) {
@@ -104,7 +111,7 @@ public class Renderer {
     }
 
     private void color() {
-        bufferBuilder.color(red, green, blue, alpha);
+        bufferBuilder.color(red / 255F, green / 255F, blue / 255F, alpha / 255F);
     }
 
     private void end() {
index ff93e2d757428780c091f2fbcb633f98e15b19f5..49b3c3d5215bf735a78d5e14b4b1e15df744626a 100644 (file)
@@ -4,22 +4,23 @@ import com.irtimaled.bbor.client.Player;
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxSlimeChunk;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class SlimeChunkRenderer extends AbstractRenderer<BoundingBoxSlimeChunk> {
     @Override
-    public void render(BoundingBoxSlimeChunk boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxSlimeChunk boundingBox) {
         OffsetBox bb = new OffsetBox(boundingBox.getMinCoords(), boundingBox.getMaxCoords());
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
-        renderCuboid(bb, color);
+        renderCuboid(matrixStack, bb, color, false);
 
         double maxY = Player.getMaxY(ConfigManager.slimeChunkMaxY.get());
         double dY = maxY - 39;
         if (dY > 0) {
             OffsetPoint min = bb.getMin().offset(0, 38, 0);
             OffsetPoint max = bb.getMax().offset(0, dY, 0);
-            renderCuboid(new OffsetBox(min, max), color);
+            renderCuboid(matrixStack, new OffsetBox(min, max), color, false);
         }
     }
 }
index 7cb1577ec5eae8514b64fbc711d1a2cdcd34a9e2..f4ae570cd3e572c5dc03ab638b5e8bbbc2fc4e46 100644 (file)
@@ -2,19 +2,20 @@ package com.irtimaled.bbor.client.renderers;
 
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.models.BoundingBoxSpawnableBlocks;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class SpawnableBlocksRenderer extends AbstractRenderer<BoundingBoxSpawnableBlocks> {
     @Override
-    public void render(BoundingBoxSpawnableBlocks boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxSpawnableBlocks boundingBox) {
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
         boundingBox.getBlocks().forEach(c -> {
             int x = c.getX();
             int y = c.getY();
             int z = c.getZ();
             OffsetBox offsetBox = new OffsetBox(x, y, z, x + 1, y, z + 1);
-            renderCuboid(offsetBox, color);
+            renderCuboid(matrixStack, offsetBox, color, false);
         });
     }
 }
index 1c07bbc2e78f7141305d7bde82dab534bb027ed2..d4116848d1ac313ac5cddaa1f910aeaaf82363ce 100644 (file)
@@ -8,50 +8,51 @@ import com.irtimaled.bbor.client.models.BoundingBoxSpawningSphere;
 import com.irtimaled.bbor.client.models.Point;
 import com.irtimaled.bbor.common.BoundingBoxType;
 import net.minecraft.client.resource.language.I18n;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.awt.*;
 
 public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawningSphere> {
     @Override
-    public void render(BoundingBoxSpawningSphere boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
         Point point = boundingBox.getPoint();
         OffsetPoint sphereCenter = new OffsetPoint(point);
 
         Color safeAreaColor = ColorHelper.getColor(ConfigManager.colorAFKSpheresSafeArea);
-        renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
 
-        renderOuterSphere(boundingBox, point);
+        renderOuterSphere(matrixStack, boundingBox, point);
 
         OffsetBox offsetBox = new OffsetBox(sphereCenter, sphereCenter).grow(0.5, 0, 0.5);
-        renderCuboid(offsetBox, safeAreaColor);
+        renderCuboid(matrixStack, offsetBox, safeAreaColor, false);
 
         Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
         if (spawnableSpacesCount != null) {
-            renderText(sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
+            renderText(matrixStack, sphereCenter, I18n.translate("bbor.renderer.spawningSphere.spawnable"),
                     spawnableSpacesCount == 0 ?
                             I18n.translate("bbor.renderer.spawningSphere.none") :
                             String.format("%,d", spawnableSpacesCount));
         }
-        renderSphere(point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SAFE_RADIUS, safeAreaColor);
 
         if (ConfigManager.renderAFKSpawnableBlocks.get() && boundingBox.isWithinSphere(Player.getPoint())) {
-            renderSpawnableSpaces(boundingBox);
+            renderSpawnableSpaces(matrixStack, boundingBox);
         }
     }
 
-    private void renderOuterSphere(BoundingBoxSpawningSphere boundingBox, Point point) {
+    private void renderOuterSphere(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox, Point point) {
         Color color = BoundingBoxTypeHelper.getColor(boundingBox.getType());
-        renderSphere(point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
+        renderSphere(matrixStack, point, BoundingBoxSpawningSphere.SPAWN_RADIUS, color);
     }
 
-    private void renderSpawnableSpaces(BoundingBoxSpawningSphere boundingBox) {
+    private void renderSpawnableSpaces(MatrixStack matrixStack, BoundingBoxSpawningSphere boundingBox) {
         Color color = BoundingBoxTypeHelper.getColor(BoundingBoxType.SpawnableBlocks);
         boundingBox.getBlocks().forEach(c -> {
             int x = c.getX();
             int y = c.getY();
             int z = c.getZ();
             OffsetBox offsetBox = new OffsetBox(x, y, z, x + 1, y, z + 1);
-            renderCuboid(offsetBox, color);
+            renderCuboid(matrixStack, offsetBox, color, false);
         });
     }
 }
index b293434a64ee4ec40da2353d007f91dcb3d163bd..1c5ab24dd4aedde4ccf601f42ddfa48d429c003d 100644 (file)
@@ -3,12 +3,13 @@ package com.irtimaled.bbor.client.renderers;
 import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.models.BoundingBoxSphere;
 import com.irtimaled.bbor.client.models.Point;
+import net.minecraft.client.util.math.MatrixStack;
 
 public class SphereRenderer extends AbstractRenderer<BoundingBoxSphere> {
     @Override
-    public void render(BoundingBoxSphere boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxSphere boundingBox) {
         Point point = boundingBox.getPoint();
         double radius = boundingBox.getRadius();
-        renderSphere(point, radius, BoundingBoxTypeHelper.getColor(boundingBox.getType()));
+        renderSphere(matrixStack, point, radius, BoundingBoxTypeHelper.getColor(boundingBox.getType()));
     }
 }
index 2eba30a4c6255b10e3701d794eb9868553e4e1cb..572046475fe3c443874f081f17b1bd297293aa15 100644 (file)
@@ -5,16 +5,17 @@ import com.irtimaled.bbor.client.config.BoundingBoxTypeHelper;
 import com.irtimaled.bbor.client.config.ConfigManager;
 import com.irtimaled.bbor.client.models.BoundingBoxWorldSpawn;
 import com.irtimaled.bbor.common.models.Coords;
+import net.minecraft.client.util.math.MatrixStack;
 
 public class WorldSpawnRenderer extends AbstractRenderer<BoundingBoxWorldSpawn> {
     @Override
-    public void render(BoundingBoxWorldSpawn boundingBox) {
+    public void render(MatrixStack matrixStack, BoundingBoxWorldSpawn boundingBox) {
         Coords minCoords = boundingBox.getMinCoords();
         Coords maxCoords = boundingBox.getMaxCoords();
 
         double y = Player.getMaxY(ConfigManager.worldSpawnMaxY.get());
 
         OffsetBox offsetBox = new OffsetBox(minCoords.getX(), y, minCoords.getZ(), maxCoords.getX(), y, maxCoords.getZ());
-        renderOutlinedCuboid(offsetBox.nudge(), BoundingBoxTypeHelper.getColor(boundingBox.getType()));
+        renderCuboid(matrixStack, offsetBox.nudge(), BoundingBoxTypeHelper.getColor(boundingBox.getType()), false);
     }
 }
index ebc39d851cbd1348411db69214735d3496401f58..683bc77647c9b8acaad45d2592717117f9dd9c91 100644 (file)
@@ -1,7 +1,12 @@
 package com.irtimaled.bbor.common;
 
 import com.irtimaled.bbor.Logger;
-import com.irtimaled.bbor.common.events.*;
+import com.irtimaled.bbor.common.events.PlayerLoggedIn;
+import com.irtimaled.bbor.common.events.PlayerLoggedOut;
+import com.irtimaled.bbor.common.events.PlayerSubscribed;
+import com.irtimaled.bbor.common.events.ServerTick;
+import com.irtimaled.bbor.common.events.StructuresLoaded;
+import com.irtimaled.bbor.common.events.WorldLoaded;
 import com.irtimaled.bbor.common.messages.AddBoundingBox;
 import com.irtimaled.bbor.common.messages.InitializeClient;
 import com.irtimaled.bbor.common.messages.PayloadBuilder;
index 29ba726df909f57699058e5c37df1515deb44b36..daf57f7b3a4ca642340a0c1d494e7a4aebf7c454 100644 (file)
@@ -3,6 +3,7 @@ package com.irtimaled.bbor.common;
 import com.irtimaled.bbor.common.models.AbstractBoundingBox;
 import com.irtimaled.bbor.common.models.BoundingBoxCuboid;
 import com.irtimaled.bbor.common.models.Coords;
+import com.irtimaled.bbor.mixin.access.IStructureStart;
 import net.minecraft.structure.StructurePiece;
 import net.minecraft.structure.StructureStart;
 import net.minecraft.util.math.BlockBox;
@@ -27,9 +28,12 @@ class StructureProcessor {
     private void addStructures(BoundingBoxType type, StructureStart<?> structureStart) {
         if (structureStart == null) return;
 
-        if (structureStart.hasNoChildren()) return;
+        try {
+            structureStart.setBoundingBoxFromChildren();
+        } catch (Throwable ignored) {
+        }
 
-        BlockBox bb = structureStart.setBoundingBoxFromChildren();
+        BlockBox bb = ((IStructureStart) structureStart).getBoundingBox();
         if (bb == null) return;
 
         AbstractBoundingBox boundingBox = buildStructure(bb, type);
index 1bf7448155c3d9e5fc382dcf5dda6584c06e1e33..dd09ffd8dead0239e4e028230f4fa049b867f0a1 100644 (file)
@@ -1,7 +1,12 @@
 package com.irtimaled.bbor.common.interop;
 
 import com.irtimaled.bbor.common.EventBus;
-import com.irtimaled.bbor.common.events.*;
+import com.irtimaled.bbor.common.events.PlayerLoggedIn;
+import com.irtimaled.bbor.common.events.PlayerLoggedOut;
+import com.irtimaled.bbor.common.events.PlayerSubscribed;
+import com.irtimaled.bbor.common.events.ServerTick;
+import com.irtimaled.bbor.common.events.StructuresLoaded;
+import com.irtimaled.bbor.common.events.WorldLoaded;
 import com.irtimaled.bbor.common.models.DimensionId;
 import com.irtimaled.bbor.common.models.ServerPlayer;
 import net.minecraft.network.ClientConnection;
diff --git a/src/main/java/com/irtimaled/bbor/mixin/access/IBeaconBlockEntity.java b/src/main/java/com/irtimaled/bbor/mixin/access/IBeaconBlockEntity.java
new file mode 100644 (file)
index 0000000..3624c79
--- /dev/null
@@ -0,0 +1,13 @@
+package com.irtimaled.bbor.mixin.access;
+
+import net.minecraft.block.entity.BeaconBlockEntity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(BeaconBlockEntity.class)
+public interface IBeaconBlockEntity {
+
+    @Accessor
+    int getLevel();
+
+}
diff --git a/src/main/java/com/irtimaled/bbor/mixin/access/IStructureStart.java b/src/main/java/com/irtimaled/bbor/mixin/access/IStructureStart.java
new file mode 100644 (file)
index 0000000..a402606
--- /dev/null
@@ -0,0 +1,14 @@
+package com.irtimaled.bbor.mixin.access;
+
+import net.minecraft.structure.StructureStart;
+import net.minecraft.util.math.BlockBox;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(StructureStart.class)
+public interface IStructureStart {
+
+    @Accessor
+    BlockBox getBoundingBox();
+
+}
diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManager.java b/src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManager.java
new file mode 100644 (file)
index 0000000..b511484
--- /dev/null
@@ -0,0 +1,13 @@
+package com.irtimaled.bbor.mixin.client.access;
+
+import net.minecraft.client.world.ClientChunkManager;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+@Mixin(ClientChunkManager.class)
+public interface IClientChunkManager {
+
+    @Accessor
+    ClientChunkManager.ClientChunkMap getChunks();
+
+}
diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManagerClientChunkMap.java b/src/main/java/com/irtimaled/bbor/mixin/client/access/IClientChunkManagerClientChunkMap.java
new file mode 100644 (file)
index 0000000..3878ae3
--- /dev/null
@@ -0,0 +1,16 @@
+package com.irtimaled.bbor.mixin.client.access;
+
+import net.minecraft.client.world.ClientChunkManager;
+import net.minecraft.world.chunk.WorldChunk;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.gen.Accessor;
+
+import java.util.concurrent.atomic.AtomicReferenceArray;
+
+@Mixin(ClientChunkManager.ClientChunkMap.class)
+public interface IClientChunkManagerClientChunkMap {
+
+    @Accessor
+    AtomicReferenceArray<WorldChunk> getChunks();
+
+}
index 3edd2126070bb97ba74c0daa53ea8ae6768f19a2..6ef02a737d9e1afcb524e7bc80b8559111ae405d 100644 (file)
@@ -1,11 +1,6 @@
 package com.irtimaled.bbor.mixin.client.gui.screen;
 
-import com.google.common.collect.Lists;
 import com.irtimaled.bbor.client.gui.SettingsScreenButton;
-import com.irtimaled.bbor.common.TypeHelper;
-import net.minecraft.client.gui.Drawable;
-import net.minecraft.client.gui.Element;
-import net.minecraft.client.gui.Selectable;
 import net.minecraft.client.gui.screen.Screen;
 import net.minecraft.client.gui.screen.option.OptionsScreen;
 import net.minecraft.client.gui.widget.ClickableWidget;
@@ -14,35 +9,24 @@ import org.spongepowered.asm.mixin.injection.At;
 import org.spongepowered.asm.mixin.injection.Inject;
 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
 
-import java.util.List;
-
 @Mixin(OptionsScreen.class)
 public class MixinOptionsScreen extends Screen {
     private MixinOptionsScreen() {
         super(null);
     }
 
-    private final List<ClickableWidget> buttons = Lists.newArrayList();
-
-    @Override
-    protected <T extends Element & Drawable & Selectable> T addDrawableChild(T drawableElement) {
-        ClickableWidget widget = TypeHelper.as(drawableElement, ClickableWidget.class);
-        if(widget != null) {
-            buttons.add(widget);
-        }
-
-        return super.addDrawableChild(drawableElement);
-    }
-
     @Inject(method = "init", at = @At("RETURN"))
     private void initGui(CallbackInfo ci) {
         //shuffle middle buttons up by 12 px to make space
         int top = this.height / 6 + 42;
         int bottom = this.height / 6 + 168;
-        for (ClickableWidget button : buttons) {
-            if (button.y >= top && button.y < bottom)
-                button.y -= 12;
-        }
+        children().stream()
+                .filter(element -> element instanceof ClickableWidget)
+                .map(element -> (ClickableWidget) element)
+                .forEach(button -> {
+                    if (button.y >= top && button.y < bottom)
+                        button.y -= 12;
+                });
         SettingsScreenButton button = new SettingsScreenButton(this.width / 2 - 155, top + 84, 150, "BBOR", this);
         this.addDrawableChild(button);
     }
diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinDebugHud.java b/src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinDebugHud.java
new file mode 100644 (file)
index 0000000..e151230
--- /dev/null
@@ -0,0 +1,20 @@
+package com.irtimaled.bbor.mixin.client.renderer;
+
+import com.irtimaled.bbor.client.RenderCulling;
+import net.minecraft.client.gui.hud.DebugHud;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import java.util.List;
+
+@Mixin(DebugHud.class)
+public class MixinDebugHud {
+
+    @Inject(method = "getLeftText", at = @At("RETURN"))
+    private void afterLeftText(CallbackInfoReturnable<List<String>> cir) {
+        cir.getReturnValue().add(RenderCulling.debugString());
+    }
+
+}
index 291d16c8fed01d83e11c36b51e6b4308c163f003..a1096a99d41c8ef43da2ec4bc00a11b7041ecfb1 100644 (file)
@@ -1,33 +1,8 @@
 package com.irtimaled.bbor.mixin.client.renderer;
 
-import com.irtimaled.bbor.client.interop.ClientInterop;
-import net.minecraft.client.MinecraftClient;
-import net.minecraft.client.render.Camera;
 import net.minecraft.client.render.GameRenderer;
-import net.minecraft.client.render.LightmapTextureManager;
-import net.minecraft.client.render.WorldRenderer;
-import net.minecraft.client.util.math.MatrixStack;
-import net.minecraft.util.math.Matrix4f;
-import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
 
-@Mixin(WorldRenderer.class)
+@Mixin(GameRenderer.class)
 public class MixinGameRenderer {
-    @Shadow
-    @Final
-    private MinecraftClient client;
-
-    @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/debug/DebugRenderer;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider$Immediate;DDD)V", shift = At.Shift.BEFORE))
-    private void renderFirst(MatrixStack ignored_1, float partialTicks, long ignored_2, boolean ignored_3, Camera ignored_4, GameRenderer ignored_5, LightmapTextureManager ignored_6, Matrix4f ignored_7, CallbackInfo ci) {
-        ClientInterop.render(partialTicks, this.client.player);
-    }
-
-    @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/WorldRenderer;renderChunkDebugInfo(Lnet/minecraft/client/render/Camera;)V", shift = At.Shift.BEFORE))
-    private void render(MatrixStack ignored_1, float partialTicks, long ignored_2, boolean ignored_3, Camera ignored_4, GameRenderer ignored_5, LightmapTextureManager ignored_6, Matrix4f ignored_7, CallbackInfo ci) {
-        ClientInterop.renderDeferred();
-    }
 }
diff --git a/src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinWorldRenderer.java b/src/main/java/com/irtimaled/bbor/mixin/client/renderer/MixinWorldRenderer.java
new file mode 100644 (file)
index 0000000..ca76e6e
--- /dev/null
@@ -0,0 +1,39 @@
+package com.irtimaled.bbor.mixin.client.renderer;
+
+import com.google.common.base.Preconditions;
+import com.irtimaled.bbor.client.Player;
+import com.irtimaled.bbor.client.RenderCulling;
+import com.irtimaled.bbor.client.interop.ClientInterop;
+import net.minecraft.client.MinecraftClient;
+import net.minecraft.client.render.Camera;
+import net.minecraft.client.render.Frustum;
+import net.minecraft.client.render.GameRenderer;
+import net.minecraft.client.render.LightmapTextureManager;
+import net.minecraft.client.render.WorldRenderer;
+import net.minecraft.client.util.math.MatrixStack;
+import net.minecraft.util.math.Matrix4f;
+import org.spongepowered.asm.mixin.Final;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+@Mixin(WorldRenderer.class)
+public class MixinWorldRenderer {
+
+    @Shadow @Final private MinecraftClient client;
+
+    @Shadow private Frustum frustum;
+
+    @Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/RenderLayer;getWaterMask()Lnet/minecraft/client/render/RenderLayer;", shift = At.Shift.BEFORE))
+    private void onRender(MatrixStack matrixStack, float partialTicks, long ignored_2, boolean ignored_3, Camera ignored_4, GameRenderer ignored_5, LightmapTextureManager ignored_6, Matrix4f ignored_7, CallbackInfo ci) {
+        Preconditions.checkNotNull(this.client.player);
+        RenderCulling.setFrustum(frustum);
+        RenderCulling.flushStats();
+        Player.setPosition(partialTicks, this.client.player);
+        ClientInterop.render(matrixStack, this.client.player);
+        ClientInterop.renderDeferred();
+    }
+
+}
index 78f2dcec0e8c72f492df9bdb8e075a23e0d2aff2..5003bff443c0879117f0bde59d9921f6bcbc6abb 100644 (file)
@@ -1,7 +1,11 @@
 package com.irtimaled.bbor.mixin.resource;
 
 import com.google.common.collect.ImmutableMap;
-import net.minecraft.resource.*;
+import net.minecraft.resource.DefaultResourcePack;
+import net.minecraft.resource.ResourcePackManager;
+import net.minecraft.resource.ResourcePackProfile;
+import net.minecraft.resource.ResourcePackSource;
+import net.minecraft.resource.VanillaDataPackProvider;
 import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
 import org.spongepowered.asm.mixin.Shadow;
diff --git a/src/main/resources/bbor.accesswidener b/src/main/resources/bbor.accesswidener
new file mode 100644 (file)
index 0000000..303001b
--- /dev/null
@@ -0,0 +1,3 @@
+accessWidener v1 named
+
+accessible    class    net/minecraft/client/world/ClientChunkManager$ClientChunkMap
index b9d605b1a1635f248f6060be9b2f0c6f1023d2d4..4cb7ceadcc02666a9a72b86b82b492b1228d45a2 100644 (file)
@@ -3,6 +3,7 @@
   "id": "bbor",
   "name": "BoundingBoxOutlineReloaded",
   "description": "Shows the bounding boxes of structures and features.",
+  "accessWidener": "bbor.accesswidener",
   "authors": [
     "Irtimaled"
   ],
index f093cdcd6022c5105e00ede146419f56ddc7a5b3..b611c7fd36d4a14fbd4fbe96abcdf01151f13ca1 100644 (file)
@@ -6,6 +6,10 @@
   "package": "com.irtimaled.bbor.mixin",
   "refmap": "mixins.bbor.refmap.json",
   "mixins": [
+    "access.IBeaconBlockEntity",
+    "access.IStructureStart",
+    "client.renderer.MixinDebugHud",
+    "client.renderer.MixinWorldRenderer",
     "network.play.client.MixinCCustomPayloadPacket",
     "server.MixinMinecraftServer",
     "server.management.MixinPlayerList",
@@ -14,6 +18,8 @@
   "client": [
     "client.MixinGameSettings",
     "client.MixinMinecraft",
+    "client.access.IClientChunkManager",
+    "client.access.IClientChunkManagerClientChunkMap",
     "client.entity.player.MixinClientPlayerEntity",
     "client.gui.screen.MixinChatScreen",
     "client.gui.screen.MixinOptionsScreen",