mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-12 15:26:39 +01:00
SuperByteBuffer fixes and improvements
- Use color as a multiplier instead of override - Always use maximum of provided light and stored light - Use stored overlay if overlay value is not provided - Use shader light directions to calculate diffuse - Require providing level when using level light - Reuse objects
This commit is contained in:
parent
ec0350cfba
commit
02dca46855
51 changed files with 383 additions and 444 deletions
|
@ -1,8 +1,6 @@
|
|||
package com.simibubi.create.compat.jei.category.animations;
|
||||
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
|
@ -12,10 +10,10 @@ import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
|||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
@ -84,14 +82,10 @@ public class AnimatedBlazeBurner extends AnimatedKinetics {
|
|||
uScroll = uScroll - Math.floor(uScroll);
|
||||
uScroll = uScroll * spriteWidth / 2;
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
MultiBufferSource.BufferSource buffer = mc.renderBuffers()
|
||||
.bufferSource();
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.cutoutMipped());
|
||||
CachedBufferer.partial(AllPartialModels.BLAZE_BURNER_FLAME, Blocks.AIR.defaultBlockState())
|
||||
.shiftUVScrolling(spriteShift, (float) uScroll, (float) vScroll)
|
||||
.light(LightTexture.FULL_BRIGHT)
|
||||
.renderInto(matrixStack, vb);
|
||||
.shiftUVScrolling(spriteShift, (float) uScroll, (float) vScroll)
|
||||
.light(LightTexture.FULL_BRIGHT)
|
||||
.renderInto(matrixStack, graphics.bufferSource().getBuffer(RenderType.cutoutMipped()));
|
||||
matrixStack.popPose();
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ public class HarvesterRenderer extends SafeBlockEntityRenderer<HarvesterBlockEnt
|
|||
superBuffer.transform(matrices.getModel());
|
||||
transform(context.world, facing, superBuffer, speed, PIVOT);
|
||||
|
||||
superBuffer
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
superBuffer.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffers.getBuffer(RenderType.cutoutMipped()));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.simibubi.create.content.contraptions.actors.psi;
|
|||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
@ -18,6 +16,8 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -55,8 +55,8 @@ public class PortableStorageInterfaceRenderer extends SafeBlockEntityRenderer<Po
|
|||
float progress = animation.getValue(renderPartialTicks);
|
||||
boolean lit = animation.settled();
|
||||
render(blockState, lit, progress, matrices.getModel(),
|
||||
sbb -> sbb
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
sbb -> sbb.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), vb));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.contraptions.actors.roller;
|
|||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.contraptions.actors.harvester.HarvesterRenderer;
|
||||
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
||||
|
@ -34,6 +35,7 @@ public class RollerRenderer extends SmartBlockEntityRenderer<RollerBlockEntity>
|
|||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
BlockState blockState = be.getBlockState();
|
||||
VertexConsumer vc = buffer.getBuffer(RenderType.cutoutMipped());
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(0, -0.25, 0);
|
||||
|
@ -45,19 +47,20 @@ public class RollerRenderer extends SmartBlockEntityRenderer<RollerBlockEntity>
|
|||
superBuffer.translate(0, -.5, .5)
|
||||
.rotateYDegrees(90)
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
|
||||
.renderInto(ms, vc);
|
||||
ms.popPose();
|
||||
|
||||
CachedBufferer.partial(AllPartialModels.ROLLER_FRAME, blockState)
|
||||
.rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180), Direction.UP)
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
|
||||
.renderInto(ms, vc);
|
||||
}
|
||||
|
||||
public static void renderInContraption(MovementContext context, VirtualRenderWorld renderWorld,
|
||||
ContraptionMatrices matrices, MultiBufferSource buffers) {
|
||||
BlockState blockState = context.state;
|
||||
Direction facing = blockState.getValue(HORIZONTAL_FACING);
|
||||
VertexConsumer vc = buffers.getBuffer(RenderType.cutoutMipped());
|
||||
SuperByteBuffer superBuffer = CachedBufferer.partial(AllPartialModels.ROLLER_WHEEL, blockState);
|
||||
float speed = (float) (!VecHelper.isVecPointingTowards(context.relativeMotion, facing.getOpposite())
|
||||
? context.getAnimationSpeed()
|
||||
|
@ -76,15 +79,17 @@ public class RollerRenderer extends SmartBlockEntityRenderer<RollerBlockEntity>
|
|||
int contraptionWorldLight = LevelRenderer.getLightColor(renderWorld, context.localPos);
|
||||
superBuffer.translate(0, -.5, .5)
|
||||
.rotateYDegrees(90)
|
||||
.light(matrices.getWorld(), contraptionWorldLight)
|
||||
.renderInto(viewProjection, buffers.getBuffer(RenderType.cutoutMipped()));
|
||||
.light(contraptionWorldLight)
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(viewProjection, vc);
|
||||
viewProjection.popPose();
|
||||
|
||||
CachedBufferer.partial(AllPartialModels.ROLLER_FRAME, blockState)
|
||||
.transform(matrices.getModel())
|
||||
.rotateCentered(AngleHelper.rad(AngleHelper.horizontalAngle(facing) + 180), Direction.UP)
|
||||
.light(matrices.getWorld(), contraptionWorldLight)
|
||||
.renderInto(viewProjection, buffers.getBuffer(RenderType.cutoutMipped()));
|
||||
.light(contraptionWorldLight)
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(viewProjection, vc);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public class TrackPaverV2 {
|
|||
Map<Pair<Integer, Integer>, Double> yLevels = new HashMap<>();
|
||||
Map<Pair<Integer, Integer>, Double> tLevels = new HashMap<>();
|
||||
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos bePosition = bc.bePositions.getFirst();
|
||||
double radius = -task.getHorizontalInterval()
|
||||
.getFirst();
|
||||
double r1 = radius - .575;
|
||||
|
@ -109,10 +109,10 @@ public class TrackPaverV2 {
|
|||
|
||||
double handleLength = bc.getHandleLength();
|
||||
Vec3 start = bc.starts.getFirst()
|
||||
.subtract(Vec3.atLowerCornerOf(tePosition))
|
||||
.subtract(Vec3.atLowerCornerOf(bePosition))
|
||||
.add(0, 3 / 16f, 0);
|
||||
Vec3 end = bc.starts.getSecond()
|
||||
.subtract(Vec3.atLowerCornerOf(tePosition))
|
||||
.subtract(Vec3.atLowerCornerOf(bePosition))
|
||||
.add(0, 3 / 16f, 0);
|
||||
Vec3 startHandle = bc.axes.getFirst()
|
||||
.scale(handleLength)
|
||||
|
@ -190,7 +190,7 @@ public class TrackPaverV2 {
|
|||
BlockPos targetPos = new BlockPos(entry.getKey()
|
||||
.getFirst(), floor,
|
||||
entry.getKey()
|
||||
.getSecond()).offset(tePosition);
|
||||
.getSecond()).offset(bePosition);
|
||||
task.put(targetPos.getX(), targetPos.getZ(), targetPos.getY() + (yValue - floor >= .5 ? .5f : 0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.content.contraptions.actors.trainControls;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
|
||||
|
@ -11,6 +10,7 @@ import com.simibubi.create.foundation.utility.AngleHelper;
|
|||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -32,7 +32,8 @@ public class ControlsRenderer {
|
|||
.center()
|
||||
.rotateYDegrees(hAngle)
|
||||
.uncenter()
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped()));
|
||||
|
||||
double yOffset = Mth.lerp(equipAnimation * equipAnimation, -0.15f, 0.05f);
|
||||
|
@ -52,7 +53,8 @@ public class ControlsRenderer {
|
|||
.translate(0, -2 / 16f, -3 / 16f)
|
||||
.translate(first ? 0 : 6 / 16f, 0, 0);
|
||||
lever.transform(ms)
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -4,9 +4,6 @@ import javax.annotation.Nullable;
|
|||
|
||||
import org.joml.Quaternionf;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import com.mojang.math.Axis;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
|
||||
|
@ -21,6 +18,9 @@ import com.simibubi.create.foundation.render.SuperByteBuffer;
|
|||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationContext;
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -72,8 +72,8 @@ public class StabilizedBearingMovementBehaviour implements MovementBehaviour {
|
|||
superBuffer.rotateCentered(orientation);
|
||||
|
||||
// render
|
||||
superBuffer
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
superBuffer.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,11 +33,10 @@ public class ElevatorPulleyRenderer extends KineticBlockEntityRenderer<ElevatorP
|
|||
// if (VisualizationManager.supportsVisualization(be.getLevel()))
|
||||
// return;
|
||||
|
||||
// from KBE. replace with super call when flw instance is implemented
|
||||
// from KBE. replace with super call when flw visual is implemented
|
||||
BlockState state = getRenderedBlockState(be);
|
||||
RenderType type = getRenderType(be, state);
|
||||
if (type != null)
|
||||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
//
|
||||
|
||||
float offset = PulleyRenderer.getBlockEntityOffset(partialTicks, be);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.simibubi.create.content.contraptions.pulley;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.content.kinetics.base.IRotate;
|
||||
|
@ -11,6 +9,8 @@ import com.simibubi.create.foundation.render.CachedBufferer;
|
|||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -53,8 +53,9 @@ public abstract class AbstractPulleyRenderer<T extends KineticBlockEntity> exten
|
|||
|
||||
Axis rotationAxis = ((IRotate) be.getBlockState()
|
||||
.getBlock()).getRotationAxis(be.getBlockState());
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
kineticRotationTransform(getRotatedCoil(be), be, rotationAxis, AngleHelper.rad(offset * 180), light)
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
|
||||
.renderInto(ms, vb);
|
||||
|
||||
Level world = be.getLevel();
|
||||
BlockState blockState = be.getBlockState();
|
||||
|
@ -65,7 +66,6 @@ public abstract class AbstractPulleyRenderer<T extends KineticBlockEntity> exten
|
|||
SuperByteBuffer magnet = renderMagnet(be);
|
||||
SuperByteBuffer rope = renderRope(be);
|
||||
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
if (running || offset == 0)
|
||||
renderAt(world, offset > .25f ? magnet : halfMagnet, offset, pos, ms, vb);
|
||||
|
||||
|
@ -85,7 +85,7 @@ public abstract class AbstractPulleyRenderer<T extends KineticBlockEntity> exten
|
|||
BlockPos actualPos = pulleyPos.below((int) offset);
|
||||
int light = LevelRenderer.getLightColor(world, world.getBlockState(actualPos), actualPos);
|
||||
partial.translate(0, -offset, 0)
|
||||
.light(light)
|
||||
.light(light)
|
||||
.renderInto(ms, buffer);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,8 +69,7 @@ public class ContraptionEntityRenderer<C extends AbstractContraptionEntity> exte
|
|||
if (!sbb.isEmpty()) {
|
||||
VertexConsumer vc = buffers.getBuffer(renderType);
|
||||
sbb.transform(matrices.getModel())
|
||||
.light(matrices.getWorld())
|
||||
.hybridLight()
|
||||
.useLevelLight(level, matrices.getWorld())
|
||||
.renderInto(poseStack, vc);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.equipment.armor;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
@ -9,7 +10,6 @@ import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
|||
import net.minecraft.client.model.EntityModel;
|
||||
import net.minecraft.client.model.HumanoidModel;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
|
@ -43,7 +43,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
return;
|
||||
|
||||
HumanoidModel<?> model = (HumanoidModel<?>) entityModel;
|
||||
RenderType renderType = Sheets.cutoutBlockSheet();
|
||||
VertexConsumer vc = buffer.getBuffer(Sheets.cutoutBlockSheet());
|
||||
BlockState renderedState = item.getBlock().defaultBlockState()
|
||||
.setValue(BacktankBlock.HORIZONTAL_FACING, Direction.SOUTH);
|
||||
SuperByteBuffer backtank = CachedBufferer.block(renderedState);
|
||||
|
@ -57,7 +57,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
|
||||
backtank.disableDiffuse()
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(renderType));
|
||||
.renderInto(ms, vc);
|
||||
|
||||
cogs.center()
|
||||
.rotateYDegrees(180)
|
||||
|
@ -68,7 +68,7 @@ public class BacktankArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
|
||||
cogs.disableDiffuse()
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(renderType));
|
||||
.renderInto(ms, vc);
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.base;
|
|||
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
|
@ -15,6 +14,7 @@ import com.simibubi.create.foundation.render.SuperByteBufferCache;
|
|||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -50,8 +50,7 @@ public class KineticBlockEntityRenderer<T extends KineticBlockEntity> extends Sa
|
|||
|
||||
BlockState state = getRenderedBlockState(be);
|
||||
RenderType type = getRenderType(be, state);
|
||||
if (type != null)
|
||||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
renderRotatingBuffer(be, getRotatedModel(be, state), ms, buffer.getBuffer(type), light);
|
||||
}
|
||||
|
||||
protected BlockState getRenderedBlockState(T be) {
|
||||
|
@ -66,7 +65,7 @@ public class KineticBlockEntityRenderer<T extends KineticBlockEntity> extends Sa
|
|||
for (RenderType type : REVERSED_CHUNK_BUFFER_LAYERS)
|
||||
if (typeSet.contains(type))
|
||||
return type;
|
||||
return null;
|
||||
return RenderType.cutoutMipped();
|
||||
}
|
||||
|
||||
protected SuperByteBuffer getRotatedModel(T be, BlockState state) {
|
||||
|
@ -84,7 +83,7 @@ public class KineticBlockEntityRenderer<T extends KineticBlockEntity> extends Sa
|
|||
standardKineticRotationTransform(superBuffer, be, light).renderInto(ms, buffer);
|
||||
}
|
||||
|
||||
public static float getAngleForTe(KineticBlockEntity be, final BlockPos pos, Axis axis) {
|
||||
public static float getAngleForBe(KineticBlockEntity be, final BlockPos pos, Axis axis) {
|
||||
float time = AnimationTickHolder.getRenderTime(be.getLevel());
|
||||
float offset = getRotationOffsetForPosition(be, pos, axis);
|
||||
float angle = ((time * be.getSpeed() * 3f / 10 + offset) % 360) / 180 * (float) Math.PI;
|
||||
|
@ -96,7 +95,7 @@ public class KineticBlockEntityRenderer<T extends KineticBlockEntity> extends Sa
|
|||
final BlockPos pos = be.getBlockPos();
|
||||
Axis axis = ((IRotate) be.getBlockState()
|
||||
.getBlock()).getRotationAxis(be.getBlockState());
|
||||
return kineticRotationTransform(buffer, be, axis, getAngleForTe(be, pos, axis), light);
|
||||
return kineticRotationTransform(buffer, be, axis, getAngleForBe(be, pos, axis), light);
|
||||
}
|
||||
|
||||
public static SuperByteBuffer kineticRotationTransform(SuperByteBuffer buffer, KineticBlockEntity be, Axis axis,
|
||||
|
|
|
@ -118,7 +118,7 @@ public class BeltRenderer extends SafeBlockEntityRenderer<BeltBlockEntity> {
|
|||
}
|
||||
|
||||
beltBuffer
|
||||
.transform(localTransforms)
|
||||
.transform(localTransforms)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
// Diagonal belt do not have a separate bottom model
|
||||
|
|
|
@ -91,7 +91,7 @@ public class ValveHandleBlockEntity extends HandCrankBlockEntity {
|
|||
@Override
|
||||
public float getIndependentAngle(float partialTicks) {
|
||||
if (inUse == 0 && source != null && getSpeed() != 0)
|
||||
return KineticBlockEntityRenderer.getAngleForTe(this, worldPosition,
|
||||
return KineticBlockEntityRenderer.getAngleForBe(this, worldPosition,
|
||||
KineticBlockEntityRenderer.getRotationAxisOf(this));
|
||||
|
||||
int step = getBlockState().getOptionalValue(ValveHandleBlock.FACING)
|
||||
|
|
|
@ -3,9 +3,6 @@ package com.simibubi.create.content.kinetics.deployer;
|
|||
import static com.simibubi.create.content.kinetics.base.DirectionalAxisKineticBlock.AXIS_ALONG_FIRST_COORDINATE;
|
||||
import static com.simibubi.create.content.kinetics.base.DirectionalKineticBlock.FACING;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Axis;
|
||||
|
@ -27,6 +24,9 @@ import com.simibubi.create.foundation.utility.NBTHelper;
|
|||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
@ -213,11 +213,14 @@ public class DeployerRenderer extends SafeBlockEntityRenderer<DeployerBlockEntit
|
|||
transform(pole, blockState, true);
|
||||
transform(hand, blockState, false);
|
||||
|
||||
shaft.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
shaft.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), builder);
|
||||
pole.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
pole.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), builder);
|
||||
hand.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
hand.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), builder);
|
||||
|
||||
m.popPose();
|
||||
|
|
|
@ -48,8 +48,8 @@ public class DrillRenderer extends KineticBlockEntityRenderer<DrillBlockEntity>
|
|||
.rotateXDegrees(AngleHelper.verticalAngle(facing))
|
||||
.rotateZDegrees(angle)
|
||||
.uncenter()
|
||||
.light(matrices.getWorld(),
|
||||
LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.solid()));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.kinetics.fan;
|
|||
|
||||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
|
@ -11,6 +10,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
|
|||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.simibubi.create.content.kinetics.saw;
|
|||
|
||||
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.FACING;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.math.Axis;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
|
@ -19,6 +17,8 @@ import com.simibubi.create.foundation.utility.AngleHelper;
|
|||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import com.simibubi.create.foundation.virtualWorld.VirtualRenderWorld;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
|
@ -198,7 +198,8 @@ public class SawRenderer extends SafeBlockEntityRenderer<SawBlockEntity> {
|
|||
}
|
||||
|
||||
superBuffer.uncenter()
|
||||
.light(matrices.getWorld(), LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.light(LevelRenderer.getLightColor(renderWorld, context.localPos))
|
||||
.useLevelLight(context.world, matrices.getWorld())
|
||||
.renderInto(matrices.getViewProjection(), buffer.getBuffer(RenderType.cutoutMipped()));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.simibubi.create.content.kinetics.simpleRelays;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntityRenderer;
|
||||
|
@ -9,6 +9,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
|
|||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider.Context;
|
||||
|
@ -38,17 +39,18 @@ public class BracketedKineticBlockEntityRenderer extends KineticBlockEntityRende
|
|||
// Large cogs sometimes have to offset their teeth by 11.25 degrees in order to
|
||||
// mesh properly
|
||||
|
||||
VertexConsumer vc = buffer.getBuffer(RenderType.solid());
|
||||
Axis axis = getRotationAxisOf(be);
|
||||
Direction facing = Direction.fromAxisAndDirection(axis, AxisDirection.POSITIVE);
|
||||
renderRotatingBuffer(be,
|
||||
CachedBufferer.partialFacingVertical(AllPartialModels.SHAFTLESS_LARGE_COGWHEEL, be.getBlockState(), facing),
|
||||
ms, buffer.getBuffer(RenderType.solid()), light);
|
||||
ms, vc, light);
|
||||
|
||||
float angle = getAngleForLargeCogShaft(be, axis);
|
||||
SuperByteBuffer shaft =
|
||||
CachedBufferer.partialFacingVertical(AllPartialModels.COGWHEEL_SHAFT, be.getBlockState(), facing);
|
||||
kineticRotationTransform(shaft, be, axis, angle, light);
|
||||
shaft.renderInto(ms, buffer.getBuffer(RenderType.solid()));
|
||||
shaft.renderInto(ms, vc);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.content.kinetics.simpleRelays.encased;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.kinetics.base.IRotate;
|
||||
|
@ -11,6 +10,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
|
|||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
|
@ -54,7 +54,7 @@ public class EncasedCogRenderer extends KineticBlockEntityRenderer<SimpleKinetic
|
|||
Axis axis = getRotationAxisOf(be);
|
||||
BlockPos pos = be.getBlockPos();
|
||||
float angle = large ? BracketedKineticBlockEntityRenderer.getAngleForLargeCogShaft(be, axis)
|
||||
: getAngleForTe(be, pos, axis);
|
||||
: getAngleForBe(be, pos, axis);
|
||||
|
||||
for (Direction d : Iterate.directionsInAxis(getRotationAxisOf(be))) {
|
||||
if (!def.hasShaftTowards(be.getLevel(), be.getBlockPos(), blockState, d))
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.content.kinetics.speedController;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
|
@ -9,9 +8,10 @@ import com.simibubi.create.foundation.blockEntity.renderer.SmartBlockEntityRende
|
|||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.render.SuperByteBuffer;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -30,7 +30,7 @@ public class SpeedControllerRenderer extends SmartBlockEntityRenderer<SpeedContr
|
|||
MultiBufferSource buffer, int light, int overlay) {
|
||||
super.renderSafe(blockEntity, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
VertexConsumer builder = buffer.getBuffer(RenderType.solid());
|
||||
VertexConsumer builder = buffer.getBuffer(Sheets.solidBlockSheet());
|
||||
if (!VisualizationManager.supportsVisualization(blockEntity.getLevel())) {
|
||||
KineticBlockEntityRenderer.renderRotatingBuffer(blockEntity, getRotatedModel(blockEntity), ms, builder, light);
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public class SteamEngineBlockEntity extends SmartBlockEntity implements IHaveGog
|
|||
return null;
|
||||
|
||||
axis = KineticBlockEntityRenderer.getRotationAxisOf(shaft);
|
||||
angle = KineticBlockEntityRenderer.getAngleForTe(shaft, shaft.getBlockPos(), axis);
|
||||
angle = KineticBlockEntityRenderer.getAngleForBe(shaft, shaft.getBlockPos(), axis);
|
||||
|
||||
if (axis == facingAxis)
|
||||
return null;
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
package com.simibubi.create.content.logistics.depot;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.transform.Rotate;
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import dev.engine_room.flywheel.lib.transform.Translate;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.kinetics.base.KineticBlockEntity;
|
||||
import com.simibubi.create.content.kinetics.base.ShaftRenderer;
|
||||
|
@ -15,6 +10,10 @@ import com.simibubi.create.foundation.utility.AngleHelper;
|
|||
import com.simibubi.create.foundation.utility.IntAttached;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import dev.engine_room.flywheel.api.visualization.VisualizationManager;
|
||||
import dev.engine_room.flywheel.lib.transform.Rotate;
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import dev.engine_room.flywheel.lib.transform.Translate;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -41,7 +40,6 @@ public class EjectorRenderer extends ShaftRenderer<EjectorBlockEntity> {
|
|||
int light, int overlay) {
|
||||
super.renderSafe(be, partialTicks, ms, buffer, light, overlay);
|
||||
|
||||
VertexConsumer vertexBuilder = buffer.getBuffer(RenderType.solid());
|
||||
float lidProgress = be.getLidProgress(partialTicks);
|
||||
float angle = lidProgress * 70;
|
||||
|
||||
|
@ -49,7 +47,7 @@ public class EjectorRenderer extends ShaftRenderer<EjectorBlockEntity> {
|
|||
SuperByteBuffer model = CachedBufferer.partial(AllPartialModels.EJECTOR_TOP, be.getBlockState());
|
||||
applyLidAngle(be, angle, model);
|
||||
model.light(light)
|
||||
.renderInto(ms, vertexBuilder);
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.solid()));
|
||||
}
|
||||
|
||||
var msr = TransformStack.of(ms);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.content.redstone.displayLink;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.foundation.blockEntity.renderer.SafeBlockEntityRenderer;
|
||||
|
@ -8,6 +7,7 @@ import com.simibubi.create.foundation.render.CachedBufferer;
|
|||
import com.simibubi.create.foundation.render.RenderTypes;
|
||||
import com.simibubi.create.foundation.utility.AngleHelper;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
|
@ -57,7 +57,7 @@ public class DisplayLinkRenderer extends SafeBlockEntityRenderer<DisplayLinkBloc
|
|||
.light(LightTexture.FULL_BRIGHT)
|
||||
.color(color, color, color, 255)
|
||||
.disableDiffuse()
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.additive()));
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.simibubi.create.content.redstone.nixieTube;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.redstone.nixieTube.DoubleFaceAttachedBlock.DoubleAttachFace;
|
||||
|
@ -16,6 +15,7 @@ import com.simibubi.create.foundation.utility.Couple;
|
|||
import com.simibubi.create.foundation.utility.DyeHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.font.glyphs.BakedGlyph;
|
||||
|
@ -180,7 +180,7 @@ public class NixieTubeRenderer extends SafeBlockEntityRenderer<NixieTubeBlockEnt
|
|||
.light(0xf000f0)
|
||||
.disableDiffuse()
|
||||
.scale(vert ? longSideGlow : 2, vert ? 2 : longSideGlow, 2)
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.additive()));
|
||||
}
|
||||
|
||||
CachedBufferer
|
||||
|
@ -189,7 +189,7 @@ public class NixieTubeRenderer extends SafeBlockEntityRenderer<NixieTubeBlockEnt
|
|||
.light(0xF000F0)
|
||||
.disableDiffuse()
|
||||
.scale(1 + 1 / 16f)
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.getAdditive()));
|
||||
.renderInto(ms, buffer.getBuffer(RenderTypes.additive()));
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.content.trains.schedule;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllPartialModels;
|
||||
import com.simibubi.create.content.contraptions.Contraption;
|
||||
|
@ -10,6 +9,7 @@ import com.simibubi.create.foundation.mixin.accessor.AgeableListModelAccessor;
|
|||
import com.simibubi.create.foundation.render.CachedBufferer;
|
||||
import com.simibubi.create.foundation.utility.Couple;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import net.minecraft.client.model.AgeableListModel;
|
||||
import net.minecraft.client.model.AxolotlModel;
|
||||
import net.minecraft.client.model.EntityModel;
|
||||
|
@ -22,7 +22,6 @@ import net.minecraft.client.model.WolfModel;
|
|||
import net.minecraft.client.model.geom.ModelPart;
|
||||
import net.minecraft.client.model.geom.ModelPart.Cube;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.client.renderer.entity.EntityRenderer;
|
||||
|
@ -55,7 +54,6 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
return;
|
||||
|
||||
M entityModel = getParentModel();
|
||||
RenderType renderType = Sheets.cutoutBlockSheet();
|
||||
ms.pushPose();
|
||||
|
||||
boolean valid = false;
|
||||
|
@ -127,7 +125,7 @@ public class TrainHatArmorLayer<T extends LivingEntity, M extends EntityModel<T>
|
|||
CachedBufferer.partial(AllPartialModels.TRAIN_HAT, air)
|
||||
.disableDiffuse()
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(renderType));
|
||||
.renderInto(ms, buffer.getBuffer(Sheets.cutoutBlockSheet()));
|
||||
}
|
||||
|
||||
ms.popPose();
|
||||
|
|
|
@ -34,7 +34,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
|||
|
||||
public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
||||
|
||||
public Couple<BlockPos> tePositions;
|
||||
public Couple<BlockPos> bePositions;
|
||||
public Couple<Vec3> starts;
|
||||
public Couple<Vec3> axes;
|
||||
public Couple<Vec3> normals;
|
||||
|
@ -59,7 +59,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
|
||||
public BezierConnection(Couple<BlockPos> positions, Couple<Vec3> starts, Couple<Vec3> axes, Couple<Vec3> normals,
|
||||
boolean primary, boolean girder, TrackMaterial material) {
|
||||
tePositions = positions;
|
||||
bePositions = positions;
|
||||
this.starts = starts;
|
||||
this.axes = axes;
|
||||
this.normals = normals;
|
||||
|
@ -70,7 +70,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
}
|
||||
|
||||
public BezierConnection secondary() {
|
||||
BezierConnection bezierConnection = new BezierConnection(tePositions.swap(), starts.swap(), axes.swap(),
|
||||
BezierConnection bezierConnection = new BezierConnection(bePositions.swap(), starts.swap(), axes.swap(),
|
||||
normals.swap(), !primary, hasGirder, trackMaterial);
|
||||
if (smoothing != null)
|
||||
bezierConnection.smoothing = smoothing.swap();
|
||||
|
@ -96,7 +96,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
}
|
||||
|
||||
private boolean equalsSansMaterialInner(BezierConnection other) {
|
||||
return this == other || (other != null && coupleEquals(this.tePositions, other.tePositions)
|
||||
return this == other || (other != null && coupleEquals(this.bePositions, other.bePositions)
|
||||
&& coupleEquals(this.starts, other.starts) && coupleEquals(this.axes, other.axes)
|
||||
&& coupleEquals(this.normals, other.normals) && this.hasGirder == other.hasGirder);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
}
|
||||
|
||||
public CompoundTag write(BlockPos localTo) {
|
||||
Couple<BlockPos> tePositions = this.tePositions.map(b -> b.subtract(localTo));
|
||||
Couple<BlockPos> tePositions = this.bePositions.map(b -> b.subtract(localTo));
|
||||
Couple<Vec3> starts = this.starts.map(v -> v.subtract(Vec3.atLowerCornerOf(localTo)));
|
||||
|
||||
CompoundTag compound = new CompoundTag();
|
||||
|
@ -143,7 +143,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
}
|
||||
|
||||
public void write(FriendlyByteBuf buffer) {
|
||||
tePositions.forEach(buffer::writeBlockPos);
|
||||
bePositions.forEach(buffer::writeBlockPos);
|
||||
starts.forEach(v -> VecHelper.write(v, buffer));
|
||||
axes.forEach(v -> VecHelper.write(v, buffer));
|
||||
normals.forEach(v -> VecHelper.write(v, buffer));
|
||||
|
@ -156,7 +156,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
}
|
||||
|
||||
public BlockPos getKey() {
|
||||
return tePositions.getSecond();
|
||||
return bePositions.getSecond();
|
||||
}
|
||||
|
||||
public boolean isPrimary() {
|
||||
|
@ -346,7 +346,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
@Override
|
||||
public Iterator<Segment> iterator() {
|
||||
resolve();
|
||||
var offset = Vec3.atLowerCornerOf(tePositions.getFirst())
|
||||
var offset = Vec3.atLowerCornerOf(bePositions.getFirst())
|
||||
.scale(-1)
|
||||
.add(0, 3 / 16f, 0);
|
||||
return new Bezierator(this, offset);
|
||||
|
@ -378,7 +378,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
if (!level.getGameRules()
|
||||
.getBoolean(GameRules.RULE_DOBLOCKDROPS))
|
||||
return;
|
||||
Vec3 origin = Vec3.atLowerCornerOf(tePositions.getFirst());
|
||||
Vec3 origin = Vec3.atLowerCornerOf(bePositions.getFirst());
|
||||
for (Segment segment : this) {
|
||||
if (segment.index % 2 != 0 || segment.index == getSegmentCount())
|
||||
continue;
|
||||
|
@ -403,7 +403,7 @@ public class BezierConnection implements Iterable<BezierConnection.Segment> {
|
|||
new BlockParticleOption(ParticleTypes.BLOCK, AllBlocks.METAL_GIRDER.getDefaultState());
|
||||
if (!(level instanceof ServerLevel slevel))
|
||||
return;
|
||||
Vec3 origin = Vec3.atLowerCornerOf(tePositions.getFirst());
|
||||
Vec3 origin = Vec3.atLowerCornerOf(bePositions.getFirst());
|
||||
for (Segment segment : this) {
|
||||
for (int offset : Iterate.positiveAndNegative) {
|
||||
Vec3 v = segment.position.add(segment.normal.scale(14 / 16f * offset))
|
||||
|
|
|
@ -369,7 +369,7 @@ public class TrackBlock extends Block
|
|||
|
||||
Map<BlockPos, BezierConnection> connections = trackBE.getConnections();
|
||||
connections.forEach((connectedPos, bc) -> ITrackBlock.addToListIfConnected(connectedTo, list,
|
||||
(d, b) -> d == 1 ? Vec3.atLowerCornerOf(bc.tePositions.get(b)) : bc.starts.get(b), bc.normals::get,
|
||||
(d, b) -> d == 1 ? Vec3.atLowerCornerOf(bc.bePositions.get(b)) : bc.starts.get(b), bc.normals::get,
|
||||
b -> world instanceof Level l ? l.dimension() : Level.OVERWORLD, bc::yOffsetAt, null, bc,
|
||||
(b, v) -> ITrackBlock.getMaterialSimple(world, v, bc.getMaterial())));
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable
|
|||
BlockPos key = entry.getKey();
|
||||
BezierConnection bc = entry.getValue();
|
||||
|
||||
if (!key.equals(bc.getKey()) || !worldPosition.equals(bc.tePositions.getFirst())) {
|
||||
if (!key.equals(bc.getKey()) || !worldPosition.equals(bc.bePositions.getFirst())) {
|
||||
invalid.add(key);
|
||||
continue;
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable
|
|||
for (BezierConnection bezierConnection : connections.values()) {
|
||||
if (!(level.getBlockEntity(bezierConnection.getKey())instanceof TrackBlockEntity tbe))
|
||||
return;
|
||||
tbe.removeConnection(bezierConnection.tePositions.getFirst());
|
||||
tbe.removeConnection(bezierConnection.bePositions.getFirst());
|
||||
if (!dropAndDiscard)
|
||||
continue;
|
||||
if (!cancelDrops)
|
||||
|
@ -282,10 +282,10 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable
|
|||
newConnection.normals.replace(transform::applyWithoutOffsetUncentered);
|
||||
newConnection.axes.replace(transform::applyWithoutOffsetUncentered);
|
||||
|
||||
BlockPos diff = newConnection.tePositions.getSecond()
|
||||
.subtract(newConnection.tePositions.getFirst());
|
||||
newConnection.tePositions
|
||||
.setSecond(BlockPos.containing(Vec3.atCenterOf(newConnection.tePositions.getFirst())
|
||||
BlockPos diff = newConnection.bePositions.getSecond()
|
||||
.subtract(newConnection.bePositions.getFirst());
|
||||
newConnection.bePositions
|
||||
.setSecond(BlockPos.containing(Vec3.atCenterOf(newConnection.bePositions.getFirst())
|
||||
.add(transform.applyWithoutOffsetUncentered(Vec3.atLowerCornerOf(diff)))));
|
||||
|
||||
Vec3 beVec = Vec3.atLowerCornerOf(worldPosition);
|
||||
|
@ -364,7 +364,7 @@ public class TrackBlockEntity extends SmartBlockEntity implements ITransformable
|
|||
|
||||
public void manageFakeTracksAlong(BezierConnection bc, boolean remove) {
|
||||
Map<Pair<Integer, Integer>, Double> yLevels = new HashMap<>();
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos tePosition = bc.bePositions.getFirst();
|
||||
Vec3 end1 = bc.starts.getFirst()
|
||||
.subtract(Vec3.atLowerCornerOf(tePosition))
|
||||
.add(0, 3 / 16f, 0);
|
||||
|
|
|
@ -163,7 +163,7 @@ public class TrackMaterial {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public record TrackModelHolder(PartialModel tie, PartialModel segment_left, PartialModel segment_right) {
|
||||
public record TrackModelHolder(PartialModel tie, PartialModel leftSegment, PartialModel rightSegment) {
|
||||
static final TrackModelHolder DEFAULT = new TrackModelHolder(AllPartialModels.TRACK_TIE,
|
||||
AllPartialModels.TRACK_SEGMENT_LEFT, AllPartialModels.TRACK_SEGMENT_RIGHT);
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class TrackPaver {
|
|||
}
|
||||
|
||||
Map<Pair<Integer, Integer>, Double> yLevels = new HashMap<>();
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos tePosition = bc.bePositions.getFirst();
|
||||
Vec3 end1 = bc.starts.getFirst()
|
||||
.subtract(Vec3.atLowerCornerOf(tePosition))
|
||||
.add(0, 3 / 16f, 0);
|
||||
|
|
|
@ -48,15 +48,15 @@ public class TrackRenderer extends SafeBlockEntityRenderer<TrackBlockEntity> {
|
|||
return;
|
||||
|
||||
ms.pushPose();
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos bePosition = bc.bePositions.getFirst();
|
||||
BlockState air = Blocks.AIR.defaultBlockState();
|
||||
SegmentAngles[] segments = bc.getBakedSegments();
|
||||
|
||||
renderGirder(level, bc, ms, vb, tePosition);
|
||||
renderGirder(level, bc, ms, vb, bePosition);
|
||||
|
||||
for (int i = 1; i < segments.length; i++) {
|
||||
SegmentAngles segment = segments[i];
|
||||
int light = LevelRenderer.getLightColor(level, segment.lightPosition.offset(tePosition));
|
||||
int light = LevelRenderer.getLightColor(level, segment.lightPosition.offset(bePosition));
|
||||
|
||||
TrackMaterial.TrackModelHolder modelHolder = bc.getMaterial().getModelHolder();
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class TrackRenderer extends SafeBlockEntityRenderer<TrackBlockEntity> {
|
|||
|
||||
for (boolean first : Iterate.trueAndFalse) {
|
||||
Pose transform = segment.railTransforms.get(first);
|
||||
CachedBufferer.partial(first ? modelHolder.segment_left() : modelHolder.segment_right(), air)
|
||||
CachedBufferer.partial(first ? modelHolder.leftSegment() : modelHolder.rightSegment(), air)
|
||||
.mulPose(transform.pose())
|
||||
.mulNormal(transform.normal())
|
||||
.light(light)
|
||||
|
|
|
@ -123,7 +123,7 @@ public class TrackVisual extends AbstractBlockEntityVisual<TrackBlockEntity> {
|
|||
private @Nullable GirderVisual girder;
|
||||
|
||||
private BezierTrackVisual(BezierConnection bc) {
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos tePosition = bc.bePositions.getFirst();
|
||||
girder = bc.hasGirder ? new GirderVisual(bc) : null;
|
||||
|
||||
PoseStack pose = new PoseStack();
|
||||
|
@ -142,9 +142,9 @@ public class TrackVisual extends AbstractBlockEntityVisual<TrackBlockEntity> {
|
|||
|
||||
instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.tie()))
|
||||
.createInstances(ties);
|
||||
instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.segment_left()))
|
||||
instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.leftSegment()))
|
||||
.createInstances(left);
|
||||
instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.segment_right()))
|
||||
instancerProvider.instancer(InstanceTypes.TRANSFORMED, Models.partial(modelHolder.rightSegment()))
|
||||
.createInstances(right);
|
||||
|
||||
SegmentAngles[] segments = bc.getBakedSegments();
|
||||
|
@ -209,11 +209,11 @@ public class TrackVisual extends AbstractBlockEntityVisual<TrackBlockEntity> {
|
|||
private final BlockPos[] lightPos;
|
||||
|
||||
private GirderVisual(BezierConnection bc) {
|
||||
BlockPos tePosition = bc.tePositions.getFirst();
|
||||
BlockPos tePosition = bc.bePositions.getFirst();
|
||||
PoseStack pose = new PoseStack();
|
||||
TransformStack.of(pose)
|
||||
.translate(getVisualPosition())
|
||||
.nudge((int) bc.tePositions.getFirst()
|
||||
.nudge((int) bc.bePositions.getFirst()
|
||||
.asLong());
|
||||
|
||||
int segCount = bc.getSegmentCount();
|
||||
|
|
|
@ -33,7 +33,7 @@ import net.minecraftforge.fluids.FluidType;
|
|||
public class FluidRenderer {
|
||||
|
||||
public static VertexConsumer getFluidBuilder(MultiBufferSource buffer) {
|
||||
return buffer.getBuffer(RenderTypes.getFluid());
|
||||
return buffer.getBuffer(RenderTypes.fluid());
|
||||
}
|
||||
|
||||
public static void renderFluidStream(FluidStack fluidStack, Direction direction, float radius, float progress,
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simibubi.create.foundation.gui;
|
||||
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
@ -10,7 +9,6 @@ public class CustomLightingSettings implements ILightingSettings {
|
|||
|
||||
private Vector3f light1;
|
||||
private Vector3f light2;
|
||||
private Matrix4f lightMatrix;
|
||||
|
||||
protected CustomLightingSettings(float yRot, float xRot) {
|
||||
init(yRot, xRot, 0, 0, false);
|
||||
|
@ -32,14 +30,11 @@ public class CustomLightingSettings implements ILightingSettings {
|
|||
} else {
|
||||
light2 = new Vector3f();
|
||||
}
|
||||
|
||||
lightMatrix = new Matrix4f();
|
||||
lightMatrix.identity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyLighting() {
|
||||
RenderSystem.setupLevelDiffuseLighting(light1, light2, lightMatrix);
|
||||
RenderSystem.setShaderLights(light1, light2);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
|
|
|
@ -171,8 +171,7 @@ public class GuiGameElement {
|
|||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
BlockRenderDispatcher blockRenderer = mc.getBlockRenderer();
|
||||
MultiBufferSource.BufferSource buffer = mc.renderBuffers()
|
||||
.bufferSource();
|
||||
MultiBufferSource.BufferSource buffer = graphics.bufferSource();
|
||||
|
||||
transformMatrix(matrixStack);
|
||||
|
||||
|
@ -264,11 +263,11 @@ public class GuiGameElement {
|
|||
PoseStack matrixStack = graphics.pose();
|
||||
prepareMatrix(matrixStack);
|
||||
transformMatrix(matrixStack);
|
||||
renderItemIntoGUI(matrixStack, stack, customLighting == null);
|
||||
renderItemIntoGUI(graphics, matrixStack, stack, customLighting == null);
|
||||
cleanUpMatrix(matrixStack);
|
||||
}
|
||||
|
||||
public static void renderItemIntoGUI(PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
||||
public static void renderItemIntoGUI(GuiGraphics graphics, PoseStack matrixStack, ItemStack stack, boolean useDefaultLighting) {
|
||||
ItemRenderer renderer = Minecraft.getInstance().getItemRenderer();
|
||||
BakedModel bakedModel = renderer.getModel(stack, null, null, 0);
|
||||
|
||||
|
@ -282,7 +281,7 @@ public class GuiGameElement {
|
|||
matrixStack.translate(0, 0, 100.0F);
|
||||
matrixStack.translate(8.0F, -8.0F, 0.0F);
|
||||
matrixStack.scale(16.0F, 16.0F, 16.0F);
|
||||
MultiBufferSource.BufferSource buffer = Minecraft.getInstance().renderBuffers().bufferSource();
|
||||
MultiBufferSource.BufferSource buffer = graphics.bufferSource();
|
||||
boolean flatLighting = !bakedModel.usesBlockLight();
|
||||
if (useDefaultLighting && flatLighting) {
|
||||
Lighting.setupForFlatItems();
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.foundation.utility.Iterate;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.MultiBufferSource;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.Sheets;
|
||||
import net.minecraft.client.renderer.entity.ItemRenderer;
|
||||
import net.minecraft.client.resources.model.BakedModel;
|
||||
import net.minecraft.core.Direction;
|
||||
|
@ -41,19 +42,19 @@ public class PartialItemModelRenderer {
|
|||
}
|
||||
|
||||
public void render(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getItemPartialTranslucent(), light);
|
||||
render(model, Sheets.translucentCullBlockSheet(), light);
|
||||
}
|
||||
|
||||
public void renderSolid(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getItemPartialSolid(), light);
|
||||
}
|
||||
|
||||
public void renderSolidGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingSolid(), light);
|
||||
render(model, Sheets.solidBlockSheet(), light);
|
||||
}
|
||||
|
||||
public void renderGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.getGlowingTranslucent(), light);
|
||||
render(model, RenderTypes.itemGlowingTranslucent(), light);
|
||||
}
|
||||
|
||||
public void renderSolidGlowing(BakedModel model, int light) {
|
||||
render(model, RenderTypes.itemGlowingSolid(), light);
|
||||
}
|
||||
|
||||
public void render(BakedModel model, RenderType type, int light) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.simibubi.create.foundation.mixin.accessor;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Accessor;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
@Mixin(RenderSystem.class)
|
||||
public interface RenderSystemAccessor {
|
||||
@Accessor("shaderLightDirections")
|
||||
static Vector3f[] create$getShaderLightDirections() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -70,7 +70,7 @@ public class AABBOutline extends Outline {
|
|||
if (lineWidth == 0)
|
||||
return;
|
||||
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid());
|
||||
renderBoxEdges(ms, consumer, minPos, maxPos, lineWidth, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class AABBOutline extends Outline {
|
|||
return;
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
|
||||
RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), cull);
|
||||
RenderType renderType = RenderTypes.outlineTranslucent(faceTexture.getLocation(), cull);
|
||||
VertexConsumer consumer = buffer.getLateBuffer(renderType);
|
||||
|
||||
float alphaMult = highlighted ? 1 : 0.5f;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class BlockClusterOutline extends Outline {
|
|||
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
PoseStack.Pose pose = ms.last();
|
||||
RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true);
|
||||
RenderType renderType = RenderTypes.outlineTranslucent(faceTexture.getLocation(), true);
|
||||
VertexConsumer consumer = buffer.getLateBuffer(renderType);
|
||||
|
||||
cluster.visibleFaces.forEach((face, axisDirection) -> {
|
||||
|
@ -89,7 +89,7 @@ public class BlockClusterOutline extends Outline {
|
|||
cluster.anchor.getZ() - camera.z);
|
||||
|
||||
PoseStack.Pose pose = ms.last();
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid());
|
||||
|
||||
cluster.visibleEdges.forEach(edge -> {
|
||||
BlockPos pos = edge.pos;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class LineOutline extends Outline {
|
|||
if (width == 0)
|
||||
return;
|
||||
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.outlineSolid());
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.apache.commons.lang3.mutable.MutableObject;
|
|||
import org.joml.Matrix4f;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.foundation.gui.UIRenderHelper;
|
||||
import com.simibubi.create.foundation.outliner.Outliner;
|
||||
|
@ -31,8 +30,6 @@ import com.simibubi.create.foundation.ponder.element.WorldSectionElement;
|
|||
import com.simibubi.create.foundation.ponder.instruction.HideAllInstruction;
|
||||
import com.simibubi.create.foundation.ponder.instruction.PonderInstruction;
|
||||
import com.simibubi.create.foundation.ponder.ui.PonderUI;
|
||||
import com.simibubi.create.foundation.render.DiffuseLightCalculator;
|
||||
import com.simibubi.create.foundation.render.ForcedDiffuseState;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
import com.simibubi.create.foundation.utility.AnimationTickHolder;
|
||||
import com.simibubi.create.foundation.utility.Pair;
|
||||
|
@ -40,6 +37,7 @@ import com.simibubi.create.foundation.utility.VecHelper;
|
|||
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
|
||||
import com.simibubi.create.infrastructure.ponder.PonderIndex;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import net.minecraft.client.Camera;
|
||||
|
@ -236,7 +234,6 @@ public class PonderScene {
|
|||
}
|
||||
|
||||
public void renderScene(SuperRenderTypeBuffer buffer, PoseStack ms, float pt) {
|
||||
ForcedDiffuseState.pushCalculator(DiffuseLightCalculator.DEFAULT);
|
||||
ms.pushPose();
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
@ -256,7 +253,6 @@ public class PonderScene {
|
|||
outliner.renderOutlines(ms, buffer, Vec3.ZERO, pt);
|
||||
|
||||
ms.popPose();
|
||||
ForcedDiffuseState.popCalculator();
|
||||
}
|
||||
|
||||
public void renderOverlay(PonderUI screen, GuiGraphics graphics, float partialTicks) {
|
||||
|
|
|
@ -305,7 +305,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
public void renderFirst(PonderWorld world, MultiBufferSource buffer, PoseStack ms, float fade, float pt) {
|
||||
int light = -1;
|
||||
if (fade != 1)
|
||||
light = (int) (Mth.lerp(fade, 5, 14));
|
||||
light = (int) (Mth.lerp(fade, 5, 15));
|
||||
if (redraw) {
|
||||
renderedBlockEntities = null;
|
||||
tickableBlockEntities = null;
|
||||
|
@ -359,14 +359,14 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
|
||||
if (redraw)
|
||||
bufferCache.invalidate(DOC_WORLD_SECTION, key);
|
||||
SuperByteBuffer contraptionBuffer =
|
||||
SuperByteBuffer structureBuffer =
|
||||
bufferCache.get(DOC_WORLD_SECTION, key, () -> buildStructureBuffer(world, type));
|
||||
if (contraptionBuffer.isEmpty())
|
||||
if (structureBuffer.isEmpty())
|
||||
return;
|
||||
|
||||
transformMS(contraptionBuffer.getTransforms(), pt);
|
||||
transformMS(structureBuffer.getTransforms(), pt);
|
||||
int light = lightCoordsFromFade(fade);
|
||||
contraptionBuffer
|
||||
structureBuffer
|
||||
.light(light)
|
||||
.renderInto(ms, buffer.getBuffer(type));
|
||||
}
|
||||
|
@ -415,6 +415,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
sbbBuilder.begin();
|
||||
|
||||
world.setMask(this.section);
|
||||
world.pushFakeLight(0);
|
||||
ModelBlockRenderer.enableCaching();
|
||||
section.forEach(pos -> {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
|
@ -444,6 +445,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
}
|
||||
});
|
||||
ModelBlockRenderer.clearCache();
|
||||
world.popLight();
|
||||
world.clearMask();
|
||||
|
||||
return sbbBuilder.end();
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraftforge.client.model.lighting.QuadLighter;
|
||||
|
||||
public interface DiffuseLightCalculator {
|
||||
DiffuseLightCalculator DEFAULT = DiffuseLightCalculator::diffuseLight;
|
||||
DiffuseLightCalculator NETHER = DiffuseLightCalculator::diffuseLightNether;
|
||||
|
||||
static DiffuseLightCalculator forLevel(ClientLevel level) {
|
||||
return level.effects().constantAmbientLight() ? NETHER : DEFAULT;
|
||||
}
|
||||
|
||||
float getDiffuse(float normalX, float normalY, float normalZ, boolean shaded);
|
||||
|
||||
static float diffuseLight(float x, float y, float z, boolean shaded) {
|
||||
if (!shaded) {
|
||||
return 1f;
|
||||
}
|
||||
return QuadLighter.calculateShade(x, y, z, false);
|
||||
}
|
||||
|
||||
static float diffuseLightNether(float x, float y, float z, boolean shaded) {
|
||||
if (!shaded) {
|
||||
return 0.9f;
|
||||
}
|
||||
return QuadLighter.calculateShade(x, y, z, true);
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
||||
|
||||
public final class ForcedDiffuseState {
|
||||
private static final ThreadLocal<ObjectArrayList<DiffuseLightCalculator>> FORCED_DIFFUSE = ThreadLocal.withInitial(ObjectArrayList::new);
|
||||
|
||||
private ForcedDiffuseState() {
|
||||
}
|
||||
|
||||
public static void pushCalculator(DiffuseLightCalculator calculator) {
|
||||
FORCED_DIFFUSE.get().push(calculator);
|
||||
}
|
||||
|
||||
public static void popCalculator() {
|
||||
FORCED_DIFFUSE.get().pop();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static DiffuseLightCalculator getForcedCalculator() {
|
||||
ObjectArrayList<DiffuseLightCalculator> stack = FORCED_DIFFUSE.get();
|
||||
if (stack.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return stack.top();
|
||||
}
|
||||
}
|
|
@ -1,43 +1,104 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
import com.mojang.blaze3d.vertex.VertexFormat;
|
||||
import com.simibubi.create.AllSpecialTextures;
|
||||
import com.simibubi.create.Create;
|
||||
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.renderer.RenderStateShard;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.ShaderInstance;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceProvider;
|
||||
import net.minecraft.world.inventory.InventoryMenu;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.client.event.RegisterShadersEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
|
||||
|
||||
// TODO 1.17: use custom shaders instead of vanilla ones
|
||||
public class RenderTypes extends RenderStateShard {
|
||||
|
||||
public static final RenderStateShard.ShaderStateShard GLOWING_SHADER = new RenderStateShard.ShaderStateShard(() -> Shaders.glowingShader);
|
||||
|
||||
private static final RenderType ENTITY_SOLID_BLOCK_MIPPED = RenderType.create(createLayerName("entity_solid_block_mipped"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false,
|
||||
RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||
.setTransparencyState(NO_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType ENTITY_CUTOUT_BLOCK_MIPPED = RenderType.create(createLayerName("entity_cutout_block_mipped"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false,
|
||||
RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_CUTOUT_SHADER)
|
||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||
.setTransparencyState(NO_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType ENTITY_TRANSLUCENT_BLOCK_MIPPED = RenderType.create(createLayerName("entity_translucent_block_mipped"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true,
|
||||
RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK,
|
||||
VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_SOLID_SHADER)
|
||||
.setTextureState(BLOCK_SHEET)
|
||||
.setTransparencyState(ADDITIVE_TRANSPARENCY)
|
||||
.setCullState(NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType FLUID = RenderType.create(createLayerName("fluid"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||
.setCullState(NO_CULL)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType ITEM_GLOWING_SOLID = RenderType.create(createLayerName("item_glowing_solid"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, false, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(BLOCK_SHEET)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType ITEM_GLOWING_TRANSLUCENT = RenderType.create(createLayerName("item_glowing_translucent"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(BLOCK_SHEET)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
private static final RenderType OUTLINE_SOLID =
|
||||
RenderType.create(createLayerName("outline_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false,
|
||||
false, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(AllSpecialTextures.BLANK.getLocation(), false, false))
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(false));
|
||||
|
||||
public static RenderType getOutlineSolid() {
|
||||
return OUTLINE_SOLID;
|
||||
}
|
||||
|
||||
public static RenderType getOutlineTranslucent(ResourceLocation texture, boolean cull) {
|
||||
private static final BiFunction<ResourceLocation, Boolean, RenderType> OUTLINE_TRANSLUCENT = Util.memoize((texture, cull) -> {
|
||||
return RenderType.create(createLayerName("outline_translucent" + (cull ? "_cull" : "")),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(cull ? RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER : RENDERTYPE_ENTITY_TRANSLUCENT_SHADER)
|
||||
|
@ -48,96 +109,44 @@ public class RenderTypes extends RenderStateShard {
|
|||
.setOverlayState(OVERLAY)
|
||||
.setWriteMaskState(COLOR_WRITE)
|
||||
.createCompositeState(false));
|
||||
});
|
||||
|
||||
public static RenderType entitySolidBlockMipped() {
|
||||
return ENTITY_SOLID_BLOCK_MIPPED;
|
||||
}
|
||||
|
||||
public static RenderType getGlowingSolid(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256,
|
||||
true, false, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
public static RenderType entityCutoutBlockMipped() {
|
||||
return ENTITY_CUTOUT_BLOCK_MIPPED;
|
||||
}
|
||||
|
||||
private static final RenderType GLOWING_SOLID_DEFAULT = getGlowingSolid(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingSolid() {
|
||||
return GLOWING_SOLID_DEFAULT;
|
||||
public static RenderType entityTranslucentBlockMipped() {
|
||||
return ENTITY_TRANSLUCENT_BLOCK_MIPPED;
|
||||
}
|
||||
|
||||
public static RenderType getGlowingTranslucent(ResourceLocation texture) {
|
||||
return RenderType.create(createLayerName("glowing_translucent"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS,
|
||||
256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(GLOWING_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(texture, false, false))
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
}
|
||||
|
||||
private static final RenderType ADDITIVE = RenderType.create(createLayerName("additive"), DefaultVertexFormat.BLOCK,
|
||||
VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_SOLID_SHADER)
|
||||
.setTextureState(new RenderStateShard.TextureStateShard(InventoryMenu.BLOCK_ATLAS, false, false))
|
||||
.setTransparencyState(ADDITIVE_TRANSPARENCY)
|
||||
.setCullState(NO_CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
public static RenderType getAdditive() {
|
||||
public static RenderType additive() {
|
||||
return ADDITIVE;
|
||||
}
|
||||
|
||||
private static final RenderType GLOWING_TRANSLUCENT_DEFAULT = getGlowingTranslucent(InventoryMenu.BLOCK_ATLAS);
|
||||
|
||||
public static RenderType getGlowingTranslucent() {
|
||||
return GLOWING_TRANSLUCENT_DEFAULT;
|
||||
}
|
||||
|
||||
private static final RenderType ITEM_PARTIAL_SOLID =
|
||||
RenderType.create(createLayerName("item_partial_solid"), DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true,
|
||||
false, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_SOLID_SHADER)
|
||||
.setTextureState(BLOCK_SHEET)
|
||||
.setCullState(CULL)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
public static RenderType getItemPartialSolid() {
|
||||
return ITEM_PARTIAL_SOLID;
|
||||
}
|
||||
|
||||
private static final RenderType ITEM_PARTIAL_TRANSLUCENT = RenderType.create(createLayerName("item_partial_translucent"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, true, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||
.setTextureState(BLOCK_SHEET)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
public static RenderType getItemPartialTranslucent() {
|
||||
return ITEM_PARTIAL_TRANSLUCENT;
|
||||
}
|
||||
|
||||
private static final RenderType FLUID = RenderType.create(createLayerName("fluid"),
|
||||
DefaultVertexFormat.NEW_ENTITY, VertexFormat.Mode.QUADS, 256, false, true, RenderType.CompositeState.builder()
|
||||
.setShaderState(RENDERTYPE_ENTITY_TRANSLUCENT_CULL_SHADER)
|
||||
.setTextureState(BLOCK_SHEET_MIPPED)
|
||||
.setTransparencyState(TRANSLUCENT_TRANSPARENCY)
|
||||
.setLightmapState(LIGHTMAP)
|
||||
.setOverlayState(OVERLAY)
|
||||
.createCompositeState(true));
|
||||
|
||||
public static RenderType getFluid() {
|
||||
public static RenderType fluid() {
|
||||
return FLUID;
|
||||
}
|
||||
|
||||
public static RenderType itemGlowingSolid() {
|
||||
return ITEM_GLOWING_SOLID;
|
||||
}
|
||||
|
||||
public static RenderType itemGlowingTranslucent() {
|
||||
return ITEM_GLOWING_TRANSLUCENT;
|
||||
}
|
||||
|
||||
public static RenderType outlineSolid() {
|
||||
return OUTLINE_SOLID;
|
||||
}
|
||||
|
||||
public static RenderType outlineTranslucent(ResourceLocation texture, boolean cull) {
|
||||
return OUTLINE_TRANSLUCENT.apply(texture, cull);
|
||||
}
|
||||
|
||||
private static String createLayerName(String name) {
|
||||
return Create.ID + ":" + name;
|
||||
}
|
||||
|
@ -157,5 +166,4 @@ public class RenderTypes extends RenderStateShard {
|
|||
event.registerShader(new ShaderInstance(resourceProvider, Create.asResource("glowing_shader"), DefaultVertexFormat.NEW_ENTITY), shader -> glowingShader = shader);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,29 +1,32 @@
|
|||
package com.simibubi.create.foundation.render;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector3fc;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import dev.engine_room.flywheel.lib.util.ShadersModHandler;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.foundation.block.render.SpriteShiftEntry;
|
||||
import com.simibubi.create.foundation.mixin.accessor.RenderSystemAccessor;
|
||||
import com.simibubi.create.foundation.utility.Color;
|
||||
|
||||
import dev.engine_room.flywheel.lib.transform.TransformStack;
|
||||
import dev.engine_room.flywheel.lib.util.ShadersModHandler;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.LevelRenderer;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.BlockAndTintGetter;
|
||||
|
||||
public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
||||
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
|
||||
|
||||
private final TemplateMesh template;
|
||||
private final int[] shadeSwapVertices;
|
||||
|
||||
|
@ -31,32 +34,40 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
private final PoseStack transforms = new PoseStack();
|
||||
|
||||
// Vertex Coloring
|
||||
private boolean shouldColor;
|
||||
private float r, g, b, a;
|
||||
private boolean disableDiffuseMult;
|
||||
private DiffuseLightCalculator diffuseCalculator;
|
||||
private boolean disableDiffuse;
|
||||
|
||||
// Vertex Texture Coords
|
||||
@Nullable
|
||||
private SpriteShiftFunc spriteShiftFunc;
|
||||
|
||||
// Vertex Overlay Color
|
||||
private int overlay = OverlayTexture.NO_OVERLAY;
|
||||
// Vertex Overlay
|
||||
private boolean hasCustomOverlay;
|
||||
private int overlay;
|
||||
|
||||
// Vertex Lighting
|
||||
private boolean useWorldLight;
|
||||
private Matrix4f lightTransform;
|
||||
// Vertex Light
|
||||
private boolean hasCustomLight;
|
||||
private int packedLightCoords;
|
||||
private boolean hybridLight;
|
||||
private int packedLight;
|
||||
private boolean useLevelLight;
|
||||
@Nullable
|
||||
private BlockAndTintGetter levelWithLight;
|
||||
@Nullable
|
||||
private Matrix4f lightTransform;
|
||||
|
||||
// Temporary
|
||||
private static final Long2IntMap WORLD_LIGHT_CACHE = new Long2IntOpenHashMap();
|
||||
// Reused objects
|
||||
private final Matrix4f modelMat = new Matrix4f();
|
||||
private final Matrix3f normalMat = new Matrix3f();
|
||||
private final Vector4f pos = new Vector4f();
|
||||
private final Vector3f normal = new Vector3f();
|
||||
private final Vector3f lightDir0 = new Vector3f();
|
||||
private final Vector3f lightDir1 = new Vector3f();
|
||||
private final ShiftOutput shiftOutput = new ShiftOutput();
|
||||
private final Vector4f lightPos = new Vector4f();
|
||||
|
||||
public SuperByteBuffer(TemplateMesh template, int[] shadeSwapVertices) {
|
||||
this.template = template;
|
||||
this.shadeSwapVertices = shadeSwapVertices;
|
||||
|
||||
transforms.pushPose();
|
||||
reset();
|
||||
}
|
||||
|
||||
public SuperByteBuffer(TemplateMesh template) {
|
||||
|
@ -64,56 +75,49 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
}
|
||||
|
||||
public void renderInto(PoseStack input, VertexConsumer builder) {
|
||||
if (isEmpty())
|
||||
if (isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Matrix4f modelMat = new Matrix4f(input.last()
|
||||
if (useLevelLight) {
|
||||
WORLD_LIGHT_CACHE.clear();
|
||||
}
|
||||
|
||||
Matrix4f modelMat = this.modelMat.set(input.last()
|
||||
.pose());
|
||||
Matrix4f localTransforms = transforms.last()
|
||||
.pose();
|
||||
modelMat.mul(localTransforms);
|
||||
|
||||
Matrix3f normalMat = new Matrix3f(input.last()
|
||||
Matrix3f normalMat = this.normalMat.set(input.last()
|
||||
.normal());
|
||||
Matrix3f localNormalTransforms = transforms.last()
|
||||
.normal();
|
||||
normalMat.mul(localNormalTransforms);
|
||||
|
||||
if (useWorldLight) {
|
||||
WORLD_LIGHT_CACHE.clear();
|
||||
}
|
||||
|
||||
class ShiftOutput implements SpriteShiftFunc.Output {
|
||||
public float u;
|
||||
public float v;
|
||||
|
||||
@Override
|
||||
public void accept(float u, float v) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
};
|
||||
|
||||
final Vector4f pos = new Vector4f();
|
||||
final Vector3f normal = new Vector3f();
|
||||
final ShiftOutput shiftOutput = new ShiftOutput();
|
||||
final Vector4f lightPos = new Vector4f();
|
||||
|
||||
DiffuseLightCalculator diffuseCalculator = ForcedDiffuseState.getForcedCalculator();
|
||||
final boolean disableDiffuseMult =
|
||||
this.disableDiffuseMult || (ShadersModHandler.isShaderPackInUse() && diffuseCalculator == null);
|
||||
if (diffuseCalculator == null) {
|
||||
diffuseCalculator = this.diffuseCalculator;
|
||||
if (diffuseCalculator == null) {
|
||||
diffuseCalculator = DiffuseLightCalculator.forLevel(Minecraft.getInstance().level);
|
||||
}
|
||||
}
|
||||
Vector4f pos = this.pos;
|
||||
Vector3f normal = this.normal;
|
||||
ShiftOutput shiftOutput = this.shiftOutput;
|
||||
Vector3f lightDir0 = this.lightDir0;
|
||||
Vector3f lightDir1 = this.lightDir1;
|
||||
Vector4f lightPos = this.lightPos;
|
||||
|
||||
boolean applyDiffuse = !disableDiffuse && !ShadersModHandler.isShaderPackInUse();
|
||||
boolean shaded = true;
|
||||
int shadeSwapIndex = 0;
|
||||
int nextShadeSwapVertex = shadeSwapIndex < shadeSwapVertices.length ? shadeSwapVertices[shadeSwapIndex] : -1;
|
||||
float unshadedDiffuse = 1;
|
||||
if (applyDiffuse) {
|
||||
lightDir0.set(RenderSystemAccessor.create$getShaderLightDirections()[0]).normalize();
|
||||
lightDir1.set(RenderSystemAccessor.create$getShaderLightDirections()[1]).normalize();
|
||||
if (shadeSwapVertices.length > 0) {
|
||||
normal.set(0, 1, 0);
|
||||
normal.mul(normalMat);
|
||||
unshadedDiffuse = calculateDiffuse(normal, lightDir0, lightDir1);
|
||||
}
|
||||
}
|
||||
|
||||
final int vertexCount = template.vertexCount();
|
||||
int vertexCount = template.vertexCount();
|
||||
for (int i = 0; i < vertexCount; i++) {
|
||||
if (i == nextShadeSwapVertex) {
|
||||
shaded = !shaded;
|
||||
|
@ -133,27 +137,14 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
float normalZ = ((byte) ((packedNormal >>> 16) & 0xFF)) / 127.0f;
|
||||
normal.set(normalX, normalY, normalZ);
|
||||
normal.mul(normalMat);
|
||||
normalX = normal.x();
|
||||
normalY = normal.y();
|
||||
normalZ = normal.z();
|
||||
|
||||
float r, g, b, a;
|
||||
if (shouldColor) {
|
||||
r = this.r;
|
||||
g = this.g;
|
||||
b = this.b;
|
||||
a = this.a;
|
||||
} else {
|
||||
int color = template.color(i);
|
||||
r = (color & 0xFF) / 255.0f;
|
||||
g = ((color >>> 8) & 0xFF) / 255.0f;
|
||||
b = ((color >>> 16) & 0xFF) / 255.0f;
|
||||
a = ((color >>> 24) & 0xFF) / 255.0f;
|
||||
}
|
||||
if (!disableDiffuseMult) {
|
||||
// Transformed normal is in camera space, but it is needed in world space to calculate diffuse.
|
||||
normal.mul(RenderSystem.getInverseViewRotationMatrix());
|
||||
float diffuse = diffuseCalculator.getDiffuse(normal.x(), normal.y(), normal.z(), shaded);
|
||||
int color = template.color(i);
|
||||
float r = (color & 0xFF) / 255.0f * this.r;
|
||||
float g = ((color >>> 8) & 0xFF) / 255.0f * this.g;
|
||||
float b = ((color >>> 16) & 0xFF) / 255.0f * this.b;
|
||||
float a = ((color >>> 24) & 0xFF) / 255.0f * this.a;
|
||||
if (applyDiffuse) {
|
||||
float diffuse = shaded ? calculateDiffuse(normal, lightDir0, lightDir1) : unshadedDiffuse;
|
||||
r *= diffuse;
|
||||
g *= diffuse;
|
||||
b *= diffuse;
|
||||
|
@ -167,28 +158,27 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
v = shiftOutput.v;
|
||||
}
|
||||
|
||||
int light;
|
||||
if (useWorldLight) {
|
||||
int overlay;
|
||||
if (hasCustomOverlay) {
|
||||
overlay = this.overlay;
|
||||
} else {
|
||||
overlay = template.overlay(i);
|
||||
}
|
||||
|
||||
int light = template.light(i);
|
||||
if (hasCustomLight) {
|
||||
light = maxLight(light, packedLight);
|
||||
}
|
||||
if (useLevelLight) {
|
||||
lightPos.set(((x - .5f) * 15 / 16f) + .5f, (y - .5f) * 15 / 16f + .5f, (z - .5f) * 15 / 16f + .5f, 1f);
|
||||
lightPos.mul(localTransforms);
|
||||
if (lightTransform != null) {
|
||||
lightPos.mul(lightTransform);
|
||||
}
|
||||
|
||||
light = getLight(Minecraft.getInstance().level, lightPos);
|
||||
if (hasCustomLight) {
|
||||
light = maxLight(light, packedLightCoords);
|
||||
}
|
||||
} else if (hasCustomLight) {
|
||||
light = packedLightCoords;
|
||||
} else {
|
||||
light = template.light(i);
|
||||
}
|
||||
if (hybridLight) {
|
||||
light = maxLight(light, template.light(i));
|
||||
light = maxLight(light, getLight(levelWithLight, lightPos));
|
||||
}
|
||||
|
||||
builder.vertex(pos.x(), pos.y(), pos.z(), r, g, b, a, u, v, overlay, light, normalX, normalY, normalZ);
|
||||
builder.vertex(pos.x(), pos.y(), pos.z(), r, g, b, a, u, v, overlay, light, normal.x(), normal.y(), normal.z());
|
||||
}
|
||||
|
||||
reset();
|
||||
|
@ -199,20 +189,19 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
transforms.popPose();
|
||||
transforms.pushPose();
|
||||
|
||||
shouldColor = false;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
a = 0;
|
||||
disableDiffuseMult = false;
|
||||
diffuseCalculator = null;
|
||||
r = 1;
|
||||
g = 1;
|
||||
b = 1;
|
||||
a = 1;
|
||||
disableDiffuse = false;
|
||||
spriteShiftFunc = null;
|
||||
hasCustomOverlay = false;
|
||||
overlay = OverlayTexture.NO_OVERLAY;
|
||||
useWorldLight = false;
|
||||
lightTransform = null;
|
||||
hasCustomLight = false;
|
||||
packedLightCoords = 0;
|
||||
hybridLight = false;
|
||||
packedLight = 0;
|
||||
useLevelLight = false;
|
||||
levelWithLight = null;
|
||||
lightTransform = null;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -271,7 +260,6 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
}
|
||||
|
||||
public SuperByteBuffer color(float r, float g, float b, float a) {
|
||||
shouldColor = true;
|
||||
this.r = r;
|
||||
this.g = g;
|
||||
this.b = b;
|
||||
|
@ -293,18 +281,8 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
return color(c.getRGB());
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevents vertex colors from being multiplied by the diffuse value calculated
|
||||
* from the final transformed normal vector. Useful for entity rendering, when
|
||||
* diffuse is applied automatically later.
|
||||
*/
|
||||
public SuperByteBuffer disableDiffuse() {
|
||||
disableDiffuseMult = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer diffuseCalculator(DiffuseLightCalculator diffuseCalculator) {
|
||||
this.diffuseCalculator = diffuseCalculator;
|
||||
disableDiffuse = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -346,40 +324,27 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
}
|
||||
|
||||
public SuperByteBuffer overlay(int overlay) {
|
||||
hasCustomOverlay = true;
|
||||
this.overlay = overlay;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer light() {
|
||||
useWorldLight = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer light(Matrix4f lightTransform) {
|
||||
useWorldLight = true;
|
||||
this.lightTransform = lightTransform;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer light(int packedLightCoords) {
|
||||
public SuperByteBuffer light(int packedLight) {
|
||||
hasCustomLight = true;
|
||||
this.packedLightCoords = packedLightCoords;
|
||||
this.packedLight = packedLight;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SuperByteBuffer light(Matrix4f lightTransform, int packedLightCoords) {
|
||||
light(lightTransform);
|
||||
light(packedLightCoords);
|
||||
public SuperByteBuffer useLevelLight(BlockAndTintGetter level) {
|
||||
useLevelLight = true;
|
||||
levelWithLight = level;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses max light from calculated light (world light or custom light) and vertex
|
||||
* light for the final light value. Ineffective if any other light method was
|
||||
* not called.
|
||||
*/
|
||||
public SuperByteBuffer hybridLight() {
|
||||
hybridLight = true;
|
||||
public SuperByteBuffer useLevelLight(BlockAndTintGetter level, Matrix4f lightTransform) {
|
||||
useLevelLight = true;
|
||||
levelWithLight = level;
|
||||
this.lightTransform = lightTransform;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -391,7 +356,14 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
return LightTexture.pack(Math.max(blockLight1, blockLight2), Math.max(skyLight1, skyLight2));
|
||||
}
|
||||
|
||||
private static int getLight(Level world, Vector4f lightPos) {
|
||||
// Adapted from minecraft:shaders/include/light.glsl
|
||||
private static float calculateDiffuse(Vector3fc normal, Vector3fc lightDir0, Vector3fc lightDir1) {
|
||||
float light0 = Math.max(0.0f, lightDir0.dot(normal));
|
||||
float light1 = Math.max(0.0f, lightDir1.dot(normal));
|
||||
return Math.min(1.0f, (light0 + light1) * 0.6f + 0.4f);
|
||||
}
|
||||
|
||||
private static int getLight(BlockAndTintGetter world, Vector4f lightPos) {
|
||||
BlockPos pos = BlockPos.containing(lightPos.x(), lightPos.y(), lightPos.z());
|
||||
return WORLD_LIGHT_CACHE.computeIfAbsent(pos.asLong(), $ -> LevelRenderer.getLightColor(world, pos));
|
||||
}
|
||||
|
@ -405,8 +377,14 @@ public class SuperByteBuffer implements TransformStack<SuperByteBuffer> {
|
|||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface VertexLighter {
|
||||
int getPackedLight(float x, float y, float z);
|
||||
}
|
||||
private class ShiftOutput implements SpriteShiftFunc.Output {
|
||||
public float u;
|
||||
public float v;
|
||||
|
||||
@Override
|
||||
public void accept(float u, float v) {
|
||||
this.u = u;
|
||||
this.v = v;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -79,10 +79,12 @@ public class SuperRenderTypeBuffer implements MultiBufferSource {
|
|||
put(map, RenderType.entityGlint());
|
||||
put(map, RenderType.entityGlintDirect());
|
||||
put(map, RenderType.waterMask());
|
||||
put(map, RenderTypes.getOutlineSolid());
|
||||
ModelBakery.DESTROY_TYPES.forEach((p_173062_) -> {
|
||||
put(map, p_173062_);
|
||||
});
|
||||
|
||||
// extras
|
||||
put(map, RenderTypes.outlineSolid());
|
||||
});
|
||||
private final MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediateWithBuffers(fixedBuffers, new BufferBuilder(256));
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ public class VirtualRenderHelper {
|
|||
ShadedBlockSbbBuilder sbbBuilder = objects.sbbBuilder;
|
||||
sbbBuilder.begin();
|
||||
|
||||
ModelData modelData = model.getModelData(VirtualEmptyBlockGetter.INSTANCE, BlockPos.ZERO, state, VIRTUAL_DATA);
|
||||
ModelData modelData = model.getModelData(VirtualEmptyBlockGetter.FULL_DARK, BlockPos.ZERO, state, VIRTUAL_DATA);
|
||||
poseStack.pushPose();
|
||||
renderer.tesselateBlock(VirtualEmptyBlockGetter.INSTANCE, model, state, BlockPos.ZERO, poseStack, sbbBuilder, false, random, 42L, OverlayTexture.NO_OVERLAY, modelData, null);
|
||||
renderer.tesselateBlock(VirtualEmptyBlockGetter.FULL_DARK, model, state, BlockPos.ZERO, poseStack, sbbBuilder, false, random, 42L, OverlayTexture.NO_OVERLAY, modelData, null);
|
||||
poseStack.popPose();
|
||||
|
||||
return sbbBuilder.end();
|
||||
|
|
|
@ -60,7 +60,7 @@ public abstract class Outline {
|
|||
if (lineWidth == 0)
|
||||
return;
|
||||
|
||||
VertexConsumer builder = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
VertexConsumer builder = buffer.getBuffer(RenderTypes.outlineSolid());
|
||||
|
||||
Vec3 diff = end.subtract(start);
|
||||
if (diff.x + diff.y + diff.z < 0) {
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
"accessor.GameRendererAccessor",
|
||||
"accessor.HumanoidArmorLayerAccessor",
|
||||
"accessor.ParticleEngineAccessor",
|
||||
"accessor.RenderSystemAccessor",
|
||||
"client.BlockDestructionProgressMixin",
|
||||
"client.CameraMixin",
|
||||
"client.EntityContraptionInteractionMixin",
|
||||
|
|
Loading…
Reference in a new issue