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:
SD 2020-09-26 20:12:09 +05:30
parent 1ba21ebb86
commit 3b95a8c801
No known key found for this signature in database
GPG key ID: E36B57EE08544BC5
2 changed files with 30 additions and 21 deletions

View file

@ -1,9 +1,12 @@
package org.dimdev.dimdoors.client;
import java.util.List;
import java.util.Random;
import java.util.stream.Collector;
import java.util.stream.IntStream;
import com.google.common.collect.ImmutableList;
import it.unimi.dsi.fastutil.ints.AbstractInt2FloatMap;
import org.dimdev.dimdoors.block.entity.EntranceRiftBlockEntity;
import org.dimdev.dimdoors.util.RGBA;
@ -23,15 +26,18 @@ import net.fabricmc.api.Environment;
@Environment(EnvType.CLIENT)
public class EntranceRiftBlockEntityRenderer extends BlockEntityRenderer<EntranceRiftBlockEntity> {
private static final Random RANDOM = new Random(31100L);
public EntranceRiftBlockEntityRenderer(BlockEntityRenderDispatcher blockEntityRenderDispatcher) {
super(blockEntityRenderDispatcher);
}
@Override
public void render(EntranceRiftBlockEntity blockEntity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
List<RenderLayer> layers = IntStream.range(0, 16).mapToObj((i) -> {
return MyRenderLayer.getDimensionalPortal(i + 1, blockEntity);
}).collect(ImmutableList.toImmutableList());
// List<RenderLayer> layers = IntStream.range(0, 16).mapToObj((i) -> {
// return MyRenderLayer.getDimensionalPortal(i + 1, blockEntity);
// }).collect(ImmutableList.toImmutableList());
List<RenderLayer> layers = IntStream.range(0, 16).mapToObj(MyRenderLayer::getPortal).collect(ImmutableList.toImmutableList());
matrices.push();
if (MinecraftClient.getInstance().world == null) {
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) {
RGBA[] colors = MyRenderLayer.getColors(6);
for (RGBA color : colors) {
float red = color.getRed();
float green = color.getGreen();
float blue = color.getBlue();
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, 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, 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, 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, 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);
}
float r = (RANDOM.nextFloat() * 0.5F + 0.1F) * v;
float g = (RANDOM.nextFloat() * 0.5F + 0.4F) * v;
float b = (RANDOM.nextFloat() * 0.5F + 0.5F) * v;
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 0.0F, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, r, g, b, Direction.SOUTH);
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 0.0F, 1.0F, 1.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, r, g, b, Direction.NORTH);
this.drawVertices(blockEntity, matrix4f, vertexConsumer, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.0F, r, g, b, Direction.EAST);
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, 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, 1.0F, 1.0F, 1.0F, 1.0F, 1.0F, 0.0F, 0.0F, r, g, b, 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) {

View file

@ -15,6 +15,7 @@ import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.RenderPhase;
import net.minecraft.client.render.VertexFormat;
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.DirectionProperty;
import net.minecraft.state.property.EnumProperty;
@ -80,13 +81,18 @@ public class MyRenderLayer extends RenderLayer {
.fog(BLACK_FOG).build(false));
}
public static RGBA[] getColors(int count) {
Random rand = new Random(31100L);
float[][] colors = new float[count][];
for (int i = 0; i < count; i++) {
colors[i] = new float[]{rand.nextFloat() * 0.4F + 0.1F, rand.nextFloat() * 0.3F + 0.4F, rand.nextFloat() * 0.5F + 0.3F, 1};
public static RenderLayer getPortal(int layer) {
RenderPhase.Transparency transparency;
RenderPhase.Texture texture;
if (layer <= 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 {