diff --git a/src/main/java/com/simibubi/create/content/optics/mirror/MirrorRenderer.java b/src/main/java/com/simibubi/create/content/optics/mirror/MirrorRenderer.java index 3b376464f..1fe5f710b 100644 --- a/src/main/java/com/simibubi/create/content/optics/mirror/MirrorRenderer.java +++ b/src/main/java/com/simibubi/create/content/optics/mirror/MirrorRenderer.java @@ -1,5 +1,9 @@ package com.simibubi.create.content.optics.mirror; +import static net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer.TEXTURE_BEACON_BEAM; + +import javax.annotation.ParametersAreNonnullByDefault; + import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import com.simibubi.create.AllBlockPartials; @@ -20,36 +24,32 @@ import net.minecraft.util.math.vector.Matrix3f; import net.minecraft.util.math.vector.Matrix4f; import net.minecraft.util.math.vector.Vector3f; -import javax.annotation.ParametersAreNonnullByDefault; - -import static net.minecraft.client.renderer.tileentity.BeaconTileEntityRenderer.TEXTURE_BEACON_BEAM; - @ParametersAreNonnullByDefault public class MirrorRenderer extends KineticTileEntityRenderer { public MirrorRenderer(TileEntityRendererDispatcher dispatcher) { super(dispatcher); } - private static void renderBeam(MatrixStack ms, IVertexBuilder builder, float[] colors, double segemntLength, double length, float p_228840_8_, float p_228840_9_, float p_228840_10_, float p_228840_11_, float p_228840_12_, float p_228840_13_, float p_228840_14_, float p_228840_15_, float p_228840_16_, float p_228840_17_, float p_228840_18_, float p_228840_19_) { + private static void renderBeam(MatrixStack ms, IVertexBuilder builder, float[] colors, float alpha, double segemntLength, double length, float p_228840_8_, float p_228840_9_, float p_228840_10_, float p_228840_11_, float p_228840_12_, float p_228840_13_, float p_228840_14_, float p_228840_15_, float p_228840_16_, float p_228840_17_, float p_228840_18_, float p_228840_19_) { MatrixStack.Entry matrixstack$entry = ms.peek(); Matrix4f model = matrixstack$entry.getModel(); Matrix3f normal = matrixstack$entry.getNormal(); - putVertices(model, normal, builder, colors, segemntLength, length, p_228840_8_, p_228840_9_, p_228840_10_, p_228840_11_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); - putVertices(model, normal, builder, colors, segemntLength, length, p_228840_14_, p_228840_15_, p_228840_12_, p_228840_13_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); - putVertices(model, normal, builder, colors, segemntLength, length, p_228840_10_, p_228840_11_, p_228840_14_, p_228840_15_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); - putVertices(model, normal, builder, colors, segemntLength, length, p_228840_12_, p_228840_13_, p_228840_8_, p_228840_9_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); + putVertices(model, normal, builder, colors, alpha, segemntLength, length, p_228840_8_, p_228840_9_, p_228840_10_, p_228840_11_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); + putVertices(model, normal, builder, colors, alpha, segemntLength, length, p_228840_14_, p_228840_15_, p_228840_12_, p_228840_13_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); + putVertices(model, normal, builder, colors, alpha, segemntLength, length, p_228840_10_, p_228840_11_, p_228840_14_, p_228840_15_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); + putVertices(model, normal, builder, colors, alpha, segemntLength, length, p_228840_12_, p_228840_13_, p_228840_8_, p_228840_9_, p_228840_16_, p_228840_17_, p_228840_18_, p_228840_19_); } - private static void putVertices(Matrix4f model, Matrix3f normal, IVertexBuilder builder, float[] colors, double segemntLength, double length, float p_228839_9_, float p_228839_10_, float p_228839_11_, float p_228839_12_, float p_228839_13_, float p_228839_14_, float p_228839_15_, float p_228839_16_) { - putVertex(model, normal, builder, colors, (float) length, p_228839_9_, p_228839_10_, p_228839_14_, p_228839_15_); - putVertex(model, normal, builder, colors, (float) segemntLength, p_228839_9_, p_228839_10_, p_228839_14_, p_228839_16_); - putVertex(model, normal, builder, colors, (float) segemntLength, p_228839_11_, p_228839_12_, p_228839_13_, p_228839_16_); - putVertex(model, normal, builder, colors, (float) length, p_228839_11_, p_228839_12_, p_228839_13_, p_228839_15_); + private static void putVertices(Matrix4f model, Matrix3f normal, IVertexBuilder builder, float[] colors, float alpha, double segemntLength, double length, float p_228839_9_, float p_228839_10_, float p_228839_11_, float p_228839_12_, float p_228839_13_, float p_228839_14_, float p_228839_15_, float p_228839_16_) { + putVertex(model, normal, builder, colors, alpha, (float) length, p_228839_9_, p_228839_10_, p_228839_14_, p_228839_15_); + putVertex(model, normal, builder, colors, alpha, (float) segemntLength, p_228839_9_, p_228839_10_, p_228839_14_, p_228839_16_); + putVertex(model, normal, builder, colors, alpha, (float) segemntLength, p_228839_11_, p_228839_12_, p_228839_13_, p_228839_16_); + putVertex(model, normal, builder, colors, alpha, (float) length, p_228839_11_, p_228839_12_, p_228839_13_, p_228839_15_); } - private static void putVertex(Matrix4f model, Matrix3f normal, IVertexBuilder builder, float[] colors, float vertexY, float vertexX, float vertexZ, float textureX, float textureY) { + private static void putVertex(Matrix4f model, Matrix3f normal, IVertexBuilder builder, float[] colors, float alpha, float vertexY, float vertexX, float vertexZ, float textureX, float textureY) { builder.vertex(model, vertexX, vertexY, vertexZ) - .color(colors[0], colors[1], colors[2], 1f) + .color(colors[0], colors[1], colors[2], alpha) .texture(textureX, textureY) .overlay(OverlayTexture.DEFAULT_UV) .light(15728880) @@ -62,8 +62,6 @@ public class MirrorRenderer extends KineticTileEntityRenderer { int light, int overlay) { // if (FastRenderDispatcher.available(te.getWorld())) return; - - super.renderSafe(te, partialTicks, ms, buffer, light, overlay); MirrorTileEntity mirrorTe = (MirrorTileEntity) te; renderMirror(mirrorTe, partialTicks, ms, buffer, light); @@ -100,10 +98,13 @@ public class MirrorRenderer extends KineticTileEntityRenderer { ms.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(adjustedGameTime * 2.25F - 45.0F)); float textureOffset1 = MathHelper.fractionalPart(-adjustedGameTime * 0.2F - (float) MathHelper.floor(-adjustedGameTime * 0.1F)) - 1; float textureOffset2 = (float) beamSegment.getLength() * 2.5f + textureOffset1; - renderBeam(ms, buffer.getBuffer(RenderType.getBeaconBeam(TEXTURE_BEACON_BEAM, true)), beamSegment.colors, + renderBeam(ms, buffer.getBuffer(RenderType.getBeaconBeam(TEXTURE_BEACON_BEAM, false)), beamSegment.colors, 1F, prevLength, totalLength, 0F, 0.2F, .2F, 0F, -.2f, 0f, 0f, -.2f, 0f, 1f, textureOffset2, textureOffset1); ms.pop(); + renderBeam(ms, buffer.getBuffer(RenderType.getBeaconBeam(TEXTURE_BEACON_BEAM, true)), beamSegment.colors, 0.125F, + prevLength, totalLength, 0F, -.25f, .25f, -.25f, -.25f, + .25f, .25f, .25f, 0.0F, 1.0F, textureOffset2, textureOffset1); ms.pop(); ms.pop(); } diff --git a/src/main/java/com/simibubi/create/content/optics/mirror/MirrorTileEntity.java b/src/main/java/com/simibubi/create/content/optics/mirror/MirrorTileEntity.java index 036dbc00d..2d4e368f9 100644 --- a/src/main/java/com/simibubi/create/content/optics/mirror/MirrorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/optics/mirror/MirrorTileEntity.java @@ -16,8 +16,11 @@ import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.tileentity.BeaconTileEntity; import net.minecraft.tileentity.TileEntityType; import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.vector.Vector3d; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import javax.annotation.Nonnull; @@ -144,4 +147,15 @@ public class MirrorTileEntity extends KineticTileEntity implements ILightHandler private Direction.Axis getAxis() { return getBlockState().get(BlockStateProperties.AXIS); } + + @Override + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + @OnlyIn(Dist.CLIENT) + public double getMaxRenderDistanceSquared() { + return 256.0D; + } }