]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/blobdiff - src/main/java/com/irtimaled/bbor/client/gui/ControlList.java
Setup for 1.16.3 Fabric
[BoundingBoxOutlineReloaded.git] / src / main / java / com / irtimaled / bbor / client / gui / ControlList.java
index 9331c63998ded6ab70e5a37adfa563bd6afbd010..80554db10d5027a701ad8ff21d6f0ff5958b0615 100644 (file)
@@ -5,6 +5,7 @@ import com.irtimaled.bbor.client.renderers.Renderer;
 import com.irtimaled.bbor.common.MathHelper;
 import net.minecraft.client.MinecraftClient;
 import net.minecraft.client.gui.DrawableHelper;
+import net.minecraft.client.util.math.MatrixStack;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -152,7 +153,7 @@ public class ControlList extends DrawableHelper implements IControlSet {
         return true;
     }
 
-    public void render(int mouseX, int mouseY) {
+    public void render(MatrixStack matrixStack, int mouseX, int mouseY) {
         this.amountScrolled = MathHelper.clamp(this.amountScrolled, 0.0D, this.getMaxScroll());
 
         RenderHelper.disableLighting();
@@ -161,11 +162,15 @@ public class ControlList extends DrawableHelper implements IControlSet {
 
         int listTop = this.top + PADDING - (int) this.amountScrolled;
 
-        drawEntries(mouseX, mouseY, listTop);
+        drawEntries(matrixStack, mouseX, mouseY, listTop);
+
+        RenderHelper.enableDepthTest();
+        RenderHelper.depthFuncAlways();
 
-        RenderHelper.disableDepthTest();
         this.overlayBackground(0, this.top);
         this.overlayBackground(this.bottom, this.height);
+        RenderHelper.depthFuncLessEqual();
+        RenderHelper.disableDepthTest();
         RenderHelper.enableBlend();
         RenderHelper.blendFuncGui();
         RenderHelper.disableAlphaTest();
@@ -185,7 +190,7 @@ public class ControlList extends DrawableHelper implements IControlSet {
     }
 
     private void drawListBackground() {
-        this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
+        this.minecraft.getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
         Renderer.startTextured()
                 .setColor(32, 32, 32)
                 .setAlpha(255)
@@ -196,7 +201,7 @@ public class ControlList extends DrawableHelper implements IControlSet {
                 .render();
     }
 
-    private void drawEntries(int mouseX, int mouseY, int top) {
+    private void drawEntries(MatrixStack matrixStack, int mouseX, int mouseY, int top) {
         for (ControlListEntry entry : this.entries) {
             if (!entry.isVisible()) continue;
 
@@ -204,24 +209,27 @@ public class ControlList extends DrawableHelper implements IControlSet {
             entry.setY(top);
 
             int height = entry.getControlHeight();
-            drawEntry(mouseX, mouseY, top, entry, height);
-            top += height;
+            int bottom = top + height;
+            if(top <= this.bottom && bottom >= this.top) {
+                drawEntry(matrixStack, mouseX, mouseY, top, entry, height);
+            }
+            top = bottom;
         }
     }
 
-    protected void drawEntry(int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
-        entry.render(mouseX, mouseY);
+    protected void drawEntry(MatrixStack matrixStack, int mouseX, int mouseY, int top, ControlListEntry entry, int height) {
+        entry.render(matrixStack, mouseX, mouseY);
     }
 
     private void overlayBackground(int top, int bottom) {
-        this.minecraft.getTextureManager().bindTexture(DrawableHelper.BACKGROUND_LOCATION);
+        this.minecraft.getTextureManager().bindTexture(DrawableHelper.OPTIONS_BACKGROUND_TEXTURE);
         Renderer.startTextured()
                 .setColor(64, 64, 64)
                 .setAlpha(255)
-                .addPoint(0, bottom, 0.0D, 0.0D, (float) bottom / 32.0F)
-                .addPoint(this.width, bottom, 0.0D, (float) this.width / 32.0F, (float) bottom / 32.0F)
-                .addPoint(this.width, top, 0.0D, (float) this.width / 32.0F, (float) top / 32.0F)
-                .addPoint(0, top, 0.0D, 0.0D, (float) top / 32.0F)
+                .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();
     }