Overhauled renderers

Changes to be committed:
	modified:   src/main/java/org/dimdev/dimdoors/DimensionalDoorsInitializer.java
	modified:   src/main/java/org/dimdev/dimdoors/block/entity/EntranceRiftBlockEntity.java
	modified:   src/main/java/org/dimdev/dimdoors/client/DimensionalPortalRenderer.java
	modified:   src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java
	renamed:    src/main/java/org/dimdev/dimdoors/entity/MaskRenderer.java -> src/main/java/org/dimdev/dimdoors/client/MaskRenderer.java
	renamed:    src/main/java/org/dimdev/dimdoors/entity/MonolithRenderer.java -> src/main/java/org/dimdev/dimdoors/client/MonolithRenderer.java
	modified:   src/main/java/org/dimdev/dimdoors/client/RiftRenderer.java
	modified:   src/main/java/org/dimdev/dimdoors/entity/ModEntityTypes.java
	renamed:    src/main/java/org/dimdev/dimdoors/block/entity/RiftEntity.java -> src/main/java/org/dimdev/dimdoors/entity/RiftEntity.java
	new file:   src/main/java/org/dimdev/dimdoors/mixin/DirectionMixin.java
	modified:   src/main/java/org/dimdev/dimdoors/pockets/SchematicHandler.java
	new file:   src/main/java/org/dimdev/util/RGBA.java
	modified:   src/main/resources/dimdoors.mixins.json
This commit is contained in:
SD 2020-07-23 20:33:55 +05:30
parent 0b2945eeed
commit 8b8a04cfe5
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
13 changed files with 597 additions and 120 deletions

View file

@ -7,7 +7,6 @@ import org.dimdev.dimdoors.block.entity.ModBlockEntityTypes;
import org.dimdev.dimdoors.command.*;
import org.dimdev.dimdoors.entity.ModEntityTypes;
import org.dimdev.dimdoors.item.ModItems;
import org.dimdev.dimdoors.pockets.SchematicHandler;
import org.dimdev.dimdoors.rift.targets.*;
import org.dimdev.dimdoors.sound.ModSoundEvents;
import org.dimdev.dimdoors.world.ModBiomes;
@ -45,7 +44,5 @@ public class DimensionalDoorsInitializer implements ModInitializer {
VirtualTarget.registry.put("relative", RelativeReference.class);
Targets.registerDefaultTargets();
SchematicHandler.INSTANCE.loadSchematics();
}
}

View file

@ -11,6 +11,7 @@ import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import org.dimdev.annotatednbt.AnnotatedNbt;
import org.dimdev.dimdoors.ModConfig;
import org.dimdev.util.RGBA;
import org.dimdev.util.TeleportUtil;
import java.util.Random;
@ -56,7 +57,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
}
@Environment(EnvType.CLIENT)
public float[][] getColors(int count) {
public RGBA[] getColors(int count) {
Random rand = new Random(31100L);
float[][] colors = new float[count][];
@ -64,7 +65,7 @@ public class EntranceRiftBlockEntity extends RiftBlockEntity {
colors[i] = getEntranceRenderColor(rand);
}
return colors;
return RGBA.fromFloatArray(colors);
}
@Environment(EnvType.CLIENT)

View file

@ -1,30 +1,73 @@
package org.dimdev.dimdoors.client;
import java.nio.FloatBuffer;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Random;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3f;
import com.flowpowered.math.vector.Vector3i;
import com.flowpowered.math.vector.VectorNi;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import org.dimdev.dimdoors.block.ModBlocks;
import org.dimdev.dimdoors.block.entity.RiftBlockEntity;
import org.dimdev.dimdoors.mixin.DirectionMixin;
import org.dimdev.util.RGBA;
import org.lwjgl.opengl.GL11;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.DoorBlock;
import net.minecraft.block.enums.DoorHinge;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.render.*;
import net.minecraft.client.render.BufferBuilder;
import net.minecraft.client.render.Tessellator;
import net.minecraft.client.render.VertexFormats;
import net.minecraft.client.render.block.BlockModels;
import net.minecraft.client.render.model.BakedModel;
import net.minecraft.client.render.model.BakedModelManager;
import net.minecraft.client.render.model.BakedQuad;
import net.minecraft.client.texture.SpriteAtlasTexture;
import net.minecraft.client.texture.TextureManager;
import net.minecraft.client.util.GlAllocationUtils;
import net.minecraft.client.util.ModelIdentifier;
import net.minecraft.state.property.BooleanProperty;
import net.minecraft.state.property.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.Identifier;
import net.minecraft.util.Util;
import net.minecraft.util.math.Direction;
import org.lwjgl.opengl.GL11;
import java.nio.FloatBuffer;
import net.minecraft.util.registry.Registry;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import static com.mojang.blaze3d.platform.GlStateManager.TexCoord.*;
import static com.mojang.blaze3d.platform.GlStateManager.enableTexGen;
import static org.lwjgl.opengl.GL11.*;
@Environment(EnvType.CLIENT)
public final class DimensionalPortalRenderer { // TODO
private static final FloatBuffer BUFFER = GlAllocationUtils.allocateFloatBuffer(16);
private static final Identifier WARP_TEX = new Identifier("dimdoors", "textures/other/warp.png");
public final class DimensionalPortalRenderer {
private static final FloatBuffer buffer = GlAllocationUtils.allocateFloatBuffer(16);
private static final Identifier warpPath = new Identifier("dimdoors:textures/other/warp.png");
private static final BooleanProperty openProperty = BooleanProperty.of("open");
private static final EnumProperty<DoorHinge> hingeProperty = EnumProperty.of("hinge", DoorHinge.class);
private static final DirectionProperty facingProperty = DirectionProperty.of("facing", Arrays.asList(DirectionMixin.getHorizontal()));
private static final TextureManager textureManager = MinecraftClient.getInstance().getTextureManager();
private static final BlockModels blockModelShapes = MinecraftClient.getInstance().getBlockRenderManager().getModels();
private static final BakedModelManager modelManager = blockModelShapes.getModelManager();
private static final VectorNi COLORLESS = new VectorNi(255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255);
// TODO: any render angle
/**
* Renders a dimensional portal, for use in various situations. Code is mostly based
* on vanilla's BlockEntityEndGatewayRenderer.
* on vanilla's TileEntityEndGatewayRenderer.
*
* @param x The x coordinate of the wall's center.
* @param y The y coordinate of the wall's center.
@ -36,18 +79,18 @@ public final class DimensionalPortalRenderer { // TODO
* @param height The height of the wall.
* @param colors An array containing the color to use on each pass. Its length determines the number of passes to do.
*/
public static void renderDimensionalPortal(VertexConsumerProvider vc, double x, double y, double z, Direction orientation, double width, double height, float[][] colors) { // TODO: Make this work at any angle
public static void renderDimensionalPortal(double x, double y, double z, Direction orientation, double width, double height, RGBA[] colors) { // TODO: Make this work at any angle
RenderSystem.disableLighting();
RenderSystem.disableCull();
for (int pass = 0; pass < 16; pass++) {
for (int pass = 0; pass < 4; pass++) {
RenderSystem.pushMatrix();
float translationScale = 16 - pass;
float scale = 0.2625F;
float colorMultiplier = 1.0F / (translationScale + .80F);
MinecraftClient.getInstance().getTextureManager().bindTexture(WARP_TEX);
MinecraftClient.getInstance().getTextureManager().bindTexture(warpPath);
RenderSystem.enableBlend();
if (pass == 0) {
@ -55,72 +98,78 @@ public final class DimensionalPortalRenderer { // TODO
translationScale = 25.0F;
scale = 0.125F;
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (pass == 1) {
scale = 0.5F;
RenderSystem.blendFunc(GL11.GL_ONE, GL11.GL_ONE);
RenderSystem.blendFunc(GL_ONE, GL_ONE);
}
double offset = Util.getMeasuringTimeNano() % 200000L / 200000.0F;
RenderSystem.translated(offset, offset, offset);
GlStateManager.texGenMode(S, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGenMode(T, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGenMode(R, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.S, GL_OBJECT_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.T, GL_OBJECT_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.R, GL_OBJECT_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.Q, GL_OBJECT_LINEAR);
if (orientation == Direction.UP || orientation == Direction.DOWN) {
GlStateManager.texGenMode(Q, GL11.GL_EYE_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.Q, GL11.GL_EYE_LINEAR);
} else {
GlStateManager.texGenMode(Q, GL11.GL_OBJECT_LINEAR);
GlStateManager.texGenMode(GlStateManager.TexCoord.Q, GL11.GL_OBJECT_LINEAR);
}
switch (orientation) { // TODO: Why 0.15F? Is that a door's thickness? If yes, don't hardcode that.
case SOUTH:
GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, -0.15F));
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, -0.15F));
break;
case WEST:
GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.15F));
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.15F));
break;
case NORTH:
GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.15F));
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.15F));
break;
case EAST:
GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(Q, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, -0.15F));
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL_OBJECT_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, -0.15F));
break;
case UP:
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
break;
case DOWN:
GlStateManager.texGenParam(S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.S, GL11.GL_OBJECT_PLANE, getBuffer(1.0F, 0.0F, 0.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.T, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 1.0F, 0.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.R, GL11.GL_OBJECT_PLANE, getBuffer(0.0F, 0.0F, 0.0F, 1.0F));
GlStateManager.texGenParam(GlStateManager.TexCoord.Q, GL11.GL_EYE_PLANE, getBuffer(0.0F, 1.0F, 0.0F, 0.0F));
break;
}
enableTexGen(S);
enableTexGen(T);
enableTexGen(R);
enableTexGen(Q);
GlStateManager.enableTexGen(GlStateManager.TexCoord.S);
GlStateManager.enableTexGen(GlStateManager.TexCoord.T);
GlStateManager.enableTexGen(GlStateManager.TexCoord.R);
GlStateManager.enableTexGen(GlStateManager.TexCoord.Q);
RenderSystem.popMatrix();
RenderSystem.matrixMode(GL11.GL_TEXTURE);
RenderSystem.matrixMode(GL_TEXTURE);
RenderSystem.pushMatrix();
RenderSystem.loadIdentity();
RenderSystem.translatef(0.0F, (float) (offset * translationScale), 0.0F);
RenderSystem.translated(0.0F, offset * translationScale, 0.0F);
RenderSystem.scaled(scale, scale, scale);
RenderSystem.translatef(0.5F, 0.5F, 0.5F);
RenderSystem.rotatef((pass * pass * 4321 + pass * 9) * 2.0F, 0.0F, 0.0F, 1.0F);
@ -128,69 +177,427 @@ public final class DimensionalPortalRenderer { // TODO
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldRenderer = tessellator.getBuffer();
worldRenderer.begin(GL11.GL_QUADS, VertexFormats.POSITION);
worldRenderer.begin(GL_QUADS, VertexFormats.POSITION);
float[] color = colors[pass];
RenderSystem.color4f(color[0] * colorMultiplier, color[1] * colorMultiplier, color[2] * colorMultiplier, color[3]);
RGBA color = colors[pass];
RenderSystem.color4f(color.getRed() * colorMultiplier, color.getGreen() * colorMultiplier, color.getBlue() * colorMultiplier, color.getAlpha());
switch (orientation) {
case NORTH:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x, y + height, z).next();
worldRenderer.vertex(x + width, y + height, z).next();
worldRenderer.vertex(x + width, y, z).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x, y + height, z);
worldRenderer.vertex(x + width, y + height, z);
worldRenderer.vertex(x + width, y, z);
break;
case SOUTH:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x + width, y, z).next();
worldRenderer.vertex(x + width, y + height, z).next();
worldRenderer.vertex(x, y + height, z).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x + width, y, z);
worldRenderer.vertex(x + width, y + height, z);
worldRenderer.vertex(x, y + height, z);
break;
case WEST:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x, y, z + width).next();
worldRenderer.vertex(x, y + height, z + width).next();
worldRenderer.vertex(x, y + height, z).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x, y, z + width);
worldRenderer.vertex(x, y + height, z + width);
worldRenderer.vertex(x, y + height, z);
break;
case EAST:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x, y + height, z).next();
worldRenderer.vertex(x, y + height, z + width).next();
worldRenderer.vertex(x, y, z + width).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x, y + height, z);
worldRenderer.vertex(x, y + height, z + width);
worldRenderer.vertex(x, y, z + width);
break;
case UP:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x, y, z + width).next();
worldRenderer.vertex(x + width, y, z + width).next();
worldRenderer.vertex(x + width, y, z).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x, y, z + width);
worldRenderer.vertex(x + width, y, z + width);
worldRenderer.vertex(x + width, y, z);
break;
case DOWN:
worldRenderer.vertex(x, y, z).next();
worldRenderer.vertex(x + width, y, z).next();
worldRenderer.vertex(x + width, y, z + width).next();
worldRenderer.vertex(x, y, z + width).next();
worldRenderer.vertex(x, y, z);
worldRenderer.vertex(x + width, y, z);
worldRenderer.vertex(x + width, y, z + width);
worldRenderer.vertex(x, y, z + width);
break;
}
tessellator.draw();
RenderSystem.popMatrix();
RenderSystem.matrixMode(GL11.GL_MODELVIEW);
RenderSystem.matrixMode(GL_MODELVIEW);
}
RenderSystem.disableBlend();
GlStateManager.disableTexGen(S);
GlStateManager.disableTexGen(T);
GlStateManager.disableTexGen(R);
GlStateManager.disableTexGen(Q);
GlStateManager.disableTexGen(GlStateManager.TexCoord.S);
GlStateManager.disableTexGen(GlStateManager.TexCoord.T);
GlStateManager.disableTexGen(GlStateManager.TexCoord.R);
GlStateManager.disableTexGen(GlStateManager.TexCoord.Q);
RenderSystem.enableCull();
RenderSystem.enableLighting();
}
private static FloatBuffer getBuffer(float f1, float f2, float f3, float f4) {
BUFFER.clear();
BUFFER.put(f1).put(f2).put(f3).put(f4);
BUFFER.flip();
return BUFFER;
//TODO Check to make sure block type is valid (and not air)
@SuppressWarnings("Duplicates")
public static void renderFoxWallAxis(RiftBlockEntity blockEntity, Vector3d pos, Vector3d offset, Direction orientation, double width, double height, RGBA[] colors) {
//System.out.println(orientation);
if (orientation == null) return;
switch (orientation) {
case UP:
case DOWN:
return;
}
final float pathLength = 10;
final float doorDistanceMul = 1.5f;
final int endOpacity = 0;
// incoming depth function is GL_LEQUAL
// this means that you can redraw geometry multiple times as long as you don't translate.
/*int glDepthFunc = glGetInteger(GL_DEPTH_FUNC);
switch (glDepthFunc) {
case GL_LESS:
System.out.println("less");
break;
case GL_LEQUAL:
System.out.println("lequal");
break;
case GL_GREATER:
System.out.println("greater");
break;
case GL_GEQUAL:
System.out.println("gequal");
break;
}*/
//System.out.println("RENDER");
//System.out.println(height);
RenderSystem.disableLighting();
//RenderSystem.activeTexture(OpenGlHelper.lightmapTexUnit);
RenderSystem.disableTexture();
//RenderSystem.activeTexture(OpenGlHelper.defaultTexUnit);
RenderSystem.disableTexture();
GlStateManager.genFramebuffers();
//RenderSystem.disableCull();
//RenderSystem.disableDepth();
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 0xff);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilMask(0xFF);
glClearStencil(0);
glClear(GL_STENCIL_BUFFER_BIT);
//System.out.println(glGetInteger(GL_STENCIL_BITS));
final Vector3d merged = pos.add(offset);
final Vector3d left, right, back, depth, up;
switch (orientation) {
case NORTH:
left = merged.add(width, 0, 0);//new Vector3d(x + width, y, z);
right = merged;
back = new Vector3d(0, 0, 1);
break;
case SOUTH:
left = merged;
right = merged.add(width, 0, 0);
back = new Vector3d(0, 0, -1);
break;
case WEST:
left = merged;
right = merged.add(0, 0, width);
back = new Vector3d(1, 0, 0);
break;
case EAST:
left = merged.add(0, 0, width);
right = merged;
back = new Vector3d(-1, 0, 0);
break;
default:
return;
}
depth = back.mul(pathLength);
up = new Vector3d(0, height, 0);
Vector3d leftTop = left.add(up),
rightTop = right.add(up),
leftBack = left.add(depth),
rightBack = right.add(depth),
leftTopBack = leftTop.add(depth),
rightTopBack = rightTop.add(depth);
Vector3f voidColor;
Vector3i pathColor;
// boolean personal = blockType instanceof BlockDimensionalDoorQuartz;
final float brightness = 0.99f;
voidColor = new Vector3f(brightness, brightness, brightness);
pathColor = new Vector3i(255, 210, 0);
// if (personal) {
// } else {
// voidColor = new Vector3f(0, 0, 0);
// pathColor = new Vector3i(50, 255, 255);
// }
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldRenderer = tessellator.getBuffer();
RenderSystem.color4f(voidColor.getX(), voidColor.getY(), voidColor.getZ(), 1f);
worldRenderer.begin(GL_QUADS, VertexFormats.POSITION);
worldRenderer.vertex(left.getX(), left.getY(), left.getZ());
worldRenderer.vertex(right.getX(), right.getY(), right.getZ());
worldRenderer.vertex(rightTop.getX(), rightTop.getY(), rightTop.getZ());
worldRenderer.vertex(leftTop.getX(), leftTop.getY(), leftTop.getZ());
tessellator.draw();
glStencilMask(0);
glStencilFunc(GL_EQUAL, 1, 0xff);
RenderSystem.disableDepthTest();
RenderSystem.enableBlend();
//TODO put blendfunc back to original state
RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
int oldShadeModel = GlStateManager.getInteger(GL_SHADE_MODEL);
RenderSystem.shadeModel(GL_SMOOTH);
RenderSystem.disableAlphaTest();
/*worldRenderer.begin(GL_QUADS, DefaultVertexFormats.POSITION_COLOR);
worldRenderer.pos(left.getX(), left.getY(), left.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 127)
.endVertex();
worldRenderer.pos(right.getX(), right.getY(), right.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 127)
.endVertex();
worldRenderer.pos(rightBack.getX(), rightBack.getY(), rightBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity)
.endVertex();
worldRenderer.pos(leftBack.getX(), leftBack.getY(), leftBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity)
.endVertex();
tessellator.draw();*/
// Modelled path ===============================================================================================
// RenderSystem.blendFunc();
RenderSystem.enableTexture();
//RenderSystem.disableDepth();
textureManager.bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
Block stonebrick = Blocks.STONE_BRICKS;
BlockState stonebrickState = stonebrick.getDefaultState();
Map<BlockState, ModelIdentifier> stonebrickMap = Maps.newHashMap();
stonebrickMap.put(Blocks.STONE_BRICKS.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(Blocks.STONE_BRICKS).toString()));
stonebrickMap.put(Blocks.CRACKED_STONE_BRICKS.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(Blocks.CRACKED_STONE_BRICKS).toString()));
stonebrickMap.put(Blocks.CHISELED_STONE_BRICKS.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(Blocks.CHISELED_STONE_BRICKS).toString()));
RenderSystem.matrixMode(GL_MODELVIEW);
RenderSystem.pushMatrix();
RenderSystem.translated(pos.getX(), pos.getY() - 1, pos.getZ());
VectorNi pathColorVec = createColorVec(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 255);
int numPathTiles = 10;
float deltaOp = 255f / numPathTiles;
for (int i = 0; i < numPathTiles; i++) {
int nearOp = 255 - (int) (i * deltaOp);
int farOp = (int) (nearOp - deltaOp);
VectorNi colorVec = new VectorNi(pathColorVec);
setOpacity(colorVec, nearOp, nearOp, farOp, farOp);
pathColorVec = rotateTopFaceColor(colorVec, orientation);
drawState(tessellator, worldRenderer, stonebrickMap, stonebrickState, Direction.UP, pathColorVec);
RenderSystem.translated(back.getX(), 0, back.getZ());
}
RenderSystem.popMatrix();
RenderSystem.disableTexture();
worldRenderer.begin(GL_LINES, VertexFormats.POSITION_COLOR);
worldRenderer.vertex(leftTop.getX(), leftTop.getY(), leftTop.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 255);
worldRenderer.vertex(leftTopBack.getX(), leftTopBack.getY(), leftTopBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity);
worldRenderer.vertex(rightTop.getX(), rightTop.getY(), rightTop.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 255);
worldRenderer.vertex(rightTopBack.getX(), rightTopBack.getY(), rightTopBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity);
worldRenderer.vertex(left.getX(), left.getY(), left.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 255);
worldRenderer.vertex(leftBack.getX(), leftBack.getY(), leftBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity);
worldRenderer.vertex(right.getX(), right.getY(), right.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), 255);
worldRenderer.vertex(rightBack.getX(), rightBack.getY(), rightBack.getZ())
.color(pathColor.getX(), pathColor.getY(), pathColor.getZ(), endOpacity);
tessellator.draw();
RenderSystem.enableAlphaTest();
RenderSystem.disableBlend();
RenderSystem.blendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
{
//RenderSystem.disableDepth();
//glDisable(GL_STENCIL_TEST);
//RenderSystem.matrixMode(GL_MODELVIEW);
RenderSystem.pushMatrix();
RenderSystem.translated(pos.getX(), pos.getY(), pos.getZ());
textureManager.bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
Map<BlockState, ModelIdentifier> doorMap = Maps.newHashMap();
doorMap.put(ModBlocks.GOLD_DIMENSIONAL_DOOR.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(ModBlocks.GOLD_DIMENSIONAL_DOOR).toString()));
doorMap.put(ModBlocks.QUARTZ_DIMENSIONAL_DOOR.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(ModBlocks.QUARTZ_DIMENSIONAL_DOOR).toString()));
doorMap.put(ModBlocks.OAK_DIMENSIONAL_DOOR.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(ModBlocks.OAK_DIMENSIONAL_DOOR).toString()));
doorMap.put(ModBlocks.GOLD_DIMENSIONAL_DOOR.getDefaultState(), new ModelIdentifier(Registry.BLOCK.getId(ModBlocks.GOLD_DIMENSIONAL_DOOR).toString()));
BlockState doorBottomState = blockEntity.getWorld().getBlockState(blockEntity.getPos());
BlockState doorTopState = blockEntity.getWorld().getBlockState(blockEntity.getPos().up());
if (doorBottomState.getBlock() instanceof DoorBlock && doorTopState.getBlock() instanceof DoorBlock) {
doorBottomState = doorBottomState.with(hingeProperty, doorTopState.get(hingeProperty));
// System.out.println();
// System.out.println("---------------------------------------------");
// System.out.println(doorBottomState.getProperties());
// System.out.println("---------------------------------------------");
doorTopState = doorTopState.with(openProperty, doorBottomState.get(openProperty))
.with(facingProperty, doorBottomState.get(facingProperty));
//System.out.println(doorTopState);
//System.out.println(doorBottomState);
//System.out.println(doorBottomState.getProperties());
//System.out.println();
//System.out.println(doorBottomState.getValue(PropertyEnum.create("hinge", BlockDoor.EnumHingePosition.class)));
//RenderSystem.activeTexture(OpenGlHelper.defaultTexUnit);
RenderSystem.enableTexture();
if (doorBottomState.get(openProperty)) {
//RenderSystem.activeTexture(OpenGlHelper.lightmapTexUnit);
// if (!personal) {
// RenderSystem.enableTexture2D();
// RenderSystem.enableLighting();
// }
drawState(tessellator, worldRenderer, doorMap, doorBottomState, null);
RenderSystem.translatef(0, 1, 0);
drawState(tessellator, worldRenderer, doorMap, doorTopState, null);
RenderSystem.translatef(0, -1, 0);
RenderSystem.disableTexture();
//RenderSystem.activeTexture(OpenGlHelper.defaultTexUnit);
RenderSystem.disableLighting();
}
Vector3d doorDepth = depth.mul(doorDistanceMul);
RenderSystem.translated(doorDepth.getX(), doorDepth.getY(), doorDepth.getZ());
drawState(tessellator, worldRenderer, doorMap, doorBottomState.with(openProperty, false), orientation);
RenderSystem.translated(0, 1, 0);
drawState(tessellator, worldRenderer, doorMap, doorTopState.with(openProperty, false), orientation);
}
RenderSystem.popMatrix();
}
//RenderSystem.rotate(Quaternion);
glStencilMask(0xff);
glDisable(GL_STENCIL_TEST);
RenderSystem.shadeModel(oldShadeModel);
RenderSystem.disableBlend();
//RenderSystem.activeTexture(OpenGlHelper.defaultTexUnit);
RenderSystem.enableTexture();
//RenderSystem.activeTexture(OpenGlHelper.lightmapTexUnit);
RenderSystem.enableTexture();
RenderSystem.enableCull();
RenderSystem.enableLighting();
RenderSystem.enableDepthTest();
}
}
private static void drawState(Tessellator tessellator, BufferBuilder worldRenderer, Map<BlockState, ModelIdentifier> map,
BlockState blockState, Direction side) {
drawState(tessellator, worldRenderer, map, blockState, side, COLORLESS);
}
private static void drawState(Tessellator tessellator, BufferBuilder bufferBuilder, Map<BlockState, ModelIdentifier> map,
BlockState blockState, Direction side, VectorNi colors) {
if (colors.size() < 16) colors = COLORLESS;
ModelIdentifier location;
BakedModel model;
List<BakedQuad> quads;
location = map.get(blockState);
model = modelManager.getModel(location);
quads = model.getQuads(null, side, new Random(1));
if (!quads.isEmpty()) {
bufferBuilder.begin(GL_QUADS, VertexFormats.POSITION);
//System.out.println(quads.size());
for (BakedQuad quad : quads) {
//worldRenderer.(quad.getVertexData());
/*for (int i = 1; i <5 ; i++) {
worldRenderer.putColorMultiplier(1, 0, 0, i);
}*/
/*worldRenderer.putColorRGB_F(1, 0, 0, 4);
worldRenderer.putColorRGB_F(1, 1, 0, 3);
worldRenderer.putColorRGB_F(0, 1, 0, 2);
worldRenderer.putColorRGB_F(0, 0.3f, 1, 1);*/
for (int i = 0, j = 4; i < 16; i += 4, j--) {
bufferBuilder.color( colors.get(i), colors.get(i + 1), colors.get(i + 2), colors.get(i + 3));
}
}
tessellator.draw();
}
}
private static VectorNi rotateTopFaceColor(VectorNi vec, Direction facing) {
VectorNi ret = new VectorNi(vec);
if (facing == null) return ret;
int shiftAmount;
switch (facing) {
case NORTH:
shiftAmount = 4;
break;
case EAST:
shiftAmount = 8;
break;
case SOUTH:
shiftAmount = 12;
break;
case WEST:
shiftAmount = 0;
break;
default:
return ret;
}
for (int i = 0; i < 16; i++) {
ret.set(i, vec.get((i + shiftAmount) & 15));
}
return ret;
}
private static void setOpacity(VectorNi vec, int op1, int op2, int op3, int op4) {
if (vec.size() < 16) return;
vec.set(3, op1);
vec.set(7, op2);
vec.set(11, op3);
vec.set(15, op4);
}
private static VectorNi createColorVec(int red, int green, int blue, int alpha) {
return new VectorNi(red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha, red, green, blue, alpha);
}
private static FloatBuffer getBuffer(float f1, float f2, float f3, float f4) {
buffer.clear();
buffer.put(f1).put(f2).put(f3).put(f4);
buffer.flip();
return buffer;
}
}

View file

@ -30,7 +30,6 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
vec.scale((float) (orientation == Direction.NORTH || orientation == Direction.WEST || orientation == Direction.UP ? 0.01 : 0.01 - 1));
Vec3d offset = new Vec3d(vec);
DimensionalPortalRenderer.renderDimensionalPortal(
vertexConsumerProvider,
entrance.getPos().getX() + offset.x,
entrance.getPos().getY() + offset.y,
entrance.getPos().getZ() + offset.z,

View file

@ -1,4 +1,6 @@
package org.dimdev.dimdoors.entity;
package org.dimdev.dimdoors.client;
import org.dimdev.dimdoors.entity.MaskEntity;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
@ -8,7 +10,7 @@ import net.minecraft.util.Identifier;
public class MaskRenderer extends EntityRenderer<MaskEntity> {
private final EntityRendererRegistry.Context context;
protected MaskRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
public MaskRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher);
this.context = context;
}

View file

@ -1,10 +1,11 @@
package org.dimdev.dimdoors.entity;
package org.dimdev.dimdoors.client;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
import net.minecraft.client.render.entity.EntityRenderDispatcher;
import net.minecraft.client.render.entity.LivingEntityRenderer;
import net.minecraft.util.Identifier;
import org.dimdev.dimdoors.client.MonolithModel;
import org.dimdev.dimdoors.entity.MonolithEntity;
import java.util.Arrays;
import java.util.List;
@ -31,7 +32,7 @@ public class MonolithRenderer extends LivingEntityRenderer<MonolithEntity, Monol
new Identifier("dimdoors:textures/mob/monolith/monolith17.png"),
new Identifier("dimdoors:textures/mob/monolith/monolith18.png"));
protected MonolithRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
public MonolithRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher, new MonolithModel(), 0);
}

View file

@ -2,7 +2,7 @@ package org.dimdev.dimdoors.client;
import java.util.ArrayList;
import org.dimdev.dimdoors.block.entity.RiftEntity;
import org.dimdev.dimdoors.entity.RiftEntity;
import net.minecraft.client.render.TexturedRenderLayers;
import net.minecraft.client.render.VertexConsumer;
@ -15,7 +15,7 @@ import net.minecraft.util.Identifier;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
public class RiftRenderer extends EntityRenderer<RiftEntity> {
protected RiftRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
public RiftRenderer(EntityRenderDispatcher dispatcher, EntityRendererRegistry.Context context) {
super(dispatcher);
}

View file

@ -1,5 +1,9 @@
package org.dimdev.dimdoors.entity;
import org.dimdev.dimdoors.client.MaskRenderer;
import org.dimdev.dimdoors.client.MonolithRenderer;
import org.dimdev.dimdoors.client.RiftRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.rendereregistry.v1.EntityRendererRegistry;
@ -24,6 +28,11 @@ public class ModEntityTypes {
MaskEntity::new,
1, 1
);
public static final EntityType<RiftEntity> RIFT = register(
"dimdoors:rift",
RiftEntity::new,
1, 1
);
public static void init() {
FabricDefaultAttributeRegistry.register(MONOLITH, MonolithEntity.createMobAttributes());
@ -34,6 +43,7 @@ public class ModEntityTypes {
public static void initClient() {
EntityRendererRegistry.INSTANCE.register(MONOLITH, MonolithRenderer::new);
EntityRendererRegistry.INSTANCE.register(MASK, MaskRenderer::new);
EntityRendererRegistry.INSTANCE.register(RIFT, RiftRenderer::new);
}
private static <E extends Entity> EntityType<E> register(String id, EntityType.EntityFactory<E> factory, int width, int height) {

View file

@ -1,4 +1,4 @@
package org.dimdev.dimdoors.block.entity;
package org.dimdev.dimdoors.entity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;

View file

@ -0,0 +1,14 @@
package org.dimdev.dimdoors.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.util.math.Direction;
@Mixin(Direction.class)
public interface DirectionMixin {
@Accessor("HORIZONTAL")
static Direction[] getHorizontal() {
throw new AssertionError();
}
}

View file

@ -49,7 +49,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
private Map<String, Map<String, Integer>> nameMap; // group -> name -> index in templates
private List<Entry<PocketTemplate, Integer>> usageList = new ArrayList<>(); //template and nr of usages
private Map<PocketTemplate, Integer> usageMap = new HashMap<>(); //template -> index in usageList
public void loadSchematics() {
long startTime = System.currentTimeMillis();
@ -58,7 +58,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
String[] names = {"default_dungeon_nether", "default_dungeon_normal", "default_private", "default_public", "default_blank"}; // TODO: don't hardcode
for (String name : names) {
try {
URL resource = DimensionalDoorsInitializer.class.getResource("/assets/dimdoors/pockets/json/" + name + ".json");
URL resource = DimensionalDoorsInitializer.class.getResource("/data/dimdoors/pockets/json/" + name + ".json");
String jsonString = IOUtils.toString(resource, StandardCharsets.UTF_8);
templates.addAll(loadTemplatesFromJson(jsonString));
} catch (IOException e) {
@ -165,7 +165,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
}
}
}
if (isCustomFile) {
Schematic schematic = null;
try {
@ -181,13 +181,13 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
isValidFormat = false;
}
}
if (streamOpened && isValidFormat) {
template.setSchematicBytecode(schematicBytecode);
validTemplates.add(template);
validTemplates.add(template);
}
}
return validTemplates;
}
@ -338,7 +338,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
if (savedDungeons.containsKey(id)) {
templates.remove((int) savedDungeons.remove(id));
}
//create byte array
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
byte[] schematicBytecode = null;
@ -349,13 +349,13 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
} catch (IOException ex) {
LOGGER.error("Something went wrong while converting schematic " + id + " to bytecode.", ex);
}
if (schematicBytecode != null) {
templates.add(new PocketTemplate(SAVED_POCKETS_GROUP_NAME, id, null, null, null, schematic, schematicBytecode, -1, 0));
nameMap.get(SAVED_POCKETS_GROUP_NAME).put(id, templates.size() - 1);
}
}
private int getUsage(PocketTemplate template) {
if (!usageMap.containsKey(template)) return -1;
int index = usageMap.get(template);
@ -370,14 +370,14 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
return getUsage(template);
}
}
public boolean isUsedOftenEnough(PocketTemplate template) {
int maxNrOfCachedSchematics = ModConfig.POCKETS.cachedSchematics;
int usageRank = usageMap.get(template);
return usageRank < maxNrOfCachedSchematics;
}
public void incrementUsage(PocketTemplate template) {
public void incrementUsage(PocketTemplate template) {
int startIndex;
int newUsage;
if (!usageMap.containsKey(template)) {
@ -388,7 +388,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
startIndex = usageMap.get(template);
newUsage = usageList.get(startIndex).getValue() + 1;
}
int insertionIndex = findFirstEqualOrLessUsage(newUsage, 0, startIndex);
//shift all entries inbetween the insertionIndex and the currentIndex to the right
PocketTemplate currentTemplate;
@ -396,24 +396,24 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
usageList.set(i, usageList.get(i-1));
currentTemplate = usageList.get(i).getKey();
usageMap.put(currentTemplate, i);
}
}
//insert the incremented entry at the correct place
usageList.set(insertionIndex, new SimpleEntry(template, newUsage));
usageMap.put(template, insertionIndex);
if (insertionIndex < ModConfig.POCKETS.cachedSchematics) { //if the schematic of this template is supposed to get cached
if (usageList.size() > ModConfig.POCKETS.cachedSchematics) { //if there are more used templates than there are schematics allowed to be cached
usageList.get(ModConfig.POCKETS.cachedSchematics).getKey().setSchematic(null); //make sure that the number of cached schematics is limited
}
}
}
//uses binary search
private int findFirstEqualOrLessUsage(int usage, int indexMin, int indexMax) {
if (usageList.get(indexMin).getValue() <= usage) {
return indexMin;
}
}
int halfwayIndex = (indexMin + indexMax) / 2;
if (usageList.get(halfwayIndex).getValue() > usage) {
return findFirstEqualOrLessUsage(usage, halfwayIndex + 1, indexMax);
@ -421,7 +421,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
return findFirstEqualOrLessUsage(usage, indexMin, halfwayIndex);
}
}
private void reSortUsages() {
//sort the usageList
usageList = mergeSortPairArrayByPairValue(usageList);
@ -429,7 +429,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
for (Entry<PocketTemplate, Integer> pair: usageList) {
usageMap.put(pair.getKey(), pair.getValue());
}
//make sure that everything in the usageMap is actually in the usageList
for (Entry<PocketTemplate, Integer> entry: usageMap.entrySet()) {
PocketTemplate template = entry.getKey();
@ -441,7 +441,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
}
}
}
//TODO make these a more common implementation for which PocketTemplate could be anything.
private List<Entry<PocketTemplate, Integer>> mergeSortPairArrayByPairValue(List<Entry<PocketTemplate, Integer>> input) {
if (input.size() < 2) {
@ -452,7 +452,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
return mergePairArraysByPairValue(a, b);
}
}
private List<Entry<PocketTemplate, Integer>> mergePairArraysByPairValue(List<Entry<PocketTemplate, Integer>> a, List<Entry<PocketTemplate, Integer>> b) {
List<Entry<PocketTemplate, Integer>> output = new ArrayList<>();
int aPointer = 0;
@ -461,7 +461,7 @@ public class SchematicHandler { // TODO: parts of this should be moved to the or
if (aPointer >= a.size()) {
output.addAll(b.subList(bPointer, b.size()));
break;
}
}
if (bPointer >= b.size()) {
output.addAll(a.subList(aPointer, a.size()));
break;

View file

@ -0,0 +1,45 @@
package org.dimdev.util;
public class RGBA {
float red;
float green;
float blue;
float alpha;
public RGBA() {}
public RGBA (float red, float green, float blue, float alpha) {
this.red = red;
this.green = green;
this.blue = blue;
this.alpha = alpha;
}
public float getRed() {
return red;
}
public float getGreen() {
return green;
}
public float getBlue() {
return blue;
}
public float getAlpha() {
return alpha;
}
public static RGBA fromFloatArray(float[] f) {
return new RGBA(f[0], f[1], f[2], f[3]);
}
public static RGBA[] fromFloatArray(float[][] f) {
RGBA[] arr = new RGBA[4];
arr[0] = fromFloatArray(f[0]);
arr[1] = fromFloatArray(f[1]);
arr[2] = fromFloatArray(f[2]);
arr[3] = fromFloatArray(f[3]);
return arr;
}
}

View file

@ -3,6 +3,7 @@
"package": "org.dimdev.dimdoors.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
"DirectionMixin"
],
"client": [
"InGameHudMixin"