diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankUtil.java b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankUtil.java index 19f0d659b..ab061a94e 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/BacktankUtil.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/BacktankUtil.java @@ -29,6 +29,7 @@ import java.util.function.Function; public class BacktankUtil { private static final List>> BACKTANK_SUPPLIERS = new ArrayList<>(); + static { addBacktankSupplier(entity -> { List stacks = new ArrayList<>(); @@ -76,6 +77,7 @@ public class BacktankUtil { if (!(entity instanceof ServerPlayer player)) return; + sendWarning(player, air, newAir, maxAir / 10f); sendWarning(player, air, newAir, 1); } @@ -152,12 +154,15 @@ public class BacktankUtil { return Math.round(13.0F - (float) stack.getDamageValue() / stack.getMaxDamage() * 13.0F); if (backtanks.size() == 1) - return backtanks.get(0).getItem().getBarWidth(backtanks.get(0)); + return backtanks.get(0) + .getItem() + .getBarWidth(backtanks.get(0)); // If there is more than one backtank, average the bar widths. int sumBarWidth = backtanks.stream() - .map(backtank -> backtank.getItem().getBarWidth(backtank)) - .reduce(0 , Integer::sum); + .map(backtank -> backtank.getItem() + .getBarWidth(backtank)) + .reduce(0, Integer::sum); return Math.round((float) sumBarWidth / backtanks.size()); } @@ -171,7 +176,9 @@ public class BacktankUtil { List backtanks = getAllWithAir(player); // Just return the "first" backtank for the bar color since that's the one we are consuming from - return backtanks.get(0).getItem().getBarColor(backtanks.get(0)); + return backtanks.get(0) + .getItem() + .getBarColor(backtanks.get(0)); } /** diff --git a/src/main/java/com/simibubi/create/content/equipment/armor/DivingHelmetItem.java b/src/main/java/com/simibubi/create/content/equipment/armor/DivingHelmetItem.java index b7eaaed40..173624e7f 100644 --- a/src/main/java/com/simibubi/create/content/equipment/armor/DivingHelmetItem.java +++ b/src/main/java/com/simibubi/create/content/equipment/armor/DivingHelmetItem.java @@ -84,7 +84,9 @@ public class DivingHelmetItem extends BaseArmorItem { if (lavaDiving) { if (entity instanceof ServerPlayer sp) AllAdvancements.DIVING_SUIT_LAVA.awardTo(sp); - if (backtanks.stream().noneMatch(backtank -> backtank.getItem().isFireResistant())) + if (backtanks.stream() + .noneMatch(backtank -> backtank.getItem() + .isFireResistant())) return; } @@ -93,7 +95,9 @@ public class DivingHelmetItem extends BaseArmorItem { if (world.isClientSide) entity.getPersistentData() - .putInt("VisualBacktankAir", Math.round(backtanks.stream().map(BacktankUtil::getAir).reduce(0f, Float::sum))); + .putInt("VisualBacktankAir", Math.round(backtanks.stream() + .map(BacktankUtil::getAir) + .reduce(0f, Float::sum))); if (!second) return; diff --git a/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java b/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java index 2e42c6675..b8fdd98d4 100644 --- a/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java +++ b/src/main/java/com/simibubi/create/content/trains/entity/Navigation.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.IdentityHashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -736,18 +737,7 @@ public class Navigation { if (destination == null) return tag; - // Remove null values in train navigation fixing a rare crash that could occur - List> toRemove = new ArrayList<>(); - for (Couple couple : currentPath) { - if (couple == null || couple.getFirst() == null || couple.getSecond() == null) - toRemove.add(couple); - } - if (toRemove.size() > 0) { - Create.LOGGER.error("Found null values in path of train with name: "+train.name.getString()+", id: "+train.id.toString()); - } - for (Couple brokenCouple : toRemove) { - currentPath.remove(brokenCouple); - } + removeBrokenPathEntries(); tag.putUUID("Destination", destination.id); tag.putDouble("DistanceToDestination", distanceToDestination); @@ -786,6 +776,9 @@ public class Navigation { c -> currentPath.add(Couple .deserializeEach(c.getList("Nodes", Tag.TAG_COMPOUND), c2 -> TrackNodeLocation.read(c2, dimensions)) .map(graph::locateNode))); + + removeBrokenPathEntries(); + waitingForSignal = tag.contains("BlockingSignal") ? Pair.of(tag.getUUID("BlockingSignal"), tag.getBoolean("BlockingSignalSide")) : null; @@ -795,4 +788,25 @@ public class Navigation { ticksWaitingForSignal = tag.getInt("TicksWaitingForSignal"); } + private void removeBrokenPathEntries() { + /* + * Trains might load or save with null entries in their path, this method avoids + * that anomaly from causing NPEs. The underlying issue has not been found. + */ + + boolean nullEntriesPresent = false; + + for (Iterator> iterator = currentPath.iterator(); iterator.hasNext();) { + Couple couple = iterator.next(); + if (couple == null || couple.getFirst() == null || couple.getSecond() == null) { + iterator.remove(); + nullEntriesPresent = true; + } + } + + if (nullEntriesPresent) + Create.LOGGER.error("Found null values in path of train with name: " + train.name.getString() + ", id: " + + train.id.toString()); + } + } diff --git a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java index 05ce35ad0..2b284b9c8 100644 --- a/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java +++ b/src/main/java/com/simibubi/create/foundation/ponder/SceneBuilder.java @@ -296,7 +296,7 @@ public class SceneBuilder { addInstruction(scene -> SuperGlueItem.spawnParticles(scene.getWorld(), pos, side, fullBlock)); } - private void rotationIndicator(BlockPos pos, boolean direction, BlockPos displayPos) { + private void rotationIndicator(BlockPos pos, boolean direction, BlockPos displayPos) { addInstruction(scene -> { BlockState blockState = scene.getWorld() .getBlockState(pos); @@ -531,9 +531,10 @@ public class SceneBuilder { return instruction.createLink(scene); } - public ElementLink showIndependentSection(Selection selection, Direction fadeInDirection, int duration) { + public ElementLink showIndependentSection(Selection selection, Direction fadeInDirection, + int fadeInDuration) { DisplayWorldSectionInstruction instruction = - new DisplayWorldSectionInstruction(duration, fadeInDirection, selection, Optional.empty()); + new DisplayWorldSectionInstruction(fadeInDuration, fadeInDirection, selection, Optional.empty()); addInstruction(instruction); return instruction.createLink(scene); } @@ -564,8 +565,9 @@ public class SceneBuilder { addInstruction(new FadeOutOfSceneInstruction<>(15, fadeOutDirection, link)); } - public void hideIndependentSection(ElementLink link, Direction fadeOutDirection, int duration) { - addInstruction(new FadeOutOfSceneInstruction<>(duration, fadeOutDirection, link)); + public void hideIndependentSection(ElementLink link, Direction fadeOutDirection, + int fadeOutDuration) { + addInstruction(new FadeOutOfSceneInstruction<>(fadeOutDuration, fadeOutDirection, link)); } public void hideIndependentSectionImmediately(ElementLink link) { diff --git a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java index f2dc7a70d..d96c52953 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java +++ b/src/main/java/com/simibubi/create/foundation/utility/NBTProcessors.java @@ -106,6 +106,8 @@ public final class NBTProcessors { return false; if (name.contains("Damage")) return false; + if (name.equals("display")) + return false; return true; } diff --git a/src/main/resources/assets/create/lang/Localization Readme.md b/src/main/resources/assets/create/lang/README.md similarity index 100% rename from src/main/resources/assets/create/lang/Localization Readme.md rename to src/main/resources/assets/create/lang/README.md