Yeet the old texturing code
Changes to be committed: modified: src/main/java/org/dimdev/dimdoors/client/EntranceRiftBlockEntityRenderer.java modified: src/main/java/org/dimdev/dimdoors/client/MyRenderLayer.java
This commit is contained in:
parent
1ba21ebb86
commit
3b95a8c801
2 changed files with 30 additions and 21 deletions
|
@ -1,9 +1,12 @@
|
||||||
package org.dimdev.dimdoors.client;
|
package org.dimdev.dimdoors.client;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.stream.Collector;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import it.unimi.dsi.fastutil.ints.AbstractInt2FloatMap;
|
||||||
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
|
||||||
import org.dimdev.dimdoors.util.RGBA;
|
import org.dimdev.dimdoors.util.RGBA;
|
||||||
|
|
||||||
|
@ -23,15 +26,18 @@ import net.fabricmc.api.Environment;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<EntranceRiftBlockEntity> {
|
public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<EntranceRiftBlockEntity> {
|
||||||
|
private static final Random RANDOM = new Random(31100L);
|
||||||
|
|
||||||
public EntranceRiftBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
public EntranceRiftBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
|
||||||
super(blockEntityRenderDispatcher);
|
super(blockEntityRenderDispatcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
|
||||||
List<RenderLayer> layers = IntStream.range(0, 16).mapToObj((i) -> {
|
// List<RenderLayer> layers = IntStream.range(0, 16).mapToObj((i) -> {
|
||||||
return MyRenderLayer.getDimensionalPortal(i + 1, blockEntity);
|
// return MyRenderLayer.getDimensionalPortal(i + 1, blockEntity);
|
||||||
}).collect(ImmutableList.toImmutableList());
|
// }).collect(ImmutableList.toImmutableList());
|
||||||
|
List<RenderLayer> layers = IntStream.range(0, 16).mapToObj(MyRenderLayer::getPortal).collect(ImmutableList.toImmutableList());
|
||||||
matrices.push();
|
matrices.push();
|
||||||
if (MinecraftClient.getInstance().world == null) {
|
if (MinecraftClient.getInstance().world == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -90,18 +96,15 @@ public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<Entranc
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawAllVertices(EntranceRiftBlockEntity blockEntity, float u, float v, Matrix4f matrix4f, VertexConsumer vertexConsumer, Direction dir) {
|
private void drawAllVertices(EntranceRiftBlockEntity blockEntity, float u, float v, Matrix4f matrix4f, VertexConsumer vertexConsumer, Direction dir) {
|
||||||
RGBA[] colors = MyRenderLayer.getColors(6);
|
float r = (RANDOM.nextFloat() * 0.5F + 0.1F) * v;
|
||||||
for (RGBA color : colors) {
|
float g = (RANDOM.nextFloat() * 0.5F + 0.4F) * v;
|
||||||
float red = color.getRed();
|
float b = (RANDOM.nextFloat() * 0.5F + 0.5F) * v;
|
||||||
float green = color.getGreen();
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, r, g, b, Direction.SOUTH);
|
||||||
float blue = color.getBlue();
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, r, g, b, Direction.NORTH);
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, red, green, blue, Direction.SOUTH);
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, r, g, b, Direction.EAST);
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, red, green, blue, Direction.NORTH);
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, r, g, b, Direction.WEST);
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, red, green, blue, Direction.EAST);
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, r, g, b, Direction.DOWN);
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 0.0F, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 0.0F, red, green, blue, Direction.WEST);
|
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, r, g, b, Direction.UP);
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 1.0F, 1.0F, red, green, blue, Direction.DOWN);
|
|
||||||
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, red, green, blue, Direction.UP);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void drawVertices(EntranceRiftBlockEntity endPortalBlockEntity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float x1, float x2, float y1, float y2, float z1, float z2, float z3, float z4, float red, float green, float blue, Direction direction) {
|
private void drawVertices(EntranceRiftBlockEntity endPortalBlockEntity, Matrix4f matrix4f, VertexConsumer vertexConsumer, float x1, float x2, float y1, float y2, float z1, float z2, float z3, float z4, float red, float green, float blue, Direction direction) {
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.client.render.RenderLayer;
|
||||||
import net.minecraft.client.render.RenderPhase;
|
import net.minecraft.client.render.RenderPhase;
|
||||||
import net.minecraft.client.render.VertexFormat;
|
import net.minecraft.client.render.VertexFormat;
|
||||||
import net.minecraft.client.render.VertexFormats;
|
import net.minecraft.client.render.VertexFormats;
|
||||||
|
import net.minecraft.client.render.block.entity.EndPortalBlockEntityRenderer;
|
||||||
import net.minecraft.state.property.BooleanProperty;
|
import net.minecraft.state.property.BooleanProperty;
|
||||||
import net.minecraft.state.property.DirectionProperty;
|
import net.minecraft.state.property.DirectionProperty;
|
||||||
import net.minecraft.state.property.EnumProperty;
|
import net.minecraft.state.property.EnumProperty;
|
||||||
|
@ -80,13 +81,18 @@ public class MyRenderLayer extends RenderLayer {
|
||||||
.fog(BLACK_FOG).build(false));
|
.fog(BLACK_FOG).build(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RGBA[] getColors(int count) {
|
public static RenderLayer getPortal(int layer) {
|
||||||
Random rand = new Random(31100L);
|
RenderPhase.Transparency transparency;
|
||||||
float[][] colors = new float[count][];
|
RenderPhase.Texture texture;
|
||||||
for (int i = 0; i < count; i++) {
|
if (layer <= 1) {
|
||||||
colors[i] = new float[]{rand.nextFloat() * 0.4F + 0.1F, rand.nextFloat() * 0.3F + 0.4F, rand.nextFloat() * 0.5F + 0.3F, 1};
|
transparency = TRANSLUCENT_TRANSPARENCY;
|
||||||
|
texture = new RenderPhase.Texture(WARP_PATH, false, false);
|
||||||
|
} else {
|
||||||
|
transparency = ADDITIVE_TRANSPARENCY;
|
||||||
|
texture = new RenderPhase.Texture(EndPortalBlockEntityRenderer.PORTAL_TEXTURE, false, false);
|
||||||
}
|
}
|
||||||
return RGBA.fromFloatArrays(colors);
|
|
||||||
|
return of("dimensional_portal", VertexFormats.POSITION_COLOR, 7, 256, false, true, RenderLayer.MultiPhaseParameters.builder().transparency(transparency).texture(texture).texturing(new RenderPhase.PortalTexturing(layer)).fog(BLACK_FOG).build(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class DimensionalPortalTexturing extends RenderPhase.Texturing {
|
public static class DimensionalPortalTexturing extends RenderPhase.Texturing {
|
||||||
|
|
Loading…
Reference in a new issue