Merge remote-tracking branch 'origin/mc1.16/dev' into mc1.16/dev

This commit is contained in:
Jozufozu 2021-08-06 12:14:13 -07:00
commit 085ab2d7bc
10 changed files with 35 additions and 61 deletions

View File

@ -14,7 +14,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper;
@ -34,7 +33,6 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
CuckooClockTileEntity clock = (CuckooClockTileEntity) te;
BlockState blockState = te.getBlockState();
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, te.getBlockPos());
Direction direction = blockState.getValue(CuckooClockBlock.HORIZONTAL_FACING);
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
@ -44,9 +42,9 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
SuperByteBuffer minuteHand = PartialBufferer.get(AllBlockPartials.CUCKOO_MINUTE_HAND, blockState);
float hourAngle = clock.hourHand.get(partialTicks);
float minuteAngle = clock.minuteHand.get(partialTicks);
rotateHand(hourHand, hourAngle, direction).light(packedLightmapCoords)
rotateHand(hourHand, hourAngle, direction).light(light)
.renderInto(ms, vb);
rotateHand(minuteHand, minuteAngle, direction).light(packedLightmapCoords)
rotateHand(minuteHand, minuteAngle, direction).light(light)
.renderInto(ms, vb);
// Doors
@ -72,9 +70,9 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
}
}
rotateDoor(leftDoor, angle, true, direction).light(packedLightmapCoords)
rotateDoor(leftDoor, angle, true, direction).light(light)
.renderInto(ms, vb);
rotateDoor(rightDoor, angle, false, direction).light(packedLightmapCoords)
rotateDoor(rightDoor, angle, false, direction).light(light)
.renderInto(ms, vb);
// Figure
@ -85,7 +83,7 @@ public class CuckooClockRenderer extends KineticTileEntityRenderer {
PartialBufferer.get(partialModel, blockState);
figure.rotateCentered(Direction.UP, AngleHelper.rad(AngleHelper.horizontalAngle(direction.getCounterClockWise())));
figure.translate(offset, 0, 0);
figure.light(packedLightmapCoords)
figure.light(light)
.renderInto(ms, vb);
}

View File

@ -22,7 +22,6 @@ import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
@ -169,41 +168,39 @@ public class MechanicalCrafterRenderer extends SafeTileEntityRenderer<Mechanical
if ((te.covered || te.phase != Phase.IDLE) && te.phase != Phase.CRAFTING && te.phase != Phase.INSERTING) {
SuperByteBuffer lidBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState, pos);
lidBuffer.renderInto(ms, vb);
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_LID, blockState);
lidBuffer.light(light).renderInto(ms, vb);
}
if (MechanicalCrafterBlock.isValidTarget(te.getLevel(), pos.relative(targetDirection), blockState)) {
SuperByteBuffer beltBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState, pos);
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT, blockState);
SuperByteBuffer beltFrameBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState, pos);
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_BELT_FRAME, blockState);
if (te.phase == Phase.EXPORTING) {
int textureIndex = (int) ((te.getCountDownSpeed() / 128f * AnimationTickHolder.getTicks()));
beltBuffer.shiftUVtoSheet(AllSpriteShifts.CRAFTER_THINGIES, (textureIndex % 4) / 4f, 0, 1);
}
beltBuffer.renderInto(ms, vb);
beltFrameBuffer.renderInto(ms, vb);
beltBuffer.light(light).renderInto(ms, vb);
beltFrameBuffer.light(light).renderInto(ms, vb);
} else {
SuperByteBuffer arrowBuffer =
renderAndTransform(te, AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState, pos);
arrowBuffer.renderInto(ms, vb);
renderAndTransform(AllBlockPartials.MECHANICAL_CRAFTER_ARROW, blockState);
arrowBuffer.light(light).renderInto(ms, vb);
}
}
private SuperByteBuffer renderAndTransform(MechanicalCrafterTileEntity te, PartialModel renderBlock,
BlockState crafterState, BlockPos pos) {
private SuperByteBuffer renderAndTransform(PartialModel renderBlock, BlockState crafterState) {
SuperByteBuffer buffer = PartialBufferer.get(renderBlock, crafterState);
float xRot = crafterState.getValue(MechanicalCrafterBlock.POINTING)
.getXRotation();
float yRot = AngleHelper.horizontalAngle(crafterState.getValue(HORIZONTAL_FACING));
buffer.rotateCentered(Direction.UP, (float) ((yRot + 90) / 180 * Math.PI));
buffer.rotateCentered(Direction.EAST, (float) ((xRot) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightColor(te.getLevel(), crafterState, pos));
return buffer;
}

View File

@ -29,7 +29,6 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.BlockItem;
@ -39,7 +38,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.World;
public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity> {
@ -117,16 +115,17 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
}
BlockState blockState = te.getBlockState();
BlockPos pos = te.getBlockPos();
Vector3d offset = getHandOffset(te, partialTicks, blockState);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
SuperByteBuffer hand = PartialBufferer.get(te.getHandPose(), blockState);
transform(te.getLevel(), pole.translate(offset.x, offset.y, offset.z), blockState, pos, true).renderInto(ms,
vb);
transform(te.getLevel(), hand.translate(offset.x, offset.y, offset.z), blockState, pos, false).renderInto(ms,
vb);
transform(pole.translate(offset.x, offset.y, offset.z), blockState, true)
.light(light)
.renderInto(ms, vb);
transform(hand.translate(offset.x, offset.y, offset.z), blockState, false)
.light(light)
.renderInto(ms, vb);
}
protected Vector3d getHandOffset(DeployerTileEntity te, float partialTicks, BlockState blockState) {
@ -138,8 +137,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
return KineticTileEntityRenderer.shaft(KineticTileEntityRenderer.getRotationAxisOf(te));
}
private static SuperByteBuffer transform(World world, SuperByteBuffer buffer, BlockState deployerState,
BlockPos pos, boolean axisDirectionMatters) {
private static SuperByteBuffer transform(SuperByteBuffer buffer, BlockState deployerState, boolean axisDirectionMatters) {
Direction facing = deployerState.getValue(FACING);
float zRotLast =
@ -151,7 +149,6 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
buffer.rotateCentered(Direction.SOUTH, (float) ((zRot) / 180 * Math.PI));
buffer.rotateCentered(Direction.UP, (float) ((yRot) / 180 * Math.PI));
buffer.rotateCentered(Direction.SOUTH, (float) ((zRotLast) / 180 * Math.PI));
buffer.light(WorldRenderer.getLightColor(world, deployerState, pos));
return buffer;
}
@ -159,9 +156,7 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
ContraptionMatrices matrices, IRenderTypeBuffer buffer) {
IVertexBuilder builder = buffer.getBuffer(RenderType.solid());
BlockState blockState = context.state;
BlockPos pos = BlockPos.ZERO;
Mode mode = NBTHelper.readEnum(context.tileData, "Mode", Mode.class);
World world = context.world;
PartialModel handPose = getHandPose(mode);
SuperByteBuffer pole = PartialBufferer.get(AllBlockPartials.DEPLOYER_POLE, blockState);
@ -187,8 +182,8 @@ public class DeployerRenderer extends SafeTileEntityRenderer<DeployerTileEntity>
pole.transform(m);
hand.transform(m);
pole = transform(world, pole, blockState, pos, true);
hand = transform(world, hand, blockState, pos, false);
pole = transform(pole, blockState, true);
hand = transform(hand, blockState, false);
pole.light(matrices.getWorld(), ContraptionRenderDispatcher.getContraptionWorldLight(context, renderWorld))
.renderInto(matrices.getViewProjection(), builder);

View File

@ -10,7 +10,6 @@ import com.simibubi.create.foundation.utility.AngleHelper;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction;
@ -38,7 +37,7 @@ public class EngineRenderer<T extends EngineTileEntity> extends SafeTileEntityRe
PartialBufferer.get(frame, te.getBlockState())
.rotateCentered(Direction.UP, angle)
.translate(0, 0, -1)
.light(WorldRenderer.getLightColor(te.getLevel(), te.getBlockState(), te.getBlockPos()))
.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}
}

View File

@ -13,10 +13,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
@ -37,14 +35,12 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
BlockState blockState = te.getBlockState();
MechanicalMixerTileEntity mixer = (MechanicalMixerTileEntity) te;
BlockPos pos = te.getBlockPos();
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
SuperByteBuffer superBuffer = PartialBufferer.get(AllBlockPartials.SHAFTLESS_COGWHEEL, blockState);
standardKineticRotationTransform(superBuffer, te, light).renderInto(ms, vb);
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, pos);
float renderedHeadOffset = mixer.getRenderedHeadOffset(partialTicks);
float speed = mixer.getRenderedHeadRotationSpeed(partialTicks);
float time = AnimationTickHolder.getRenderTime(te.getLevel());
@ -52,13 +48,13 @@ public class MechanicalMixerRenderer extends KineticTileEntityRenderer {
SuperByteBuffer poleRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_POLE, blockState);
poleRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.light(light)
.renderInto(ms, vb);
SuperByteBuffer headRender = PartialBufferer.get(AllBlockPartials.MECHANICAL_MIXER_HEAD, blockState);
headRender.rotateCentered(Direction.UP, angle)
.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.light(light)
.renderInto(ms, vb);
}

View File

@ -13,9 +13,7 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.math.BlockPos;
public class MechanicalPressRenderer extends KineticTileEntityRenderer {
@ -35,14 +33,12 @@ public class MechanicalPressRenderer extends KineticTileEntityRenderer {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
BlockPos pos = te.getBlockPos();
BlockState blockState = te.getBlockState();
int packedLightmapCoords = WorldRenderer.getLightColor(te.getLevel(), blockState, pos);
float renderedHeadOffset = ((MechanicalPressTileEntity) te).getRenderedHeadOffset(partialTicks);
SuperByteBuffer headRender = PartialBufferer.getFacing(AllBlockPartials.MECHANICAL_PRESS_HEAD, blockState, blockState.getValue(HORIZONTAL_FACING));
headRender.translate(0, -renderedHeadOffset, 0)
.light(packedLightmapCoords)
.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
}

View File

@ -13,7 +13,7 @@ public class ContraptionRenderInfo {
public final Contraption contraption;
public final PlacementSimulationWorld renderWorld;
private ContraptionMatrices matrices = new ContraptionMatrices();
private final ContraptionMatrices matrices = new ContraptionMatrices();
private boolean visible;
public ContraptionRenderInfo(Contraption contraption, PlacementSimulationWorld renderWorld) {

View File

@ -15,7 +15,6 @@ import com.simibubi.create.foundation.utility.Iterate;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.util.Direction;
import net.minecraft.util.math.MathHelper;
@ -43,9 +42,9 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
super.renderSafe(te, partialTicks, ms, buffer, light, overlay);
BlockState gaugeState = te.getBlockState();
GaugeTileEntity gaugeTE = (GaugeTileEntity) te;
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), gaugeState, te.getBlockPos());
PartialModel partialModel = (type == Type.SPEED ? AllBlockPartials.GAUGE_HEAD_SPEED : AllBlockPartials.GAUGE_HEAD_STRESS);
SuperByteBuffer headBuffer =
@ -64,12 +63,11 @@ public class GaugeRenderer extends KineticTileEntityRenderer {
rotateBufferTowards(dialBuffer, facing).translate(0, dialPivot, dialPivot)
.rotate(Direction.EAST, (float) (Math.PI / 2 * -progress))
.translate(0, -dialPivot, -dialPivot)
.light(lightCoords)
.light(light)
.renderInto(ms, vb);
rotateBufferTowards(headBuffer, facing).light(lightCoords)
rotateBufferTowards(headBuffer, facing).light(light)
.renderInto(ms, vb);
}
}
@Override

View File

@ -1,7 +1,6 @@
package com.simibubi.create.content.curiosities.bell;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.simibubi.create.foundation.render.PartialBufferer;
import com.simibubi.create.foundation.render.SuperByteBuffer;
import com.simibubi.create.foundation.tileEntity.renderer.SafeTileEntityRenderer;
@ -11,7 +10,6 @@ import net.minecraft.block.BellBlock;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.BellAttachment;
import net.minecraft.util.Direction;
@ -39,9 +37,8 @@ public class BellRenderer<TE extends AbstractBellTileEntity> extends SafeTileEnt
rY += 90;
bell.rotateCentered(Direction.UP, AngleHelper.rad(rY));
IVertexBuilder vb = buffer.getBuffer(RenderType.cutout());
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), state, te.getBlockPos());
bell.light(lightCoords).renderInto(ms, vb);
bell.light(light)
.renderInto(ms, buffer.getBuffer(RenderType.cutout()));
}
public static float getSwingAngle(float time) {

View File

@ -13,7 +13,6 @@ import com.simibubi.create.foundation.utility.ColorHelper;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.state.properties.AttachFace;
import net.minecraft.util.Direction;
@ -31,7 +30,6 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
if (Backend.getInstance().canUseInstancing(te.getLevel())) return;
BlockState leverState = te.getBlockState();
int lightCoords = WorldRenderer.getLightColor(te.getLevel(), leverState, te.getBlockPos());
float state = te.clientState.get(partialTicks);
IVertexBuilder vb = buffer.getBuffer(RenderType.solid());
@ -42,13 +40,13 @@ public class AnalogLeverRenderer extends SafeTileEntityRenderer<AnalogLeverTileE
transform(handle, leverState).translate(1 / 2f, 1 / 16f, 1 / 2f)
.rotate(Direction.EAST, angle)
.translate(-1 / 2f, -1 / 16f, -1 / 2f);
handle.light(lightCoords)
handle.light(light)
.renderInto(ms, vb);
// Indicator
int color = ColorHelper.mixColors(0x2C0300, 0xCD0000, state / 15f);
SuperByteBuffer indicator = transform(PartialBufferer.get(AllBlockPartials.ANALOG_LEVER_INDICATOR, leverState), leverState);
indicator.light(lightCoords)
indicator.light(light)
.color(color)
.renderInto(ms, vb);
}