mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 05:21:46 +01:00
PR tidy-up
- backport of #4998 - Rename localisation readme so github displays it in the folder view
This commit is contained in:
parent
4d7b64db49
commit
66797f233d
6 changed files with 52 additions and 23 deletions
|
@ -29,6 +29,7 @@ import java.util.function.Function;
|
|||
public class BacktankUtil {
|
||||
|
||||
private static final List<Function<LivingEntity, List<ItemStack>>> BACKTANK_SUPPLIERS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
addBacktankSupplier(entity -> {
|
||||
List<ItemStack> 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<ItemStack> 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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Couple<TrackNode>> toRemove = new ArrayList<>();
|
||||
for (Couple<TrackNode> 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<TrackNode> 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<Couple<TrackNode>> iterator = currentPath.iterator(); iterator.hasNext();) {
|
||||
Couple<TrackNode> 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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<WorldSectionElement> showIndependentSection(Selection selection, Direction fadeInDirection, int duration) {
|
||||
public ElementLink<WorldSectionElement> 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<WorldSectionElement> link, Direction fadeOutDirection, int duration) {
|
||||
addInstruction(new FadeOutOfSceneInstruction<>(duration, fadeOutDirection, link));
|
||||
public void hideIndependentSection(ElementLink<WorldSectionElement> link, Direction fadeOutDirection,
|
||||
int fadeOutDuration) {
|
||||
addInstruction(new FadeOutOfSceneInstruction<>(fadeOutDuration, fadeOutDirection, link));
|
||||
}
|
||||
|
||||
public void hideIndependentSectionImmediately(ElementLink<WorldSectionElement> link) {
|
||||
|
|
|
@ -106,6 +106,8 @@ public final class NBTProcessors {
|
|||
return false;
|
||||
if (name.contains("Damage"))
|
||||
return false;
|
||||
if (name.equals("display"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue