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
This commit is contained in:
simibubi 2023-01-14 15:15:49 +01:00
parent b502cd1c16
commit e97b75ff72
13 changed files with 35 additions and 15 deletions

View file

@ -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() {

View file

@ -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) {

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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())

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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<Trac
@Override
protected void applySettings(ServerPlayer player, TrackTileEntity te) {
int verifyDistance = AllConfigs.SERVER.trains.maxTrackPlacementLength.get() * 4;
if (!te.getBlockPos()
.closerThan(player.blockPosition(), 128)) {
.closerThan(player.blockPosition(), verifyDistance)) {
Create.LOGGER.warn(player.getScoreboardName() + " too far away from destroyed Curve track");
return;
}

View file

@ -15,6 +15,7 @@ import com.simibubi.create.content.logistics.trains.BezierConnection;
import com.simibubi.create.content.logistics.trains.ITrackBlock;
import com.simibubi.create.foundation.advancement.AllAdvancements;
import com.simibubi.create.foundation.block.ProperWaterloggedBlock;
import com.simibubi.create.foundation.config.AllConfigs;
import com.simibubi.create.foundation.utility.AngleHelper;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Iterate;
@ -101,6 +102,7 @@ public class TrackPlacement {
ItemStack stack, boolean girder, boolean maximiseTurn) {
Vec3 lookVec = player.getLookAngle();
int lookAngle = (int) (22.5 + AngleHelper.deg(Mth.atan2(lookVec.z, lookVec.x)) % 360) / 8;
int maxLength = AllConfigs.SERVER.trains.maxTrackPlacementLength.get();
if (level.isClientSide && cached != null && pos2.equals(hoveringPos) && stack.equals(lastItem)
&& hoveringMaxed == maximiseTurn && lookAngle == hoveringAngle)
@ -143,7 +145,7 @@ public class TrackPlacement {
if (pos1.equals(pos2))
return info.withMessage("second_point");
if (pos1.distSqr(pos2) > 32 * 32)
if (pos1.distSqr(pos2) > maxLength * maxLength)
return info.withMessage("too_far")
.tooJumbly();
if (!state1.hasProperty(TrackBlock.HAS_TE))

View file

@ -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";
}
}

View file

@ -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.";