mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-27 07:05:39 +00:00
Fix ASWM server patch
This commit is contained in:
parent
c9e9ae9573
commit
e0f91f7178
@ -1,36 +1,9 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
|
||||
Date: Mon, 26 Dec 2022 11:25:35 -0500
|
||||
From: Telesphoreo <me@telesphoreo.me>
|
||||
Date: Thu, 19 Oct 2023 00:00:51 -0500
|
||||
Subject: [PATCH] AdvancedSlimePaper Server Changes
|
||||
|
||||
AdvancedSlimePaper
|
||||
Copyright (C) 2023 InfernalSuite
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/build.gradle.kts b/build.gradle.kts
|
||||
index fb98936bb8a5488db75d676c5bcb4060597fbbf8..2143180a92ec6d0c0eba5559dd5497291348fdfa 100644
|
||||
--- a/build.gradle.kts
|
||||
+++ b/build.gradle.kts
|
||||
@@ -13,6 +13,7 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) {
|
||||
val alsoShade: Configuration by configurations.creating
|
||||
|
||||
dependencies {
|
||||
+ implementation(project(":aswm-core"))
|
||||
implementation(project(":paper-api"))
|
||||
implementation(project(":paper-mojangapi"))
|
||||
// Paper start
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/Converter.java b/src/main/java/com/infernalsuite/aswm/Converter.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..7d1753c0b7e89bbf0c245a0231b62773eca2779e
|
||||
@ -193,7 +166,7 @@ index 0000000000000000000000000000000000000000..61518ab2b68e7a41500f3c8c8a5ec123
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/SimpleDataFixerConverter.java b/src/main/java/com/infernalsuite/aswm/SimpleDataFixerConverter.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..1affe4c94b490a05184deccc9eb80530f67fd5ea
|
||||
index 0000000000000000000000000000000000000000..7dcfe5e080f567ab7d0cd6d0c47a6aaa4daae55f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/SimpleDataFixerConverter.java
|
||||
@@ -0,0 +1,101 @@
|
||||
@ -203,13 +176,13 @@ index 0000000000000000000000000000000000000000..1affe4c94b490a05184deccc9eb80530
|
||||
+import ca.spottedleaf.dataconverter.minecraft.walkers.generic.WalkerUtils;
|
||||
+import ca.spottedleaf.dataconverter.types.nbt.NBTMapType;
|
||||
+import com.flowpowered.nbt.CompoundTag;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunkSection;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||
+import com.infernalsuite.aswm.serialization.SlimeWorldReader;
|
||||
+import com.infernalsuite.aswm.skeleton.SkeletonSlimeWorld;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSectionSkeleton;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSkeleton;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunkSection;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||
+import net.minecraft.SharedConstants;
|
||||
+
|
||||
+import java.util.ArrayList;
|
||||
@ -248,11 +221,11 @@ index 0000000000000000000000000000000000000000..1affe4c94b490a05184deccc9eb80530
|
||||
+ for (int i = 0; i < sections.length; i++) {
|
||||
+ SlimeChunkSection dataSection = chunk.getSections()[i];
|
||||
+
|
||||
+ com.flowpowered.nbt.CompoundTag blockStateTag = blockStateTag = convertAndBack(dataSection.getBlockStatesTag(), (tag) -> {
|
||||
+ CompoundTag blockStateTag = blockStateTag = convertAndBack(dataSection.getBlockStatesTag(), (tag) -> {
|
||||
+ WalkerUtils.convertList(MCTypeRegistry.BLOCK_STATE, new NBTMapType(tag), "palette", currentVersion, newVersion);
|
||||
+ });
|
||||
+
|
||||
+ com.flowpowered.nbt.CompoundTag biomeTag = convertAndBack(dataSection.getBiomeTag(), (tag) -> {
|
||||
+ CompoundTag biomeTag = convertAndBack(dataSection.getBiomeTag(), (tag) -> {
|
||||
+ WalkerUtils.convertList(MCTypeRegistry.BIOME, new NBTMapType(tag), "palette", currentVersion, newVersion);
|
||||
+ });
|
||||
+
|
||||
@ -287,7 +260,7 @@ index 0000000000000000000000000000000000000000..1affe4c94b490a05184deccc9eb80530
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ private static com.flowpowered.nbt.CompoundTag convertAndBack(com.flowpowered.nbt.CompoundTag value, Consumer<net.minecraft.nbt.CompoundTag> acceptor) {
|
||||
+ private static CompoundTag convertAndBack(CompoundTag value, Consumer<net.minecraft.nbt.CompoundTag> acceptor) {
|
||||
+ if (value == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
@ -295,16 +268,15 @@ index 0000000000000000000000000000000000000000..1affe4c94b490a05184deccc9eb80530
|
||||
+ net.minecraft.nbt.CompoundTag converted = (net.minecraft.nbt.CompoundTag) Converter.convertTag(value);
|
||||
+ acceptor.accept(converted);
|
||||
+
|
||||
+ return (com.flowpowered.nbt.CompoundTag) Converter.convertTag(value.getName(), converted);
|
||||
+ return (CompoundTag) Converter.convertTag(value.getName(), converted);
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/SlimeNMSBridgeImpl.java b/src/main/java/com/infernalsuite/aswm/SlimeNMSBridgeImpl.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..20f16757ba8b8da525ff17d51d4f7eb660c4d22b
|
||||
index 0000000000000000000000000000000000000000..d014c27b896ea862bb3f7ff7d39df476513bb5f8
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/SlimeNMSBridgeImpl.java
|
||||
@@ -0,0 +1,206 @@
|
||||
@@ -0,0 +1,205 @@
|
||||
+package com.infernalsuite.aswm;
|
||||
+
|
||||
+import com.infernalsuite.aswm.api.SlimeNMSBridge;
|
||||
@ -315,7 +287,6 @@ index 0000000000000000000000000000000000000000..20f16757ba8b8da525ff17d51d4f7eb6
|
||||
+import com.infernalsuite.aswm.level.SlimeInMemoryWorld;
|
||||
+import com.infernalsuite.aswm.level.SlimeLevelInstance;
|
||||
+import com.mojang.serialization.Lifecycle;
|
||||
+import net.kyori.adventure.util.Services;
|
||||
+import net.minecraft.SharedConstants;
|
||||
+import net.minecraft.core.registries.Registries;
|
||||
+import net.minecraft.resources.ResourceKey;
|
||||
@ -511,19 +482,17 @@ index 0000000000000000000000000000000000000000..20f16757ba8b8da525ff17d51d4f7eb6
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/ChunkDataLoadTask.java b/src/main/java/com/infernalsuite/aswm/level/ChunkDataLoadTask.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..41e652b568598926e838e81fdc338e51f8e97ef8
|
||||
index 0000000000000000000000000000000000000000..66093eaed9a45c7b714471915c8bd38f23ac7894
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/level/ChunkDataLoadTask.java
|
||||
@@ -0,0 +1,121 @@
|
||||
@@ -0,0 +1,113 @@
|
||||
+package com.infernalsuite.aswm.level;
|
||||
+
|
||||
+import ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import io.papermc.paper.chunk.system.poi.PoiChunk;
|
||||
+import io.papermc.paper.chunk.system.scheduling.ChunkLoadTask;
|
||||
+import io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler;
|
||||
+import io.papermc.paper.chunk.system.scheduling.GenericDataLoadTask;
|
||||
@ -583,13 +552,6 @@ index 0000000000000000000000000000000000000000..41e652b568598926e838e81fdc338e51
|
||||
+ }
|
||||
+
|
||||
+ protected ChunkAccess runOnMain(final SlimeChunk data) {
|
||||
+ final PoiChunk poiChunk = this.chunkLoadTask.chunkHolder.getPoiChunk();
|
||||
+ if (poiChunk == null) {
|
||||
+ LOGGER.error("Expected poi chunk to be loaded with chunk for task " + this.toString());
|
||||
+ } else {
|
||||
+ poiChunk.load();
|
||||
+ }
|
||||
+
|
||||
+ // have tasks to run (at this point, it's just the POI consistency checking)
|
||||
+ try {
|
||||
+ // if (data.tasks != null) {
|
||||
@ -639,7 +601,6 @@ index 0000000000000000000000000000000000000000..41e652b568598926e838e81fdc338e51
|
||||
+ return true;
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/CommonLoadTask.java b/src/main/java/com/infernalsuite/aswm/level/CommonLoadTask.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fc6e46972bcc77134ed718c8c157ec3893d4bcdf
|
||||
@ -733,7 +694,7 @@ index 0000000000000000000000000000000000000000..c0e47f25e9be33da374dc737c96d8d3c
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/NMSSlimeChunk.java b/src/main/java/com/infernalsuite/aswm/level/NMSSlimeChunk.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..f1db2fe121bb3aabfad727a8133b645524b8f19a
|
||||
index 0000000000000000000000000000000000000000..c94ee5460d3859d373ae81e9d3623db071d6c38b
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/level/NMSSlimeChunk.java
|
||||
@@ -0,0 +1,203 @@
|
||||
@ -744,10 +705,10 @@ index 0000000000000000000000000000000000000000..f1db2fe121bb3aabfad727a8133b6455
|
||||
+import com.flowpowered.nbt.LongArrayTag;
|
||||
+import com.google.common.collect.Lists;
|
||||
+import com.infernalsuite.aswm.Converter;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSectionSkeleton;
|
||||
+import com.infernalsuite.aswm.api.utils.NibbleArray;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunkSection;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSectionSkeleton;
|
||||
+import com.mojang.logging.LogUtils;
|
||||
+import com.mojang.serialization.Codec;
|
||||
+import io.papermc.paper.world.ChunkEntitySlices;
|
||||
@ -940,7 +901,6 @@ index 0000000000000000000000000000000000000000..f1db2fe121bb3aabfad727a8133b6455
|
||||
+ }
|
||||
+
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/NMSSlimeWorld.java b/src/main/java/com/infernalsuite/aswm/level/NMSSlimeWorld.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9a27369c00345bbb94aa19f77687269dc94c0b0a
|
||||
@ -1351,24 +1311,24 @@ index 0000000000000000000000000000000000000000..b159fc8751e9840b311cc1eda01e496e
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java b/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..fd4cfb9cceb4f23265cb3cce7f1f251051bfba92
|
||||
index 0000000000000000000000000000000000000000..043de6fba8387ce851d1d54c501cd834a1760c60
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/level/SlimeInMemoryWorld.java
|
||||
@@ -0,0 +1,251 @@
|
||||
@@ -0,0 +1,247 @@
|
||||
+package com.infernalsuite.aswm.level;
|
||||
+
|
||||
+import com.flowpowered.nbt.CompoundTag;
|
||||
+import com.infernalsuite.aswm.ChunkPos;
|
||||
+import com.infernalsuite.aswm.api.exceptions.WorldAlreadyExistsException;
|
||||
+import com.infernalsuite.aswm.api.loaders.SlimeLoader;
|
||||
+import com.infernalsuite.aswm.serialization.slime.SlimeSerializer;
|
||||
+import com.infernalsuite.aswm.skeleton.SkeletonCloning;
|
||||
+import com.infernalsuite.aswm.skeleton.SkeletonSlimeWorld;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSkeleton;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorldInstance;
|
||||
+import com.infernalsuite.aswm.api.world.properties.SlimePropertyMap;
|
||||
+import com.infernalsuite.aswm.serialization.slime.SlimeSerializer;
|
||||
+import com.infernalsuite.aswm.skeleton.SkeletonCloning;
|
||||
+import com.infernalsuite.aswm.skeleton.SkeletonSlimeWorld;
|
||||
+import com.infernalsuite.aswm.skeleton.SlimeChunkSkeleton;
|
||||
+import net.minecraft.world.level.block.Block;
|
||||
+import net.minecraft.world.level.chunk.LevelChunk;
|
||||
+import net.minecraft.world.level.chunk.UpgradeData;
|
||||
@ -1377,11 +1337,7 @@ index 0000000000000000000000000000000000000000..fd4cfb9cceb4f23265cb3cce7f1f2510
|
||||
+import org.bukkit.World;
|
||||
+
|
||||
+import java.io.IOException;
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Collection;
|
||||
+import java.util.HashMap;
|
||||
+import java.util.List;
|
||||
+import java.util.Map;
|
||||
+import java.util.*;
|
||||
+
|
||||
+/*
|
||||
+The concept of this is a bit flawed, since ideally this should be a 1:1 representation of the MC world.
|
||||
@ -1654,7 +1610,7 @@ index 0000000000000000000000000000000000000000..4f48b7a1a41aabc78cc9276fbf9f372c
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java b/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaafcb79e175
|
||||
index 0000000000000000000000000000000000000000..10fde8e966dd89b8371c764f0c6fc08a0e28ac44
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/infernalsuite/aswm/level/SlimeLevelInstance.java
|
||||
@@ -0,0 +1,195 @@
|
||||
@ -1663,12 +1619,12 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+import ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor;
|
||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
+import com.infernalsuite.aswm.Converter;
|
||||
+import com.infernalsuite.aswm.serialization.slime.SlimeSerializer;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeChunk;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorld;
|
||||
+import com.infernalsuite.aswm.api.world.SlimeWorldInstance;
|
||||
+import com.infernalsuite.aswm.api.world.properties.SlimeProperties;
|
||||
+import com.infernalsuite.aswm.api.world.properties.SlimePropertyMap;
|
||||
+import com.infernalsuite.aswm.serialization.slime.SlimeSerializer;
|
||||
+import io.papermc.paper.chunk.system.scheduling.ChunkLoadTask;
|
||||
+import io.papermc.paper.chunk.system.scheduling.ChunkTaskScheduler;
|
||||
+import io.papermc.paper.chunk.system.scheduling.GenericDataLoadTask;
|
||||
@ -1685,6 +1641,7 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+import net.minecraft.util.datafix.DataFixers;
|
||||
+import net.minecraft.world.Difficulty;
|
||||
+import net.minecraft.world.entity.EntityType;
|
||||
+import net.minecraft.world.level.ChunkPos;
|
||||
+import net.minecraft.world.level.biome.Biome;
|
||||
+import net.minecraft.world.level.chunk.ChunkAccess;
|
||||
+import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||
@ -1692,7 +1649,6 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+import net.minecraft.world.level.storage.LevelStorageSource;
|
||||
+import net.minecraft.world.level.storage.PrimaryLevelData;
|
||||
+import net.minecraft.world.level.validation.DirectoryValidator;
|
||||
+import net.minecraft.world.level.validation.PathAllowList;
|
||||
+import org.apache.commons.io.FileUtils;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.event.world.WorldSaveEvent;
|
||||
@ -1745,7 +1701,7 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+ super(slimeBootstrap, MinecraftServer.getServer(), MinecraftServer.getServer().executor,
|
||||
+ CUSTOM_LEVEL_STORAGE.createAccess(slimeBootstrap.initial().getName() + UUID.randomUUID(), dimensionKey),
|
||||
+ primaryLevelData, worldKey, worldDimension,
|
||||
+ MinecraftServer.getServer().progressListenerFactory.create(11), false, 0,
|
||||
+ MinecraftServer.getServer().progressListenerFactory.create(11), false, null, 0,
|
||||
+ Collections.emptyList(), true, environment, null, null);
|
||||
+ this.slimeInstance = new SlimeInMemoryWorld(slimeBootstrap, this);
|
||||
+
|
||||
@ -1843,7 +1799,7 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+ .map((tag) -> (net.minecraft.nbt.CompoundTag) Converter.convertTag(tag))
|
||||
+ .collect(Collectors.toList()), this)
|
||||
+ .toList()
|
||||
+ ));
|
||||
+ ), new ChunkPos(chunkX, chunkZ));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
@ -1853,7 +1809,6 @@ index 0000000000000000000000000000000000000000..2d18d76829b6dc590913d974d50dbaaf
|
||||
+ // super.unload(chunk);
|
||||
+ // }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/com/infernalsuite/aswm/util/NmsUtil.java b/src/main/java/com/infernalsuite/aswm/util/NmsUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3500005bb09dc484bc333f1e0799613d097a37d3
|
||||
@ -1870,259 +1825,3 @@ index 0000000000000000000000000000000000000000..3500005bb09dc484bc333f1e0799613d
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||
index abd0217cf0bff183c8e262edc173a53403797c1a..ab450a0ffbfd914c33323d740b3c382a96cb0e8f 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkHolderManager.java
|
||||
@@ -165,7 +165,8 @@ public final class ChunkHolderManager {
|
||||
return this.chunkHolders.size();
|
||||
}
|
||||
|
||||
- public void close(final boolean save, final boolean halt) {
|
||||
+ public void close(boolean save, final boolean halt) { // ASWM
|
||||
+ if (this.world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance) save = false; // ASWM
|
||||
TickThread.ensureTickThread("Closing world off-main");
|
||||
if (halt) {
|
||||
LOGGER.info("Waiting 60s for chunk system to halt for world '" + this.world.getWorld().getName() + "'");
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||
index e7fb084ddb88ab62f1d493a999cc82b9258d275e..7e5b9c4033e81d5c348ff9eb110b8c9cd1b3aeeb 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
|
||||
@@ -6,6 +6,7 @@ import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock;
|
||||
import ca.spottedleaf.concurrentutil.util.ConcurrentUtil;
|
||||
import ca.spottedleaf.dataconverter.minecraft.MCDataConverter;
|
||||
import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
|
||||
+import com.infernalsuite.aswm.level.CommonLoadTask; // ASWM
|
||||
import com.mojang.logging.LogUtils;
|
||||
import io.papermc.paper.chunk.system.io.RegionFileIOThread;
|
||||
import io.papermc.paper.chunk.system.poi.PoiChunk;
|
||||
@@ -32,8 +33,8 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
||||
|
||||
private static final Logger LOGGER = LogUtils.getClassLogger();
|
||||
|
||||
- private final NewChunkHolder chunkHolder;
|
||||
- private final ChunkDataLoadTask loadTask;
|
||||
+ public final NewChunkHolder chunkHolder; // ASWM - public -> private
|
||||
+ private final CommonLoadTask loadTask; // ASWM
|
||||
|
||||
private volatile boolean cancelled;
|
||||
private NewChunkHolder.GenericDataLoadTaskCallback entityLoadTask;
|
||||
@@ -45,11 +46,20 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
||||
final NewChunkHolder chunkHolder, final PrioritisedExecutor.Priority priority) {
|
||||
super(scheduler, world, chunkX, chunkZ);
|
||||
this.chunkHolder = chunkHolder;
|
||||
- this.loadTask = new ChunkDataLoadTask(scheduler, world, chunkX, chunkZ, priority);
|
||||
- this.loadTask.addCallback((final GenericDataLoadTask.TaskResult<ChunkAccess, Throwable> result) -> {
|
||||
- ChunkLoadTask.this.loadResult = result; // must be before getAndDecrement
|
||||
- ChunkLoadTask.this.tryCompleteLoad();
|
||||
- });
|
||||
+ // ASWM start
|
||||
+ if (world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance levelInstance) {
|
||||
+
|
||||
+ this.loadTask = levelInstance.getLoadTask(this, scheduler, world, chunkX, chunkZ, priority, result -> {
|
||||
+ ChunkLoadTask.this.complete(result == null ? null : result.left(), result == null ? null : result.right());
|
||||
+ });
|
||||
+ } else {
|
||||
+ ChunkDataLoadTask task = new ChunkDataLoadTask(scheduler, world, chunkX, chunkZ, priority);
|
||||
+ task.addCallback((final GenericDataLoadTask.TaskResult<ChunkAccess, Throwable> result) -> {
|
||||
+ ChunkLoadTask.this.complete(result == null ? null : result.left(), result == null ? null : result.right());
|
||||
+ });
|
||||
+ this.loadTask = task;
|
||||
+ }
|
||||
+ // ASWM end
|
||||
}
|
||||
|
||||
private void tryCompleteLoad() {
|
||||
@@ -274,7 +284,7 @@ public final class ChunkLoadTask extends ChunkProgressionTask {
|
||||
}
|
||||
}
|
||||
|
||||
- public static final class ChunkDataLoadTask extends CallbackDataLoadTask<ChunkAccess, ChunkAccess> {
|
||||
+ public static final class ChunkDataLoadTask extends CallbackDataLoadTask<ChunkAccess, ChunkAccess> implements CommonLoadTask { // ASWM
|
||||
protected ChunkDataLoadTask(final ChunkTaskScheduler scheduler, final ServerLevel world, final int chunkX,
|
||||
final int chunkZ, final PrioritisedExecutor.Priority priority) {
|
||||
super(scheduler, world, chunkX, chunkZ, RegionFileIOThread.RegionFileType.CHUNK_DATA, priority);
|
||||
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java
|
||||
index 51304c5cf4b0ac7646693ef97ef4a3847d3342b5..56280c18be01deabc53932c1580dce7b3d83e06f 100644
|
||||
--- a/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java
|
||||
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/NewChunkHolder.java
|
||||
@@ -112,7 +112,10 @@ public final class NewChunkHolder {
|
||||
}
|
||||
|
||||
if (!transientChunk) {
|
||||
- if (entityChunk != null) {
|
||||
+ // ASWM start
|
||||
+ if (this.world instanceof com.infernalsuite.aswm.level.SlimeLevelInstance world) {
|
||||
+ world.loadEntities(this.chunkX, this.chunkZ);
|
||||
+ } else if (entityChunk != null) { // ASWM end
|
||||
final List<Entity> entities = EntityStorage.readEntities(this.world, entityChunk);
|
||||
|
||||
this.world.getEntityLookup().addEntityChunkEntities(entities);
|
||||
diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
index 7e8dc9e8f381abfdcce2746edc93122d623622d1..148db7995f8bb8bef8f1eeeadc338dffab891d57 100644
|
||||
--- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
+++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java
|
||||
@@ -36,7 +36,7 @@ public final class ChunkEntitySlices {
|
||||
protected final EntityCollectionBySection allEntities;
|
||||
protected final EntityCollectionBySection hardCollidingEntities;
|
||||
protected final Reference2ObjectOpenHashMap<Class<? extends Entity>, EntityCollectionBySection> entitiesByClass;
|
||||
- protected final EntityList entities = new EntityList();
|
||||
+ public final EntityList entities = new EntityList(); // ASWM - protected -> public
|
||||
|
||||
public FullChunkStatus status;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 67ee3a4ca8a6cdeb275653d492a1fea8037c51fb..e62ebbb2e69df4a79b87cac542482ca913681b02 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -272,7 +272,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
private final PackRepository packRepository;
|
||||
private final ServerScoreboard scoreboard;
|
||||
@Nullable
|
||||
- private CommandStorage commandStorage;
|
||||
+ public CommandStorage commandStorage; // ASWM - private -> public
|
||||
private final CustomBossEvents customBossEvents;
|
||||
private final ServerFunctionManager functionManager;
|
||||
private final FrameTimer frameTimer;
|
||||
@@ -461,18 +461,21 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
if (dimensionKey == LevelStem.NETHER) {
|
||||
if (this.isNetherEnabled()) {
|
||||
dimension = -1;
|
||||
+ if (com.infernalsuite.aswm.SlimeNMSBridgeImpl.instance().loadNetherOverride()) continue; // ASWM
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (dimensionKey == LevelStem.END) {
|
||||
if (this.server.getAllowEnd()) {
|
||||
dimension = 1;
|
||||
+ if (com.infernalsuite.aswm.SlimeNMSBridgeImpl.instance().loadEndOverride()) continue; // ASWM
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
} else if (dimensionKey != LevelStem.OVERWORLD) {
|
||||
dimension = -999;
|
||||
}
|
||||
+ else if (dimensionKey == LevelStem.OVERWORLD && com.infernalsuite.aswm.SlimeNMSBridgeImpl.instance().loadOverworldOverride()) continue; // ASWM
|
||||
|
||||
String worldType = (dimension == -999) ? dimensionKey.location().getNamespace() + "_" + dimensionKey.location().getPath() : org.bukkit.World.Environment.getEnvironment(dimension).toString().toLowerCase();
|
||||
String name = (dimensionKey == LevelStem.OVERWORLD) ? s : s + "_" + worldType;
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerChunkCache.java b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
index acbcdc8cb1523044b1657e03a141fae6389a3686..84dab69bf6cc279131ab1a3b5eb7a93c4e1e8f15 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -168,7 +168,11 @@ public class ServerChunkCache extends ChunkSource {
|
||||
public final io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet<LevelChunk> entityTickingChunks = new io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet<>(4096, 0.75f, 4096, 0.15, true);
|
||||
// Paper end
|
||||
|
||||
- public ServerChunkCache(ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory) {
|
||||
+ // ASWM start
|
||||
+ public final com.infernalsuite.aswm.level.SlimeBootstrap bootstrap;
|
||||
+ public ServerChunkCache(com.infernalsuite.aswm.level.SlimeBootstrap bootstrap, ServerLevel world, LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, StructureTemplateManager structureTemplateManager, Executor workerExecutor, ChunkGenerator chunkGenerator, int viewDistance, int simulationDistance, boolean dsync, ChunkProgressListener worldGenerationProgressListener, ChunkStatusUpdateListener chunkStatusChangeListener, Supplier<DimensionDataStorage> persistentStateManagerFactory) { // ASWM
|
||||
+ this.bootstrap = bootstrap;
|
||||
+ // ASWM end
|
||||
this.level = world;
|
||||
this.mainThreadProcessor = new ServerChunkCache.MainThreadExecutor(world);
|
||||
this.mainThread = Thread.currentThread();
|
||||
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
index 18aac3da3c88f33b1a71a5920a8daa27e9723913..20099425babf5325005d11bf25faa783e3bc2715 100644
|
||||
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -643,6 +643,14 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
// Add env and gen to constructor, IWorldDataServer -> WorldDataServer
|
||||
public ServerLevel(MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, @Nullable RandomSequences randomsequences, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
+ // ASWM start
|
||||
+ this(null, minecraftserver, executor, convertable_conversionsession, iworlddataserver, resourcekey, worlddimension, worldloadlistener, flag, i, list, flag1, env, gen, biomeProvider);
|
||||
+ }
|
||||
+
|
||||
+ public com.infernalsuite.aswm.level.SlimeInMemoryWorld slimeInstance;
|
||||
+
|
||||
+ public ServerLevel(com.infernalsuite.aswm.level.SlimeBootstrap bootstrap, MinecraftServer minecraftserver, Executor executor, LevelStorageSource.LevelStorageAccess convertable_conversionsession, PrimaryLevelData iworlddataserver, ResourceKey<Level> resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List<CustomSpawner> list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) {
|
||||
+ // ASWM end
|
||||
// IRegistryCustom.Dimension iregistrycustom_dimension = minecraftserver.registryAccess(); // CraftBukkit - decompile error
|
||||
// Holder holder = worlddimension.type(); // CraftBukkit - decompile error
|
||||
|
||||
@@ -681,6 +689,10 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
chunkgenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkgenerator, gen);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ // ASWM start
|
||||
+ ChunkGenerator result = this.getGenerator(bootstrap);
|
||||
+ if (result != null) chunkgenerator = result;
|
||||
+ // ASWM end
|
||||
boolean flag2 = minecraftserver.forceSynchronousWrites();
|
||||
DataFixer datafixer = minecraftserver.getFixerUpper();
|
||||
this.entityStorage = new EntityRegionFileStorage(convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), flag2); // Paper - rewrite chunk system //EntityPersistentStorage<Entity> entitypersistentstorage = new EntityStorage(this, convertable_conversionsession.getDimensionPath(resourcekey).resolve("entities"), datafixer, flag2, minecraftserver);
|
||||
@@ -692,7 +704,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
//PersistentEntitySectionManager persistententitysectionmanager = this.entityManager; // Paper - rewrite chunk system
|
||||
|
||||
//Objects.requireNonNull(this.entityManager); // Paper - rewrite chunk system
|
||||
- this.chunkSource = new ServerChunkCache(this, convertable_conversionsession, datafixer, structuretemplatemanager, executor, chunkgenerator, j, k, flag2, worldloadlistener, null, () -> { // Paper - rewrite chunk system
|
||||
+ this.chunkSource = new ServerChunkCache(bootstrap, this, convertable_conversionsession, datafixer, structuretemplatemanager, executor, chunkgenerator, j, k, flag2, worldloadlistener, null, () -> { // ASWM // Paper - rewrite chunk system
|
||||
return minecraftserver.overworld().getDataStorage();
|
||||
});
|
||||
this.chunkSource.getGeneratorState().ensureStructuresGenerated();
|
||||
@@ -721,7 +733,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
|
||||
this.sleepStatus = new SleepStatus();
|
||||
this.gameEventDispatcher = new GameEventDispatcher(this);
|
||||
- this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(randomsequences, () -> {
|
||||
+ this.randomSequences = (RandomSequences) Objects.requireNonNullElseGet(getRandomSequences(), () -> { // ASWM
|
||||
return (RandomSequences) this.getDataStorage().computeIfAbsent((nbttagcompound) -> {
|
||||
return RandomSequences.load(l, nbttagcompound);
|
||||
}, () -> {
|
||||
@@ -748,6 +760,12 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
||||
this.dragonFight = enderDragonFight;
|
||||
}
|
||||
|
||||
+ // ASWM start
|
||||
+ public ChunkGenerator getGenerator(com.infernalsuite.aswm.level.SlimeBootstrap bootstrap) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // ASWM end
|
||||
+
|
||||
public void setWeatherParameters(int clearDuration, int rainDuration, boolean raining, boolean thundering) {
|
||||
this.serverLevelData.setClearWeatherTime(clearDuration);
|
||||
this.serverLevelData.setRainTime(rainDuration);
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
index 7f5547dc31aa53b2863f4c09f598fa88e7fe2afd..7b28346e8256013d071b265d9e382738bb4b33c8 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java
|
||||
@@ -30,7 +30,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
};
|
||||
public final IdMap<T> registry;
|
||||
private final T @org.jetbrains.annotations.Nullable [] presetValues; // Paper - Anti-Xray - Add preset values
|
||||
- private volatile PalettedContainer.Data<T> data;
|
||||
+ public volatile PalettedContainer.Data<T> data; // ASWM - private -> public
|
||||
private final PalettedContainer.Strategy strategy;
|
||||
// private final ThreadingDetector threadingDetector = new ThreadingDetector("PalettedContainer"); // Paper - unused
|
||||
|
||||
@@ -398,7 +398,7 @@ public class PalettedContainer<T> implements PaletteResize<T>, PalettedContainer
|
||||
void accept(T object, int count);
|
||||
}
|
||||
|
||||
- static record Data<T>(PalettedContainer.Configuration<T> configuration, BitStorage storage, Palette<T> palette) {
|
||||
+ public static record Data<T>(PalettedContainer.Configuration<T> configuration, BitStorage storage, Palette<T> palette) { // ASWM - private -> public
|
||||
public void copyFrom(Palette<T> palette, BitStorage storage) {
|
||||
for(int i = 0; i < storage.getSize(); ++i) {
|
||||
T object = palette.valueFor(storage.get(i));
|
||||
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
index 9c6a2884c34a9f6e775103da42480cd6b8c693b3..8f70e99dc48bd8b0e6ebe7a955b8e3e1a826aabf 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
|
||||
@@ -434,7 +434,7 @@ public class ChunkSerializer {
|
||||
ChunkSerializer.LOGGER.error("Recoverable errors when loading section [" + chunkPos.x + ", " + y + ", " + chunkPos.z + "]: " + message);
|
||||
}
|
||||
|
||||
- private static Codec<PalettedContainerRO<Holder<Biome>>> makeBiomeCodec(Registry<Biome> biomeRegistry) {
|
||||
+ public static Codec<PalettedContainerRO<Holder<Biome>>> makeBiomeCodec(Registry<Biome> biomeRegistry) { // ASWM - private -> public
|
||||
return PalettedContainer.codecRO(biomeRegistry.asHolderIdMap(), biomeRegistry.holderByNameCodec(), PalettedContainer.Strategy.SECTION_BIOMES, biomeRegistry.getHolderOrThrow(Biomes.PLAINS));
|
||||
}
|
||||
|
||||
diff --git a/src/main/resources/META-INF/services/com.infernalsuite.aswm.api.SlimeNMSBridge b/src/main/resources/META-INF/services/com.infernalsuite.aswm.api.SlimeNMSBridge
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..916b4d2edba2f2a8a0fc1fdb6ab6a57e2a16f938
|
||||
--- /dev/null
|
||||
+++ b/src/main/resources/META-INF/services/com.infernalsuite.aswm.api.SlimeNMSBridge
|
||||
@@ -0,0 +1 @@
|
||||
+com.infernalsuite.aswm.SlimeNMSBridgeImpl
|
||||
|
@ -77,7 +77,7 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..bc5ed619e05f24f3ad50a6a81306d120
|
||||
switch (distance) {
|
||||
case -1:
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
index e7746952417a3ca4ea97103e38568db42039f717..e3c230fd2a054a8cb60328c9309410a2f53dad26 100644
|
||||
index e4cacb17f56c618bef19e1165c07aac86af61150..ebec18e919885f9220693a8a419d239e8cddd567 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||
@@ -300,7 +300,7 @@ public class Main {
|
Loading…
Reference in New Issue
Block a user