From e97b75ff72823b881d5d6ba4c2be947d09e70d92 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 14 Jan 2023 15:15:49 +0100 Subject: [PATCH] Consider testing your PR - Fixed compiler errors - Maximum placement length of tracks and turns are now configurable (#4241) - Adjusted validation guards and network visualisation to function with longer bends - Track graph no longer shows nodes and edges on f3 unless configured to - Kinetic blocks no longer show debug information on f3 unless configured to --- .../create/content/contraptions/KineticDebugger.java | 6 +++++- .../structureMovement/AbstractContraptionEntity.java | 2 +- .../structureMovement/ControlledContraptionEntity.java | 2 +- .../structureMovement/OrientedContraptionEntity.java | 2 +- .../gantry/GantryContraptionEntity.java | 2 +- .../content/logistics/trains/GlobalRailwayManager.java | 9 +++++++-- .../content/logistics/trains/TrackGraphVisualizer.java | 3 ++- .../trains/entity/CarriageContraptionEntity.java | 2 +- .../logistics/trains/entity/TrainRelocationPacket.java | 6 ++++-- .../logistics/trains/track/CurvedTrackDestroyPacket.java | 4 +++- .../content/logistics/trains/track/TrackPlacement.java | 4 +++- .../com/simibubi/create/foundation/config/CClient.java | 6 ++++-- .../com/simibubi/create/foundation/config/CTrains.java | 2 ++ 13 files changed, 35 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java index 4bf664f29..5bb3dd29a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java +++ b/src/main/java/com/simibubi/create/content/contraptions/KineticDebugger.java @@ -61,7 +61,11 @@ public class KineticDebugger { } public static boolean isActive() { - return Minecraft.getInstance().options.renderDebug && AllConfigs.CLIENT.rainbowDebug.get(); + return isF3DebugModeActive() && AllConfigs.CLIENT.rainbowDebug.get(); + } + + public static boolean isF3DebugModeActive() { + return Minecraft.getInstance().options.renderDebug; } public static KineticTileEntity getSelectedTE() { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java index 205d94255..764f9b643 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity.java @@ -745,7 +745,7 @@ public abstract class AbstractContraptionEntity extends Entity implements IEntit protected abstract float getStalledAngle(); - protected abstract void handleStallInformation(float x, float y, float z, float angle); + protected abstract void handleStallInformation(double x, double y, double z, float angle); @OnlyIn(Dist.CLIENT) protected void handleBlockChange(BlockPos localPos, BlockState newState) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java index 46d7b8ac8..9dc253c18 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ControlledContraptionEntity.java @@ -219,7 +219,7 @@ public class ControlledContraptionEntity extends AbstractContraptionEntity { } @Override - protected void handleStallInformation(float x, float y, float z, float angle) { + protected void handleStallInformation(double x, double y, double z, float angle) { setPosRaw(x, y, z); this.angle = this.prevAngle = angle; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java index cd140b891..cb9fbaa20 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/OrientedContraptionEntity.java @@ -515,7 +515,7 @@ public class OrientedContraptionEntity extends AbstractContraptionEntity { } @Override - protected void handleStallInformation(float x, float y, float z, float angle) { + protected void handleStallInformation(double x, double y, double z, float angle) { yaw = angle; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java index 845dc6caa..d20f50ef2 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/gantry/GantryContraptionEntity.java @@ -165,7 +165,7 @@ public class GantryContraptionEntity extends AbstractContraptionEntity { public void lerpTo(double x, double y, double z, float yw, float pt, int inc, boolean t) {} @Override - protected void handleStallInformation(float x, float y, float z, float angle) { + protected void handleStallInformation(double x, double y, double z, float angle) { setPosRaw(x, y, z); clientOffsetDiff = 0; } diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/GlobalRailwayManager.java b/src/main/java/com/simibubi/create/content/logistics/trains/GlobalRailwayManager.java index 994611bf4..990e876cb 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/GlobalRailwayManager.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/GlobalRailwayManager.java @@ -20,6 +20,7 @@ import com.simibubi.create.content.logistics.trains.entity.Train; import com.simibubi.create.content.logistics.trains.entity.TrainPacket; import com.simibubi.create.content.logistics.trains.management.display.GlobalTrainDisplayData; import com.simibubi.create.content.logistics.trains.management.edgePoint.signal.SignalEdgeGroup; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.AllPackets; import net.minecraft.server.MinecraftServer; @@ -256,16 +257,20 @@ public class GlobalRailwayManager { } public void tickSignalOverlay() { - if (!KineticDebugger.isActive()) + if (!isTrackGraphDebugActive()) for (TrackGraph trackGraph : trackNetworks.values()) TrackGraphVisualizer.visualiseSignalEdgeGroups(trackGraph); } public void clientTick() { - if (KineticDebugger.isActive()) + if (isTrackGraphDebugActive()) for (TrackGraph trackGraph : trackNetworks.values()) TrackGraphVisualizer.debugViewGraph(trackGraph); } + + private static boolean isTrackGraphDebugActive() { + return KineticDebugger.isF3DebugModeActive() && AllConfigs.CLIENT.showTrackGraphOnF3.get(); + } public GlobalRailwayManager sided(LevelAccessor level) { if (level != null && !level.isClientSide()) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraphVisualizer.java b/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraphVisualizer.java index e82b7ec16..66988f041 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraphVisualizer.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/TrackGraphVisualizer.java @@ -66,7 +66,8 @@ public class TrackGraphVisualizer { if (!edge.node1.location.dimension.equals(edge.node2.location.dimension)) continue; - if (other.hashCode() > hashCode && !ctrl) + if (other.hashCode() > hashCode && other.location.getLocation() + .distanceTo(camera) <= 50) continue; Vec3 yOffset = new Vec3(0, (other.hashCode() > hashCode ? 6 : 5) / 64f, 0); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java index 5c918cd84..e427b244a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java @@ -387,7 +387,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { } @Override - protected void handleStallInformation(float x, float y, float z, float angle) {} + protected void handleStallInformation(double x, double y, double z, float angle) {} Vec3 derailParticleOffset = VecHelper.offsetRandomly(Vec3.ZERO, Create.RANDOM, 1.5f) .multiply(1, .25f, 1); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocationPacket.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocationPacket.java index fe0d6edde..9db23eb93 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocationPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocationPacket.java @@ -6,6 +6,7 @@ import java.util.function.Supplier; import com.simibubi.create.Create; import com.simibubi.create.content.contraptions.components.structureMovement.ContraptionRelocationPacket; import com.simibubi.create.content.logistics.trains.track.BezierTrackPointLocation; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.networking.SimplePacketBase; import com.simibubi.create.foundation.utility.Lang; @@ -83,13 +84,14 @@ public class TrainRelocationPacket extends SimplePacketBase { if (!train.id.equals(cce.trainId)) return; + int verifyDistance = AllConfigs.SERVER.trains.maxTrackPlacementLength.get() * 2; if (!sender.position() - .closerThan(Vec3.atCenterOf(pos), 64)) { + .closerThan(Vec3.atCenterOf(pos), verifyDistance)) { Create.LOGGER.warn(messagePrefix + train.name.getString() + ": player too far from clicked pos"); return; } if (!sender.position() - .closerThan(cce.position(), 64 + cce.getBoundingBox() + .closerThan(cce.position(), verifyDistance + cce.getBoundingBox() .getXsize() / 2)) { Create.LOGGER.warn(messagePrefix + train.name.getString() + ": player too far from carriage entity"); return; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/track/CurvedTrackDestroyPacket.java b/src/main/java/com/simibubi/create/content/logistics/trains/track/CurvedTrackDestroyPacket.java index ab4b2ddce..23d2ffc4e 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/track/CurvedTrackDestroyPacket.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/track/CurvedTrackDestroyPacket.java @@ -4,6 +4,7 @@ import com.simibubi.create.AllSoundEvents; import com.simibubi.create.Create; import com.simibubi.create.content.logistics.trains.BezierConnection; import com.simibubi.create.content.logistics.trains.TrackPropagator; +import com.simibubi.create.foundation.config.AllConfigs; import com.simibubi.create.foundation.networking.TileEntityConfigurationPacket; import net.minecraft.core.BlockPos; @@ -47,8 +48,9 @@ public class CurvedTrackDestroyPacket extends TileEntityConfigurationPacket 32 * 32) + if (pos1.distSqr(pos2) > maxLength * maxLength) return info.withMessage("too_far") .tooJumbly(); if (!state1.hasProperty(TrackBlock.HAS_TE)) diff --git a/src/main/java/com/simibubi/create/foundation/config/CClient.java b/src/main/java/com/simibubi/create/foundation/config/CClient.java index 01f374a13..4fffd25fe 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CClient.java +++ b/src/main/java/com/simibubi/create/foundation/config/CClient.java @@ -17,7 +17,7 @@ public class CClient extends ConfigBase { public final ConfigFloat fanParticleDensity = f(.5f, 0, 1, "fanParticleDensity", Comments.fanParticleDensity); public final ConfigFloat filterItemRenderDistance = f(10f, 1, "filterItemRenderDistance", Comments.filterItemRenderDistance); - public final ConfigBool rainbowDebug = b(true, "enableRainbowDebug", + public final ConfigBool rainbowDebug = b(false, "enableRainbowDebug", Comments.rainbowDebug); public final ConfigInt maxContraptionLightVolume = i(16384, 0, Integer.MAX_VALUE, "maximumContraptionLightVolume", Comments.maxContraptionLightVolume); @@ -76,6 +76,7 @@ public class CClient extends ConfigBase { //train group public final ConfigGroup trains = group(1, "trains", Comments.trains); public final ConfigFloat mountedZoomMultiplier = f(3, 0, "mountedZoomMultiplier", Comments.mountedZoomMultiplier); + public final ConfigBool showTrackGraphOnF3 = b(false, "showTrackGraphOnF3", Comments.showTrackGraphOnF3); @Override public String getName() { @@ -96,7 +97,7 @@ public class CClient extends ConfigBase { "[in Blocks]", "Maximum Distance to the player at which items in Blocks' filter slots will be displayed" }; - static String rainbowDebug = "Show colourful debug information while the F3-Menu is open."; + static String rainbowDebug = "Show kinetic debug information on blocks while the F3-Menu is open."; static String maxContraptionLightVolume = "The maximum amount of blocks for which to try and calculate dynamic contraption lighting. Decrease if large contraption cause too much lag"; static String[] mainMenuConfigButtonRow = new String[]{ "Choose the menu row that the Create config button appears on in the main menu", @@ -145,6 +146,7 @@ public class CClient extends ConfigBase { static String trains = "Railway related settings"; static String mountedZoomMultiplier = "How far away the Camera should zoom when seated on a train"; + static String showTrackGraphOnF3 = "Display nodes and edges of a Railway Network while f3 debug mode is active"; } } diff --git a/src/main/java/com/simibubi/create/foundation/config/CTrains.java b/src/main/java/com/simibubi/create/foundation/config/CTrains.java index e76b70cb5..ad11fa18b 100644 --- a/src/main/java/com/simibubi/create/foundation/config/CTrains.java +++ b/src/main/java/com/simibubi/create/foundation/config/CTrains.java @@ -3,6 +3,7 @@ package com.simibubi.create.foundation.config; public class CTrains extends ConfigBase { public final ConfigBool trainsCauseDamage = b(true, "trainsCauseDamage", Comments.trainsCauseDamage); + public final ConfigInt maxTrackPlacementLength = i(32, 16, 128, "maxTrackPlacementLength", Comments.maxTrackPlacementLength); public final ConfigInt maxAssemblyLength = i(128, 5, "maxAssemblyLength", Comments.maxAssemblyLength); public final ConfigInt maxBogeyCount = i(20, 1, "maxBogeyCount", Comments.maxBogeyCount); public final ConfigFloat manualTrainSpeedModifier = f(.75f, 0, "manualTrainSpeedModifier", Comments.manualTrainSpeedModifier); @@ -33,6 +34,7 @@ public class CTrains extends ConfigBase { static String poweredTrainTurningTopSpeed = "The top speed of powered Trains during a turn."; static String poweredTrainAcceleration = "The acceleration of powered Trains."; static String trainsCauseDamage = "Whether moving Trains can hurt colliding mobs and players."; + static String maxTrackPlacementLength = "Maximum length of track that can be placed as one batch or turn."; static String maxAssemblyLength = "Maximum length of a Train Stations' assembly track."; static String maxBogeyCount = "Maximum amount of bogeys assembled as a single Train."; static String manualTrainSpeedModifier = "Relative speed of a manually controlled Train compared to a Scheduled one.";