From b2a6bf46f704c6c68f7e0f46c3ed0c0d40c9ac9d Mon Sep 17 00:00:00 2001
From: SD <harrypotter.starwars.shrish@gmail.com>
Date: Sat, 26 Sep 2020 22:36:57 +0530
Subject: [PATCH] Fix portal colors

 Changes to be ommitted:
	modified:   src/main/java/org/dimdev/dimdoors/block/ModBlocks.java
	modified:   src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java
	modified:   src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java
---
 .../org/dimdev/dimdoors/block/ModBlocks.java  |  2 +-
 .../EntranceRiftBlockEntityRenderer.java      | 19 ++++++++++---------
 .../dimdev/dimdoors/client/MyRenderLayer.java |  4 ++--
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java b/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java
index 4df0c2c9..cb36fa59 100644
--- a/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java
+++ b/src/main/java/org/dimdev/dimdoors/block/ModBlocks.java
@@ -21,7 +21,7 @@ public final class ModBlocks {
     public static final Block QUARTZ_DIMENSIONAL_DOOR = register("dimdoors:quartz_dimensional_door", new DimensionalDoorBlock(FabricBlockSettings.of(Material.STONE, MaterialColor.QUARTZ).nonOpaque()));
     public static final Block OAK_DIMENSIONAL_TRAPDOOR = register("dimdoors:wood_dimensional_trapdoor", new DimensionalTrapdoorBlock(FabricBlockSettings.of(Material.WOOD, MaterialColor.WOOD).nonOpaque()));
 
-    public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).nonOpaque().dropsNothing()));
+    public static final Block DIMENSIONAL_PORTAL = register("dimdoors:dimensional_portal", new DimensionalPortalBlock(FabricBlockSettings.of(Material.AIR).collidable(false).nonOpaque().dropsNothing().lightLevel(10)));
     public static final Block DETACHED_RIFT = register("dimdoors:detached_rift", new DetachedRiftBlock(FabricBlockSettings.of(Material.AIR).nonOpaque()));
 
     public static final Block WHITE_FABRIC = registerFabric("dimdoors:white_fabric", DyeColor.WHITE);
diff --git a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java
index 81ca7225..c2c6015e 100644
--- a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java
+++ b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java
@@ -19,6 +19,7 @@ import net.minecraft.client.render.block.entity.BlockEntityRenderer;
 import net.minecraft.client.util.math.MatrixStack;
 import net.minecraft.client.util.math.Vector3f;
 import net.minecraft.util.math.Direction;
+import net.minecraft.util.math.MathHelper;
 import net.minecraft.util.math.Matrix4f;
 
 import net.fabricmc.api.EnvType;
@@ -64,14 +65,14 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
 
     private void renderVertices(EntranceRiftBlockEntity entrance, MatrixStack matrices, VertexConsumerProvider vertexConsumers, Direction orientation, Vector3f vec, List<RenderLayer> layers) {
         vec.scale((float) (orientation == Direction.NORTH || orientation == Direction.WEST || orientation == Direction.UP ? 0.01 : 0.01 - 1));
-        double d = entrance.getPos().getSquaredDistance(this.dispatcher.camera.getPos(), true);
-        int k = this.getOffset(d);
-        float g = 0.75F;
+        double squaredDistance = entrance.getPos().getSquaredDistance(this.dispatcher.camera.getPos(), true);
+        int offset = this.getOffset(squaredDistance);
+        float u = 0.75F;
         Matrix4f matrix4f = matrices.peek().getModel();
-        this.drawAllVertices(entrance, g, 0.15F, matrix4f, vertexConsumers.getBuffer(layers.get(0)), orientation);
+        this.drawAllVertices(entrance, u, 0.15F, matrix4f, vertexConsumers.getBuffer(layers.get(0)), orientation);
 
-        for(int l = 1; l < k; ++l) {
-            this.drawAllVertices(entrance, g, 2.0F / (float)(18 - l), matrix4f, vertexConsumers.getBuffer(layers.get(l)), orientation);
+        for(int i = 1; i < offset; ++i) {
+            this.drawAllVertices(entrance, u, 2.0F / (float)(18 - i), matrix4f, vertexConsumers.getBuffer(layers.get(i)), orientation);
         }
     }
 
@@ -96,9 +97,9 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
     }
 
     private void drawAllVertices(EntranceRiftBlockEntity blockEntity, float u, float v, Matrix4f matrix4f, VertexConsumer vertexConsumer, Direction dir) {
-        float r = (RANDOM.nextFloat() * 0.5F + 0.1F) * v;
-        float g = (RANDOM.nextFloat() * 0.5F + 0.4F) * v;
-        float b = (RANDOM.nextFloat() * 0.5F + 0.5F) * v;
+        float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * v, 0, 1);
+        float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * v, 0, 1);
+        float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * v, 0, 1);
         this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, r, g, b, Direction.SOUTH);
         this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, r, g, b, Direction.NORTH);
         this.drawVertices(blockEntity, matrix4f, vertexConsumer, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, r, g, b, Direction.EAST);
diff --git a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java
index f186d5d4..6b3fb8f6 100644
--- a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java
+++ b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java
@@ -86,10 +86,10 @@ public class MyRenderLayer extends RenderLayer {
         RenderPhase.Texture texture;
         if (layer <= 1) {
             transparency = TRANSLUCENT_TRANSPARENCY;
-            texture = new RenderPhase.Texture(WARP_PATH, false, false);
+            texture = new RenderPhase.Texture(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false);
         } else {
             transparency = ADDITIVE_TRANSPARENCY;
-            texture = new RenderPhase.Texture(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false);
+            texture = new RenderPhase.Texture(WARP_PATH, false, false);
         }
 
         return of("dimensional_portal", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().transparency(transparency).texture(texture).texturing(new RenderPhase.PortalTexturing(layer)).fog(BLACK_FOG).build(false));