20w10a, Shaders

This commit is contained in:
SD 2021-03-22 16:11:09 +05:30
parent 48ff64cefd
commit baf2bd2373
27 changed files with 464 additions and 397 deletions

View file

@ -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"

View file

@ -1,6 +1,5 @@
pluginManagement {
repositories {
jcenter()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'

View file

@ -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;

View file

@ -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);
}

View file

@ -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));
// }
// }
//}

View file

@ -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<RenderLayer> 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();
}
}

View file

@ -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<EntranceRiftBlockEntity> {
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());
}
}

View file

@ -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();
// }
//}

View file

@ -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;
}
}

View file

@ -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());
}
}

View file

@ -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);
}
}

View file

@ -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;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.mixin;
package org.dimdev.dimdoors.mixin.accessor;
import java.util.List;

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.mixin;
package org.dimdev.dimdoors.mixin.accessor;
import java.nio.file.Path;

View file

@ -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));
}
}

View file

@ -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);
}
}
}

View file

@ -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));
}
}

View file

@ -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<PocketGenerator, PocketGenerationParameters> getPocketsMatchingTags(List<String> required, List<String> blackList, boolean exact) {

View file

@ -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) {

View file

@ -0,0 +1,64 @@
// Copied from the end portal shader
// h e l p
#version 150
#moj_import <matrix.glsl>
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);
}

View file

@ -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 ] }
]
}

View file

@ -0,0 +1,18 @@
// Copied from the end portal shader
// h e l p
#version 150
#moj_import <projection.glsl>
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);
}

View file

@ -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

View file

@ -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<BlockState> CODEC = Codec.STRING.comapFlatMap(Entry::to, Entry::from);
static DataResult<BlockState> 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) {