From baf2bd23731ef7b4304183392ef96d9cf0111226 Mon Sep 17 00:00:00 2001 From: SD Date: Mon, 22 Mar 2021 16:11:09 +0530 Subject: [PATCH] 20w10a, Shaders --- build.gradle | 28 +- settings.gradle | 1 - .../dimdoors/datagen/RecipeConsumer.java | 2 +- .../block/entity/EntranceRiftBlockEntity.java | 10 + .../dimdoors/client/CustomSkyProvider.java | 246 +++++++++--------- .../client/DimensionalPortalRenderer.java | 115 -------- .../EntranceRiftBlockEntityRenderer.java | 58 ++++- .../dimdoors/client/LimboSkyProvider.java | 102 ++++---- .../dimdev/dimdoors/client/ModShaders.java | 15 ++ .../dimdoors/client/ModSkyRendering.java | 15 +- .../dimdev/dimdoors/client/MyRenderLayer.java | 38 +-- .../org/dimdev/dimdoors/item/RiftKeyItem.java | 2 +- .../mixin/{ => accessor}/ListTagAccessor.java | 2 +- .../RecipesProviderAccessor.java | 2 +- .../mixin/client/GameRendererMixin.java | 32 +++ .../dimdoors/mixin/client/InGameHudMixin.java | 7 +- .../accessor/GlStateManagerAccessor.java | 19 -- .../dimdev/dimdoors/pockets/PocketLoader.java | 6 +- .../pockets/modifier/ShellModifier.java | 6 +- .../shaders/core/dimensional_portal.fsh | 64 +++++ .../shaders/core/dimensional_portal.json | 20 ++ .../shaders/core/dimensional_portal.vsh | 18 ++ src/main/resources/dimdoors.mixins.json | 6 +- .../pockets/schematic/custom/party.schem | Bin 1609 -> 1613 bytes .../pockets/schematic/custom/smile_6.schem | Bin 717 -> 711 bytes .../schematic/custom/waiting_room.schem | Bin 1092 -> 1085 bytes .../util/schematic/SchematicBlockPalette.java | 47 +++- 27 files changed, 464 insertions(+), 397 deletions(-) delete mode 100644 src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java create mode 100644 src/main/java/org/dimdev/dimdoors/client/ModShaders.java rename src/main/java/org/dimdev/dimdoors/mixin/{ => accessor}/ListTagAccessor.java (89%) rename src/main/java/org/dimdev/dimdoors/mixin/{ => accessor}/RecipesProviderAccessor.java (93%) create mode 100644 src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java delete mode 100644 src/main/java/org/dimdev/dimdoors/mixin/client/accessor/GlStateManagerAccessor.java create mode 100644 src/main/resources/assets/minecraft/shaders/core/dimensional_portal.fsh create mode 100644 src/main/resources/assets/minecraft/shaders/core/dimensional_portal.json create mode 100644 src/main/resources/assets/minecraft/shaders/core/dimensional_portal.vsh diff --git a/build.gradle b/build.gradle index 559bce7e..bd8c306f 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "fabric-loom" version "0.6-SNAPSHOT" + id "fabric-loom" version "0.7-SNAPSHOT" id "maven-publish" id 'com.matthewprenger.cursegradle' version "1.4.0" } @@ -29,10 +29,6 @@ repositories { } } - maven { - url = "https://jitpack.io" - } - maven { url = "https://server.bbkr.space/artifactory/libs-release" content { @@ -48,6 +44,14 @@ repositories { maven { url = "https://maven.shedaniel.me/" } + + maven { + url = "https://bai.jfrog.io/artifactory/maven" + } + + maven { + url = "https://jitpack.io" + } } def includeCompile(group, artifact, version) { @@ -95,7 +99,7 @@ dependencies { includeCompile("org.jgrapht", "jgrapht-core", "1.1.0") includeCompile("com.github.DimensionalDevelopment", "poly2tri.java", "0.1.1") includeCompile("com.github.DimensionalDevelopment", "Matrix", "1.0.0") - includeCompile("io.github.BoogieMonster1O1", "OpenWorlds", "c57e3ef") +// includeCompile("io.github.BoogieMonster1O1", "OpenWorlds", "c57e3ef") includeCompile("io.github.cottonmc", "LibGui", "3.3.2+1.16.4") includeCompile("me.shedaniel.cloth", "config-2", "5.0.0") includeCompile("io.github.onyxstudios.Cardinal-Components-API", "cardinal-components-base", "3.0.0-nightly.21w06a") @@ -110,11 +114,17 @@ dependencies { modCompileOnly("io.github.prospector:modmenu:2.0.0-beta.1+build.2") { exclude module: "fabric-api" } - modRuntime("io.github.prospector:modmenu:2.0.0-beta.1+build.2") { +// modRuntime("io.github.prospector:modmenu:2.0.0-beta.1+build.2") { +// exclude module: "fabric-api" +// } + modCompileOnly('mcp.mobius.waila:wthit-fabric:3.2.3') { + exclude module: "modmenu" + exclude module: "fabric-api" + } + modRuntime('mcp.mobius.waila:wthit-fabric:3.2.3') { + exclude module: "modmenu" exclude module: "fabric-api" } - modCompileOnly 'com.github.badasintended:wthit:3.0.0' - modRuntime 'com.github.badasintended:wthit:3.0.0' modCompileOnly "me.shedaniel.cloth.api:cloth-datagen-api-v1:2.0.0" modRuntime "me.shedaniel.cloth.api:cloth-datagen-api-v1:2.0.0" diff --git a/settings.gradle b/settings.gradle index 3b534539..2e69b8a1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,6 +1,5 @@ pluginManagement { repositories { - jcenter() maven { name = 'Fabric' url = 'https://maven.fabricmc.net/' diff --git a/src/datagen/java/org/dimdev/dimdoors/datagen/RecipeConsumer.java b/src/datagen/java/org/dimdev/dimdoors/datagen/RecipeConsumer.java index 0d5c0d09..a1cc2f35 100644 --- a/src/datagen/java/org/dimdev/dimdoors/datagen/RecipeConsumer.java +++ b/src/datagen/java/org/dimdev/dimdoors/datagen/RecipeConsumer.java @@ -8,7 +8,7 @@ import java.util.function.Consumer; import com.google.common.collect.Sets; import com.google.gson.JsonObject; -import org.dimdev.dimdoors.mixin.RecipesProviderAccessor; +import org.dimdev.dimdoors.mixin.accessor.RecipesProviderAccessor; import net.minecraft.data.DataCache; import net.minecraft.data.DataGenerator; diff --git a/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java b/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java index ba83f11d..a54b0889 100644 --- a/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java +++ b/src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java @@ -4,6 +4,8 @@ import java.util.Optional; import org.dimdev.dimdoors.DimensionalDoorsInitializer; import org.dimdev.dimdoors.block.CoordinateTransformerBlock; +import org.dimdev.dimdoors.client.DefaultTransformation; +import org.dimdev.dimdoors.client.Transformer; import org.dimdev.dimdoors.item.RiftKeyItem; import org.dimdev.dimdoors.rift.registry.Rift; import org.dimdev.dimdoors.util.EntityUtils; @@ -26,6 +28,9 @@ import net.minecraft.util.math.Direction; import net.minecraft.util.math.EulerAngle; import net.minecraft.util.math.Vec3d; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + public class EntranceRiftBlockEntity extends RiftBlockEntity { private boolean locked; @@ -117,6 +122,11 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity { .orElse(Direction.NORTH); } + @Environment(EnvType.CLIENT) + public Transformer getTransformer() { + return DefaultTransformation.fromDirection(this.getOrientation()); + } + public boolean hasOrientation() { return this.world != null && this.world.getBlockState(this.pos).contains(HorizontalFacingBlock.FACING); } diff --git a/src/main/java/org/dimdev/dimdoors/client/CustomSkyProvider.java b/src/main/java/org/dimdev/dimdoors/client/CustomSkyProvider.java index e8193c64..2e1d6403 100644 --- a/src/main/java/org/dimdev/dimdoors/client/CustomSkyProvider.java +++ b/src/main/java/org/dimdev/dimdoors/client/CustomSkyProvider.java @@ -1,123 +1,123 @@ -package org.dimdev.dimdoors.client; - -import io.github.waterpicker.openworlds.renderer.SkyRenderer; -import com.mojang.blaze3d.systems.RenderSystem; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.render.BufferBuilder; -import net.minecraft.client.render.BufferRenderer; -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.Identifier; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.util.math.Vec3f; -import net.minecraft.util.math.Vec3i; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -public class CustomSkyProvider implements SkyRenderer { - private final Identifier moon; - private final Identifier sun; - private final Vec3i color; - - public CustomSkyProvider(Identifier moon, Identifier sun, Vec3i color) { - this.moon = moon; - this.sun = sun; - this.color = color; - } - - @Override - public void render(MinecraftClient client, MatrixStack matrices, float tickDelta) { - BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); - RenderSystem.disableAlphaTest(); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.depthMask(false); - - matrices.push(); - - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); - Matrix4f matrix4f2 = matrices.peek().getModel(); - - float s = 30.0F; - client.getTextureManager().bindTexture(this.sun); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); - bufferBuilder.vertex(matrix4f2, -s, 100.0F, -s).texture(0.0F, 0.0F).next(); - bufferBuilder.vertex(matrix4f2, s, 100.0F, -s).texture(1.0F, 0.0F).next(); - bufferBuilder.vertex(matrix4f2, s, 100.0F, s).texture(1.0F, 1.0F).next(); - bufferBuilder.vertex(matrix4f2, -s, 100.0F, s).texture(0.0F, 1.0F).next(); - bufferBuilder.end(); - BufferRenderer.draw(bufferBuilder); - - client.getTextureManager().bindTexture(this.moon); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); - bufferBuilder.vertex(matrix4f2, -s, -100.0F, s).texture(0f, 0f).next(); - bufferBuilder.vertex(matrix4f2, s, -100.0F, s).texture(1f, 0f).next(); - bufferBuilder.vertex(matrix4f2, s, -100.0F, -s).texture(1f, 1f).next(); - bufferBuilder.vertex(matrix4f2, -s, -100.0F, -s).texture(0f, 1f).next(); - bufferBuilder.end(); - BufferRenderer.draw(bufferBuilder); - - matrices.pop(); - - RenderSystem.depthMask(true); - RenderSystem.enableTexture(); - RenderSystem.disableBlend(); - RenderSystem.enableAlphaTest(); - - this.renderSkyBox(matrices); - } - - protected void renderSkyBox(MatrixStack matrices) { - RenderSystem.disableAlphaTest(); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.depthMask(false); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - - for (int i = 0; i < 6; ++i) { - matrices.push(); - this.multiply(matrices, i); - Matrix4f matrix4f = matrices.peek().getModel(); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); - bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); - bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); - bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); - bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); - tessellator.draw(); - matrices.pop(); - } - - RenderSystem.depthMask(true); - RenderSystem.enableTexture(); - RenderSystem.disableBlend(); - RenderSystem.enableAlphaTest(); - } - - protected void multiply(MatrixStack matrices, int i) { - if (i == 1) { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); - } - - if (i == 2) { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(-90.0F)); - } - - if (i == 3) { - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); - } - - if (i == 4) { - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(90.0F)); - } - - if (i == 5) { - matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(-90.0F)); - } - } -} +//package org.dimdev.dimdoors.client; +// +//import io.github.waterpicker.openworlds.renderer.SkyRenderer; +//import com.mojang.blaze3d.systems.RenderSystem; +// +//import net.minecraft.client.MinecraftClient; +//import net.minecraft.client.render.BufferBuilder; +//import net.minecraft.client.render.BufferRenderer; +//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.Identifier; +//import net.minecraft.util.math.Matrix4f; +//import net.minecraft.util.math.Vec3f; +//import net.minecraft.util.math.Vec3i; +// +//import net.fabricmc.api.EnvType; +//import net.fabricmc.api.Environment; +// +//@Environment(EnvType.CLIENT) +//public class CustomSkyProvider implements SkyRenderer { +// private final Identifier moon; +// private final Identifier sun; +// private final Vec3i color; +// +// public CustomSkyProvider(Identifier moon, Identifier sun, Vec3i color) { +// this.moon = moon; +// this.sun = sun; +// this.color = color; +// } +// +// @Override +// public void render(MinecraftClient client, MatrixStack matrices, float tickDelta) { +// BufferBuilder bufferBuilder = Tessellator.getInstance().getBuffer(); +//// RenderSystem.disableAlphaTest(); +// RenderSystem.enableBlend(); +// RenderSystem.defaultBlendFunc(); +// RenderSystem.depthMask(false); +// +// matrices.push(); +// +// matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-90.0F)); +// Matrix4f matrix4f2 = matrices.peek().getModel(); +// +// float s = 30.0F; +// client.getTextureManager().bindTexture(this.sun); +// bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); +// bufferBuilder.vertex(matrix4f2, -s, 100.0F, -s).texture(0.0F, 0.0F).next(); +// bufferBuilder.vertex(matrix4f2, s, 100.0F, -s).texture(1.0F, 0.0F).next(); +// bufferBuilder.vertex(matrix4f2, s, 100.0F, s).texture(1.0F, 1.0F).next(); +// bufferBuilder.vertex(matrix4f2, -s, 100.0F, s).texture(0.0F, 1.0F).next(); +// bufferBuilder.end(); +// BufferRenderer.draw(bufferBuilder); +// +// client.getTextureManager().bindTexture(this.moon); +// bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE); +// bufferBuilder.vertex(matrix4f2, -s, -100.0F, s).texture(0f, 0f).next(); +// bufferBuilder.vertex(matrix4f2, s, -100.0F, s).texture(1f, 0f).next(); +// bufferBuilder.vertex(matrix4f2, s, -100.0F, -s).texture(1f, 1f).next(); +// bufferBuilder.vertex(matrix4f2, -s, -100.0F, -s).texture(0f, 1f).next(); +// bufferBuilder.end(); +// BufferRenderer.draw(bufferBuilder); +// +// matrices.pop(); +// +// RenderSystem.depthMask(true); +// RenderSystem.enableTexture(); +// RenderSystem.disableBlend(); +//// RenderSystem.enableAlphaTest(); +// +// this.renderSkyBox(matrices); +// } +// +// protected void renderSkyBox(MatrixStack matrices) { +//// RenderSystem.disableAlphaTest(); +// RenderSystem.enableBlend(); +// RenderSystem.defaultBlendFunc(); +// RenderSystem.depthMask(false); +// Tessellator tessellator = Tessellator.getInstance(); +// BufferBuilder bufferBuilder = tessellator.getBuffer(); +// +// for (int i = 0; i < 6; ++i) { +// matrices.push(); +// this.multiply(matrices, i); +// Matrix4f matrix4f = matrices.peek().getModel(); +// bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR); +// bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); +// bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); +// bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); +// bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).color(this.color.getX(), this.color.getY(), this.color.getZ(), 255).next(); +// tessellator.draw(); +// matrices.pop(); +// } +// +// RenderSystem.depthMask(true); +// RenderSystem.enableTexture(); +// RenderSystem.disableBlend(); +//// RenderSystem.enableAlphaTest(); +// } +// +// protected void multiply(MatrixStack matrices, int i) { +// if (i == 1) { +// matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(90.0F)); +// } +// +// if (i == 2) { +// matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(-90.0F)); +// } +// +// if (i == 3) { +// matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(180.0F)); +// } +// +// if (i == 4) { +// matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(90.0F)); +// } +// +// if (i == 5) { +// matrices.multiply(Vec3f.POSITIVE_Z.getDegreesQuaternion(-90.0F)); +// } +// } +//} diff --git a/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java b/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java deleted file mode 100644 index 9203be49..00000000 --- a/src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.dimdev.dimdoors.client; - -import java.util.Collections; -import java.util.List; -import java.util.Random; -import java.util.stream.Collectors; -import java.util.stream.IntStream; - -import com.google.common.collect.ImmutableList; - -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.model.ModelPart; -import net.minecraft.client.render.RenderLayer; -import net.minecraft.client.render.VertexConsumer; -import net.minecraft.client.render.VertexConsumerProvider; -import net.minecraft.client.render.entity.EntityRenderDispatcher; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -public final class DimensionalPortalRenderer { - private static final Random RANDOM = new Random(31100L); - private static final ModelPart MODEL; - private static final ModelPart TALL_MODEL; - private static final EntityRenderDispatcher ENTITY_RENDER_DISPATCHER; - private static final List RENDER_LAYERS = ImmutableList.copyOf(IntStream.range(0, 16).mapToObj(MyRenderLayer::getPortal).collect(Collectors.toList())); - - public static void renderWithTransforms(MatrixStack matrices, BlockPos pos, Transformer transformer, VertexConsumerProvider vertexConsumers, int light, int overlay, boolean tall) { - matrices.push(); - double squaredDistance = pos.getSquaredDistance(ENTITY_RENDER_DISPATCHER.camera.getPos(), true); - int offset = getOffset(squaredDistance); - transformer.transform(matrices); - renderModels(vertexConsumers, matrices, light, overlay, tall, offset); - matrices.pop(); - } - - private static void renderModels(VertexConsumerProvider vertexConsumers, MatrixStack matrices, int light, int overlay, boolean tall, int offset) { - renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(0)), matrices, light, overlay, 0.15F, tall); - - for (int count = 1; count < offset; ++count) { - renderSingleModel(vertexConsumers.getBuffer(RENDER_LAYERS.get(count)), matrices, light, overlay, 2.0F / (float) (18 - count), tall); - } - } - - private static void renderSingleModel(VertexConsumer vertexConsumer, MatrixStack matrices, int light, int overlay, float delta, boolean tall) { - float r = MathHelper.clamp((RANDOM.nextFloat() * 0.3F + 0.1F) * delta, 0, 1); - float g = MathHelper.clamp((RANDOM.nextFloat() * 0.4F + 0.1F) * delta, 0, 1); - float b = MathHelper.clamp((RANDOM.nextFloat() * 0.5F + 0.6F) * delta, 0, 1); - - ModelPart model = tall ? TALL_MODEL : MODEL; - model.render(matrices, vertexConsumer, light, overlay, r, g, b, 1); - } - - private static int getOffset(double d) { - if (d > 36864.0D) { - return 1; - } else if (d > 25600.0D) { - return 3; - } else if (d > 16384.0D) { - return 5; - } else if (d > 9216.0D) { - return 7; - } else if (d > 4096.0D) { - return 9; - } else if (d > 1024.0D) { - return 11; - } else if (d > 576.0D) { - return 13; - } else { - return d > 256.0D ? 14 : 15; - } - } - - static { - ModelPart.Cuboid small = new ModelPart.Cuboid( - 0, - 0, - 0, - 0, - 0, - 16, - 16, - 0, - 0, - 0, - 0, - false, - 1024, - 1024 - ); - MODEL = new ModelPart(Collections.singletonList(small), Collections.emptyMap()); - ModelPart.Cuboid big = new ModelPart.Cuboid( - 0, - 0, - 0, - 0, - 0, - 16, - 32, - 0, - 0, - 0, - 0, - false, - 1024, - 1024 - ); - TALL_MODEL = new ModelPart(Collections.singletonList(big), Collections.emptyMap()); - ENTITY_RENDER_DISPATCHER = MinecraftClient.getInstance().getEntityRenderDispatcher(); - } -} diff --git a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java index c801b810..e1191ec1 100644 --- a/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java +++ b/src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java @@ -1,26 +1,66 @@ package org.dimdev.dimdoors.client; +import java.util.Collections; + import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; +import net.minecraft.client.model.ModelPart; +import net.minecraft.client.render.RenderLayer; +import net.minecraft.client.render.RenderPhase; +import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.VertexConsumerProvider; +import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.VertexFormats; import net.minecraft.client.render.block.entity.BlockEntityRenderer; +import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.util.Identifier; +import net.minecraft.util.math.Matrix4f; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public class EntranceRiftBlockEntityRenderer implements BlockEntityRenderer { + public static final Identifier WARP_PATH; + private static final RenderPhase.class_5942 DIMENSIONAL_PORTAL_SHADER; + private static final RenderLayer RENDER_LAYER; + private static final ModelPart MODEL; + private static final ModelPart TALL_MODEL; + @Override - public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) { - DimensionalPortalRenderer.renderWithTransforms( - matrices, - blockEntity.getPos(), - DefaultTransformation.fromDirection(blockEntity.getOrientation()), - vertexConsumers, - light, - overlay, - blockEntity.isTall() + public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, int overlay) { + blockEntity.getTransformer().transform(matrixStack); + if (blockEntity.isTall()) { + TALL_MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay); + } else { + MODEL.render(matrixStack, vertexConsumerProvider.getBuffer(RENDER_LAYER), light, overlay); + } + } + + static { + WARP_PATH = new Identifier("dimdoors:textures/other/warp.png"); + DIMENSIONAL_PORTAL_SHADER = new RenderPhase.class_5942(ModShaders::getDimensionalPortal); + RENDER_LAYER = RenderLayer.of( + "dimensional_portal", + VertexFormats.POSITION, + VertexFormat.DrawMode.QUADS, + 256, + false, + false, + RenderLayer.MultiPhaseParameters.builder() + .method_34578(DIMENSIONAL_PORTAL_SHADER) + .method_34577( + RenderPhase.class_5940.method_34560() + .method_34563(EndPortalBlockEntityRenderer.SKY_TEXTURE, false, false) + .method_34563(WARP_PATH, false, false) + .method_34562() + ) + .build(false) ); + ModelPart.Cuboid small = new ModelPart.Cuboid(0, 0, 0, 0, 0, 16, 16, 0.2F, 0, 0, 0, false, 1024, 1024); + MODEL = new ModelPart(Collections.singletonList(small), Collections.emptyMap()); + ModelPart.Cuboid big = new ModelPart.Cuboid(0, 0, 0, 0, 0, 16, 32, 0.2F, 0, 0, 0, false, 1024, 1024); + TALL_MODEL = new ModelPart(Collections.singletonList(big), Collections.emptyMap()); } } diff --git a/src/main/java/org/dimdev/dimdoors/client/LimboSkyProvider.java b/src/main/java/org/dimdev/dimdoors/client/LimboSkyProvider.java index e7f3edb6..1c845001 100644 --- a/src/main/java/org/dimdev/dimdoors/client/LimboSkyProvider.java +++ b/src/main/java/org/dimdev/dimdoors/client/LimboSkyProvider.java @@ -1,51 +1,51 @@ -package org.dimdev.dimdoors.client; - -import com.mojang.blaze3d.systems.RenderSystem; - -import net.minecraft.client.MinecraftClient; -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.render.block.entity.EndPortalBlockEntityRenderer; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.util.math.Vec3i; - -public class LimboSkyProvider extends CustomSkyProvider { - public static final Identifier MOON_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_moon.png"); - public static final Identifier SUN_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_sun.png"); - public static final Identifier GREY_TEX = new Identifier("dimdoors:textures/other/grey.png"); - - public LimboSkyProvider() { - super(MOON_RENDER_PATH, SUN_RENDER_PATH, new Vec3i(0, 0, 0)); - } - - @Override - protected void renderSkyBox(MatrixStack matrices) { - RenderSystem.disableAlphaTest(); - RenderSystem.enableBlend(); - RenderSystem.defaultBlendFunc(); - RenderSystem.depthMask(false); - MinecraftClient.getInstance().getTextureManager().bindTexture(GREY_TEX); - Tessellator tessellator = Tessellator.getInstance(); - BufferBuilder bufferBuilder = tessellator.getBuffer(); - for (int i = 0; i < 6; ++i) { - matrices.push(); - this.multiply(matrices, i); - Matrix4f matrix4f = matrices.peek().getModel(); - bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); - bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).texture(0.0F, 0.0F).color(40, 40, 40, 255).next(); - bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).texture(0.0F, 16.0F).color(40, 40, 40, 255).next(); - bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).texture(16.0F, 16.0F).color(40, 40, 40, 255).next(); - bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).texture(16.0F, 0.0F).color(40, 40, 40, 255).next(); - tessellator.draw(); - matrices.pop(); - } - RenderSystem.depthMask(true); - RenderSystem.enableTexture(); - RenderSystem.disableBlend(); - RenderSystem.enableAlphaTest(); - } -} +//package org.dimdev.dimdoors.client; +// +//import com.mojang.blaze3d.systems.RenderSystem; +// +//import net.minecraft.client.MinecraftClient; +//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.render.block.entity.EndPortalBlockEntityRenderer; +//import net.minecraft.client.util.math.MatrixStack; +//import net.minecraft.util.Identifier; +//import net.minecraft.util.math.Matrix4f; +//import net.minecraft.util.math.Vec3i; +// +//public class LimboSkyProvider extends CustomSkyProvider { +// public static final Identifier MOON_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_moon.png"); +// public static final Identifier SUN_RENDER_PATH = new Identifier("dimdoors:textures/other/limbo_sun.png"); +// public static final Identifier GREY_TEX = new Identifier("dimdoors:textures/other/grey.png"); +// +// public LimboSkyProvider() { +// super(MOON_RENDER_PATH, SUN_RENDER_PATH, new Vec3i(0, 0, 0)); +// } +// +// @Override +// protected void renderSkyBox(MatrixStack matrices) { +//// RenderSystem.disableAlphaTest(); +// RenderSystem.enableBlend(); +// RenderSystem.defaultBlendFunc(); +// RenderSystem.depthMask(false); +// MinecraftClient.getInstance().getTextureManager().bindTexture(GREY_TEX); +// Tessellator tessellator = Tessellator.getInstance(); +// BufferBuilder bufferBuilder = tessellator.getBuffer(); +// for (int i = 0; i < 6; ++i) { +// matrices.push(); +// this.multiply(matrices, i); +// Matrix4f matrix4f = matrices.peek().getModel(); +// bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR); +// bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, -100.0F).texture(0.0F, 0.0F).color(40, 40, 40, 255).next(); +// bufferBuilder.vertex(matrix4f, -100.0F, -100.0F, 100.0F).texture(0.0F, 16.0F).color(40, 40, 40, 255).next(); +// bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, 100.0F).texture(16.0F, 16.0F).color(40, 40, 40, 255).next(); +// bufferBuilder.vertex(matrix4f, 100.0F, -100.0F, -100.0F).texture(16.0F, 0.0F).color(40, 40, 40, 255).next(); +// tessellator.draw(); +// matrices.pop(); +// } +// RenderSystem.depthMask(true); +// RenderSystem.enableTexture(); +// RenderSystem.disableBlend(); +//// RenderSystem.enableAlphaTest(); +// } +//} diff --git a/src/main/java/org/dimdev/dimdoors/client/ModShaders.java b/src/main/java/org/dimdev/dimdoors/client/ModShaders.java new file mode 100644 index 00000000..b7db5f5c --- /dev/null +++ b/src/main/java/org/dimdev/dimdoors/client/ModShaders.java @@ -0,0 +1,15 @@ +package org.dimdev.dimdoors.client; + +import net.minecraft.class_5944; + +public class ModShaders { + private static class_5944 DIMENSIONAL_PORTAL = null; + + public static void setDimensionalPortal(class_5944 dimensionalPortal) { + DIMENSIONAL_PORTAL = dimensionalPortal; + } + + public static class_5944 getDimensionalPortal() { + return DIMENSIONAL_PORTAL; + } +} diff --git a/src/main/java/org/dimdev/dimdoors/client/ModSkyRendering.java b/src/main/java/org/dimdev/dimdoors/client/ModSkyRendering.java index e4f71468..c33143ce 100644 --- a/src/main/java/org/dimdev/dimdoors/client/ModSkyRendering.java +++ b/src/main/java/org/dimdev/dimdoors/client/ModSkyRendering.java @@ -1,20 +1,15 @@ package org.dimdev.dimdoors.client; -import io.github.waterpicker.openworlds.OpenWorlds; -import org.dimdev.dimdoors.world.ModDimensions; - -import net.minecraft.util.math.Vec3i; - import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) public class ModSkyRendering { public static void initClient() { - OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE_KEY, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0))); - OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE_KEY, new LimboSkyProvider()); - OpenWorlds.registerCloudRenderer(ModDimensions.LIMBO_TYPE_KEY, (minecraftClient, matrixStack, v, v1, v2, v3) -> { - }); - OpenWorlds.registerSkyProperty(ModDimensions.LIMBO_TYPE_KEY, new LimboSkyProperties()); +// OpenWorlds.registerSkyRenderer(ModDimensions.POCKET_TYPE_KEY, new CustomSkyProvider(null, null, new Vec3i(0, 0, 0))); +// OpenWorlds.registerSkyRenderer(ModDimensions.LIMBO_TYPE_KEY, new LimboSkyProvider()); +// OpenWorlds.registerCloudRenderer(ModDimensions.LIMBO_TYPE_KEY, (minecraftClient, matrixStack, v, v1, v2, v3) -> { +// }); +// OpenWorlds.registerSkyProperty(ModDimensions.LIMBO_TYPE_KEY, new LimboSkyProperties()); } } diff --git a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java index 49b7d3c0..09ee8cc1 100644 --- a/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java +++ b/src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java @@ -34,7 +34,7 @@ public class MyRenderLayer extends RenderLayer { MultiPhaseParameters.builder() .cull(DISABLE_CULLING) .lightmap(RenderPhase.DISABLE_LIGHTMAP) - .texture(NO_TEXTURE) + .method_34577(NO_TEXTURE) .transparency(new Transparency("crack_transparency", () -> { RenderSystem.enableBlend(); @@ -55,46 +55,16 @@ public class MyRenderLayer extends RenderLayer { MultiPhaseParameters.builder() .cull(DISABLE_CULLING) .lightmap(RenderPhase.DISABLE_LIGHTMAP) - .texture(new Texture(DetachedRiftBlockEntityRenderer.TESSERACT_PATH, + .method_34577(new Texture(DetachedRiftBlockEntityRenderer.TESSERACT_PATH, false, false) ) - .alpha(Alpha.HALF_ALPHA) +// .alpha(Alpha.HALF_ALPHA) .build(false) ); - public static RenderLayer getPortal(int layer) { - RenderPhase.Transparency transparency; - RenderPhase.Texture texture; - if (layer <= 1) { - transparency = TRANSLUCENT_TRANSPARENCY; - texture = new RenderPhase.Texture(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, - false, - false - ); - } else { - transparency = ADDITIVE_TRANSPARENCY; - texture = new RenderPhase.Texture(WARP_PATH, false, false); - } - - return of( - "dimensional_portal", - VertexFormats.POSITION_COLOR, - VertexFormat.DrawMode.QUADS, - 256, - false, - true, - RenderLayer.MultiPhaseParameters.builder() - .transparency(transparency) - .texture(texture) - .texturing(new RenderPhase.PortalTexturing(layer)) - .fog(BLACK_FOG) - .build(false) - ); - } - public static RenderLayer getMonolith(Identifier texture) { - RenderLayer.MultiPhaseParameters multiPhaseParameters = RenderLayer.MultiPhaseParameters.builder().texture(new RenderPhase.Texture(texture, false, false)).transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY).diffuseLighting(RenderPhase.ENABLE_DIFFUSE_LIGHTING).alpha(RenderPhase.ONE_TENTH_ALPHA).cull(DISABLE_CULLING).lightmap(ENABLE_LIGHTMAP).depthTest(RenderPhase.ALWAYS_DEPTH_TEST).overlay(ENABLE_OVERLAY_COLOR).build(false); + RenderLayer.MultiPhaseParameters multiPhaseParameters = RenderLayer.MultiPhaseParameters.builder().method_34577(new RenderPhase.Texture(texture, false, false)).transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY).cull(DISABLE_CULLING).lightmap(ENABLE_LIGHTMAP).depthTest(RenderPhase.ALWAYS_DEPTH_TEST).overlay(ENABLE_OVERLAY_COLOR).build(false); return RenderLayer.of("monolith", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, true, multiPhaseParameters); } } diff --git a/src/main/java/org/dimdev/dimdoors/item/RiftKeyItem.java b/src/main/java/org/dimdev/dimdoors/item/RiftKeyItem.java index d8b9e127..52e6ef9e 100644 --- a/src/main/java/org/dimdev/dimdoors/item/RiftKeyItem.java +++ b/src/main/java/org/dimdev/dimdoors/item/RiftKeyItem.java @@ -8,7 +8,7 @@ import java.util.stream.Collectors; import org.dimdev.dimdoors.block.RiftProvider; import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity; import org.dimdev.dimdoors.block.entity.RiftBlockEntity; -import org.dimdev.dimdoors.mixin.ListTagAccessor; +import org.dimdev.dimdoors.mixin.accessor.ListTagAccessor; import org.dimdev.dimdoors.rift.registry.Rift; import org.dimdev.dimdoors.util.EntityUtils; import org.dimdev.dimdoors.util.Location; diff --git a/src/main/java/org/dimdev/dimdoors/mixin/ListTagAccessor.java b/src/main/java/org/dimdev/dimdoors/mixin/accessor/ListTagAccessor.java similarity index 89% rename from src/main/java/org/dimdev/dimdoors/mixin/ListTagAccessor.java rename to src/main/java/org/dimdev/dimdoors/mixin/accessor/ListTagAccessor.java index 84128880..dad4a5af 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/ListTagAccessor.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/accessor/ListTagAccessor.java @@ -1,4 +1,4 @@ -package org.dimdev.dimdoors.mixin; +package org.dimdev.dimdoors.mixin.accessor; import java.util.List; diff --git a/src/main/java/org/dimdev/dimdoors/mixin/RecipesProviderAccessor.java b/src/main/java/org/dimdev/dimdoors/mixin/accessor/RecipesProviderAccessor.java similarity index 93% rename from src/main/java/org/dimdev/dimdoors/mixin/RecipesProviderAccessor.java rename to src/main/java/org/dimdev/dimdoors/mixin/accessor/RecipesProviderAccessor.java index 28b84ef4..5072f949 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/RecipesProviderAccessor.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/accessor/RecipesProviderAccessor.java @@ -1,4 +1,4 @@ -package org.dimdev.dimdoors.mixin; +package org.dimdev.dimdoors.mixin.accessor; import java.nio.file.Path; diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java new file mode 100644 index 00000000..7ca83329 --- /dev/null +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/GameRendererMixin.java @@ -0,0 +1,32 @@ +package org.dimdev.dimdoors.mixin.client; + +import java.io.IOException; + +import org.dimdev.dimdoors.client.ModShaders; +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; + +import net.minecraft.class_5912; +import net.minecraft.class_5944; +import net.minecraft.client.render.GameRenderer; +import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.VertexFormats; +import net.minecraft.resource.ResourceManager; + +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; + +@Environment(EnvType.CLIENT) +@Mixin(GameRenderer.class) +public abstract class GameRendererMixin { + @Shadow + protected abstract class_5944 method_34522(class_5912 arg, String string, VertexFormat vertexFormat) throws IOException; + + @Inject(method = "method_34538", at = @At(value = "INVOKE", ordinal = 1, target = "Lnet/minecraft/client/render/GameRenderer;method_34522(Lnet/minecraft/class_5912;Ljava/lang/String;Lnet/minecraft/client/render/VertexFormat;)Lnet/minecraft/class_5944;")) + public void onReload(ResourceManager resourceManager, CallbackInfo ci) throws IOException { + ModShaders.setDimensionalPortal(this.method_34522(resourceManager, "dimensional_portal", VertexFormats.POSITION)); + } +} diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java index c1c4f834..64014584 100644 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java +++ b/src/main/java/org/dimdev/dimdoors/mixin/client/InGameHudMixin.java @@ -2,6 +2,7 @@ package org.dimdev.dimdoors.mixin.client; import com.mojang.blaze3d.systems.RenderSystem; import org.dimdev.dimdoors.world.ModBiomes; +import org.dimdev.dimdoors.world.ModDimensions; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -16,10 +17,10 @@ import net.fabricmc.api.Environment; @Environment(EnvType.CLIENT) @Mixin(InGameHud.class) public class InGameHudMixin { - @Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getTextureManager()Lnet/minecraft/client/texture/TextureManager;"), method = "renderVignetteOverlay(Lnet/minecraft/entity/Entity;)V") + @Inject(at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShader(Ljava/util/function/Supplier;)V"), method = "renderVignetteOverlay(Lnet/minecraft/entity/Entity;)V") public void renderVignetteOverlay(Entity entity, CallbackInfo info) { - if (entity.world.getBiome(entity.getBlockPos()) == ModBiomes.LIMBO_BIOME) { - RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F); + if (ModDimensions.isLimboDimension(entity.world)) { + RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F); } } } diff --git a/src/main/java/org/dimdev/dimdoors/mixin/client/accessor/GlStateManagerAccessor.java b/src/main/java/org/dimdev/dimdoors/mixin/client/accessor/GlStateManagerAccessor.java deleted file mode 100644 index b2197ed9..00000000 --- a/src/main/java/org/dimdev/dimdoors/mixin/client/accessor/GlStateManagerAccessor.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.dimdev.dimdoors.mixin.client.accessor; - -import java.nio.FloatBuffer; - -import com.mojang.blaze3d.platform.GlStateManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Invoker; - -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -@Mixin(GlStateManager.class) -public interface GlStateManagerAccessor { - @Invoker - static FloatBuffer invokeGetBuffer(float a, float b, float c, float d) { - throw new AssertionError(String.valueOf(a + b + c + d)); - } -} diff --git a/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java b/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java index 19d6881c..44d8b85f 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/PocketLoader.java @@ -143,7 +143,11 @@ public class PocketLoader implements SimpleSynchronousResourceReloadListener { if (tag == null || tag.getType() != NbtType.COMPOUND) { throw new RuntimeException("Could not load Schematic since its json does not represent a CompoundTag!"); } - return new PocketTemplate(Schematic.fromTag((CompoundTag) tag)); + try { + return new PocketTemplate(Schematic.fromTag((CompoundTag) tag)); + } catch (Exception e) { + throw new RuntimeException("Error loading " + tag.toString(), e); + } } public WeightedList getPocketsMatchingTags(List required, List blackList, boolean exact) { diff --git a/src/main/java/org/dimdev/dimdoors/pockets/modifier/ShellModifier.java b/src/main/java/org/dimdev/dimdoors/pockets/modifier/ShellModifier.java index c46986b2..fce56e55 100644 --- a/src/main/java/org/dimdev/dimdoors/pockets/modifier/ShellModifier.java +++ b/src/main/java/org/dimdev/dimdoors/pockets/modifier/ShellModifier.java @@ -45,12 +45,16 @@ public class ShellModifier implements LazyModifier { } tag.put("layers", layersTag); if (boxToDrawAround != null) { - tag.put("box_to_draw_around", boxToDrawAround.toNbt()); + tag.put("box_to_draw_around", toNbt(boxToDrawAround)); } return tag; } + private static IntArrayTag toNbt(BlockBox box) { + return new IntArrayTag(new int[]{box.minX, box.minY, box.minZ, box.maxX, box.maxY, box.maxZ}); + } + @Override public void applyToChunk(LazyGenerationPocket pocket, Chunk chunk) { diff --git a/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.fsh b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.fsh new file mode 100644 index 00000000..f0e1f0aa --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.fsh @@ -0,0 +1,64 @@ +// Copied from the end portal shader +// h e l p +#version 150 + +#moj_import + +uniform sampler2D Sampler0; +uniform sampler2D Sampler1; + +uniform float GameTime; +uniform int EndPortalLayers; + +in vec4 texProj0; + +const vec3[] COLORS = vec3[]( + vec3(0.022087, 0.098399, 0.110818), + vec3(0.011892, 0.095924, 0.089485), + vec3(0.027636, 0.101689, 0.100326), + vec3(0.046564, 0.109883, 0.114838), + vec3(0.064901, 0.117696, 0.097189), + vec3(0.063761, 0.086895, 0.123646), + vec3(0.084817, 0.111994, 0.166380), + vec3(0.097489, 0.154120, 0.091064), + vec3(0.106152, 0.131144, 0.195191), + vec3(0.097721, 0.110188, 0.187229), + vec3(0.133516, 0.138278, 0.148582), + vec3(0.070006, 0.243332, 0.235792), + vec3(0.196766, 0.142899, 0.214696), + vec3(0.047281, 0.315338, 0.321970), + vec3(0.204675, 0.390010, 0.302066), + vec3(0.080955, 0.314821, 0.661491) +); + +const mat4 SCALE_TRANSLATE = mat4( + 0.5, 0.0, 0.0, 0.25, + 0.0, 0.5, 0.0, 0.25, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 +); + +mat4 end_portal_layer(float layer) { + mat4 translate = mat4( + 1.0, 0.0, 0.0, 17.0 / layer, + 0.0, 1.0, 0.0, (2.0 + layer / 1.5) * (GameTime * 1.5), + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0 + ); + + mat2 rotate = mat2_rotate_z(radians((layer * layer * 4321.0 + layer * 9.0) * 2.0)); + + mat2 scale = mat2(4.5 - layer / 4.0); + + return mat4(scale * rotate) * translate * SCALE_TRANSLATE; +} + +out vec4 fragColor; + +void main() { + vec3 color = textureProj(Sampler0, texProj0).rgb * COLORS[0]; + for (int i = 0; i < EndPortalLayers; i++) { + color += textureProj(Sampler1, texProj0 * end_portal_layer(float(i + 1))).rgb * COLORS[i]; + } + fragColor = vec4(color, 1.0); +} diff --git a/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.json b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.json new file mode 100644 index 00000000..26be8ce1 --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.json @@ -0,0 +1,20 @@ +{ + "blend": { + "func": "add", + "srcrgb": "srcalpha", + "dstrgb": "1-srcalpha" + }, + "vertex": "rendertype_end_portal", + "fragment": "rendertype_end_portal", + "attributes": [], + "samplers": [ + { "name": "Sampler0" }, + { "name": "Sampler1" } + ], + "uniforms": [ + { "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] }, + { "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] }, + { "name": "EndPortalLayers", "type": "int", "count": 1, "values": [ 15 ] } + ] +} diff --git a/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.vsh b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.vsh new file mode 100644 index 00000000..de3ea06f --- /dev/null +++ b/src/main/resources/assets/minecraft/shaders/core/dimensional_portal.vsh @@ -0,0 +1,18 @@ +// Copied from the end portal shader +// h e l p +#version 150 + +#moj_import + +in vec3 Position; + +uniform mat4 ModelViewMat; +uniform mat4 ProjMat; + +out vec4 texProj0; + +void main() { + gl_Position = ProjMat * ModelViewMat * vec4(Position, 1.0); + + texProj0 = projection_from_position(gl_Position); +} diff --git a/src/main/resources/dimdoors.mixins.json b/src/main/resources/dimdoors.mixins.json index e96bb5f5..944e88f3 100644 --- a/src/main/resources/dimdoors.mixins.json +++ b/src/main/resources/dimdoors.mixins.json @@ -7,9 +7,9 @@ "ExtendedServerPlayNetworkhandlerMixin", "ItemMixin", "ItemMixin$SettingsMixin", - "ListTagAccessor", + "accessor.ListTagAccessor", "PlayerEntityMixin", - "RecipesProviderAccessor", + "accessor.RecipesProviderAccessor", "RegistryKeyMixin", "ServerPlayerEntityMixin", "ServerPlayerInteractionManagerMixin", @@ -27,7 +27,7 @@ "client.ClientPlayNetworkHandlerMixin", "client.ExtendedClientPlayNetworkHandlerMixin", "client.InGameHudMixin", - "client.accessor.GlStateManagerAccessor" + "client.GameRendererMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/party.schem b/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/party.schem index 6b81a829ae4d7e4870844d2413c262472c4195d5..05f7762545a0ee1b5a3cf4bb45259948b61dac45 100644 GIT binary patch literal 1613 zcmchQ{Xf$Q0D#$<*ePk7*PKIT-nUhTt$YysASEwFB&Ia0%u8clQ!Dc_I_E7Zlj%m@ zDr`eL;VU_$ByW?nS`(JdTV9s#b9ev4JwHA_JdZ)Pio$}t~-0^73bW1uH)2(F>z`$KK7c_C?{5+eU9iklaAnO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Du~> z-dm)FGzLWh1F1C4tnaR}tDxx6{*cHiu0gmq8`L7H1aI+ZFbl_b)n)*Yui&Ct;_`;U z!d(ba4aA@NQi1Gr^+3H6&q|}$+Cg1Z&yKO0%Y=ac33gFsAEe4^wDl_P`g4uH-~4NU zGeE%Mf(uXgVD5fFlv;LzO*eI(V;_k%7J$ErhduUkjN;s3vSZzR)T)uzPmjNfDeT*Q z509>_1bS59T~vPCR1Xv{naYi#b8x?J?v+QqsL+a}NKO!3a!&V%Q>UBh>2_dtYFT8qYkh~4dR7~TH6bGdYqBmh3!-p1I7q;3U z7Cr?NWFIAy$InRMjp|fAr+^=rT#HQ?m6TfwH{6lPRdxOG+5Cd)={Dl`ZBYA991j>7 z!ZurR(!>#9@p#lj*jm1RJ!d3ciq HSw!R?R%RUw diff --git a/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/smile_6.schem b/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/smile_6.schem index b1db3d31056faf4933d8ec52ff9c96ee1f82d222..94525a546af8019242dc3e203f298e713ae75eb7 100644 GIT binary patch delta 674 zcmV;T0$u&h1;+&=ABzY800000006aBUuzRV5TD-WlICI+6#L>!$a6rf#fL(XBQk%3 z`a3_y5jVnT;B~n~WAKb$0zl1!+Csr#ZzK}*H4n|fKxjYiry@!|X=NxLC)*Z-gJl3!mYPo?_eBzQ zri9yOHpWg$qQuP^T?V~^UGZU`1WbQYs*%gS)vnORT!x*=c#OIolM*`;L(^7cOmfEd zSWQuv`Kt^b7yJXs{o%5B=kIe%%YWD0jDEHEs4b&S=RoxolgPwS_h9=B4G*~C4C)uh zZ^JM}^I<-p|0>Bnl7E)uk0j55XiiW>v4J{+#t~5zIlON*s2@t@53QO~{(ygCZRN`X zX91iH=3q@z_*_T*!LwD!n*gK3hB(xQ$9K;8<3#QrUUWmX>&<0fVp=cv%EMC#~o$w3z4Pc)? ImLvxN0M=Yb(*OVf delta 680 zcmV;Z0$2UV1`M@#fM;#BQk%5 z#yda8G1J_)!R;}DTH`6Z0DzhcwWY#_7h|5FuUM!%L$3UIkn$+`B)IN|Or+RWQWJ+v zy8G=J)2M`uA`EilXCkZEu)CsQT#*iJ*bDeLkW!_cISL_XgOCjs_sOowk|=O{M#qMJ!7hKitz-ZU#VkW}wbTUEJj!B7KfuU~8 z2`0-1Cvt|W%wM(PVZlEX%pa|axBfo2F#Na8ZPTyz9+hD<=`5(8U=ryV8ZOjNQL}() zW<%rr=xrFLs6Q+gi(e(VPx8-_{E_4Z5X~|2DAv%hp?OFYMGp5{4H^eR`Xhg%rj$RR zSUdSLz*+(;gE`pH6h2o`fAH)S@-|@8VRE*caYI)|Cq2?kkqY8QVh=DxY$_)3|^b`B!S(N zDP(sg`%HJ0b#?VhT?Z!%11B3|B%a}g-iHTYTADzs(>gfvj$ie9{nmWfrSTa&DvYz3 zMw2&}Q*VeuCQ;$^wB!^{l_tNo*C#)wuyA?;dxg`X^b)B(A?3)}&3@lqy#VIDp-pL= zNU6`*P#}04&qMlnI8_{jfmX=UsluG&-iF)SF4T(6vA{X!ftjF9sOCe__|RCqr0+Z7 O=kOcxrRml#2LJ%p!%yP? diff --git a/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/waiting_room.schem b/src/main/resources/resourcepacks/default_pockets/data/dimdoors/pockets/schematic/custom/waiting_room.schem index 8d50e9f62e2b6172a11df01610810942e7773686..5434dc93498f70e15b5b6793d67fdd683537a89c 100644 GIT binary patch delta 1065 zcmV+^1lIe+2)zi9BYy$~7q!qN&_L6gx-@Ova;)w~r^Bn=V|RsON}!+m%S!)F|3Tf^ zl`QG(ODa3TRY(>D_ss6iJoC(~U@nBlVcf$$w^_^}Jm3PY#V7nZ0Nf5C7#kQI_A`mG z=3Tp=3T{l4bBRaDjcr>!z?M|n_S#)847Q9K(6cuWxkW8hntx(4-W(#m;vavd7@G`! znR?ckL=tTeb=1*Wd>k3eGi{E#JkDg=_Ay#LF1qcGvR3t5rpI$^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}f z6il9@{mv_CA9x?|o|oVXckwQRkH#I-lAP`zSFu3lqBi&U5q$T;^29q`PErL|@3dZ) zU7^!f8GLnVKRBJuW<8v*f;mx_RdAW^?iq^4)GRPKn)_2Wq2dZ(vLyx&Cms@Ei8G6) z*n^JvOn-~~t;}hDAe7QaW8x(=*{PWj?*xSe+07)lmdgmP4We3`8?J9`OvAgy-HYKFzqdER&CShg!FMLX>%yB$ z@C@9_WnOrXWbVU7ICoTUIKkToKO}e?f_xqLo=FXs^YLk4IpGA_kaUZ6UwSh`L(GvU_U$`%!{>QeX#rE#@_RFF2i&@IgXDJ_^QI;Mjurf7-(&P<= zaKg79&Op00p6^l7G_GQdjA*+M%6`TTp%VMxD!^#OhCJpJKHbwQu}x|X8gS=P$?7) qDXK#WDo;h?|FG0yaq!c`pE*7K@1N7t)4%EY7ybu`IlwZ#7XSeHbP=Qg diff --git a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicBlockPalette.java b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicBlockPalette.java index 153af369..1d41c484 100644 --- a/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicBlockPalette.java +++ b/src/main/schematics/org/dimdev/dimdoors/util/schematic/SchematicBlockPalette.java @@ -3,12 +3,18 @@ package org.dimdev.dimdoors.util.schematic; import java.util.Iterator; import java.util.Objects; +import com.mojang.brigadier.ImmutableStringReader; +import com.mojang.brigadier.StringReader; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; import com.mojang.serialization.codecs.UnboundedMapCodec; import net.minecraft.block.Block; import net.minecraft.block.BlockState; +import net.minecraft.command.argument.BlockArgumentParser; +import net.minecraft.command.argument.BlockStateArgument; +import net.minecraft.command.argument.BlockStateArgumentType; import net.minecraft.state.property.Property; import net.minecraft.util.Identifier; import net.minecraft.util.StringIdentifiable; @@ -25,21 +31,34 @@ public class SchematicBlockPalette { Codec CODEC = Codec.STRING.comapFlatMap(Entry::to, Entry::from); static DataResult to(String string) { - if (!string.contains("[") && !string.contains("]")) { - BlockState state = Registry.BLOCK.get(new Identifier(string)).getDefaultState(); - return DataResult.success(state); - } else { - Block block = Objects.requireNonNull(Registry.BLOCK.get(new Identifier(string.substring(0, string.indexOf("["))))); - BlockState state = block.getDefaultState(); - - String[] stateArray = string.substring(string.indexOf("[") + 1, string.length() - 1).split(","); - for (String stateString : stateArray) { - Property property = Objects.requireNonNull(block.getStateManager().getProperty(stateString.split("=")[0])); - state = process(property, stateString.split("=")[1], state); - } - - return DataResult.success(state); + StringReader reader = new StringReader(string); + BlockArgumentParser parser = new BlockArgumentParser(reader, true); + try { + parser.parse(true); + } catch (CommandSyntaxException e) { + return DataResult.error(e.getMessage()); } + return DataResult.success(parser.getBlockState()); +// if (!string.contains("[") && !string.contains("]")) { +// BlockState state = Registry.BLOCK.get(new Identifier(string)).getDefaultState(); +// return DataResult.success(state); +// } else { +// Block block = Objects.requireNonNull(Registry.BLOCK.get(new Identifier(string.substring(0, string.indexOf("["))))); +// BlockState state = block.getDefaultState(); +// +// String[] stateArray = string.substring(string.indexOf("[") + 1, string.length() - 1).split(","); +// for (String stateString : stateArray) { +// Property property; +// try { +// property = Objects.requireNonNull(block.getStateManager().getProperty(stateString.split("=")[0])); +// } catch (RuntimeException e) { +// return DataResult.error("Unknown block state property \"" + stateString + "\"", state); +// } +// state = process(property, stateString.split("=")[1], state); +// } +// +// return DataResult.success(state); +// } } static String from(BlockState state) {