diff --git a/patches/server/1047-SW-WallBlock-Cache-Improvements.patch b/patches/server/1047-SW-WallBlock-Cache-Improvements.patch new file mode 100644 index 0000000000..863c746c3b --- /dev/null +++ b/patches/server/1047-SW-WallBlock-Cache-Improvements.patch @@ -0,0 +1,118 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:40:37 +0200 +Subject: [PATCH] SW WallBlock Cache Improvements + + +diff --git a/src/main/java/net/minecraft/world/level/block/WallBlock.java b/src/main/java/net/minecraft/world/level/block/WallBlock.java +index 83956032bef4d34eddb9899f0a2847e66bfd83f4..bea1d8a72d5528335b755aeda6168764778b924f 100644 +--- a/src/main/java/net/minecraft/world/level/block/WallBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/WallBlock.java +@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap; + import com.google.common.collect.ImmutableMap.Builder; + import com.mojang.serialization.MapCodec; + import java.util.Map; ++import java.util.Objects; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; + import net.minecraft.tags.BlockTags; +@@ -35,8 +36,14 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + public static final EnumProperty SOUTH_WALL = BlockStateProperties.SOUTH_WALL; + public static final EnumProperty WEST_WALL = BlockStateProperties.WEST_WALL; + public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; +- private final Map shapeByIndex; +- private final Map collisionShapeByIndex; ++ private static final Map shapeByIndex; ++ private static final Map collisionShapeByIndex; ++ ++ static { ++ shapeByIndex = makeShapes(4.0F, 3.0F, 16.0F, 0.0F, 14.0F, 16.0F); ++ collisionShapeByIndex = makeShapes(4.0F, 3.0F, 24.0F, 0.0F, 24.0F, 24.0F); ++ } ++ + private static final int WALL_WIDTH = 3; + private static final int WALL_HEIGHT = 14; + private static final int POST_WIDTH = 4; +@@ -66,8 +73,6 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + .setValue(WEST_WALL, WallSide.NONE) + .setValue(WATERLOGGED, Boolean.valueOf(false)) + ); +- this.shapeByIndex = this.makeShapes(4.0F, 3.0F, 16.0F, 0.0F, 14.0F, 16.0F); +- this.collisionShapeByIndex = this.makeShapes(4.0F, 3.0F, 24.0F, 0.0F, 24.0F, 24.0F); + } + + private static VoxelShape applyWallShape(VoxelShape base, WallSide wallShape, VoxelShape tall, VoxelShape low) { +@@ -78,7 +83,7 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + } + } + +- private Map makeShapes(float f, float g, float h, float i, float j, float k) { ++ private static Map makeShapes(float f, float g, float h, float i, float j, float k) { + float l = 8.0F - f; + float m = 8.0F + f; + float n = 8.0F - g; +@@ -92,7 +97,7 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + VoxelShape voxelShape7 = Block.box((double)n, (double)i, (double)n, (double)o, (double)k, 16.0); + VoxelShape voxelShape8 = Block.box(0.0, (double)i, (double)n, (double)o, (double)k, (double)o); + VoxelShape voxelShape9 = Block.box((double)n, (double)i, (double)n, 16.0, (double)k, (double)o); +- Builder builder = ImmutableMap.builder(); ++ Builder builder = ImmutableMap.builder(); + + for (Boolean boolean_ : UP.getPossibleValues()) { + for (WallSide wallSide : EAST_WALL.getPossibleValues()) { +@@ -108,14 +113,8 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + voxelShape10 = Shapes.or(voxelShape10, voxelShape); + } + +- BlockState blockState = this.defaultBlockState() +- .setValue(UP, boolean_) +- .setValue(EAST_WALL, wallSide) +- .setValue(WEST_WALL, wallSide3) +- .setValue(NORTH_WALL, wallSide2) +- .setValue(SOUTH_WALL, wallSide4); +- builder.put(blockState.setValue(WATERLOGGED, Boolean.valueOf(false)), voxelShape10); +- builder.put(blockState.setValue(WATERLOGGED, Boolean.valueOf(true)), voxelShape10); ++ builder.put(hashWallState(wallSide, wallSide2, wallSide4, boolean_, Boolean.FALSE, wallSide3), voxelShape10); ++ builder.put(hashWallState(wallSide, wallSide2, wallSide4, boolean_, Boolean.TRUE , wallSide3), voxelShape10); + } + } + } +@@ -125,14 +124,36 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { + return builder.build(); + } + ++ private static int mapHashCode(Map, Comparable> values) { ++ return hashWallState( ++ (WallSide) values.get(EAST_WALL), ++ (WallSide) values.get(NORTH_WALL), ++ (WallSide) values.get(SOUTH_WALL), ++ (Boolean) values.get(UP), ++ (Boolean) values.get(WATERLOGGED), ++ (WallSide) values.get(WEST_WALL) ++ ); ++ } ++ ++ private static int hashWallState(WallSide east, WallSide north, WallSide south, boolean up, boolean waterlogged, WallSide west) { ++ int hash = 7; ++ hash = 31 * hash + east.hashCode(); ++ hash = 31 * hash + north.hashCode(); ++ hash = 31 * hash + south.hashCode(); ++ hash = 31 * hash + Objects.hashCode(up); ++ hash = 31 * hash + Objects.hashCode(waterlogged); ++ hash = 31 * hash + west.hashCode(); ++ return hash; ++ } ++ + @Override + protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { +- return this.shapeByIndex.get(state); ++ return shapeByIndex.get(mapHashCode(state.getValues())); + } + + @Override + protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { +- return this.collisionShapeByIndex.get(state); ++ return collisionShapeByIndex.get(mapHashCode(state.getValues())); + } + + @Override diff --git a/patches/server/1048-SW-Remove-Debug-Messages.patch b/patches/server/1048-SW-Remove-Debug-Messages.patch new file mode 100644 index 0000000000..1e0c6f9c94 --- /dev/null +++ b/patches/server/1048-SW-Remove-Debug-Messages.patch @@ -0,0 +1,121 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:42:59 +0200 +Subject: [PATCH] SW Remove Debug Messages + + +diff --git a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java +index 660b2ec6b63a4ceffee44ab11f54dfa7c0d0996f..81902d28ac96cebb98d66bf5a4ff4237bf00d181 100644 +--- a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java ++++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java +@@ -92,7 +92,7 @@ public enum VersionHistoryManager { + )) { + gson.toJson(currentData, writer); + } catch (final IOException e) { +- logger.log(Level.SEVERE, "Failed to write to version history file", e); ++ //logger.log(Level.SEVERE, "Failed to write to version history file", e); + } + } + +diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java +index 87e5f614ba988547a827486740db217e28585773..c83eae306debfe34fb6383cb83a3dad0f74431a4 100644 +--- a/src/main/java/io/papermc/paper/configuration/Configurations.java ++++ b/src/main/java/io/papermc/paper/configuration/Configurations.java +@@ -114,7 +114,7 @@ public abstract class Configurations { + loader.save(node); + } catch (ConfigurateException ex) { + if (ex.getCause() instanceof AccessDeniedException) { +- LOGGER.warn("Could not save {}: Paper could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at https://docs.papermc.io/paper/configuration for more details.", filename, ex); ++ //LOGGER.warn("Could not save {}: Paper could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at https://docs.papermc.io/paper/configuration for more details.", filename, ex); + } else throw ex; + } + } +diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +index 783eac6e458c6f1a0584301fb84a2fe341868f34..ec2194d292f79ea66a2b85835189f270cb727f9f 100644 +--- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java ++++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +@@ -459,8 +459,6 @@ public class PaperConfigurations extends Configurations> { + + Objects.requireNonNull(jsonarray); + stream.forEach(jsonarray::add); +- BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); ++ BufferedWriter bufferedwriter; ++ try { ++ bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); ++ } catch (FileNotFoundException e) { ++ return; ++ } + + try { + StoredUserList.GSON.toJson(jsonarray, StoredUserList.GSON.newJsonWriter(bufferedwriter)); +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index c8b82bc41f2042bb4b067f06265a3a22e51f7629..e7f63e2f9271b05748db152be43ce9dfad6ff3a5 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -502,7 +502,7 @@ public final class CraftServer implements Server { + try { + this.configuration.save(this.getConfigFile()); + } catch (IOException ex) { +- Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getConfigFile(), ex); ++ //Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getConfigFile(), ex); + } + } + +@@ -510,7 +510,7 @@ public final class CraftServer implements Server { + try { + this.commandsConfiguration.save(this.getCommandsConfigFile()); + } catch (IOException ex) { +- Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getCommandsConfigFile(), ex); ++ //Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getCommandsConfigFile(), ex); + } + } + +@@ -600,7 +600,7 @@ public final class CraftServer implements Server { + DefaultPermissions.registerCorePermissions(); + CraftDefaultPermissions.registerCorePermissions(); + if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper +- this.helpMap.initializeCommands(); ++ //this.helpMap.initializeCommands(); + this.syncCommands(); + } + } +diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java +index 4dbb109d0526afee99b9190fc256585121aac9b5..3e819b143f62506d733ca88f585ba016c6765045 100644 +--- a/src/main/java/org/spigotmc/SpigotConfig.java ++++ b/src/main/java/org/spigotmc/SpigotConfig.java +@@ -126,7 +126,7 @@ public class SpigotConfig + SpigotConfig.config.save( SpigotConfig.CONFIG_FILE ); + } catch ( IOException ex ) + { +- Bukkit.getLogger().log( Level.SEVERE, "Could not save " + SpigotConfig.CONFIG_FILE, ex ); ++ //Bukkit.getLogger().log( Level.SEVERE, "Could not save " + SpigotConfig.CONFIG_FILE, ex ); + } + } + diff --git a/patches/server/1049-SW-Use-optimized-NeighbourTable.patch b/patches/server/1049-SW-Use-optimized-NeighbourTable.patch new file mode 100644 index 0000000000..3fb139e8b3 --- /dev/null +++ b/patches/server/1049-SW-Use-optimized-NeighbourTable.patch @@ -0,0 +1,223 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:44:11 +0200 +Subject: [PATCH] SW Use optimized NeighbourTable + + +diff --git a/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java b/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java +index 46af72761c0bfbc10c14d78c855255969e2cf8a3..3a449e13951ea183b9ae7910a424b51e841608da 100644 +--- a/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java ++++ b/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java +@@ -11,10 +11,8 @@ import com.mojang.serialization.Decoder; + import com.mojang.serialization.Encoder; + import com.mojang.serialization.MapCodec; + import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap; +-import java.util.Collection; +-import java.util.Collections; +-import java.util.List; +-import java.util.Map; ++ ++import java.util.*; + import java.util.Map.Entry; + import java.util.function.Function; + import java.util.function.Supplier; +@@ -22,7 +20,8 @@ import java.util.regex.Pattern; + import java.util.stream.Collectors; + import java.util.stream.Stream; + import javax.annotation.Nullable; +-import net.minecraft.world.level.block.state.properties.Property; ++ ++import net.minecraft.world.level.block.state.properties.*; + + public class StateDefinition> { + static final Pattern NAME_PATTERN = Pattern.compile("^[a-z0-9_]+$"); +@@ -41,7 +40,6 @@ public class StateDefinition> { + } + + MapCodec mapCodec2 = mapCodec; +- Map, Comparable>, S> map = Maps.newLinkedHashMap(); + List list = Lists.newArrayList(); + Stream, Comparable>>> stream = Stream.of(Collections.emptyList()); + +@@ -53,6 +51,7 @@ public class StateDefinition> { + })); + } + ++ NeighbourTable table = new NeighbourTable<>(propertiesMap); + stream.forEach(list2 -> { + Reference2ObjectArrayMap, Comparable> reference2ObjectArrayMap = new Reference2ObjectArrayMap<>(list2.size()); + +@@ -61,13 +60,12 @@ public class StateDefinition> { + } + + S stateHolderx = factory.create(owner, reference2ObjectArrayMap, mapCodec2); +- map.put(reference2ObjectArrayMap, stateHolderx); + list.add(stateHolderx); +- }); + +- for (S stateHolder : list) { +- stateHolder.populateNeighbours(map); +- } ++ int index = table.put(reference2ObjectArrayMap, stateHolderx); ++ ++ stateHolderx.populateNeighbours(table, index); ++ }); + + this.states = ImmutableList.copyOf(list); + } +@@ -157,4 +155,60 @@ public class StateDefinition> { + public interface Factory { + S create(O owner, Reference2ObjectArrayMap, Comparable> propertyMap, MapCodec codec); + } ++ ++ public static class NeighbourTable { ++ private final Map, Pair> offsetMasks; ++ private final Object[] array; ++ ++ public NeighbourTable(Map> propertiesMap) { ++ offsetMasks = new IdentityHashMap<>(propertiesMap.size()); ++ int offset = 0; ++ for(Property property : propertiesMap.values()) { ++ int bits = Integer.SIZE - Integer.numberOfLeadingZeros((property instanceof EnumProperty ? property.getValueClass().getEnumConstants().length : property.getPossibleValues().size()) - 1); ++ offsetMasks.put(property, Pair.of(offset, ~(((1<, Comparable> key, S value) { ++ int index = 0; ++ for(Map.Entry, Comparable> k : key.entrySet()) { ++ index = setIndex(index, k.getKey(), k.getValue()); ++ } ++ array[index] = value; ++ return index; ++ } ++ ++ private int setIndex(int index, Property property, Comparable value) { ++ Pair offsetMask = offsetMasks.get(property); ++ if(property instanceof BooleanProperty) { ++ return index | (((Boolean)value) ? 1 : 0) << offsetMask.getFirst(); ++ } else if(property instanceof EnumProperty) { ++ return index | ((Enum)value).ordinal() << offsetMask.getFirst(); ++ } else if(property instanceof IntegerProperty intProperty) { ++ return index | (((Integer)value) - intProperty.min) << offsetMask.getFirst(); ++ } else { ++ throw new IllegalArgumentException("Unknown property type " + property.getClass().getName()); ++ } ++ } ++ ++ public S getNeighbour(int index, Property property, Comparable value) { ++ return (S)array[modIndex(index, property, value)]; ++ } ++ ++ private int modIndex(int index, Property property, Comparable value) { ++ Pair offsetMask = offsetMasks.get(property); ++ if(property instanceof BooleanProperty) { ++ return (index & offsetMask.getSecond()) | (((Boolean)value) ? 1 : 0) << offsetMask.getFirst(); ++ } else if(property instanceof EnumProperty) { ++ return (index & offsetMask.getSecond()) | ((Enum)value).ordinal() << offsetMask.getFirst(); ++ } else if(property instanceof IntegerProperty intProperty) { ++ return (index & offsetMask.getSecond()) | (((Integer)value) - intProperty.min) << offsetMask.getFirst(); ++ } else { ++ throw new IllegalArgumentException("Unknown property type " + property.getClass().getName()); ++ } ++ } ++ } + } +diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +index 45744d86e9582a93a0cec26009deea091080fbbe..7e2ecb0457150dedc665f05c6c8ad068c00e3642 100644 +--- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java ++++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java +@@ -37,15 +37,14 @@ public abstract class StateHolder { + }; + protected final O owner; + private final Reference2ObjectArrayMap, Comparable> values; +- private Table, Comparable, S> neighbours; + protected final MapCodec propertiesCodec; +- protected final io.papermc.paper.util.table.ZeroCollidingReferenceStateTable optimisedTable; // Paper - optimise state lookup ++ private StateDefinition.NeighbourTable neighbourTable; ++ private int neighbourIndex; + + protected StateHolder(O owner, Reference2ObjectArrayMap, Comparable> propertyMap, MapCodec codec) { + this.owner = owner; + this.values = propertyMap; + this.propertiesCodec = codec; +- this.optimisedTable = new io.papermc.paper.util.table.ZeroCollidingReferenceStateTable(this, propertyMap); // Paper - optimise state lookup + } + + public > S cycle(Property property) { +@@ -86,11 +85,11 @@ public abstract class StateHolder { + } + + public > boolean hasProperty(Property property) { +- return this.optimisedTable.get(property) != null; // Paper - optimise state lookup ++ return this.values.containsKey(property); + } + + public > T getValue(Property property) { +- Comparable comparable = this.optimisedTable.get(property); // Paper - optimise state lookup ++ Comparable comparable = this.values.get(property); + if (comparable == null) { + throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner); + } else { +@@ -99,52 +98,26 @@ public abstract class StateHolder { + } + + public > Optional getOptionalValue(Property property) { +- Comparable comparable = this.optimisedTable.get(property); // Paper - optimise state lookup ++ Comparable comparable = this.values.get(property); + return comparable == null ? Optional.empty() : Optional.of(property.getValueClass().cast(comparable)); + } + + public , V extends T> S setValue(Property property, V value) { +- // Paper start - optimise state lookup +- final S ret = (S)this.optimisedTable.get(property, value); +- if (ret == null) { +- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); +- } +- return ret; +- // Paper end - optimise state lookup ++ return this.neighbourTable.getNeighbour(this.neighbourIndex, property, value); + } + + public , V extends T> S trySetValue(Property property, V value) { + Comparable comparable = this.values.get(property); + if (comparable != null && !comparable.equals(value)) { +- S object = this.neighbours.get(property, value); +- if (object == null) { +- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); +- } else { +- return object; +- } ++ return this.neighbourTable.getNeighbour(this.neighbourIndex, property, value); + } else { + return (S)this; + } + } + +- public void populateNeighbours(Map, Comparable>, S> states) { +- if (this.neighbours != null) { +- throw new IllegalStateException(); +- } else { +- Table, Comparable, S> table = HashBasedTable.create(); +- +- for (Entry, Comparable> entry : this.values.entrySet()) { +- Property property = entry.getKey(); +- +- for (Comparable comparable : property.getPossibleValues()) { +- if (!comparable.equals(entry.getValue())) { +- table.put(property, comparable, states.get(this.makeNeighbourValues(property, comparable))); +- } +- } +- } +- +- this.neighbours = (Table, Comparable, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup +- } ++ public void populateNeighbours(StateDefinition.NeighbourTable states, int ownIndex) { ++ this.neighbourTable = states; ++ this.neighbourIndex = ownIndex; + } + + private Map, Comparable> makeNeighbourValues(Property property, Comparable value) { diff --git a/patches/server/1050-SW-optimized-Blocks-cache.patch b/patches/server/1050-SW-optimized-Blocks-cache.patch new file mode 100644 index 0000000000..f2e5bde9bb --- /dev/null +++ b/patches/server/1050-SW-optimized-Blocks-cache.patch @@ -0,0 +1,42 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:45:21 +0200 +Subject: [PATCH] SW optimized Blocks cache + + +diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java +index 223259e7a09ada681b6181c898f6857888594f85..3f31a3115c69fd976ccb1e396018d94bba0f3557 100644 +--- a/src/main/java/net/minecraft/world/level/block/Blocks.java ++++ b/src/main/java/net/minecraft/world/level/block/Blocks.java +@@ -1,7 +1,9 @@ + package net.minecraft.world.level.block; + ++import java.util.concurrent.ExecutorService; + import java.util.function.Function; + import java.util.function.ToIntFunction; ++import net.minecraft.Util; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; + import net.minecraft.core.Direction; +@@ -7797,17 +7799,18 @@ public class Blocks { + } + + public static void rebuildCache() { +- Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); ++ ExecutorService executor = Util.backgroundExecutor(); ++ Block.BLOCK_STATE_REGISTRY.forEach(b -> executor.submit(b::initCache)); + } + + static { + for (Block block : BuiltInRegistries.BLOCK) { + for (BlockState blockState : block.getStateDefinition().getPossibleStates()) { + Block.BLOCK_STATE_REGISTRY.add(blockState); +- blockState.initCache(); ++ //blockState.initCache(); + } + +- block.getLootTable(); ++ //block.getLootTable(); + } + } + } diff --git a/patches/server/1047-SW-Patches.patch b/patches/server/1051-SW-Remove-or-Optimize-Caches.patch similarity index 95% rename from patches/server/1047-SW-Patches.patch rename to patches/server/1051-SW-Remove-or-Optimize-Caches.patch index 9ff30851ab..e4714cac00 100644 --- a/patches/server/1047-SW-Patches.patch +++ b/patches/server/1051-SW-Remove-or-Optimize-Caches.patch @@ -1,7 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lixfel -Date: Wed, 1 Feb 2023 21:36:57 +0100 -Subject: [PATCH] SW Patches +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:45:59 +0200 +Subject: [PATCH] SW Remove or Optimize Caches diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/helpers/HelperBlockFlatteningV1450.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/helpers/HelperBlockFlatteningV1450.java @@ -95,46 +95,6 @@ index 4f4f4cb6037c2a46ffcf427f5812164bbb98b8b7..eef5249db9a5808216397dd03b882dcb return ret == null ? FLATTENED_BY_ID[0] : ret; } -diff --git a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java -index 660b2ec6b63a4ceffee44ab11f54dfa7c0d0996f..81902d28ac96cebb98d66bf5a4ff4237bf00d181 100644 ---- a/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java -+++ b/src/main/java/com/destroystokyo/paper/VersionHistoryManager.java -@@ -92,7 +92,7 @@ public enum VersionHistoryManager { - )) { - gson.toJson(currentData, writer); - } catch (final IOException e) { -- logger.log(Level.SEVERE, "Failed to write to version history file", e); -+ //logger.log(Level.SEVERE, "Failed to write to version history file", e); - } - } - -diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java -index 87e5f614ba988547a827486740db217e28585773..c83eae306debfe34fb6383cb83a3dad0f74431a4 100644 ---- a/src/main/java/io/papermc/paper/configuration/Configurations.java -+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java -@@ -114,7 +114,7 @@ public abstract class Configurations { - loader.save(node); - } catch (ConfigurateException ex) { - if (ex.getCause() instanceof AccessDeniedException) { -- LOGGER.warn("Could not save {}: Paper could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at https://docs.papermc.io/paper/configuration for more details.", filename, ex); -+ //LOGGER.warn("Could not save {}: Paper could not persist the full set of configuration settings in the configuration file. Any setting missing from the configuration file will be set with its default value in memory. Admins should make sure to review the configuration documentation at https://docs.papermc.io/paper/configuration for more details.", filename, ex); - } else throw ex; - } - } -diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index 783eac6e458c6f1a0584301fb84a2fe341868f34..ec2194d292f79ea66a2b85835189f270cb727f9f 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -459,8 +459,6 @@ public class PaperConfigurations extends Configurations map)); this.mappingsByMojangName = maps.stream().collect(Collectors.toUnmodifiableMap(ClassMapping::mojangName, map -> map)); -diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java -index 1d1e76de60e40224f5cb81893f9ee50fe987badb..c2367bcc8dafb71877259dfb46accb42a743d0ee 100644 ---- a/src/main/java/net/minecraft/commands/Commands.java -+++ b/src/main/java/net/minecraft/commands/Commands.java -@@ -156,65 +156,64 @@ public class Commands { - - public Commands(Commands.CommandSelection environment, CommandBuildContext commandRegistryAccess) { - // Paper -- AdvancementCommands.register(this.dispatcher); -- AttributeCommand.register(this.dispatcher, commandRegistryAccess); -- ExecuteCommand.register(this.dispatcher, commandRegistryAccess); -- BossBarCommands.register(this.dispatcher, commandRegistryAccess); -+ //AdvancementCommands.register(this.dispatcher); -+ //AttributeCommand.register(this.dispatcher, commandRegistryAccess); -+ //ExecuteCommand.register(this.dispatcher, commandRegistryAccess); -+ //BossBarCommands.register(this.dispatcher, commandRegistryAccess); - ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess); -- CloneCommands.register(this.dispatcher, commandRegistryAccess); -- DamageCommand.register(this.dispatcher, commandRegistryAccess); -- DataCommands.register(this.dispatcher); -- DataPackCommand.register(this.dispatcher); -- DebugCommand.register(this.dispatcher); -- DefaultGameModeCommands.register(this.dispatcher); -- DifficultyCommand.register(this.dispatcher); -+ //CloneCommands.register(this.dispatcher, commandRegistryAccess); -+ //DamageCommand.register(this.dispatcher, commandRegistryAccess); -+ //DataCommands.register(this.dispatcher); -+ //DataPackCommand.register(this.dispatcher); -+ //DebugCommand.register(this.dispatcher); -+ //DefaultGameModeCommands.register(this.dispatcher); -+ //DifficultyCommand.register(this.dispatcher); - EffectCommands.register(this.dispatcher, commandRegistryAccess); -- EmoteCommands.register(this.dispatcher); -+ //EmoteCommands.register(this.dispatcher); - EnchantCommand.register(this.dispatcher, commandRegistryAccess); -- ExperienceCommand.register(this.dispatcher); -- FillCommand.register(this.dispatcher, commandRegistryAccess); -+ //ExperienceCommand.register(this.dispatcher); -+ //FillCommand.register(this.dispatcher, commandRegistryAccess); - FillBiomeCommand.register(this.dispatcher, commandRegistryAccess); -- ForceLoadCommand.register(this.dispatcher); -- FunctionCommand.register(this.dispatcher); -+ //ForceLoadCommand.register(this.dispatcher); -+ //FunctionCommand.register(this.dispatcher); - GameModeCommand.register(this.dispatcher); - GameRuleCommand.register(this.dispatcher); - GiveCommand.register(this.dispatcher, commandRegistryAccess); -- HelpCommand.register(this.dispatcher); -- ItemCommands.register(this.dispatcher, commandRegistryAccess); -+ //HelpCommand.register(this.dispatcher); -+ //ItemCommands.register(this.dispatcher, commandRegistryAccess); - KickCommand.register(this.dispatcher); - KillCommand.register(this.dispatcher); -- ListPlayersCommand.register(this.dispatcher); -- LocateCommand.register(this.dispatcher, commandRegistryAccess); -- LootCommand.register(this.dispatcher, commandRegistryAccess); -- MsgCommand.register(this.dispatcher); -- ParticleCommand.register(this.dispatcher, commandRegistryAccess); -- PlaceCommand.register(this.dispatcher); -- PlaySoundCommand.register(this.dispatcher); -- RandomCommand.register(this.dispatcher); -- ReloadCommand.register(this.dispatcher); -- RecipeCommand.register(this.dispatcher); -- ReturnCommand.register(this.dispatcher); -- RideCommand.register(this.dispatcher); -- SayCommand.register(this.dispatcher); -- ScheduleCommand.register(this.dispatcher); -- ScoreboardCommand.register(this.dispatcher, commandRegistryAccess); -- SeedCommand.register(this.dispatcher, environment != Commands.CommandSelection.INTEGRATED); -- SetBlockCommand.register(this.dispatcher, commandRegistryAccess); -- SetSpawnCommand.register(this.dispatcher); -+ //ListPlayersCommand.register(this.dispatcher); -+ //LocateCommand.register(this.dispatcher, commandRegistryAccess); -+ //LootCommand.register(this.dispatcher, commandRegistryAccess); -+ //MsgCommand.register(this.dispatcher); -+ //ParticleCommand.register(this.dispatcher, commandRegistryAccess); -+ //PlaceCommand.register(this.dispatcher); -+ //PlaySoundCommand.register(this.dispatcher); -+ //ReloadCommand.register(this.dispatcher); -+ //RecipeCommand.register(this.dispatcher); -+ //ReturnCommand.register(this.dispatcher); -+ //RideCommand.register(this.dispatcher); -+ //SayCommand.register(this.dispatcher); -+ //ScheduleCommand.register(this.dispatcher); -+ //ScoreboardCommand.register(this.dispatcher); -+ //SeedCommand.register(this.dispatcher, environment != Commands.CommandSelection.INTEGRATED); -+ //SetBlockCommand.register(this.dispatcher, commandRegistryAccess); -+ //SetSpawnCommand.register(this.dispatcher); - SetWorldSpawnCommand.register(this.dispatcher); - SpectateCommand.register(this.dispatcher); -- SpreadPlayersCommand.register(this.dispatcher); -- StopSoundCommand.register(this.dispatcher); -+ //SpreadPlayersCommand.register(this.dispatcher); -+ //StopSoundCommand.register(this.dispatcher); - SummonCommand.register(this.dispatcher, commandRegistryAccess); -- TagCommand.register(this.dispatcher); -- TeamCommand.register(this.dispatcher, commandRegistryAccess); -- TeamMsgCommand.register(this.dispatcher); -+ //TagCommand.register(this.dispatcher); -+ //TeamCommand.register(this.dispatcher, commandRegistryAccess); -+ //TeamMsgCommand.register(this.dispatcher); - TeleportCommand.register(this.dispatcher); -- TellRawCommand.register(this.dispatcher, commandRegistryAccess); -+ //TellRawCommand.register(this.dispatcher, commandRegistryAccess); - TickCommand.register(this.dispatcher); - TimeCommand.register(this.dispatcher); -- TitleCommand.register(this.dispatcher, commandRegistryAccess); -- TriggerCommand.register(this.dispatcher); -+ //TitleCommand.register(this.dispatcher, commandRegistryAccess); -+ //TriggerCommand.register(this.dispatcher); - WeatherCommand.register(this.dispatcher); - WorldBorderCommand.register(this.dispatcher); - if (JvmProfiler.INSTANCE.isAvailable()) { -@@ -235,20 +234,20 @@ public class Commands { - } - - if (environment.includeDedicated) { -- BanIpCommands.register(this.dispatcher); -- BanListCommands.register(this.dispatcher); -- BanPlayerCommands.register(this.dispatcher); -- DeOpCommands.register(this.dispatcher); -- OpCommand.register(this.dispatcher); -- PardonCommand.register(this.dispatcher); -- PardonIpCommand.register(this.dispatcher); -- PerfCommand.register(this.dispatcher); -+ //BanIpCommands.register(this.dispatcher); -+ //BanListCommands.register(this.dispatcher); -+ //BanPlayerCommands.register(this.dispatcher); -+ //DeOpCommands.register(this.dispatcher); -+ //OpCommand.register(this.dispatcher); -+ //PardonCommand.register(this.dispatcher); -+ //PardonIpCommand.register(this.dispatcher); -+ //PerfCommand.register(this.dispatcher); - SaveAllCommand.register(this.dispatcher); - SaveOffCommand.register(this.dispatcher); - SaveOnCommand.register(this.dispatcher); -- SetPlayerIdleTimeoutCommand.register(this.dispatcher); -+ //SetPlayerIdleTimeoutCommand.register(this.dispatcher); - StopCommand.register(this.dispatcher); -- TransferCommand.register(this.dispatcher); -+ //TransferCommand.register(this.dispatcher); - WhitelistCommand.register(this.dispatcher); - } - -diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java -index c038da20b76c0b7b1c18471b20be01e849d29f3a..f5611bf250aaa2851ca8873291c7f4b6c3771281 100644 ---- a/src/main/java/net/minecraft/server/players/StoredUserList.java -+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java -@@ -9,10 +9,8 @@ import com.google.gson.JsonArray; - import com.google.gson.JsonElement; - import com.google.gson.JsonObject; - import com.mojang.logging.LogUtils; --import java.io.BufferedReader; --import java.io.BufferedWriter; --import java.io.File; --import java.io.IOException; -+ -+import java.io.*; - import java.nio.charset.StandardCharsets; - import java.util.Collection; - import java.util.Iterator; -@@ -114,7 +112,12 @@ public abstract class StoredUserList> { - - Objects.requireNonNull(jsonarray); - stream.forEach(jsonarray::add); -- BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); -+ BufferedWriter bufferedwriter; -+ try { -+ bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8); -+ } catch (FileNotFoundException e) { -+ return; -+ } - - try { - StoredUserList.GSON.toJson(jsonarray, StoredUserList.GSON.newJsonWriter(bufferedwriter)); diff --git a/src/main/java/net/minecraft/util/datafix/fixes/BlockStateData.java b/src/main/java/net/minecraft/util/datafix/fixes/BlockStateData.java index 6b1af6df2427a6c2f7954c89935bf33279d58204..51f32a847c954846fb0c18e802287a26d507ee9f 100644 --- a/src/main/java/net/minecraft/util/datafix/fixes/BlockStateData.java @@ -9992,490 +9777,3 @@ index f06a35024af284addf41dfe160849e8e5e15e822..ca945f615cc9699660809afd0fd96092 } } } -diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java -index 223259e7a09ada681b6181c898f6857888594f85..3f31a3115c69fd976ccb1e396018d94bba0f3557 100644 ---- a/src/main/java/net/minecraft/world/level/block/Blocks.java -+++ b/src/main/java/net/minecraft/world/level/block/Blocks.java -@@ -1,7 +1,9 @@ - package net.minecraft.world.level.block; - -+import java.util.concurrent.ExecutorService; - import java.util.function.Function; - import java.util.function.ToIntFunction; -+import net.minecraft.Util; - import javax.annotation.Nullable; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; -@@ -7797,17 +7799,18 @@ public class Blocks { - } - - public static void rebuildCache() { -- Block.BLOCK_STATE_REGISTRY.forEach(BlockBehaviour.BlockStateBase::initCache); -+ ExecutorService executor = Util.backgroundExecutor(); -+ Block.BLOCK_STATE_REGISTRY.forEach(b -> executor.submit(b::initCache)); - } - - static { - for (Block block : BuiltInRegistries.BLOCK) { - for (BlockState blockState : block.getStateDefinition().getPossibleStates()) { - Block.BLOCK_STATE_REGISTRY.add(blockState); -- blockState.initCache(); -+ //blockState.initCache(); - } - -- block.getLootTable(); -+ //block.getLootTable(); - } - } - } -diff --git a/src/main/java/net/minecraft/world/level/block/WallBlock.java b/src/main/java/net/minecraft/world/level/block/WallBlock.java -index 83956032bef4d34eddb9899f0a2847e66bfd83f4..bea1d8a72d5528335b755aeda6168764778b924f 100644 ---- a/src/main/java/net/minecraft/world/level/block/WallBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/WallBlock.java -@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap; - import com.google.common.collect.ImmutableMap.Builder; - import com.mojang.serialization.MapCodec; - import java.util.Map; -+import java.util.Objects; - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.tags.BlockTags; -@@ -35,8 +36,14 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - public static final EnumProperty SOUTH_WALL = BlockStateProperties.SOUTH_WALL; - public static final EnumProperty WEST_WALL = BlockStateProperties.WEST_WALL; - public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; -- private final Map shapeByIndex; -- private final Map collisionShapeByIndex; -+ private static final Map shapeByIndex; -+ private static final Map collisionShapeByIndex; -+ -+ static { -+ shapeByIndex = makeShapes(4.0F, 3.0F, 16.0F, 0.0F, 14.0F, 16.0F); -+ collisionShapeByIndex = makeShapes(4.0F, 3.0F, 24.0F, 0.0F, 24.0F, 24.0F); -+ } -+ - private static final int WALL_WIDTH = 3; - private static final int WALL_HEIGHT = 14; - private static final int POST_WIDTH = 4; -@@ -66,8 +73,6 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - .setValue(WEST_WALL, WallSide.NONE) - .setValue(WATERLOGGED, Boolean.valueOf(false)) - ); -- this.shapeByIndex = this.makeShapes(4.0F, 3.0F, 16.0F, 0.0F, 14.0F, 16.0F); -- this.collisionShapeByIndex = this.makeShapes(4.0F, 3.0F, 24.0F, 0.0F, 24.0F, 24.0F); - } - - private static VoxelShape applyWallShape(VoxelShape base, WallSide wallShape, VoxelShape tall, VoxelShape low) { -@@ -78,7 +83,7 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - } - } - -- private Map makeShapes(float f, float g, float h, float i, float j, float k) { -+ private static Map makeShapes(float f, float g, float h, float i, float j, float k) { - float l = 8.0F - f; - float m = 8.0F + f; - float n = 8.0F - g; -@@ -92,7 +97,7 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - VoxelShape voxelShape7 = Block.box((double)n, (double)i, (double)n, (double)o, (double)k, 16.0); - VoxelShape voxelShape8 = Block.box(0.0, (double)i, (double)n, (double)o, (double)k, (double)o); - VoxelShape voxelShape9 = Block.box((double)n, (double)i, (double)n, 16.0, (double)k, (double)o); -- Builder builder = ImmutableMap.builder(); -+ Builder builder = ImmutableMap.builder(); - - for (Boolean boolean_ : UP.getPossibleValues()) { - for (WallSide wallSide : EAST_WALL.getPossibleValues()) { -@@ -108,14 +113,8 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - voxelShape10 = Shapes.or(voxelShape10, voxelShape); - } - -- BlockState blockState = this.defaultBlockState() -- .setValue(UP, boolean_) -- .setValue(EAST_WALL, wallSide) -- .setValue(WEST_WALL, wallSide3) -- .setValue(NORTH_WALL, wallSide2) -- .setValue(SOUTH_WALL, wallSide4); -- builder.put(blockState.setValue(WATERLOGGED, Boolean.valueOf(false)), voxelShape10); -- builder.put(blockState.setValue(WATERLOGGED, Boolean.valueOf(true)), voxelShape10); -+ builder.put(hashWallState(wallSide, wallSide2, wallSide4, boolean_, Boolean.FALSE, wallSide3), voxelShape10); -+ builder.put(hashWallState(wallSide, wallSide2, wallSide4, boolean_, Boolean.TRUE , wallSide3), voxelShape10); - } - } - } -@@ -125,14 +124,36 @@ public class WallBlock extends Block implements SimpleWaterloggedBlock { - return builder.build(); - } - -+ private static int mapHashCode(Map, Comparable> values) { -+ return hashWallState( -+ (WallSide) values.get(EAST_WALL), -+ (WallSide) values.get(NORTH_WALL), -+ (WallSide) values.get(SOUTH_WALL), -+ (Boolean) values.get(UP), -+ (Boolean) values.get(WATERLOGGED), -+ (WallSide) values.get(WEST_WALL) -+ ); -+ } -+ -+ private static int hashWallState(WallSide east, WallSide north, WallSide south, boolean up, boolean waterlogged, WallSide west) { -+ int hash = 7; -+ hash = 31 * hash + east.hashCode(); -+ hash = 31 * hash + north.hashCode(); -+ hash = 31 * hash + south.hashCode(); -+ hash = 31 * hash + Objects.hashCode(up); -+ hash = 31 * hash + Objects.hashCode(waterlogged); -+ hash = 31 * hash + west.hashCode(); -+ return hash; -+ } -+ - @Override - protected VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { -- return this.shapeByIndex.get(state); -+ return shapeByIndex.get(mapHashCode(state.getValues())); - } - - @Override - protected VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { -- return this.collisionShapeByIndex.get(state); -+ return collisionShapeByIndex.get(mapHashCode(state.getValues())); - } - - @Override -diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index ded6d148110fe3fbb6272ce44582a28472dd49a6..16fe0554f38665cd652eef8fe693371c5de4542a 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -77,6 +77,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.BlockHitResult; - import net.minecraft.world.phys.Vec3; -+import net.minecraft.world.phys.shapes.BooleanOp; - import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; -@@ -1435,7 +1436,7 @@ public abstract class BlockBehaviour implements FeatureElement { - } - } - -- this.isCollisionShapeFullBlock = Block.isShapeFullBlock(state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO)); -+ this.isCollisionShapeFullBlock = !Shapes.joinIsNotEmpty(Shapes.block(), state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO), BooleanOp.NOT_SAME); //Block.isShapeFullBlock(state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO)); - } - } - -diff --git a/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java b/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java -index 46af72761c0bfbc10c14d78c855255969e2cf8a3..3a449e13951ea183b9ae7910a424b51e841608da 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java -+++ b/src/main/java/net/minecraft/world/level/block/state/StateDefinition.java -@@ -11,10 +11,8 @@ import com.mojang.serialization.Decoder; - import com.mojang.serialization.Encoder; - import com.mojang.serialization.MapCodec; - import it.unimi.dsi.fastutil.objects.Reference2ObjectArrayMap; --import java.util.Collection; --import java.util.Collections; --import java.util.List; --import java.util.Map; -+ -+import java.util.*; - import java.util.Map.Entry; - import java.util.function.Function; - import java.util.function.Supplier; -@@ -22,7 +20,8 @@ import java.util.regex.Pattern; - import java.util.stream.Collectors; - import java.util.stream.Stream; - import javax.annotation.Nullable; --import net.minecraft.world.level.block.state.properties.Property; -+ -+import net.minecraft.world.level.block.state.properties.*; - - public class StateDefinition> { - static final Pattern NAME_PATTERN = Pattern.compile("^[a-z0-9_]+$"); -@@ -41,7 +40,6 @@ public class StateDefinition> { - } - - MapCodec mapCodec2 = mapCodec; -- Map, Comparable>, S> map = Maps.newLinkedHashMap(); - List list = Lists.newArrayList(); - Stream, Comparable>>> stream = Stream.of(Collections.emptyList()); - -@@ -53,6 +51,7 @@ public class StateDefinition> { - })); - } - -+ NeighbourTable table = new NeighbourTable<>(propertiesMap); - stream.forEach(list2 -> { - Reference2ObjectArrayMap, Comparable> reference2ObjectArrayMap = new Reference2ObjectArrayMap<>(list2.size()); - -@@ -61,13 +60,12 @@ public class StateDefinition> { - } - - S stateHolderx = factory.create(owner, reference2ObjectArrayMap, mapCodec2); -- map.put(reference2ObjectArrayMap, stateHolderx); - list.add(stateHolderx); -- }); - -- for (S stateHolder : list) { -- stateHolder.populateNeighbours(map); -- } -+ int index = table.put(reference2ObjectArrayMap, stateHolderx); -+ -+ stateHolderx.populateNeighbours(table, index); -+ }); - - this.states = ImmutableList.copyOf(list); - } -@@ -157,4 +155,60 @@ public class StateDefinition> { - public interface Factory { - S create(O owner, Reference2ObjectArrayMap, Comparable> propertyMap, MapCodec codec); - } -+ -+ public static class NeighbourTable { -+ private final Map, Pair> offsetMasks; -+ private final Object[] array; -+ -+ public NeighbourTable(Map> propertiesMap) { -+ offsetMasks = new IdentityHashMap<>(propertiesMap.size()); -+ int offset = 0; -+ for(Property property : propertiesMap.values()) { -+ int bits = Integer.SIZE - Integer.numberOfLeadingZeros((property instanceof EnumProperty ? property.getValueClass().getEnumConstants().length : property.getPossibleValues().size()) - 1); -+ offsetMasks.put(property, Pair.of(offset, ~(((1<, Comparable> key, S value) { -+ int index = 0; -+ for(Map.Entry, Comparable> k : key.entrySet()) { -+ index = setIndex(index, k.getKey(), k.getValue()); -+ } -+ array[index] = value; -+ return index; -+ } -+ -+ private int setIndex(int index, Property property, Comparable value) { -+ Pair offsetMask = offsetMasks.get(property); -+ if(property instanceof BooleanProperty) { -+ return index | (((Boolean)value) ? 1 : 0) << offsetMask.getFirst(); -+ } else if(property instanceof EnumProperty) { -+ return index | ((Enum)value).ordinal() << offsetMask.getFirst(); -+ } else if(property instanceof IntegerProperty intProperty) { -+ return index | (((Integer)value) - intProperty.min) << offsetMask.getFirst(); -+ } else { -+ throw new IllegalArgumentException("Unknown property type " + property.getClass().getName()); -+ } -+ } -+ -+ public S getNeighbour(int index, Property property, Comparable value) { -+ return (S)array[modIndex(index, property, value)]; -+ } -+ -+ private int modIndex(int index, Property property, Comparable value) { -+ Pair offsetMask = offsetMasks.get(property); -+ if(property instanceof BooleanProperty) { -+ return (index & offsetMask.getSecond()) | (((Boolean)value) ? 1 : 0) << offsetMask.getFirst(); -+ } else if(property instanceof EnumProperty) { -+ return (index & offsetMask.getSecond()) | ((Enum)value).ordinal() << offsetMask.getFirst(); -+ } else if(property instanceof IntegerProperty intProperty) { -+ return (index & offsetMask.getSecond()) | (((Integer)value) - intProperty.min) << offsetMask.getFirst(); -+ } else { -+ throw new IllegalArgumentException("Unknown property type " + property.getClass().getName()); -+ } -+ } -+ } - } -diff --git a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -index 45744d86e9582a93a0cec26009deea091080fbbe..7e2ecb0457150dedc665f05c6c8ad068c00e3642 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -+++ b/src/main/java/net/minecraft/world/level/block/state/StateHolder.java -@@ -37,15 +37,14 @@ public abstract class StateHolder { - }; - protected final O owner; - private final Reference2ObjectArrayMap, Comparable> values; -- private Table, Comparable, S> neighbours; - protected final MapCodec propertiesCodec; -- protected final io.papermc.paper.util.table.ZeroCollidingReferenceStateTable optimisedTable; // Paper - optimise state lookup -+ private StateDefinition.NeighbourTable neighbourTable; -+ private int neighbourIndex; - - protected StateHolder(O owner, Reference2ObjectArrayMap, Comparable> propertyMap, MapCodec codec) { - this.owner = owner; - this.values = propertyMap; - this.propertiesCodec = codec; -- this.optimisedTable = new io.papermc.paper.util.table.ZeroCollidingReferenceStateTable(this, propertyMap); // Paper - optimise state lookup - } - - public > S cycle(Property property) { -@@ -86,11 +85,11 @@ public abstract class StateHolder { - } - - public > boolean hasProperty(Property property) { -- return this.optimisedTable.get(property) != null; // Paper - optimise state lookup -+ return this.values.containsKey(property); - } - - public > T getValue(Property property) { -- Comparable comparable = this.optimisedTable.get(property); // Paper - optimise state lookup -+ Comparable comparable = this.values.get(property); - if (comparable == null) { - throw new IllegalArgumentException("Cannot get property " + property + " as it does not exist in " + this.owner); - } else { -@@ -99,52 +98,26 @@ public abstract class StateHolder { - } - - public > Optional getOptionalValue(Property property) { -- Comparable comparable = this.optimisedTable.get(property); // Paper - optimise state lookup -+ Comparable comparable = this.values.get(property); - return comparable == null ? Optional.empty() : Optional.of(property.getValueClass().cast(comparable)); - } - - public , V extends T> S setValue(Property property, V value) { -- // Paper start - optimise state lookup -- final S ret = (S)this.optimisedTable.get(property, value); -- if (ret == null) { -- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); -- } -- return ret; -- // Paper end - optimise state lookup -+ return this.neighbourTable.getNeighbour(this.neighbourIndex, property, value); - } - - public , V extends T> S trySetValue(Property property, V value) { - Comparable comparable = this.values.get(property); - if (comparable != null && !comparable.equals(value)) { -- S object = this.neighbours.get(property, value); -- if (object == null) { -- throw new IllegalArgumentException("Cannot set property " + property + " to " + value + " on " + this.owner + ", it is not an allowed value"); -- } else { -- return object; -- } -+ return this.neighbourTable.getNeighbour(this.neighbourIndex, property, value); - } else { - return (S)this; - } - } - -- public void populateNeighbours(Map, Comparable>, S> states) { -- if (this.neighbours != null) { -- throw new IllegalStateException(); -- } else { -- Table, Comparable, S> table = HashBasedTable.create(); -- -- for (Entry, Comparable> entry : this.values.entrySet()) { -- Property property = entry.getKey(); -- -- for (Comparable comparable : property.getPossibleValues()) { -- if (!comparable.equals(entry.getValue())) { -- table.put(property, comparable, states.get(this.makeNeighbourValues(property, comparable))); -- } -- } -- } -- -- this.neighbours = (Table, Comparable, S>)(table.isEmpty() ? table : ArrayTable.create(table)); this.optimisedTable.loadInTable((Table)this.neighbours, this.values); // Paper - optimise state lookup -- } -+ public void populateNeighbours(StateDefinition.NeighbourTable states, int ownIndex) { -+ this.neighbourTable = states; -+ this.neighbourIndex = ownIndex; - } - - private Map, Comparable> makeNeighbourValues(Property property, Comparable value) { -diff --git a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -index 427ee4d6f12a7abd8da0c65e0b9081b25824df40..4c2ad01150972940688cb8301fc84a210844c48f 100644 ---- a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -+++ b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java -@@ -507,7 +507,6 @@ public class LevelStorageSource { - - public class LevelStorageAccess implements AutoCloseable { - -- final DirectoryLock lock; - public final LevelStorageSource.LevelDirectory levelDirectory; - private final String levelId; - private final Map resources = Maps.newHashMap(); -@@ -519,7 +518,6 @@ public class LevelStorageSource { - // CraftBukkit end - this.levelId = s; - this.levelDirectory = new LevelStorageSource.LevelDirectory(path); -- this.lock = DirectoryLock.create(path); - } - - public long estimateDiskSpace() { -@@ -568,9 +566,7 @@ public class LevelStorageSource { - } - - private void checkLock() { -- if (!this.lock.isValid()) { -- throw new IllegalStateException("Lock is no longer valid"); -- } -+ //nope - } - - public PlayerDataStorage createPlayerStorage() { -@@ -626,7 +622,7 @@ public class LevelStorageSource { - } - - public Optional getIconFile() { -- return !this.lock.isValid() ? Optional.empty() : Optional.of(this.levelDirectory.iconFile()); -+ return Optional.of(this.levelDirectory.iconFile()); - } - - public void deleteLevel() throws IOException { -@@ -655,7 +651,6 @@ public class LevelStorageSource { - throw ioexception; - } else { - if (path1.equals(LevelStorageAccess.this.levelDirectory.path())) { -- LevelStorageAccess.this.lock.close(); - Files.deleteIfExists(path); - } - -@@ -757,7 +752,7 @@ public class LevelStorageSource { - } - - public void close() throws IOException { -- this.lock.close(); -+ //ignored - } - - public boolean restoreLevelDataFromOld() { -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c8b82bc41f2042bb4b067f06265a3a22e51f7629..e7f63e2f9271b05748db152be43ce9dfad6ff3a5 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -502,7 +502,7 @@ public final class CraftServer implements Server { - try { - this.configuration.save(this.getConfigFile()); - } catch (IOException ex) { -- Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getConfigFile(), ex); -+ //Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getConfigFile(), ex); - } - } - -@@ -510,7 +510,7 @@ public final class CraftServer implements Server { - try { - this.commandsConfiguration.save(this.getCommandsConfigFile()); - } catch (IOException ex) { -- Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getCommandsConfigFile(), ex); -+ //Logger.getLogger(CraftServer.class.getName()).log(Level.SEVERE, "Could not save " + this.getCommandsConfigFile(), ex); - } - } - -@@ -600,7 +600,7 @@ public final class CraftServer implements Server { - DefaultPermissions.registerCorePermissions(); - CraftDefaultPermissions.registerCorePermissions(); - if (!io.papermc.paper.configuration.GlobalConfiguration.get().misc.loadPermissionsYmlBeforePlugins) this.loadCustomPermissions(); // Paper -- this.helpMap.initializeCommands(); -+ //this.helpMap.initializeCommands(); - this.syncCommands(); - } - } -diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 4dbb109d0526afee99b9190fc256585121aac9b5..3e819b143f62506d733ca88f585ba016c6765045 100644 ---- a/src/main/java/org/spigotmc/SpigotConfig.java -+++ b/src/main/java/org/spigotmc/SpigotConfig.java -@@ -126,7 +126,7 @@ public class SpigotConfig - SpigotConfig.config.save( SpigotConfig.CONFIG_FILE ); - } catch ( IOException ex ) - { -- Bukkit.getLogger().log( Level.SEVERE, "Could not save " + SpigotConfig.CONFIG_FILE, ex ); -+ //Bukkit.getLogger().log( Level.SEVERE, "Could not save " + SpigotConfig.CONFIG_FILE, ex ); - } - } - diff --git a/patches/server/1052-SW-Disable-Commands.patch b/patches/server/1052-SW-Disable-Commands.patch new file mode 100644 index 0000000000..fc2151f6bf --- /dev/null +++ b/patches/server/1052-SW-Disable-Commands.patch @@ -0,0 +1,150 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:46:11 +0200 +Subject: [PATCH] SW Disable Commands + + +diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java +index 1d1e76de60e40224f5cb81893f9ee50fe987badb..c2367bcc8dafb71877259dfb46accb42a743d0ee 100644 +--- a/src/main/java/net/minecraft/commands/Commands.java ++++ b/src/main/java/net/minecraft/commands/Commands.java +@@ -156,65 +156,64 @@ public class Commands { + + public Commands(Commands.CommandSelection environment, CommandBuildContext commandRegistryAccess) { + // Paper +- AdvancementCommands.register(this.dispatcher); +- AttributeCommand.register(this.dispatcher, commandRegistryAccess); +- ExecuteCommand.register(this.dispatcher, commandRegistryAccess); +- BossBarCommands.register(this.dispatcher, commandRegistryAccess); ++ //AdvancementCommands.register(this.dispatcher); ++ //AttributeCommand.register(this.dispatcher, commandRegistryAccess); ++ //ExecuteCommand.register(this.dispatcher, commandRegistryAccess); ++ //BossBarCommands.register(this.dispatcher, commandRegistryAccess); + ClearInventoryCommands.register(this.dispatcher, commandRegistryAccess); +- CloneCommands.register(this.dispatcher, commandRegistryAccess); +- DamageCommand.register(this.dispatcher, commandRegistryAccess); +- DataCommands.register(this.dispatcher); +- DataPackCommand.register(this.dispatcher); +- DebugCommand.register(this.dispatcher); +- DefaultGameModeCommands.register(this.dispatcher); +- DifficultyCommand.register(this.dispatcher); ++ //CloneCommands.register(this.dispatcher, commandRegistryAccess); ++ //DamageCommand.register(this.dispatcher, commandRegistryAccess); ++ //DataCommands.register(this.dispatcher); ++ //DataPackCommand.register(this.dispatcher); ++ //DebugCommand.register(this.dispatcher); ++ //DefaultGameModeCommands.register(this.dispatcher); ++ //DifficultyCommand.register(this.dispatcher); + EffectCommands.register(this.dispatcher, commandRegistryAccess); +- EmoteCommands.register(this.dispatcher); ++ //EmoteCommands.register(this.dispatcher); + EnchantCommand.register(this.dispatcher, commandRegistryAccess); +- ExperienceCommand.register(this.dispatcher); +- FillCommand.register(this.dispatcher, commandRegistryAccess); ++ //ExperienceCommand.register(this.dispatcher); ++ //FillCommand.register(this.dispatcher, commandRegistryAccess); + FillBiomeCommand.register(this.dispatcher, commandRegistryAccess); +- ForceLoadCommand.register(this.dispatcher); +- FunctionCommand.register(this.dispatcher); ++ //ForceLoadCommand.register(this.dispatcher); ++ //FunctionCommand.register(this.dispatcher); + GameModeCommand.register(this.dispatcher); + GameRuleCommand.register(this.dispatcher); + GiveCommand.register(this.dispatcher, commandRegistryAccess); +- HelpCommand.register(this.dispatcher); +- ItemCommands.register(this.dispatcher, commandRegistryAccess); ++ //HelpCommand.register(this.dispatcher); ++ //ItemCommands.register(this.dispatcher, commandRegistryAccess); + KickCommand.register(this.dispatcher); + KillCommand.register(this.dispatcher); +- ListPlayersCommand.register(this.dispatcher); +- LocateCommand.register(this.dispatcher, commandRegistryAccess); +- LootCommand.register(this.dispatcher, commandRegistryAccess); +- MsgCommand.register(this.dispatcher); +- ParticleCommand.register(this.dispatcher, commandRegistryAccess); +- PlaceCommand.register(this.dispatcher); +- PlaySoundCommand.register(this.dispatcher); +- RandomCommand.register(this.dispatcher); +- ReloadCommand.register(this.dispatcher); +- RecipeCommand.register(this.dispatcher); +- ReturnCommand.register(this.dispatcher); +- RideCommand.register(this.dispatcher); +- SayCommand.register(this.dispatcher); +- ScheduleCommand.register(this.dispatcher); +- ScoreboardCommand.register(this.dispatcher, commandRegistryAccess); +- SeedCommand.register(this.dispatcher, environment != Commands.CommandSelection.INTEGRATED); +- SetBlockCommand.register(this.dispatcher, commandRegistryAccess); +- SetSpawnCommand.register(this.dispatcher); ++ //ListPlayersCommand.register(this.dispatcher); ++ //LocateCommand.register(this.dispatcher, commandRegistryAccess); ++ //LootCommand.register(this.dispatcher, commandRegistryAccess); ++ //MsgCommand.register(this.dispatcher); ++ //ParticleCommand.register(this.dispatcher, commandRegistryAccess); ++ //PlaceCommand.register(this.dispatcher); ++ //PlaySoundCommand.register(this.dispatcher); ++ //ReloadCommand.register(this.dispatcher); ++ //RecipeCommand.register(this.dispatcher); ++ //ReturnCommand.register(this.dispatcher); ++ //RideCommand.register(this.dispatcher); ++ //SayCommand.register(this.dispatcher); ++ //ScheduleCommand.register(this.dispatcher); ++ //ScoreboardCommand.register(this.dispatcher); ++ //SeedCommand.register(this.dispatcher, environment != Commands.CommandSelection.INTEGRATED); ++ //SetBlockCommand.register(this.dispatcher, commandRegistryAccess); ++ //SetSpawnCommand.register(this.dispatcher); + SetWorldSpawnCommand.register(this.dispatcher); + SpectateCommand.register(this.dispatcher); +- SpreadPlayersCommand.register(this.dispatcher); +- StopSoundCommand.register(this.dispatcher); ++ //SpreadPlayersCommand.register(this.dispatcher); ++ //StopSoundCommand.register(this.dispatcher); + SummonCommand.register(this.dispatcher, commandRegistryAccess); +- TagCommand.register(this.dispatcher); +- TeamCommand.register(this.dispatcher, commandRegistryAccess); +- TeamMsgCommand.register(this.dispatcher); ++ //TagCommand.register(this.dispatcher); ++ //TeamCommand.register(this.dispatcher, commandRegistryAccess); ++ //TeamMsgCommand.register(this.dispatcher); + TeleportCommand.register(this.dispatcher); +- TellRawCommand.register(this.dispatcher, commandRegistryAccess); ++ //TellRawCommand.register(this.dispatcher, commandRegistryAccess); + TickCommand.register(this.dispatcher); + TimeCommand.register(this.dispatcher); +- TitleCommand.register(this.dispatcher, commandRegistryAccess); +- TriggerCommand.register(this.dispatcher); ++ //TitleCommand.register(this.dispatcher, commandRegistryAccess); ++ //TriggerCommand.register(this.dispatcher); + WeatherCommand.register(this.dispatcher); + WorldBorderCommand.register(this.dispatcher); + if (JvmProfiler.INSTANCE.isAvailable()) { +@@ -235,20 +234,20 @@ public class Commands { + } + + if (environment.includeDedicated) { +- BanIpCommands.register(this.dispatcher); +- BanListCommands.register(this.dispatcher); +- BanPlayerCommands.register(this.dispatcher); +- DeOpCommands.register(this.dispatcher); +- OpCommand.register(this.dispatcher); +- PardonCommand.register(this.dispatcher); +- PardonIpCommand.register(this.dispatcher); +- PerfCommand.register(this.dispatcher); ++ //BanIpCommands.register(this.dispatcher); ++ //BanListCommands.register(this.dispatcher); ++ //BanPlayerCommands.register(this.dispatcher); ++ //DeOpCommands.register(this.dispatcher); ++ //OpCommand.register(this.dispatcher); ++ //PardonCommand.register(this.dispatcher); ++ //PardonIpCommand.register(this.dispatcher); ++ //PerfCommand.register(this.dispatcher); + SaveAllCommand.register(this.dispatcher); + SaveOffCommand.register(this.dispatcher); + SaveOnCommand.register(this.dispatcher); +- SetPlayerIdleTimeoutCommand.register(this.dispatcher); ++ //SetPlayerIdleTimeoutCommand.register(this.dispatcher); + StopCommand.register(this.dispatcher); +- TransferCommand.register(this.dispatcher); ++ //TransferCommand.register(this.dispatcher); + WhitelistCommand.register(this.dispatcher); + } + diff --git a/patches/server/1053-SW-Some-Util-Stuff.patch b/patches/server/1053-SW-Some-Util-Stuff.patch new file mode 100644 index 0000000000..bad1fc109e --- /dev/null +++ b/patches/server/1053-SW-Some-Util-Stuff.patch @@ -0,0 +1,84 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Chaoscaot +Date: Tue, 13 Aug 2024 11:46:27 +0200 +Subject: [PATCH] SW Some Util Stuff + + +diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +index ded6d148110fe3fbb6272ce44582a28472dd49a6..16fe0554f38665cd652eef8fe693371c5de4542a 100644 +--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java ++++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +@@ -77,6 +77,7 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams; + import net.minecraft.world.phys.AABB; + import net.minecraft.world.phys.BlockHitResult; + import net.minecraft.world.phys.Vec3; ++import net.minecraft.world.phys.shapes.BooleanOp; + import net.minecraft.world.phys.shapes.CollisionContext; + import net.minecraft.world.phys.shapes.Shapes; + import net.minecraft.world.phys.shapes.VoxelShape; +@@ -1435,7 +1436,7 @@ public abstract class BlockBehaviour implements FeatureElement { + } + } + +- this.isCollisionShapeFullBlock = Block.isShapeFullBlock(state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO)); ++ this.isCollisionShapeFullBlock = !Shapes.joinIsNotEmpty(Shapes.block(), state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO), BooleanOp.NOT_SAME); //Block.isShapeFullBlock(state.getCollisionShape(EmptyBlockGetter.INSTANCE, BlockPos.ZERO)); + } + } + +diff --git a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java +index 427ee4d6f12a7abd8da0c65e0b9081b25824df40..4c2ad01150972940688cb8301fc84a210844c48f 100644 +--- a/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java ++++ b/src/main/java/net/minecraft/world/level/storage/LevelStorageSource.java +@@ -507,7 +507,6 @@ public class LevelStorageSource { + + public class LevelStorageAccess implements AutoCloseable { + +- final DirectoryLock lock; + public final LevelStorageSource.LevelDirectory levelDirectory; + private final String levelId; + private final Map resources = Maps.newHashMap(); +@@ -519,7 +518,6 @@ public class LevelStorageSource { + // CraftBukkit end + this.levelId = s; + this.levelDirectory = new LevelStorageSource.LevelDirectory(path); +- this.lock = DirectoryLock.create(path); + } + + public long estimateDiskSpace() { +@@ -568,9 +566,7 @@ public class LevelStorageSource { + } + + private void checkLock() { +- if (!this.lock.isValid()) { +- throw new IllegalStateException("Lock is no longer valid"); +- } ++ //nope + } + + public PlayerDataStorage createPlayerStorage() { +@@ -626,7 +622,7 @@ public class LevelStorageSource { + } + + public Optional getIconFile() { +- return !this.lock.isValid() ? Optional.empty() : Optional.of(this.levelDirectory.iconFile()); ++ return Optional.of(this.levelDirectory.iconFile()); + } + + public void deleteLevel() throws IOException { +@@ -655,7 +651,6 @@ public class LevelStorageSource { + throw ioexception; + } else { + if (path1.equals(LevelStorageAccess.this.levelDirectory.path())) { +- LevelStorageAccess.this.lock.close(); + Files.deleteIfExists(path); + } + +@@ -757,7 +752,7 @@ public class LevelStorageSource { + } + + public void close() throws IOException { +- this.lock.close(); ++ //ignored + } + + public boolean restoreLevelDataFromOld() {