mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-10 12:53:52 +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 {
|
public class BacktankUtil {
|
||||||
|
|
||||||
private static final List<Function<LivingEntity, List<ItemStack>>> BACKTANK_SUPPLIERS = new ArrayList<>();
|
private static final List<Function<LivingEntity, List<ItemStack>>> BACKTANK_SUPPLIERS = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
addBacktankSupplier(entity -> {
|
addBacktankSupplier(entity -> {
|
||||||
List<ItemStack> stacks = new ArrayList<>();
|
List<ItemStack> stacks = new ArrayList<>();
|
||||||
|
@ -76,6 +77,7 @@ public class BacktankUtil {
|
||||||
|
|
||||||
if (!(entity instanceof ServerPlayer player))
|
if (!(entity instanceof ServerPlayer player))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendWarning(player, air, newAir, maxAir / 10f);
|
sendWarning(player, air, newAir, maxAir / 10f);
|
||||||
sendWarning(player, air, newAir, 1);
|
sendWarning(player, air, newAir, 1);
|
||||||
}
|
}
|
||||||
|
@ -152,12 +154,15 @@ public class BacktankUtil {
|
||||||
return Math.round(13.0F - (float) stack.getDamageValue() / stack.getMaxDamage() * 13.0F);
|
return Math.round(13.0F - (float) stack.getDamageValue() / stack.getMaxDamage() * 13.0F);
|
||||||
|
|
||||||
if (backtanks.size() == 1)
|
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.
|
// If there is more than one backtank, average the bar widths.
|
||||||
int sumBarWidth = backtanks.stream()
|
int sumBarWidth = backtanks.stream()
|
||||||
.map(backtank -> backtank.getItem().getBarWidth(backtank))
|
.map(backtank -> backtank.getItem()
|
||||||
.reduce(0 , Integer::sum);
|
.getBarWidth(backtank))
|
||||||
|
.reduce(0, Integer::sum);
|
||||||
|
|
||||||
return Math.round((float) sumBarWidth / backtanks.size());
|
return Math.round((float) sumBarWidth / backtanks.size());
|
||||||
}
|
}
|
||||||
|
@ -171,7 +176,9 @@ public class BacktankUtil {
|
||||||
List<ItemStack> backtanks = getAllWithAir(player);
|
List<ItemStack> backtanks = getAllWithAir(player);
|
||||||
|
|
||||||
// Just return the "first" backtank for the bar color since that's the one we are consuming from
|
// 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 (lavaDiving) {
|
||||||
if (entity instanceof ServerPlayer sp)
|
if (entity instanceof ServerPlayer sp)
|
||||||
AllAdvancements.DIVING_SUIT_LAVA.awardTo(sp);
|
AllAdvancements.DIVING_SUIT_LAVA.awardTo(sp);
|
||||||
if (backtanks.stream().noneMatch(backtank -> backtank.getItem().isFireResistant()))
|
if (backtanks.stream()
|
||||||
|
.noneMatch(backtank -> backtank.getItem()
|
||||||
|
.isFireResistant()))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +95,9 @@ public class DivingHelmetItem extends BaseArmorItem {
|
||||||
|
|
||||||
if (world.isClientSide)
|
if (world.isClientSide)
|
||||||
entity.getPersistentData()
|
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)
|
if (!second)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
@ -736,18 +737,7 @@ public class Navigation {
|
||||||
if (destination == null)
|
if (destination == null)
|
||||||
return tag;
|
return tag;
|
||||||
|
|
||||||
// Remove null values in train navigation fixing a rare crash that could occur
|
removeBrokenPathEntries();
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.putUUID("Destination", destination.id);
|
tag.putUUID("Destination", destination.id);
|
||||||
tag.putDouble("DistanceToDestination", distanceToDestination);
|
tag.putDouble("DistanceToDestination", distanceToDestination);
|
||||||
|
@ -786,6 +776,9 @@ public class Navigation {
|
||||||
c -> currentPath.add(Couple
|
c -> currentPath.add(Couple
|
||||||
.deserializeEach(c.getList("Nodes", Tag.TAG_COMPOUND), c2 -> TrackNodeLocation.read(c2, dimensions))
|
.deserializeEach(c.getList("Nodes", Tag.TAG_COMPOUND), c2 -> TrackNodeLocation.read(c2, dimensions))
|
||||||
.map(graph::locateNode)));
|
.map(graph::locateNode)));
|
||||||
|
|
||||||
|
removeBrokenPathEntries();
|
||||||
|
|
||||||
waitingForSignal = tag.contains("BlockingSignal")
|
waitingForSignal = tag.contains("BlockingSignal")
|
||||||
? Pair.of(tag.getUUID("BlockingSignal"), tag.getBoolean("BlockingSignalSide"))
|
? Pair.of(tag.getUUID("BlockingSignal"), tag.getBoolean("BlockingSignalSide"))
|
||||||
: null;
|
: null;
|
||||||
|
@ -795,4 +788,25 @@ public class Navigation {
|
||||||
ticksWaitingForSignal = tag.getInt("TicksWaitingForSignal");
|
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));
|
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 -> {
|
addInstruction(scene -> {
|
||||||
BlockState blockState = scene.getWorld()
|
BlockState blockState = scene.getWorld()
|
||||||
.getBlockState(pos);
|
.getBlockState(pos);
|
||||||
|
@ -531,9 +531,10 @@ public class SceneBuilder {
|
||||||
return instruction.createLink(scene);
|
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 =
|
DisplayWorldSectionInstruction instruction =
|
||||||
new DisplayWorldSectionInstruction(duration, fadeInDirection, selection, Optional.empty());
|
new DisplayWorldSectionInstruction(fadeInDuration, fadeInDirection, selection, Optional.empty());
|
||||||
addInstruction(instruction);
|
addInstruction(instruction);
|
||||||
return instruction.createLink(scene);
|
return instruction.createLink(scene);
|
||||||
}
|
}
|
||||||
|
@ -564,8 +565,9 @@ public class SceneBuilder {
|
||||||
addInstruction(new FadeOutOfSceneInstruction<>(15, fadeOutDirection, link));
|
addInstruction(new FadeOutOfSceneInstruction<>(15, fadeOutDirection, link));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideIndependentSection(ElementLink<WorldSectionElement> link, Direction fadeOutDirection, int duration) {
|
public void hideIndependentSection(ElementLink<WorldSectionElement> link, Direction fadeOutDirection,
|
||||||
addInstruction(new FadeOutOfSceneInstruction<>(duration, fadeOutDirection, link));
|
int fadeOutDuration) {
|
||||||
|
addInstruction(new FadeOutOfSceneInstruction<>(fadeOutDuration, fadeOutDirection, link));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideIndependentSectionImmediately(ElementLink<WorldSectionElement> link) {
|
public void hideIndependentSectionImmediately(ElementLink<WorldSectionElement> link) {
|
||||||
|
|
|
@ -106,6 +106,8 @@ public final class NBTProcessors {
|
||||||
return false;
|
return false;
|
||||||
if (name.contains("Damage"))
|
if (name.contains("Damage"))
|
||||||
return false;
|
return false;
|
||||||
|
if (name.equals("display"))
|
||||||
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue