Update to Minecraft 1.20.5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-04-24 01:15:00 +10:00
parent 4deda9501f
commit 65bc2541a3
524 changed files with 7788 additions and 6181 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/Convertable.java
+++ b/net/minecraft/world/level/storage/Convertable.java
@@ -81,6 +81,10 @@
@@ -77,6 +77,10 @@
import net.minecraft.world.level.validation.PathAllowList;
import org.slf4j.Logger;
@@ -11,7 +11,7 @@
public class Convertable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -151,7 +155,7 @@
@@ -148,7 +152,7 @@
}
public static WorldDataConfiguration readDataConfig(Dynamic<?> dynamic) {
@@ -20,7 +20,7 @@
Logger logger = Convertable.LOGGER;
Objects.requireNonNull(logger);
@@ -174,6 +178,7 @@
@@ -167,6 +171,7 @@
WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry);
Lifecycle lifecycle = worlddimensions_b.lifecycle().add(iregistrycustom_dimension.allRegistriesLifecycle());
WorldDataServer worlddataserver = WorldDataServer.parse(dynamic1, worldsettings, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle);
@@ -28,16 +28,7 @@
return new LevelDataAndDimensions(worlddataserver, worlddimensions_b);
}
@@ -193,7 +198,7 @@
throw new LevelStorageException(IChatBaseComponent.translatable("selectWorld.load_folder_access"));
} else {
try {
- Stream stream = Files.list(this.baseDir);
+ Stream<Path> stream = Files.list(this.baseDir); // CraftBukkit - decompile error
Convertable.a convertable_a;
@@ -423,27 +428,41 @@
@@ -409,27 +414,41 @@
return this.backupDir;
}
@@ -83,21 +74,21 @@
public static record a(List<Convertable.b> levels) implements Iterable<Convertable.b> {
public boolean isEmpty() {
@@ -502,8 +521,12 @@
@@ -488,8 +507,12 @@
public final Convertable.b levelDirectory;
private final String levelId;
private final Map<SavedFile, Path> resources = Maps.newHashMap();
+ // CraftBukkit start
+ public final ResourceKey<WorldDimension> dimensionType;
- ConversionSession(String s, Path path) throws IOException {
+ ConversionSession(String s, Path path, ResourceKey<WorldDimension> dimensionType) throws IOException {
- ConversionSession(final String s, final Path path) throws IOException {
+ ConversionSession(final String s, final Path path, final ResourceKey<WorldDimension> dimensionType) throws IOException {
+ this.dimensionType = dimensionType;
+ // CraftBukkit end
this.levelId = s;
this.levelDirectory = new Convertable.b(path);
this.lock = SessionLock.create(path);
@@ -531,7 +554,7 @@
@@ -529,7 +552,7 @@
}
public Path getLevelPath(SavedFile savedfile) {
@@ -106,7 +97,7 @@
Convertable.b convertable_b = this.levelDirectory;
Objects.requireNonNull(this.levelDirectory);
@@ -539,7 +562,7 @@
@@ -537,7 +560,7 @@
}
public Path getDimensionPath(ResourceKey<World> resourcekey) {

View File

@@ -20,7 +20,7 @@
public class WorldDataServer implements IWorldDataServer, SaveData {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -81,6 +94,20 @@
@@ -79,6 +92,20 @@
private boolean wasModded;
private final Set<String> removedFeatureFlags;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> scheduledEvents;
@@ -39,27 +39,27 @@
+ }
+ // CraftBukkit end
private WorldDataServer(@Nullable NBTTagCompound nbttagcompound, boolean flag, int i, int j, int k, float f, long l, long i1, int j1, int k1, int l1, boolean flag1, int i2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int j2, int k2, @Nullable UUID uuid, Set<String> set, Set<String> set1, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, EnderDragonBattle.a enderdragonbattle_a, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
private WorldDataServer(@Nullable NBTTagCompound nbttagcompound, boolean flag, BlockPosition blockposition, float f, long i, long j, int k, int l, int i1, boolean flag1, int j1, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k1, int l1, @Nullable UUID uuid, Set<String> set, Set<String> set1, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, EnderDragonBattle.a enderdragonbattle_a, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
this.wasModded = flag;
@@ -120,7 +147,7 @@
@@ -116,7 +143,7 @@
public static <T> WorldDataServer parse(Dynamic<T> dynamic, WorldSettings worldsettings, WorldDataServer.a worlddataserver_a, WorldOptions worldoptions, Lifecycle lifecycle) {
long i = dynamic.get("Time").asLong(0L);
- NBTTagCompound nbttagcompound = (NBTTagCompound) NBTTagCompound.CODEC.parse(dynamic.get("Player").orElseEmptyMap()).result().orElse((Object) null);
+ NBTTagCompound nbttagcompound = (NBTTagCompound) NBTTagCompound.CODEC.parse(dynamic.get("Player").orElseEmptyMap()).result().orElse(null); // CraftBukkit - decompile error
boolean flag = dynamic.get("WasModded").asBoolean(false);
int j = dynamic.get("SpawnX").asInt(0);
int k = dynamic.get("SpawnY").asInt(0);
@@ -138,7 +165,7 @@
- OptionalDynamic optionaldynamic = dynamic.get("Player");
+ OptionalDynamic<T> optionaldynamic = dynamic.get("Player"); // CraftBukkit - decompile error
Codec codec = NBTTagCompound.CODEC;
Objects.requireNonNull(codec);
@@ -136,7 +163,7 @@
WorldBorder.c worldborder_c = WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS);
int j2 = dynamic.get("WanderingTraderSpawnDelay").asInt(0);
int k2 = dynamic.get("WanderingTraderSpawnChance").asInt(0);
int k1 = dynamic.get("WanderingTraderSpawnDelay").asInt(0);
int l1 = dynamic.get("WanderingTraderSpawnChance").asInt(0);
- UUID uuid = (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null);
+ UUID uuid = (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse(null); // CraftBukkit - decompile error
Set set = (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
return dynamic1.asString().result().stream();
}).collect(Collectors.toCollection(Sets::newLinkedHashSet));
@@ -147,7 +174,7 @@
@@ -145,7 +172,7 @@
}).collect(Collectors.toSet());
CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream());
NBTTagCompound nbttagcompound1 = (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue();
@@ -68,16 +68,16 @@
Logger logger = WorldDataServer.LOGGER;
Objects.requireNonNull(logger);
@@ -182,7 +209,7 @@
@@ -180,7 +207,7 @@
nbttagcompound.put("Version", nbttagcompound2);
GameProfileSerializer.addCurrentDataVersion(nbttagcompound);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom);
DynamicOps<NBTBase> dynamicops = iregistrycustom.createSerializationContext(DynamicOpsNBT.INSTANCE);
- DataResult dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, iregistrycustom);
+ DataResult<NBTBase> dataresult = GeneratorSettings.encode(dynamicops, this.worldOptions, new WorldDimensions(this.customDimensions != null ? this.customDimensions : iregistrycustom.registryOrThrow(Registries.LEVEL_STEM))); // CraftBukkit
Logger logger = WorldDataServer.LOGGER;
Objects.requireNonNull(logger);
@@ -234,11 +261,13 @@
@@ -230,11 +257,13 @@
nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId);
}
@@ -92,7 +92,7 @@
Objects.requireNonNull(nbttaglist);
stream.forEach(nbttaglist::add);
@@ -346,6 +375,20 @@
@@ -310,6 +339,20 @@
@Override
public void setThundering(boolean flag) {
@@ -113,7 +113,7 @@
this.thundering = flag;
}
@@ -366,6 +409,20 @@
@@ -330,6 +373,20 @@
@Override
public void setRaining(boolean flag) {
@@ -134,7 +134,7 @@
this.raining = flag;
}
@@ -432,6 +489,12 @@
@@ -396,6 +453,12 @@
@Override
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.settings = this.settings.withDifficulty(enumdifficulty);
@@ -147,7 +147,7 @@
}
@Override
@@ -568,6 +631,14 @@
@@ -532,6 +595,14 @@
return this.settings.copy();
}

View File

@@ -1,62 +1,101 @@
--- a/net/minecraft/world/level/storage/WorldNBTStorage.java
+++ b/net/minecraft/world/level/storage/WorldNBTStorage.java
@@ -15,6 +15,13 @@
@@ -15,8 +15,10 @@
import net.minecraft.nbt.NBTCompressedStreamTools;
import net.minecraft.nbt.NBTReadLimiter;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.server.level.EntityPlayer;
import net.minecraft.util.datafix.DataFixTypes;
import net.minecraft.world.entity.player.EntityHuman;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.slf4j.Logger;
+// CraftBukkit start
+import java.io.FileInputStream;
+import java.io.InputStream;
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+// CraftBukkit end
+
public class WorldNBTStorage {
@@ -49,34 +51,36 @@
private static final Logger LOGGER = LogUtils.getLogger();
@@ -59,6 +66,16 @@
}
- private void backup(EntityHuman entityhuman, String s) {
+ private void backup(String name, String s1, String s) { // name, uuid, extension
Path path = this.playerDir.toPath();
- String s1 = entityhuman.getStringUUID();
+ // String s1 = entityhuman.getStringUUID(); // CraftBukkit - used above
Path path1 = path.resolve(s1 + s);
- s1 = entityhuman.getStringUUID();
+ // s1 = entityhuman.getStringUUID(); // CraftBukkit - used above
Path path2 = path.resolve(s1 + "_corrupted_" + LocalDateTime.now().format(WorldNBTStorage.FORMATTER) + s);
if (Files.isRegularFile(path1, new LinkOption[0])) {
try {
Files.copy(path1, path2, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
} catch (Exception exception) {
- WorldNBTStorage.LOGGER.warn("Failed to copy the player.dat file for {}", entityhuman.getName().getString(), exception);
+ WorldNBTStorage.LOGGER.warn("Failed to copy the player.dat file for {}", name, exception); // CraftBukkit
}
}
}
- private Optional<NBTTagCompound> load(EntityHuman entityhuman, String s) {
+ // CraftBukkit start
+ private Optional<NBTTagCompound> load(String name, String s1, String s) { // name, uuid, extension
+ // CraftBukkit end
File file = this.playerDir;
- String s1 = entityhuman.getStringUUID();
+ // String s1 = entityhuman.getStringUUID(); // CraftBukkit - used above
File file1 = new File(file, s1 + s);
if (file1.exists() && file1.isFile()) {
try {
return Optional.of(NBTCompressedStreamTools.readCompressed(file1.toPath(), NBTReadLimiter.unlimitedHeap()));
} catch (Exception exception) {
- WorldNBTStorage.LOGGER.warn("Failed to load player data for {}", entityhuman.getName().getString());
+ WorldNBTStorage.LOGGER.warn("Failed to load player data for {}", name); // CraftBukkit
}
}
if (nbttagcompound != null) {
+ // CraftBukkit start
@@ -84,20 +88,44 @@
}
public Optional<NBTTagCompound> load(EntityHuman entityhuman) {
- Optional<NBTTagCompound> optional = this.load(entityhuman, ".dat");
+ // CraftBukkit start
+ return load(entityhuman.getName().getString(), entityhuman.getStringUUID()).map((nbttagcompound) -> {
+ if (entityhuman instanceof EntityPlayer) {
+ CraftPlayer player = (CraftPlayer) entityhuman.getBukkitEntity();
+ // Only update first played if it is older than the one we have
+ long modified = new File(this.playerDir, entityhuman.getUUID().toString() + ".dat").lastModified();
+ long modified = new File(this.playerDir, entityhuman.getStringUUID() + ".dat").lastModified();
+ if (modified < player.getFirstPlayed()) {
+ player.setFirstPlayed(modified);
+ }
+ }
+ // CraftBukkit end
+
+ entityhuman.load(nbttagcompound); // From below
+ return nbttagcompound;
+ });
+ }
+
+ public Optional<NBTTagCompound> load(String name, String uuid) {
+ // CraftBukkit end
+ Optional<NBTTagCompound> optional = this.load(name, uuid, ".dat"); // CraftBukkit
if (optional.isEmpty()) {
- this.backup(entityhuman, ".dat");
+ this.backup(name, uuid, ".dat"); // CraftBukkit
}
return optional.or(() -> {
- return this.load(entityhuman, ".dat_old");
+ return this.load(name, uuid, ".dat_old"); // CraftBukkit
}).map((nbttagcompound) -> {
int i = GameProfileSerializer.getDataVersion(nbttagcompound, -1);
nbttagcompound = DataFixTypes.PLAYER.updateToCurrentVersion(this.fixerUpper, nbttagcompound, i);
@@ -68,6 +85,22 @@
return nbttagcompound;
}
+ // CraftBukkit start
+ public NBTTagCompound getPlayerData(String s) {
+ try {
+ File file1 = new File(this.playerDir, s + ".dat");
+
+ if (file1.exists()) {
+ return NBTCompressedStreamTools.readCompressed(file1.toPath(), NBTReadLimiter.unlimitedHeap());
+ }
+ } catch (Exception exception) {
+ LOGGER.warn("Failed to load player data for " + s);
+ }
+
+ return null;
+ }
+ // CraftBukkit end
+
public String[] getSeenPlayers() {
String[] astring = this.playerDir.list();
@@ -83,4 +116,10 @@
return astring;
- entityhuman.load(nbttagcompound);
+ // entityhuman.load(nbttagcompound); // CraftBukkit - handled above
return nbttagcompound;
});
}
+
+ // CraftBukkit start

View File

@@ -1,48 +0,0 @@
--- a/net/minecraft/world/level/storage/loot/LootDataManager.java
+++ b/net/minecraft/world/level/storage/loot/LootDataManager.java
@@ -22,6 +22,8 @@
import net.minecraft.util.ProblemReporter;
import net.minecraft.util.profiling.GameProfilerFiller;
import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSets;
+import org.bukkit.craftbukkit.CraftLootTable;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.slf4j.Logger;
public class LootDataManager implements IReloadListener, LootDataResolver {
@@ -89,7 +91,7 @@
@Nullable
@Override
public <T> T getElement(LootDataId<T> lootdataid) {
- return map1.get(lootdataid);
+ return (T) map1.get(lootdataid); // CraftBukkit - decompile error
}
});
@@ -99,18 +101,25 @@
problemreporter_a.get().forEach((s, s1) -> {
LootDataManager.LOGGER.warn("Found loot table element validation problem in {}: {}", s, s1);
});
+ // CraftBukkit start
+ map1.forEach((key, lootTable) -> {
+ if (object instanceof LootTable table) {
+ table.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(key.location()), table);
+ }
+ });
+ // CraftBukkit end
this.elements = map1;
this.typeKeys = com_google_common_collect_immutablemultimap_builder.build();
}
private static <T> void castAndValidate(LootCollector lootcollector, LootDataId<T> lootdataid, Object object) {
- lootdataid.type().runValidation(lootcollector, lootdataid, object);
+ lootdataid.type().runValidation(lootcollector, lootdataid, (T) object); // CraftBukkit - decompile error
}
@Nullable
@Override
public <T> T getElement(LootDataId<T> lootdataid) {
- return this.elements.get(lootdataid);
+ return (T) this.elements.get(lootdataid); // CraftBukkit - decompile error
}
public Collection<MinecraftKey> getKeys(LootDataType<?> lootdatatype) {

View File

@@ -0,0 +1,22 @@
--- a/net/minecraft/world/level/storage/loot/LootDataType.java
+++ b/net/minecraft/world/level/storage/loot/LootDataType.java
@@ -16,6 +16,11 @@
import net.minecraft.world.level.storage.loot.predicates.LootItemConditions;
import org.slf4j.Logger;
+// CraftBukkit start
+import org.bukkit.craftbukkit.CraftLootTable;
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
+// CraftBukkit end
+
public record LootDataType<T>(ResourceKey<IRegistry<T>> registryKey, Codec<T> codec, String directory, LootDataType.a<T> validator) {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -49,6 +54,7 @@
private static LootDataType.a<LootTable> createLootTableValidator() {
return (lootcollector, resourcekey, loottable) -> {
loottable.validate(lootcollector.setParams(loottable.getParamSet()).enterElement("{" + String.valueOf(resourcekey.registry()) + "/" + String.valueOf(resourcekey.location()) + "}", resourcekey));
+ loottable.craftLootTable = new CraftLootTable(CraftNamespacedKey.fromMinecraft(resourcekey.location()), loottable); // CraftBukkit
};
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/net/minecraft/world/level/storage/loot/LootTable.java
@@ -29,6 +29,13 @@
@@ -31,6 +31,13 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameterSets;
import org.slf4j.Logger;
@@ -14,7 +14,7 @@
public class LootTable {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -50,6 +57,7 @@
@@ -54,6 +61,7 @@
private final List<LootSelector> pools;
private final List<LootItemFunction> functions;
private final BiFunction<ItemStack, LootTableInfo, ItemStack> compositeFunction;
@@ -22,7 +22,7 @@
LootTable(LootContextParameterSet lootcontextparameterset, Optional<MinecraftKey> optional, List<LootSelector> list, List<LootItemFunction> list1) {
this.paramSet = lootcontextparameterset;
@@ -149,9 +157,22 @@
@@ -153,9 +161,22 @@
}
public void fill(IInventory iinventory, LootParams lootparams, long i) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java
+++ b/net/minecraft/world/level/storage/loot/predicates/LootItemConditionRandomChanceWithLooting.java
@@ -34,6 +34,11 @@
@@ -35,6 +35,11 @@
if (entity instanceof EntityLiving) {
i = EnchantmentManager.getMobLooting((EntityLiving) entity);
}