mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-15 22:13:40 +01:00
Fix saw and PSI diffuse
- Fix saw and portable storage/fluid interface diffuse lighting - Remove "disableDiffuseTransform" option from SuperByteBuffer - Switch argument order in RenderedContraption constructor to be consistent with superclass (ContraptionWorldHolder)
This commit is contained in:
parent
285b8f98cf
commit
3c84087f15
5 changed files with 34 additions and 52 deletions
|
@ -15,7 +15,6 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.MatrixStacker;
|
||||
import com.simibubi.create.foundation.utility.worldWrappers.PlacementSimulationWorld;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
|
@ -39,8 +38,8 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
|||
BlockState blockState = te.getBlockState();
|
||||
float progress = te.getExtensionDistance(partialTicks);
|
||||
IVertexBuilder vb = buffer.getBuffer(RenderType.getSolid());
|
||||
render(blockState, progress, te.isConnected(), sbb -> sbb.light(light)
|
||||
.renderInto(ms, vb), ms);
|
||||
render(blockState, te.isConnected(), progress, null, sbb -> sbb.light(light)
|
||||
.renderInto(ms, vb));
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, PlacementSimulationWorld renderWorld,
|
||||
|
@ -57,39 +56,36 @@ public class PortableStorageInterfaceRenderer extends SafeTileEntityRenderer<Por
|
|||
lit = te.isConnected();
|
||||
}
|
||||
|
||||
render(blockState, progress, lit, sbb -> sbb.transform(matrices.contraptionStack)
|
||||
.disableDiffuseTransform()
|
||||
.light(matrices.entityMatrix,
|
||||
render(blockState, lit, progress, matrices.contraptionStack, sbb -> sbb.light(matrices.entityMatrix,
|
||||
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
|
||||
.renderInto(matrices.entityStack, vb), matrices.contraptionStack);
|
||||
.renderInto(matrices.entityStack, vb));
|
||||
}
|
||||
|
||||
private static void render(BlockState blockState, float progress, boolean lit,
|
||||
Consumer<SuperByteBuffer> drawCallback, MatrixStack ms) {
|
||||
ms.push();
|
||||
|
||||
private static void render(BlockState blockState, boolean lit, float progress,
|
||||
MatrixStack local, Consumer<SuperByteBuffer> drawCallback) {
|
||||
SuperByteBuffer middle = PartialBufferer.get(getMiddleForState(blockState, lit), blockState);
|
||||
SuperByteBuffer top = PartialBufferer.get(getTopForState(blockState), blockState);
|
||||
|
||||
if (local != null) {
|
||||
middle.transform(local);
|
||||
top.transform(local);
|
||||
}
|
||||
Direction facing = blockState.get(PortableStorageInterfaceBlock.FACING);
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.unCentre();
|
||||
|
||||
ms.translate(0, progress / 2f, 0);
|
||||
ms.push();
|
||||
ms.translate(0, 6 / 16f, 0);
|
||||
rotateToFacing(middle, facing);
|
||||
rotateToFacing(top, facing);
|
||||
middle.translate(0, progress * 0.5f + 0.375f, 0);
|
||||
top.translate(0, progress, 0);
|
||||
|
||||
drawCallback.accept(middle);
|
||||
|
||||
ms.pop();
|
||||
ms.translate(0, progress / 2f, 0);
|
||||
|
||||
drawCallback.accept(top);
|
||||
}
|
||||
|
||||
ms.pop();
|
||||
private static void rotateToFacing(SuperByteBuffer buffer, Direction facing) {
|
||||
buffer.matrixStacker()
|
||||
.centre()
|
||||
.rotateY(AngleHelper.horizontalAngle(facing))
|
||||
.rotateX(facing == Direction.UP ? 0 : facing == Direction.DOWN ? 180 : 90)
|
||||
.unCentre();
|
||||
}
|
||||
|
||||
protected static PortableStorageInterfaceTileEntity getTargetPSI(MovementContext context) {
|
||||
|
|
|
@ -56,11 +56,9 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
|
||||
protected void renderBlade(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light) {
|
||||
BlockState blockState = te.getBlockState();
|
||||
SuperByteBuffer superBuffer;
|
||||
PartialModel partial;
|
||||
float speed = te.getSpeed();
|
||||
|
||||
ms.push();
|
||||
boolean rotate = false;
|
||||
|
||||
if (SawBlock.isHorizontal(blockState)) {
|
||||
if (speed > 0) {
|
||||
|
@ -80,16 +78,17 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
}
|
||||
|
||||
if (!blockState.get(SawBlock.AXIS_ALONG_FIRST_COORDINATE))
|
||||
MatrixStacker.of(ms)
|
||||
.centre()
|
||||
.rotateY(90)
|
||||
.unCentre();
|
||||
rotate = true;
|
||||
}
|
||||
superBuffer = PartialBufferer.getFacing(partial, blockState);
|
||||
superBuffer.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
|
||||
ms.pop();
|
||||
SuperByteBuffer superBuffer = PartialBufferer.getFacing(partial, blockState);
|
||||
if (rotate) {
|
||||
superBuffer.rotateCentered(Direction.UP, AngleHelper.rad(90));
|
||||
}
|
||||
superBuffer
|
||||
.color(0xFFFFFF)
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
}
|
||||
|
||||
protected void renderShaft(SawTileEntity te, MatrixStack ms, IRenderTypeBuffer buffer, int light, int overlay) {
|
||||
|
@ -198,7 +197,6 @@ public class SawRenderer extends SafeTileEntityRenderer<SawTileEntity> {
|
|||
|
||||
superBuffer
|
||||
.transform(m)
|
||||
.disableDiffuseTransform()
|
||||
.light(matrices.entityMatrix,
|
||||
ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
|
||||
.renderInto(matrices.entityStack, buffer.getBuffer(RenderType.getCutoutMipped()));
|
||||
|
|
|
@ -160,7 +160,7 @@ public class ContraptionRenderDispatcher {
|
|||
|
||||
if (contraption == null) {
|
||||
PlacementSimulationWorld renderWorld = setupRenderWorld(world, c);
|
||||
contraption = new RenderedContraption(renderWorld, c);
|
||||
contraption = new RenderedContraption(c, renderWorld);
|
||||
RENDERERS.put(entityId, contraption);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RenderedContraption extends ContraptionWorldHolder {
|
|||
private Matrix4f model;
|
||||
private AxisAlignedBB lightBox;
|
||||
|
||||
public RenderedContraption(PlacementSimulationWorld renderWorld, Contraption contraption) {
|
||||
public RenderedContraption(Contraption contraption, PlacementSimulationWorld renderWorld) {
|
||||
super(contraption, renderWorld);
|
||||
this.lighter = contraption.makeLighter();
|
||||
this.materialManager = new ContraptionMaterialManager(CreateContexts.CWORLD);
|
||||
|
|
|
@ -37,7 +37,6 @@ public class SuperByteBuffer {
|
|||
// Vertex Coloring
|
||||
private boolean shouldColor;
|
||||
private int r, g, b, a;
|
||||
private boolean disableDiffuseTransform;
|
||||
|
||||
// Vertex Lighting
|
||||
private boolean useWorldLight;
|
||||
|
@ -120,12 +119,7 @@ public class SuperByteBuffer {
|
|||
int colorB = Math.min(255, (int) (((float) this.b) * instanceDiffuse));
|
||||
builder.color(colorR, colorG, colorB, this.a);
|
||||
} else {
|
||||
float diffuseMult;
|
||||
if (disableDiffuseTransform) {
|
||||
diffuseMult = 1.0f;
|
||||
} else {
|
||||
diffuseMult = instanceDiffuse / staticDiffuse;
|
||||
}
|
||||
float diffuseMult = instanceDiffuse / staticDiffuse;
|
||||
int colorR = Math.min(255, (int) (((float) Byte.toUnsignedInt(r)) * diffuseMult));
|
||||
int colorG = Math.min(255, (int) (((float) Byte.toUnsignedInt(g)) * diffuseMult));
|
||||
int colorB = Math.min(255, (int) (((float) Byte.toUnsignedInt(b)) * diffuseMult));
|
||||
|
@ -179,7 +173,6 @@ public class SuperByteBuffer {
|
|||
g = 0;
|
||||
b = 0;
|
||||
a = 0;
|
||||
disableDiffuseTransform = false;
|
||||
useWorldLight = false;
|
||||
hybridLight = false;
|
||||
packedLightCoords = 0;
|
||||
|
@ -248,11 +241,6 @@ public class SuperByteBuffer {
|
|||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer disableDiffuseTransform() {
|
||||
disableDiffuseTransform = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer shiftUV(SpriteShiftEntry entry) {
|
||||
this.spriteShiftFunc = (builder, u, v) -> {
|
||||
float targetU = entry.getTarget()
|
||||
|
|
Loading…
Reference in a new issue