mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-05 03:22:37 +01:00
Merge remote-tracking branch 'upstream/mc1.18/dev' into 1.18/api
# Conflicts: # src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageCouplingRenderer.java
This commit is contained in:
commit
6cf204f6af
33 changed files with 271 additions and 227 deletions
|
@ -18,8 +18,10 @@
|
|||
"es-ES": "es_es",
|
||||
"es-MX": "es_mx",
|
||||
"fa": "fa_ir",
|
||||
"fi": "fi_fi",
|
||||
"fr": "fr_fr",
|
||||
"hu": "hu_hu",
|
||||
"id": "id_id",
|
||||
"is": "is_is",
|
||||
"it": "it_it",
|
||||
"ja": "ja_jp",
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.network.chat.ClickEvent;
|
|||
import net.minecraft.network.chat.ComponentUtils;
|
||||
import net.minecraft.network.chat.HoverEvent;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.client.gui.OverlayRegistry;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
|
|
|
@ -5,7 +5,6 @@ import static net.minecraft.util.Mth.lerp;
|
|||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.CreateClient;
|
||||
import com.simibubi.create.content.contraptions.KineticDebugger;
|
||||
|
@ -32,13 +31,13 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
public class CouplingRenderer {
|
||||
|
||||
public static void renderAll(PoseStack ms, MultiBufferSource buffer) {
|
||||
CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level,
|
||||
c -> {
|
||||
if (c.getFirst().hasContraptionCoupling(true))
|
||||
return;
|
||||
CouplingRenderer.renderCoupling(ms, buffer, c.map(MinecartController::cart));
|
||||
});
|
||||
public static void renderAll(PoseStack ms, MultiBufferSource buffer, Vec3 camera) {
|
||||
CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, c -> {
|
||||
if (c.getFirst()
|
||||
.hasContraptionCoupling(true))
|
||||
return;
|
||||
CouplingRenderer.renderCoupling(ms, buffer, camera, c.map(MinecartController::cart));
|
||||
});
|
||||
}
|
||||
|
||||
public static void tickDebugModeRenders() {
|
||||
|
@ -46,21 +45,20 @@ public class CouplingRenderer {
|
|||
CouplingHandler.forEachLoadedCoupling(Minecraft.getInstance().level, CouplingRenderer::doDebugRender);
|
||||
}
|
||||
|
||||
public static void renderCoupling(PoseStack ms, MultiBufferSource buffer, Couple<AbstractMinecart> carts) {
|
||||
public static void renderCoupling(PoseStack ms, MultiBufferSource buffer, Vec3 camera, Couple<AbstractMinecart> carts) {
|
||||
ClientLevel world = Minecraft.getInstance().level;
|
||||
|
||||
if (carts.getFirst() == null || carts.getSecond() == null)
|
||||
return;
|
||||
|
||||
Couple<Integer> lightValues =
|
||||
carts.map(c -> LevelRenderer.getLightColor(world, new BlockPos(c.getBoundingBox()
|
||||
.getCenter())));
|
||||
Couple<Integer> lightValues = carts.map(c -> LevelRenderer.getLightColor(world, new BlockPos(c.getBoundingBox()
|
||||
.getCenter())));
|
||||
|
||||
Vec3 center = carts.getFirst()
|
||||
.position()
|
||||
.add(carts.getSecond()
|
||||
.position())
|
||||
.scale(.5f);
|
||||
.position()
|
||||
.add(carts.getSecond()
|
||||
.position())
|
||||
.scale(.5f);
|
||||
|
||||
Couple<CartEndpoint> transforms = carts.map(c -> getSuitableCartEndpoint(c, center));
|
||||
|
||||
|
@ -72,20 +70,20 @@ public class CouplingRenderer {
|
|||
|
||||
Vec3 zero = Vec3.ZERO;
|
||||
Vec3 firstEndpoint = transforms.getFirst()
|
||||
.apply(zero);
|
||||
.apply(zero);
|
||||
Vec3 secondEndpoint = transforms.getSecond()
|
||||
.apply(zero);
|
||||
.apply(zero);
|
||||
Vec3 endPointDiff = secondEndpoint.subtract(firstEndpoint);
|
||||
double connectorYaw = -Math.atan2(endPointDiff.z, endPointDiff.x) * 180.0D / Math.PI;
|
||||
double connectorPitch = Math.atan2(endPointDiff.y, endPointDiff.multiply(1, 0, 1)
|
||||
.length()) * 180 / Math.PI;
|
||||
.length()) * 180 / Math.PI;
|
||||
|
||||
TransformStack msr = TransformStack.cast(ms);
|
||||
carts.forEachWithContext((cart, isFirst) -> {
|
||||
CartEndpoint cartTransform = transforms.get(isFirst);
|
||||
|
||||
ms.pushPose();
|
||||
cartTransform.apply(ms);
|
||||
cartTransform.apply(ms, camera);
|
||||
attachment.light(lightValues.get(isFirst))
|
||||
.renderInto(ms, builder);
|
||||
msr.rotateY(connectorYaw - cartTransform.yaw);
|
||||
|
@ -100,7 +98,7 @@ public class CouplingRenderer {
|
|||
int meanSkyLight = (((l1 >> 20) & 0xf) + ((l2 >> 20) & 0xf)) / 2;
|
||||
|
||||
ms.pushPose();
|
||||
msr.translate(firstEndpoint)
|
||||
msr.translate(firstEndpoint.subtract(camera))
|
||||
.rotateY(connectorYaw)
|
||||
.rotateZ(connectorPitch);
|
||||
ms.scale((float) endPointDiff.length(), 1, 1);
|
||||
|
@ -113,9 +111,9 @@ public class CouplingRenderer {
|
|||
private static CartEndpoint getSuitableCartEndpoint(AbstractMinecart cart, Vec3 centerOfCoupling) {
|
||||
long i = cart.getId() * 493286711L;
|
||||
i = i * i * 4392167121L + i * 98761L;
|
||||
float x = (((float) (i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
float y = (((float) (i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F + 0.375F;
|
||||
float z = (((float) (i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
double x = (((float) (i >> 16 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
double y = (((float) (i >> 20 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F + 0.375F;
|
||||
double z = (((float) (i >> 24 & 7L) + 0.5F) / 8.0F - 0.5F) * 0.004F;
|
||||
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
|
@ -164,8 +162,7 @@ public class CouplingRenderer {
|
|||
}
|
||||
|
||||
final float offsetMagnitude = 13 / 16f;
|
||||
boolean isBackFaceCloser =
|
||||
frontVec.distanceToSqr(centerOfCoupling) > backVec.distanceToSqr(centerOfCoupling);
|
||||
boolean isBackFaceCloser = frontVec.distanceToSqr(centerOfCoupling) > backVec.distanceToSqr(centerOfCoupling);
|
||||
flip = isBackFaceCloser;
|
||||
float offset = isBackFaceCloser ? -offsetMagnitude : offsetMagnitude;
|
||||
|
||||
|
@ -174,16 +171,16 @@ public class CouplingRenderer {
|
|||
|
||||
static class CartEndpoint {
|
||||
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
double x;
|
||||
double y;
|
||||
double z;
|
||||
float yaw;
|
||||
float pitch;
|
||||
float roll;
|
||||
float offset;
|
||||
boolean flip;
|
||||
|
||||
public CartEndpoint(float x, float y, float z, float yaw, float pitch, float roll, float offset, boolean flip) {
|
||||
public CartEndpoint(double x, double y, double z, float yaw, float pitch, float roll, float offset, boolean flip) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
|
@ -202,14 +199,15 @@ public class CouplingRenderer {
|
|||
return vec.add(x, y, z);
|
||||
}
|
||||
|
||||
public void apply(PoseStack ms) {
|
||||
ms.translate(x, y, z);
|
||||
ms.mulPose(Vector3f.YP.rotationDegrees(yaw));
|
||||
ms.mulPose(Vector3f.ZP.rotationDegrees(pitch));
|
||||
ms.mulPose(Vector3f.XP.rotationDegrees(roll));
|
||||
ms.translate(offset, 0, 0);
|
||||
if (flip)
|
||||
ms.mulPose(Vector3f.YP.rotationDegrees(180));
|
||||
public void apply(PoseStack ms, Vec3 camera) {
|
||||
TransformStack.cast(ms)
|
||||
.translate(camera.scale(-1)
|
||||
.add(x, y, z))
|
||||
.rotateY(yaw)
|
||||
.rotateZ(pitch)
|
||||
.rotateX(roll)
|
||||
.translate(offset, 0, 0)
|
||||
.rotateY(flip ? 180 : 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -219,24 +217,24 @@ public class CouplingRenderer {
|
|||
MinecartController first = c.getFirst();
|
||||
AbstractMinecart mainCart = first.cart();
|
||||
Vec3 mainCenter = mainCart.position()
|
||||
.add(0, yOffset, 0);
|
||||
.add(0, yOffset, 0);
|
||||
Vec3 connectedCenter = c.getSecond()
|
||||
.cart()
|
||||
.position()
|
||||
.add(0, yOffset, 0);
|
||||
.cart()
|
||||
.position()
|
||||
.add(0, yOffset, 0);
|
||||
|
||||
int color = Color.mixColors(0xabf0e9, 0xee8572, (float) Mth
|
||||
.clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1));
|
||||
.clamp(Math.abs(first.getCouplingLength(true) - connectedCenter.distanceTo(mainCenter)) * 8, 0, 1));
|
||||
|
||||
CreateClient.OUTLINER.showLine(mainCart.getId() + "", mainCenter, connectedCenter)
|
||||
.colored(color)
|
||||
.lineWidth(1 / 8f);
|
||||
.colored(color)
|
||||
.lineWidth(1 / 8f);
|
||||
|
||||
Vec3 point = mainCart.position()
|
||||
.add(0, yOffset, 0);
|
||||
.add(0, yOffset, 0);
|
||||
CreateClient.OUTLINER.showLine(mainCart.getId() + "_dot", point, point.add(0, 1 / 128f, 0))
|
||||
.colored(0xffffff)
|
||||
.lineWidth(1 / 4f);
|
||||
.colored(0xffffff)
|
||||
.lineWidth(1 / 4f);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -111,8 +111,7 @@ public class SymmetryHandler {
|
|||
|
||||
PoseStack ms = event.getPoseStack();
|
||||
ms.pushPose();
|
||||
ms.translate(-view.x(), -view.y(), -view.z());
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ms.translate(pos.getX() - view.x(), pos.getY() - view.y(), pos.getZ() - view.z());
|
||||
ms.translate(0, yShift + .2f, 0);
|
||||
mirror.applyModelTransform(ms);
|
||||
BakedModel model = mirror.getModel()
|
||||
|
|
|
@ -26,17 +26,12 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
public class CarriageCouplingRenderer {
|
||||
|
||||
public static void renderAll(PoseStack ms, MultiBufferSource buffer) {
|
||||
public static void renderAll(PoseStack ms, MultiBufferSource buffer, Vec3 camera) {
|
||||
Collection<Train> trains = CreateClient.RAILWAYS.trains.values();
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.solid());
|
||||
BlockState air = Blocks.AIR.defaultBlockState();
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
Entity cameraEntity = Minecraft.getInstance().cameraEntity;
|
||||
if (cameraEntity == null)
|
||||
return;
|
||||
|
||||
Vec3 camera = cameraEntity.getPosition(partialTicks);
|
||||
Level level = cameraEntity.level;
|
||||
Level level = Minecraft.getInstance().level;
|
||||
|
||||
for (Train train : trains) {
|
||||
List<Carriage> carriages = train.carriages;
|
||||
|
@ -72,42 +67,48 @@ public class CarriageCouplingRenderer {
|
|||
Vec3 position2 = entity2.getPosition(partialTicks);
|
||||
|
||||
ms.pushPose();
|
||||
ms.pushPose();
|
||||
ms.translate(anchor.x, anchor.y, anchor.z);
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air)
|
||||
.rotateY(-yRot)
|
||||
.rotateX(xRot)
|
||||
.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
float margin = 3 / 16f;
|
||||
double couplingDistance = train.carriageSpacing.get(i) - 2 * margin
|
||||
- bogey1.type.getConnectorAnchorOffset(bogey1.isUpsideDown()).z - bogey2.type.getConnectorAnchorOffset(bogey2.isUpsideDown()).z;
|
||||
int couplingSegments = (int) Math.round(couplingDistance * 4);
|
||||
double stretch = ((anchor2.distanceTo(anchor) - 2 * margin) * 4) / couplingSegments;
|
||||
for (int j = 0; j < couplingSegments; j++) {
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_CABLE, air)
|
||||
.rotateY(-yRot + 180)
|
||||
.rotateX(-xRot)
|
||||
.translate(0, 0, margin + 2 / 16f)
|
||||
.scale(1, 1, (float) stretch)
|
||||
.translate(0, 0, j / 4f)
|
||||
{
|
||||
ms.pushPose();
|
||||
ms.translate(anchor.x - camera.x, anchor.y - camera.y, anchor.z - camera.z);
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air)
|
||||
.rotateY(-yRot)
|
||||
.rotateX(xRot)
|
||||
.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
|
||||
float margin = 3 / 16f;
|
||||
double couplingDistance = train.carriageSpacing.get(i) - 2 * margin
|
||||
- bogey1.type.getConnectorAnchorOffset(bogey1.isUpsideDown()).z - bogey2.type.getConnectorAnchorOffset(bogey2.isUpsideDown()).z;
|
||||
int couplingSegments = (int) Math.round(couplingDistance * 4);
|
||||
double stretch = ((anchor2.distanceTo(anchor) - 2 * margin) * 4) / couplingSegments;
|
||||
for (int j = 0; j < couplingSegments; j++) {
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_CABLE, air)
|
||||
.rotateY(-yRot + 180)
|
||||
.rotateX(-xRot)
|
||||
.translate(0, 0, margin + 2 / 16f)
|
||||
.scale(1, 1, (float) stretch)
|
||||
.translate(0, 0, j / 4f)
|
||||
.light(lightCoords)
|
||||
.renderInto(ms, vb);
|
||||
}
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
ms.popPose();
|
||||
{
|
||||
ms.pushPose();
|
||||
Vec3 translation = position2.subtract(position)
|
||||
.add(anchor2)
|
||||
.subtract(camera);
|
||||
ms.translate(translation.x, translation.y, translation.z);
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air)
|
||||
.rotateY(-yRot + 180)
|
||||
.rotateX(-xRot)
|
||||
.light(lightCoords2)
|
||||
.renderInto(ms, vb);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(-position.x, -position.y, -position.z);
|
||||
ms.translate(position2.x, position2.y, position2.z);
|
||||
ms.translate(anchor2.x, anchor2.y, anchor2.z);
|
||||
CachedBufferer.partial(AllBlockPartials.TRAIN_COUPLING_HEAD, air)
|
||||
.rotateY(-yRot + 180)
|
||||
.rotateX(-xRot)
|
||||
.light(lightCoords2)
|
||||
.renderInto(ms, vb);
|
||||
ms.popPose();
|
||||
ms.popPose();
|
||||
|
||||
}
|
||||
|
|
|
@ -322,8 +322,6 @@ public class TrackTargetingBehaviour<T extends TrackEdgePoint> extends TileEntit
|
|||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
|
||||
ITrackBlock track = (ITrackBlock) block;
|
||||
PartialModel partial = track.prepareTrackOverlay(level, pos, trackState, bezier, direction, ms, type);
|
||||
if (partial != null)
|
||||
|
@ -333,7 +331,6 @@ public class TrackTargetingBehaviour<T extends TrackEdgePoint> extends TileEntit
|
|||
.translate(-.5, 0, -.5)
|
||||
.light(LevelRenderer.getLightColor(level, pos))
|
||||
.renderInto(ms, buffer.getBuffer(RenderType.cutoutMipped()));
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.simibubi.create.content.logistics.trains.management.edgePoint;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.Create;
|
||||
import com.simibubi.create.content.logistics.trains.GraphLocation;
|
||||
|
@ -116,7 +117,7 @@ public class TrackTargetingClient {
|
|||
});
|
||||
}
|
||||
|
||||
public static void render(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||
public static void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {
|
||||
if (lastLocation == null || lastResult.feedback != null)
|
||||
return;
|
||||
|
||||
|
@ -128,8 +129,13 @@ public class TrackTargetingClient {
|
|||
RenderedTrackOverlayType type = lastType == EdgePointType.SIGNAL ? RenderedTrackOverlayType.SIGNAL
|
||||
: lastType == EdgePointType.OBSERVER ? RenderedTrackOverlayType.OBSERVER : RenderedTrackOverlayType.STATION;
|
||||
|
||||
ms.pushPose();
|
||||
TransformStack.cast(ms)
|
||||
.translate(Vec3.atLowerCornerOf(pos)
|
||||
.subtract(camera));
|
||||
TrackTargetingBehaviour.render(mc.level, pos, direction, lastHoveredBezierSegment, ms, buffer, light,
|
||||
OverlayTexture.NO_OVERLAY, type, 1 + 1 / 16f);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.content.logistics.trains.management.edgePoint.observer;
|
||||
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.content.logistics.trains.ITrackBlock;
|
||||
import com.simibubi.create.content.logistics.trains.management.edgePoint.TrackTargetingBehaviour;
|
||||
|
@ -35,7 +36,8 @@ public class TrackObserverRenderer extends SmartTileEntityRenderer<TrackObserver
|
|||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
TransformStack.cast(ms)
|
||||
.translate(targetPosition.subtract(pos));
|
||||
RenderedTrackOverlayType type = RenderedTrackOverlayType.OBSERVER;
|
||||
TrackTargetingBehaviour.render(level, targetPosition, target.getTargetDirection(), target.getTargetBezier(), ms,
|
||||
buffer, light, overlay, type, 1);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.simibubi.create.content.logistics.trains.management.edgePoint.signal;
|
||||
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
import com.simibubi.create.content.logistics.trains.ITrackBlock;
|
||||
|
@ -52,7 +53,8 @@ public class SignalRenderer extends SafeTileEntityRenderer<SignalTileEntity> {
|
|||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
TransformStack.cast(ms)
|
||||
.translate(targetPosition.subtract(pos));
|
||||
RenderedTrackOverlayType type =
|
||||
overlayState == OverlayState.DUAL ? RenderedTrackOverlayType.DUAL_SIGNAL : RenderedTrackOverlayType.SIGNAL;
|
||||
TrackTargetingBehaviour.render(level, targetPosition, target.getTargetDirection(), target.getTargetBezier(), ms,
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.logistics.trains.management.edgePoint.statio
|
|||
|
||||
import com.jozufozu.flywheel.core.PartialModel;
|
||||
import com.jozufozu.flywheel.util.transform.Transform;
|
||||
import com.jozufozu.flywheel.util.transform.TransformStack;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.simibubi.create.AllBlockPartials;
|
||||
|
@ -48,13 +49,14 @@ public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
|
|||
GlobalStation station = te.getStation();
|
||||
boolean isAssembling = te.getBlockState()
|
||||
.getValue(StationBlock.ASSEMBLING);
|
||||
|
||||
|
||||
if (!isAssembling || (station == null || station.getPresentTrain() != null) && !te.isVirtual()) {
|
||||
renderFlag(
|
||||
te.flag.getValue(partialTicks) > 0.75f ? AllBlockPartials.STATION_ON : AllBlockPartials.STATION_OFF, te,
|
||||
partialTicks, ms, buffer, light, overlay);
|
||||
ms.pushPose();
|
||||
ms.translate(-pos.getX(), -pos.getY(), -pos.getZ());
|
||||
TransformStack.cast(ms)
|
||||
.translate(targetPosition.subtract(pos));
|
||||
TrackTargetingBehaviour.render(level, targetPosition, target.getTargetDirection(), target.getTargetBezier(),
|
||||
ms, buffer, light, overlay, RenderedTrackOverlayType.STATION, 1);
|
||||
ms.popPose();
|
||||
|
@ -68,7 +70,7 @@ public class StationRenderer extends SafeTileEntityRenderer<StationTileEntity> {
|
|||
|
||||
if (te.isVirtual() && te.bogeyLocations == null)
|
||||
te.refreshAssemblyInfo();
|
||||
|
||||
|
||||
if (direction == null || te.assemblyLength == 0 || te.bogeyLocations == null)
|
||||
return;
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ public class TrackBlockOutline {
|
|||
}
|
||||
}
|
||||
|
||||
public static void drawCurveSelection(PoseStack ms, MultiBufferSource buffer) {
|
||||
public static void drawCurveSelection(PoseStack ms, MultiBufferSource buffer, Vec3 camera) {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
if (mc.options.hideGui || mc.gameMode.getPlayerMode() == GameType.SPECTATOR)
|
||||
return;
|
||||
|
@ -152,7 +152,8 @@ public class TrackBlockOutline {
|
|||
return;
|
||||
|
||||
VertexConsumer vb = buffer.getBuffer(RenderType.lines());
|
||||
Vec3 vec = result.vec();
|
||||
Vec3 vec = result.vec()
|
||||
.subtract(camera);
|
||||
Vec3 angles = result.angles();
|
||||
TransformStack.cast(ms)
|
||||
.pushPose()
|
||||
|
|
|
@ -45,6 +45,7 @@ import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlac
|
|||
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.BlockHitResult;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
import net.minecraftforge.client.gui.IIngameOverlay;
|
||||
|
||||
|
@ -193,7 +194,7 @@ public class SchematicHandler {
|
|||
.display(wMirroredLR);
|
||||
}
|
||||
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {
|
||||
boolean present = activeSchematicItem != null;
|
||||
if (!active && !present)
|
||||
return;
|
||||
|
@ -201,12 +202,12 @@ public class SchematicHandler {
|
|||
if (active) {
|
||||
ms.pushPose();
|
||||
currentTool.getTool()
|
||||
.renderTool(ms, buffer);
|
||||
.renderTool(ms, buffer, camera);
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
ms.pushPose();
|
||||
transformation.applyGLTransformations(ms);
|
||||
transformation.applyTransformations(ms, camera);
|
||||
|
||||
if (!renderers.isEmpty()) {
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
|
|
@ -19,15 +19,19 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
public class SchematicTransformation {
|
||||
|
||||
private LerpedFloat x, y, z, scaleFrontBack, scaleLeftRight;
|
||||
private Vec3 chasingPos;
|
||||
private Vec3 prevChasingPos;
|
||||
private BlockPos target;
|
||||
|
||||
private LerpedFloat scaleFrontBack, scaleLeftRight;
|
||||
private LerpedFloat rotation;
|
||||
private double xOrigin;
|
||||
private double zOrigin;
|
||||
|
||||
public SchematicTransformation() {
|
||||
x = LerpedFloat.linear();
|
||||
y = LerpedFloat.linear();
|
||||
z = LerpedFloat.linear();
|
||||
chasingPos = Vec3.ZERO;
|
||||
prevChasingPos = Vec3.ZERO;
|
||||
target = BlockPos.ZERO;
|
||||
scaleFrontBack = LerpedFloat.linear();
|
||||
scaleLeftRight = LerpedFloat.linear();
|
||||
rotation = LerpedFloat.angular();
|
||||
|
@ -48,20 +52,18 @@ public class SchematicTransformation {
|
|||
rotation.chase(0, 0.45f, Chaser.EXP)
|
||||
.startWithValue(r);
|
||||
|
||||
Vec3 vec = fromAnchor(anchor);
|
||||
x.chase(0, 0.45f, Chaser.EXP)
|
||||
.startWithValue((float) vec.x);
|
||||
y.chase(0, 0.45f, Chaser.EXP)
|
||||
.startWithValue((float) vec.y);
|
||||
z.chase(0, 0.45f, Chaser.EXP)
|
||||
.startWithValue((float) vec.z);
|
||||
target = fromAnchor(anchor);
|
||||
chasingPos = Vec3.atLowerCornerOf(target);
|
||||
prevChasingPos = chasingPos;
|
||||
}
|
||||
|
||||
public void applyGLTransformations(PoseStack ms) {
|
||||
public void applyTransformations(PoseStack ms, Vec3 camera) {
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
// Translation
|
||||
ms.translate(x.getValue(pt), y.getValue(pt), z.getValue(pt));
|
||||
TransformStack.cast(ms)
|
||||
.translate(VecHelper.lerp(pt, prevChasingPos, chasingPos)
|
||||
.subtract(camera));
|
||||
Vec3 rotationOffset = getRotationOffset(true);
|
||||
|
||||
// Rotation & Mirror
|
||||
|
@ -101,7 +103,7 @@ public class SchematicTransformation {
|
|||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
Vec3 rotationOffset = getRotationOffset(true);
|
||||
|
||||
vec = vec.subtract(x.getValue(pt), y.getValue(pt), z.getValue(pt));
|
||||
vec = vec.subtract(VecHelper.lerp(pt, prevChasingPos, chasingPos));
|
||||
vec = vec.subtract(xOrigin + rotationOffset.x, 0, zOrigin + rotationOffset.z);
|
||||
vec = VecHelper.rotate(vec, -rotation.getValue(pt), Axis.Y);
|
||||
vec = vec.add(rotationOffset.x, 0, rotationOffset.z);
|
||||
|
@ -157,12 +159,11 @@ public class SchematicTransformation {
|
|||
vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget());
|
||||
vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y);
|
||||
vec = vec.add(xOrigin, 0, zOrigin);
|
||||
|
||||
vec = vec.add(x.getChaseTarget(), y.getChaseTarget(), z.getChaseTarget());
|
||||
vec = vec.add(target.getX(), target.getY(), target.getZ());
|
||||
return new BlockPos(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
public Vec3 fromAnchor(BlockPos pos) {
|
||||
public BlockPos fromAnchor(BlockPos pos) {
|
||||
Vec3 vec = Vec3.ZERO.add(.5, 0, .5);
|
||||
Vec3 rotationOffset = getRotationOffset(false);
|
||||
vec = vec.subtract(xOrigin, 0, zOrigin);
|
||||
|
@ -170,8 +171,7 @@ public class SchematicTransformation {
|
|||
vec = vec.multiply(getScaleFB().getChaseTarget(), 1, getScaleLR().getChaseTarget());
|
||||
vec = VecHelper.rotate(vec, rotation.getChaseTarget(), Axis.Y);
|
||||
vec = vec.add(xOrigin, 0, zOrigin);
|
||||
|
||||
return Vec3.atLowerCornerOf(pos.subtract(new BlockPos(vec.x, vec.y, vec.z)));
|
||||
return pos.subtract(new BlockPos(vec.x, vec.y, vec.z));
|
||||
}
|
||||
|
||||
public int getRotationTarget() {
|
||||
|
@ -190,9 +190,8 @@ public class SchematicTransformation {
|
|||
}
|
||||
|
||||
public void tick() {
|
||||
x.tickChaser();
|
||||
y.tickChaser();
|
||||
z.tickChaser();
|
||||
prevChasingPos = chasingPos;
|
||||
chasingPos = VecHelper.lerp(0.45f, chasingPos, Vec3.atLowerCornerOf(target));
|
||||
getScaleLR().tickChaser();
|
||||
getScaleFB().tickChaser();
|
||||
rotation.tickChaser();
|
||||
|
@ -209,25 +208,22 @@ public class SchematicTransformation {
|
|||
rotation.updateChaseTarget(rotation.getChaseTarget() + (clockwise ? -90 : 90));
|
||||
}
|
||||
|
||||
public void move(float xIn, float yIn, float zIn) {
|
||||
moveTo(x.getChaseTarget() + xIn, y.getChaseTarget() + yIn, z.getChaseTarget() + zIn);
|
||||
public void move(int xIn, int yIn, int zIn) {
|
||||
moveTo(target.offset(xIn, yIn, zIn));
|
||||
}
|
||||
|
||||
public void startAt(BlockPos pos) {
|
||||
x.startWithValue(pos.getX());
|
||||
y.startWithValue(pos.getY() - 10);
|
||||
z.startWithValue(pos.getZ());
|
||||
chasingPos = Vec3.atLowerCornerOf(pos);
|
||||
prevChasingPos = chasingPos;
|
||||
moveTo(pos);
|
||||
}
|
||||
|
||||
public void moveTo(BlockPos pos) {
|
||||
moveTo(pos.getX(), pos.getY(), pos.getZ());
|
||||
target = pos;
|
||||
}
|
||||
|
||||
public void moveTo(float xIn, float yIn, float zIn) {
|
||||
x.updateChaseTarget(xIn);
|
||||
y.updateChaseTarget(yIn);
|
||||
z.updateChaseTarget(zIn);
|
||||
public void moveTo(int xIn, int yIn, int zIn) {
|
||||
moveTo(new BlockPos(xIn, yIn, zIn));
|
||||
}
|
||||
|
||||
public LerpedFloat getScaleFB() {
|
||||
|
|
|
@ -36,8 +36,8 @@ public class DeployTool extends PlacementToolBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||
super.renderTool(ms, buffer);
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {
|
||||
super.renderTool(ms, buffer, camera);
|
||||
|
||||
if (selectedPos == null)
|
||||
return;
|
||||
|
@ -58,7 +58,7 @@ public class DeployTool extends PlacementToolBase {
|
|||
double zOrigin = bounds.getZsize() / 2f;
|
||||
Vec3 origin = new Vec3(xOrigin, 0, zOrigin);
|
||||
|
||||
ms.translate(x - centerX, y, z - centerZ);
|
||||
ms.translate(x - centerX - camera.x, y - camera.y, z - centerZ - camera.z);
|
||||
TransformStack.cast(ms)
|
||||
.translate(origin)
|
||||
.translate(rotationOffset)
|
||||
|
@ -67,7 +67,7 @@ public class DeployTool extends PlacementToolBase {
|
|||
.translateBack(origin);
|
||||
|
||||
AABBOutline outline = schematicHandler.getOutline();
|
||||
outline.render(ms, buffer, pt);
|
||||
outline.render(ms, buffer, Vec3.ZERO, pt);
|
||||
outline.getParams()
|
||||
.clearTextures();
|
||||
ms.popPose();
|
||||
|
|
|
@ -75,7 +75,7 @@ public class FlipTool extends PlacementToolBase {
|
|||
.disableLineNormals()
|
||||
.colored(0xdddddd)
|
||||
.withFaceTextures(tex, tex);
|
||||
outline.render(ms, buffer, AnimationTickHolder.getPartialTicks());
|
||||
outline.render(ms, buffer, Vec3.ZERO, AnimationTickHolder.getPartialTicks());
|
||||
|
||||
super.renderOnSchematic(ms, buffer);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.schematics.client.tools;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
|
||||
public interface ISchematicTool {
|
||||
|
@ -13,7 +14,7 @@ public interface ISchematicTool {
|
|||
public boolean handleRightClick();
|
||||
public boolean handleMouseWheel(double delta);
|
||||
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer);
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera);
|
||||
public void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height);
|
||||
public void renderOnSchematic(PoseStack ms, SuperRenderTypeBuffer buffer);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ public class MoveTool extends PlacementToolBase {
|
|||
Vec3 vec = Vec3.atLowerCornerOf(selectedFace.getNormal()).scale(-Math.signum(delta));
|
||||
vec = vec.multiply(transformation.getMirrorModifier(Axis.X), 1, transformation.getMirrorModifier(Axis.Z));
|
||||
vec = VecHelper.rotate(vec, transformation.getRotationTarget(), Axis.Y);
|
||||
transformation.move((float) vec.x, 0, (float) vec.z);
|
||||
transformation.move((int) vec.x, 0, (int) vec.z);
|
||||
schematicHandler.markDirty();
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
package com.simibubi.create.content.schematics.client.tools;
|
||||
|
||||
import net.minecraft.util.Mth;
|
||||
|
||||
public class MoveVerticalTool extends PlacementToolBase {
|
||||
|
||||
@Override
|
||||
public boolean handleMouseWheel(double delta) {
|
||||
if (schematicHandler.isDeployed()) {
|
||||
schematicHandler.getTransformation().move(0, (float) Math.signum(delta), 0);
|
||||
schematicHandler.getTransformation().move(0, Mth.sign(delta), 0);
|
||||
schematicHandler.markDirty();
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simibubi.create.content.schematics.client.tools;
|
|||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.gui.ForgeIngameGui;
|
||||
|
||||
public abstract class PlacementToolBase extends SchematicToolBase {
|
||||
|
@ -18,8 +19,8 @@ public abstract class PlacementToolBase extends SchematicToolBase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||
super.renderTool(ms, buffer);
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {
|
||||
super.renderTool(ms, buffer, camera);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,7 +36,7 @@ public class RotateTool extends PlacementToolBase {
|
|||
.colored(0xdddddd)
|
||||
.lineWidth(1 / 16f);
|
||||
line.set(start, end)
|
||||
.render(ms, buffer, AnimationTickHolder.getPartialTicks());
|
||||
.render(ms, buffer, Vec3.ZERO, AnimationTickHolder.getPartialTicks());
|
||||
|
||||
super.renderOnSchematic(ms, buffer);
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ public abstract class SchematicToolBase implements ISchematicTool {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer) {}
|
||||
public void renderTool(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {}
|
||||
|
||||
@Override
|
||||
public void renderOverlay(ForgeIngameGui gui, PoseStack poseStack, float partialTicks, int width, int height) {}
|
||||
|
@ -143,7 +143,7 @@ public abstract class SchematicToolBase implements ISchematicTool {
|
|||
.colored(0x6886c5)
|
||||
.withFaceTexture(AllSpecialTextures.CHECKERED)
|
||||
.lineWidth(1 / 16f);
|
||||
outline.render(ms, buffer, AnimationTickHolder.getPartialTicks());
|
||||
outline.render(ms, buffer, Vec3.ZERO, AnimationTickHolder.getPartialTicks());
|
||||
outline.getParams()
|
||||
.clearTextures();
|
||||
ms.popPose();
|
||||
|
|
|
@ -204,26 +204,23 @@ public class ClientEvents {
|
|||
|
||||
@SubscribeEvent
|
||||
public static void onRenderWorld(RenderLevelLastEvent event) {
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
float pt = AnimationTickHolder.getPartialTicks();
|
||||
|
||||
PoseStack ms = event.getPoseStack();
|
||||
ms.pushPose();
|
||||
ms.translate(-cameraPos.x(), -cameraPos.y(), -cameraPos.z());
|
||||
SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
|
||||
float partialTicks = AnimationTickHolder.getPartialTicks();
|
||||
Vec3 camera = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
|
||||
TrackBlockOutline.drawCurveSelection(ms, buffer);
|
||||
TrackTargetingClient.render(ms, buffer);
|
||||
CouplingRenderer.renderAll(ms, buffer);
|
||||
CarriageCouplingRenderer.renderAll(ms, buffer);
|
||||
CreateClient.SCHEMATIC_HANDLER.render(ms, buffer);
|
||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer);
|
||||
TrackBlockOutline.drawCurveSelection(ms, buffer, camera);
|
||||
TrackTargetingClient.render(ms, buffer, camera);
|
||||
CouplingRenderer.renderAll(ms, buffer, camera);
|
||||
CarriageCouplingRenderer.renderAll(ms, buffer, camera);
|
||||
CreateClient.SCHEMATIC_HANDLER.render(ms, buffer, camera);
|
||||
CreateClient.GHOST_BLOCKS.renderAll(ms, buffer, camera);
|
||||
CreateClient.OUTLINER.renderOutlines(ms, buffer, camera, partialTicks);
|
||||
|
||||
CreateClient.OUTLINER.renderOutlines(ms, buffer, pt);
|
||||
buffer.draw();
|
||||
RenderSystem.enableCull();
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
|
@ -322,14 +319,14 @@ public class ClientEvents {
|
|||
|
||||
if (AllFluids.CHOCOLATE.get()
|
||||
.isSame(fluid)) {
|
||||
event.scaleFarPlaneDistance(1f/32f);
|
||||
event.scaleFarPlaneDistance(1f / 32f);
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (AllFluids.HONEY.get()
|
||||
.isSame(fluid)) {
|
||||
event.scaleFarPlaneDistance(1f/8f);
|
||||
event.scaleFarPlaneDistance(1f / 8f);
|
||||
event.setCanceled(true);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ public class PonderScene {
|
|||
camera.set(transform.xRotation.getValue(pt) + 90, transform.yRotation.getValue(pt) + 180);
|
||||
world.renderEntities(ms, buffer, camera, pt);
|
||||
world.renderParticles(ms, buffer, camera, pt);
|
||||
outliner.renderOutlines(ms, buffer, pt);
|
||||
outliner.renderOutlines(ms, buffer, Vec3.ZERO, pt);
|
||||
|
||||
ms.popPose();
|
||||
ForcedDiffuseState.popCalculator();
|
||||
|
|
|
@ -399,7 +399,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
|
|||
.lineWidth(1 / 64f)
|
||||
.colored(0xefefef)
|
||||
.disableLineNormals();
|
||||
aabbOutline.render(ms, (SuperRenderTypeBuffer) buffer, pt);
|
||||
aabbOutline.render(ms, (SuperRenderTypeBuffer) buffer, Vec3.ZERO, pt);
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
boolean hasTransform = transform != null;
|
||||
if (transform instanceof Sided && params.getHighlightedFace() != null)
|
||||
((Sided) transform).fromSide(params.getHighlightedFace());
|
||||
|
@ -84,11 +84,11 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ms.translate(pos.getX() - camera.x, pos.getY() - camera.y, pos.getZ() - camera.z);
|
||||
if (hasTransform)
|
||||
transform.transform(blockState, ms);
|
||||
params.colored(isPassive ? passiveColor : highlightColor);
|
||||
super.render(ms, buffer, pt);
|
||||
super.render(ms, buffer, Vec3.ZERO, pt);
|
||||
|
||||
float fontScale = hasTransform ? -transform.getFontScale() : -1 / 64f;
|
||||
ms.scale(fontScale, fontScale, fontScale);
|
||||
|
|
|
@ -24,6 +24,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
public abstract class GhostBlockRenderer {
|
||||
|
@ -40,12 +41,12 @@ public abstract class GhostBlockRenderer {
|
|||
return TRANSPARENT;
|
||||
}
|
||||
|
||||
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params);
|
||||
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, GhostBlockParams params);
|
||||
|
||||
private static class DefaultGhostBlockRenderer extends GhostBlockRenderer {
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, GhostBlockParams params) {
|
||||
ms.pushPose();
|
||||
|
||||
BlockRenderDispatcher dispatcher = Minecraft.getInstance()
|
||||
|
@ -57,7 +58,7 @@ public abstract class GhostBlockRenderer {
|
|||
VertexConsumer vb = buffer.getEarlyBuffer(layer);
|
||||
|
||||
BlockPos pos = params.pos;
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ms.translate(pos.getX() - camera.x, pos.getY() - camera.y, pos.getZ() - camera.z);
|
||||
|
||||
dispatcher.getModelRenderer()
|
||||
.renderModel(ms.last(), vb, params.state, model, 1f, 1f, 1f, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY,
|
||||
|
@ -71,7 +72,7 @@ public abstract class GhostBlockRenderer {
|
|||
private static class TransparentGhostBlockRenderer extends GhostBlockRenderer {
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, GhostBlockParams params) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, GhostBlockParams params) {
|
||||
ms.pushPose();
|
||||
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
|
@ -83,7 +84,7 @@ public abstract class GhostBlockRenderer {
|
|||
VertexConsumer vb = buffer.getEarlyBuffer(layer);
|
||||
|
||||
BlockPos pos = params.pos;
|
||||
ms.translate(pos.getX(), pos.getY(), pos.getZ());
|
||||
ms.translate(pos.getX() - camera.x, pos.getY() - camera.y, pos.getZ() - camera.z);
|
||||
|
||||
ms.translate(.5, .5, .5);
|
||||
ms.scale(.85f, .85f, .85f);
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
|||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class GhostBlocks {
|
||||
|
||||
|
@ -54,10 +55,10 @@ public class GhostBlocks {
|
|||
ghosts.entrySet().removeIf(e -> !e.getValue().isAlive());
|
||||
}
|
||||
|
||||
public void renderAll(PoseStack ms, SuperRenderTypeBuffer buffer) {
|
||||
public void renderAll(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera) {
|
||||
ghosts.forEach((slot, entry) -> {
|
||||
GhostBlockRenderer ghost = entry.ghost;
|
||||
ghost.render(ms, buffer, entry.params);
|
||||
ghost.render(ms, buffer, camera, entry.params);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ import com.simibubi.create.AllSpecialTextures;
|
|||
import com.simibubi.create.foundation.render.RenderTypes;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
|
@ -44,24 +43,23 @@ public class AABBOutline extends Outline {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
|
||||
renderBox(ms, buffer, bb, color, lightmap, disableLineNormals);
|
||||
renderBox(ms, buffer, camera, bb, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderBox(PoseStack ms, SuperRenderTypeBuffer buffer, AABB box, Vector4f color, int lightmap, boolean disableLineNormals) {
|
||||
protected void renderBox(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, AABB box, Vector4f color, int lightmap, boolean disableLineNormals) {
|
||||
Vector3f minPos = minPosTemp1;
|
||||
Vector3f maxPos = maxPosTemp1;
|
||||
|
||||
Vec3 cameraPos = Minecraft.getInstance().gameRenderer.getMainCamera()
|
||||
.getPosition();
|
||||
boolean cameraInside = box.contains(cameraPos);
|
||||
boolean cameraInside = box.contains(camera);
|
||||
boolean cull = !cameraInside && !params.disableCull;
|
||||
float inflate = cameraInside ? -1 / 128f : 1 / 128f;
|
||||
|
||||
box = box.move(camera.scale(-1));
|
||||
minPos.set((float) box.minX - inflate, (float) box.minY - inflate, (float) box.minZ - inflate);
|
||||
maxPos.set((float) box.maxX + inflate, (float) box.maxY + inflate, (float) box.maxZ + inflate);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.Direction.Axis;
|
||||
import net.minecraft.core.Direction.AxisDirection;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class BlockClusterOutline extends Outline {
|
||||
|
||||
|
@ -38,22 +39,28 @@ public class BlockClusterOutline extends Outline {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
|
||||
renderFaces(ms, buffer, pt, color, lightmap);
|
||||
renderEdges(ms, buffer, pt, color, lightmap, disableLineNormals);
|
||||
renderFaces(ms, buffer, camera, pt, color, lightmap);
|
||||
renderEdges(ms, buffer, camera, pt, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, float pt, Vector4f color, int lightmap) {
|
||||
protected void renderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap) {
|
||||
Optional<AllSpecialTextures> optionalFaceTexture = params.faceTexture;
|
||||
if (!optionalFaceTexture.isPresent())
|
||||
return;
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
if (cluster.isEmpty())
|
||||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(cluster.anchor.getX() - camera.x, cluster.anchor.getY() - camera.y,
|
||||
cluster.anchor.getZ() - camera.z);
|
||||
|
||||
AllSpecialTextures faceTexture = optionalFaceTexture.get();
|
||||
PoseStack.Pose pose = ms.last();
|
||||
RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true);
|
||||
VertexConsumer consumer = buffer.getLateBuffer(renderType);
|
||||
|
@ -65,12 +72,20 @@ public class BlockClusterOutline extends Outline {
|
|||
pos = pos.relative(direction.getOpposite());
|
||||
bufferBlockFace(pose, consumer, pos, direction, color, lightmap);
|
||||
});
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
protected void renderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, float pt, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
protected void renderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
float lineWidth = params.getLineWidth();
|
||||
if (lineWidth == 0)
|
||||
return;
|
||||
if (cluster.isEmpty())
|
||||
return;
|
||||
|
||||
ms.pushPose();
|
||||
ms.translate(cluster.anchor.getX() - camera.x, cluster.anchor.getY() - camera.y,
|
||||
cluster.anchor.getZ() - camera.z);
|
||||
|
||||
PoseStack.Pose pose = ms.last();
|
||||
VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid());
|
||||
|
@ -82,6 +97,8 @@ public class BlockClusterOutline extends Outline {
|
|||
Direction direction = Direction.get(AxisDirection.POSITIVE, edge.axis);
|
||||
bufferCuboidLine(pose, consumer, origin, direction, 1, lineWidth, color, lightmap, disableNormals);
|
||||
});
|
||||
|
||||
ms.popPose();
|
||||
}
|
||||
|
||||
public static void loadFaceData(Direction face, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector3f normal) {
|
||||
|
@ -162,6 +179,7 @@ public class BlockClusterOutline extends Outline {
|
|||
|
||||
private static class Cluster {
|
||||
|
||||
private BlockPos anchor;
|
||||
private Map<MergeEntry, AxisDirection> visibleFaces;
|
||||
private Set<MergeEntry> visibleEdges;
|
||||
|
||||
|
@ -169,8 +187,16 @@ public class BlockClusterOutline extends Outline {
|
|||
visibleEdges = new HashSet<>();
|
||||
visibleFaces = new HashMap<>();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return anchor == null;
|
||||
}
|
||||
|
||||
public void include(BlockPos pos) {
|
||||
if (anchor == null)
|
||||
anchor = pos;
|
||||
|
||||
pos = pos.subtract(anchor);
|
||||
|
||||
// 6 FACES
|
||||
for (Axis axis : Iterate.axes) {
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
|||
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class ChasingAABBOutline extends AABBOutline {
|
||||
|
||||
|
@ -29,20 +30,18 @@ public class ChasingAABBOutline extends AABBOutline {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
params.loadColor(colorTemp);
|
||||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
|
||||
renderBox(ms, buffer, interpolateBBs(prevBB, bb, pt), color, lightmap, disableLineNormals);
|
||||
renderBox(ms, buffer, camera, interpolateBBs(prevBB, bb, pt), color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
private static AABB interpolateBBs(AABB current, AABB target, float pt) {
|
||||
return new AABB(Mth.lerp(pt, current.minX, target.minX),
|
||||
Mth.lerp(pt, current.minY, target.minY), Mth.lerp(pt, current.minZ, target.minZ),
|
||||
Mth.lerp(pt, current.maxX, target.maxX), Mth.lerp(pt, current.maxY, target.maxY),
|
||||
Mth.lerp(pt, current.maxZ, target.maxZ));
|
||||
return new AABB(Mth.lerp(pt, current.minX, target.minX), Mth.lerp(pt, current.minY, target.minY),
|
||||
Mth.lerp(pt, current.minZ, target.minZ), Mth.lerp(pt, current.maxX, target.maxX),
|
||||
Mth.lerp(pt, current.maxY, target.maxY), Mth.lerp(pt, current.maxZ, target.maxZ));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.simibubi.create.foundation.utility.outliner;
|
|||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector3d;
|
||||
import com.mojang.math.Vector4f;
|
||||
import com.simibubi.create.foundation.render.RenderTypes;
|
||||
import com.simibubi.create.foundation.render.SuperRenderTypeBuffer;
|
||||
|
@ -12,23 +12,23 @@ import net.minecraft.world.phys.Vec3;
|
|||
|
||||
public class LineOutline extends Outline {
|
||||
|
||||
protected final Vector3f start = new Vector3f();
|
||||
protected final Vector3f end = new Vector3f();
|
||||
protected final Vector3d start = new Vector3d(0, 0, 0);
|
||||
protected final Vector3d end = new Vector3d(0, 0, 0);
|
||||
|
||||
public LineOutline set(Vector3f start, Vector3f end) {
|
||||
this.start.load(start);
|
||||
this.start.load(end);
|
||||
public LineOutline set(Vector3d start, Vector3d end) {
|
||||
this.start.set(start.x, start.y, start.z);
|
||||
this.end.set(end.x, end.y, end.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
public LineOutline set(Vec3 start, Vec3 end) {
|
||||
this.start.set((float) start.x, (float) start.y, (float) start.z);
|
||||
this.end.set((float) end.x, (float) end.y, (float) end.z);
|
||||
this.start.set(start.x, start.y, start.z);
|
||||
this.end.set(end.x, end.y, end.z);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
float width = params.getLineWidth();
|
||||
if (width == 0)
|
||||
return;
|
||||
|
@ -38,11 +38,12 @@ public class LineOutline extends Outline {
|
|||
Vector4f color = colorTemp;
|
||||
int lightmap = params.lightmap;
|
||||
boolean disableLineNormals = params.disableLineNormals;
|
||||
renderInner(ms, consumer, pt, width, color, lightmap, disableLineNormals);
|
||||
renderInner(ms, consumer, camera, pt, width, color, lightmap, disableLineNormals);
|
||||
}
|
||||
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, float pt, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
bufferCuboidLine(ms, consumer, start, end, width, color, lightmap, disableNormals);
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, Vec3 camera, float pt, float width,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
bufferCuboidLine(ms, consumer, camera, start, end, width, color, lightmap, disableNormals);
|
||||
}
|
||||
|
||||
public static class EndChasingLineOutline extends LineOutline {
|
||||
|
@ -50,7 +51,7 @@ public class LineOutline extends Outline {
|
|||
private float prevProgress = 0;
|
||||
private boolean lockStart;
|
||||
|
||||
private final Vector3f startTemp = new Vector3f();
|
||||
private final Vector3d startTemp = new Vector3d(0, 0, 0);
|
||||
|
||||
public EndChasingLineOutline(boolean lockStart) {
|
||||
this.lockStart = lockStart;
|
||||
|
@ -63,9 +64,11 @@ public class LineOutline extends Outline {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, float pt, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
protected void renderInner(PoseStack ms, VertexConsumer consumer, Vec3 camera, float pt, float width,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
float distanceToTarget = Mth.lerp(pt, prevProgress, progress);
|
||||
Vector3f end;
|
||||
|
||||
Vector3d end;
|
||||
if (lockStart) {
|
||||
end = this.start;
|
||||
} else {
|
||||
|
@ -73,13 +76,12 @@ public class LineOutline extends Outline {
|
|||
distanceToTarget = 1 - distanceToTarget;
|
||||
}
|
||||
|
||||
Vector3f start = this.startTemp;
|
||||
start.load(this.start);
|
||||
start.sub(end);
|
||||
start.mul(distanceToTarget);
|
||||
start.add(end);
|
||||
|
||||
bufferCuboidLine(ms, consumer, start, end, width, color, lightmap, disableNormals);
|
||||
Vector3d start = this.startTemp;
|
||||
double x = (this.start.x - end.x) * distanceToTarget + end.x;
|
||||
double y = (this.start.y - end.y) * distanceToTarget + end.y;
|
||||
double z = (this.start.z - end.z) * distanceToTarget + end.z;
|
||||
start.set((float) x, (float) y, (float) z);
|
||||
bufferCuboidLine(ms, consumer, camera, start, end, width, color, lightmap, disableNormals);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
|||
import com.mojang.blaze3d.vertex.VertexConsumer;
|
||||
import com.mojang.math.Matrix3f;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import com.mojang.math.Vector3d;
|
||||
import com.mojang.math.Vector3f;
|
||||
import com.mojang.math.Vector4f;
|
||||
import com.simibubi.create.AllSpecialTextures;
|
||||
|
@ -20,6 +21,7 @@ import net.minecraft.client.renderer.LightTexture;
|
|||
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public abstract class Outline {
|
||||
|
||||
|
@ -40,14 +42,14 @@ public abstract class Outline {
|
|||
return params;
|
||||
}
|
||||
|
||||
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, float pt);
|
||||
public abstract void render(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt);
|
||||
|
||||
public void tick() {}
|
||||
|
||||
public void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vector3f start, Vector3f end, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
public void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, Vector3d start, Vector3d end,
|
||||
float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector3f diff = this.diffPosTemp;
|
||||
diff.load(end);
|
||||
diff.sub(start);
|
||||
diff.set((float) (end.x - start.x), (float) (end.y - start.y), (float) (end.z - start.z));
|
||||
|
||||
float length = Mth.sqrt(diff.x() * diff.x() + diff.y() * diff.y() + diff.z() * diff.z());
|
||||
float hAngle = AngleHelper.deg(Mth.atan2(diff.x(), diff.z()));
|
||||
|
@ -56,13 +58,16 @@ public abstract class Outline {
|
|||
|
||||
poseStack.pushPose();
|
||||
TransformStack.cast(poseStack)
|
||||
.translate(start.x - camera.x, start.y - camera.y, start.z - camera.z)
|
||||
.rotateY(hAngle)
|
||||
.rotateX(vAngle);
|
||||
bufferCuboidLine(poseStack.last(), consumer, start, Direction.NORTH, length, width, color, lightmap, disableNormals);
|
||||
bufferCuboidLine(poseStack.last(), consumer, Vector3f.ZERO, Direction.SOUTH, length, width, color, lightmap,
|
||||
disableNormals);
|
||||
poseStack.popPose();
|
||||
}
|
||||
|
||||
public void bufferCuboidLine(PoseStack.Pose pose, VertexConsumer consumer, Vector3f origin, Direction direction, float length, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
public void bufferCuboidLine(PoseStack.Pose pose, VertexConsumer consumer, Vector3f origin, Direction direction,
|
||||
float length, float width, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector3f minPos = minPosTemp;
|
||||
Vector3f maxPos = maxPosTemp;
|
||||
|
||||
|
@ -94,7 +99,8 @@ public abstract class Outline {
|
|||
bufferCuboid(pose, consumer, minPos, maxPos, color, lightmap, disableNormals);
|
||||
}
|
||||
|
||||
public void bufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap, boolean disableNormals) {
|
||||
public void bufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos,
|
||||
Vector4f color, int lightmap, boolean disableNormals) {
|
||||
Vector4f posTransformTemp = this.posTransformTemp;
|
||||
Vector3f normalTransformTemp = this.normalTransformTemp;
|
||||
|
||||
|
@ -423,11 +429,13 @@ public abstract class Outline {
|
|||
.endVertex();
|
||||
}
|
||||
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, int lightmap, Vector3f normal) {
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2,
|
||||
Vector3f pos3, Vector4f color, int lightmap, Vector3f normal) {
|
||||
bufferQuad(pose, consumer, pos0, pos1, pos2, pos3, color, 0, 0, 1, 1, lightmap, normal);
|
||||
}
|
||||
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal) {
|
||||
public void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2,
|
||||
Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal) {
|
||||
Vector4f posTransformTemp = this.posTransformTemp;
|
||||
Vector3f normalTransformTemp = this.normalTransformTemp;
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ public class Outliner {
|
|||
}
|
||||
}
|
||||
|
||||
public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, float pt) {
|
||||
public void renderOutlines(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt) {
|
||||
outlines.forEach((key, entry) -> {
|
||||
Outline outline = entry.getOutline();
|
||||
OutlineParams params = outline.getParams();
|
||||
|
@ -163,7 +163,7 @@ public class Outliner {
|
|||
if (params.alpha < 1 / 8f)
|
||||
return;
|
||||
}
|
||||
outline.render(ms, buffer, pt);
|
||||
outline.render(ms, buffer, camera, pt);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue