Update to Minecraft 1.20

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-06-08 01:30:00 +10:00
parent bac55e67d6
commit 9d740b84b0
269 changed files with 2605 additions and 2568 deletions

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/level/storage/Convertable.java
+++ b/net/minecraft/world/level/storage/Convertable.java
@@ -68,6 +68,10 @@
import net.minecraft.world.level.levelgen.WorldDimensions;
@@ -74,6 +74,10 @@
import net.minecraft.world.level.validation.PathAllowList;
import org.slf4j.Logger;
+// CraftBukkit start
@@ -11,7 +11,7 @@
public class Convertable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -114,7 +118,7 @@
@@ -160,7 +164,7 @@
}
private static WorldDataConfiguration readDataConfig(Dynamic<?> dynamic) {
@@ -20,7 +20,16 @@
Logger logger = Convertable.LOGGER;
Objects.requireNonNull(logger);
@@ -252,6 +256,7 @@
@@ -176,7 +180,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;
@@ -320,6 +324,7 @@
WorldDimensions.b worlddimensions_b = generatorsettings.dimensions().bake(iregistry);
Lifecycle lifecycle1 = worlddimensions_b.lifecycle().add(lifecycle);
WorldDataServer worlddataserver = WorldDataServer.parse(dynamic, datafixer, i, nbttagcompound2, worldsettings, levelversion, worlddimensions_b.specialWorldProperty(), generatorsettings.options(), lifecycle1);
@@ -28,17 +37,36 @@
return Pair.of(worlddataserver, worlddimensions_b);
};
@@ -333,9 +338,23 @@
@@ -415,27 +420,41 @@
return this.backupDir;
}
- public Convertable.ConversionSession validateAndCreateAccess(String s) throws IOException, ContentValidationException {
+ public Convertable.ConversionSession validateAndCreateAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException, ContentValidationException { // CraftBukkit
Path path = this.getLevelPath(s);
List<ForbiddenSymlinkInfo> list = this.worldDirValidator.validateSave(path, true);
if (!list.isEmpty()) {
throw new ContentValidationException(path, list);
} else {
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
}
- public Convertable.ConversionSession createAccess(String s) throws IOException {
- return new Convertable.ConversionSession(s);
+ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException { // CraftBukkit
Path path = this.getLevelPath(s);
- return new Convertable.ConversionSession(s, path);
+ return new Convertable.ConversionSession(s, path, dimensionType); // CraftBukkit
}
public DirectoryValidator getWorldDirValidator() {
return this.worldDirValidator;
}
+ // CraftBukkit start
+ public Convertable.ConversionSession createAccess(String s, ResourceKey<WorldDimension> dimensionType) throws IOException {
+ return new Convertable.ConversionSession(s, dimensionType);
+ }
+
+ public static Path getStorageFolder(Path path, ResourceKey<WorldDimension> dimensionType) {
+ if (dimensionType == WorldDimension.OVERWORLD) {
+ return path;
@@ -49,26 +77,27 @@
+ } else {
+ return path.resolve("dimensions").resolve(dimensionType.location().getNamespace()).resolve(dimensionType.location().getPath());
+ }
}
+ }
+ // CraftBukkit end
+
public static record a(List<Convertable.b> levels) implements Iterable<Convertable.b> {
@@ -388,8 +407,12 @@
public boolean isEmpty() {
@@ -487,8 +506,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;
- public ConversionSession(String s) throws IOException {
+ public ConversionSession(String s, ResourceKey<WorldDimension> dimensionType) throws IOException {
- ConversionSession(String s, Path path) throws IOException {
+ ConversionSession(String s, Path path, ResourceKey<WorldDimension> dimensionType) throws IOException {
+ this.dimensionType = dimensionType;
+ // CraftBukkit end
this.levelId = s;
this.levelDirectory = new Convertable.b(Convertable.this.baseDir.resolve(s));
this.lock = SessionLock.create(this.levelDirectory.path());
@@ -400,7 +423,7 @@
this.levelDirectory = new Convertable.b(path);
this.lock = SessionLock.create(path);
@@ -499,7 +522,7 @@
}
public Path getLevelPath(SavedFile savedfile) {
@@ -77,7 +106,7 @@
Convertable.b convertable_b = this.levelDirectory;
Objects.requireNonNull(this.levelDirectory);
@@ -408,7 +431,7 @@
@@ -507,7 +530,7 @@
}
public Path getDimensionPath(ResourceKey<World> resourcekey) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/WorldDataServer.java
+++ b/net/minecraft/world/level/storage/WorldDataServer.java
@@ -43,6 +43,19 @@
@@ -45,6 +45,19 @@
import net.minecraft.world.level.timers.CustomFunctionCallbackTimers;
import org.slf4j.Logger;
@@ -20,9 +20,9 @@
public class WorldDataServer implements IWorldDataServer, SaveData {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -83,6 +96,20 @@
private final Set<String> knownServerBrands;
@@ -86,6 +99,20 @@
private boolean wasModded;
private final Set<String> removedFeatureFlags;
private final CustomFunctionCallbackTimerQueue<MinecraftServer> scheduledEvents;
+ // CraftBukkit start - Add world and pdc
+ public IRegistry<WorldDimension> customDimensions;
@@ -39,28 +39,27 @@
+ }
+ // CraftBukkit end
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @Nullable UUID uuid, Set<String> set, CustomFunctionCallbackTimerQueue<MinecraftServer> customfunctioncallbacktimerqueue, @Nullable NBTTagCompound nbttagcompound1, NBTTagCompound nbttagcompound2, WorldSettings worldsettings, WorldOptions worldoptions, WorldDataServer.a worlddataserver_a, Lifecycle lifecycle) {
private WorldDataServer(@Nullable DataFixer datafixer, int i, @Nullable NBTTagCompound nbttagcompound, boolean flag, int j, int k, int l, float f, long i1, long j1, int k1, int l1, int i2, boolean flag1, int j2, boolean flag2, boolean flag3, boolean flag4, WorldBorder.c worldborder_c, int k2, int l2, @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.fixerUpper = datafixer;
@@ -127,7 +154,8 @@
return dynamic.get("DimensionData").get("1").get("DragonFight").orElseEmptyMap();
})).convert(DynamicOpsNBT.INSTANCE).getValue();
- return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse((Object) null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
+ // CraftBukkit - decompile error
+ return new WorldDataServer(datafixer, i, nbttagcompound, dynamic.get("WasModded").asBoolean(false), dynamic.get("SpawnX").asInt(0), dynamic.get("SpawnY").asInt(0), dynamic.get("SpawnZ").asInt(0), dynamic.get("SpawnAngle").asFloat(0.0F), j, dynamic.get("DayTime").asLong(j), levelversion.levelDataVersion(), dynamic.get("clearWeatherTime").asInt(0), dynamic.get("rainTime").asInt(0), dynamic.get("raining").asBoolean(false), dynamic.get("thunderTime").asInt(0), dynamic.get("thundering").asBoolean(false), dynamic.get("initialized").asBoolean(true), dynamic.get("DifficultyLocked").asBoolean(false), WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS), dynamic.get("WanderingTraderSpawnDelay").asInt(0), dynamic.get("WanderingTraderSpawnChance").asInt(0), (UUID) dynamic.get("WanderingTraderId").read(UUIDUtil.CODEC).result().orElse(null), (Set) dynamic.get("ServerBrands").asStream().flatMap((dynamic1) -> {
@@ -144,7 +171,7 @@
WorldBorder.c worldborder_c = WorldBorder.c.read(dynamic, WorldBorder.DEFAULT_SETTINGS);
int k2 = dynamic.get("WanderingTraderSpawnDelay").asInt(0);
int l2 = 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)), new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream()), (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue(), nbttagcompound1, worldsettings, worldoptions, worlddataserver_a, lifecycle);
}
@@ -147,7 +175,7 @@
}).collect(Collectors.toCollection(Sets::newLinkedHashSet));
@@ -153,7 +180,7 @@
}).collect(Collectors.toSet());
CustomFunctionCallbackTimerQueue customfunctioncallbacktimerqueue = new CustomFunctionCallbackTimerQueue<>(CustomFunctionCallbackTimers.SERVER_CALLBACKS, dynamic.get("ScheduledEvents").asStream());
NBTTagCompound nbttagcompound1 = (NBTTagCompound) dynamic.get("CustomBossEvents").orElseEmptyMap().getValue();
- DataResult dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC);
+ DataResult<EnderDragonBattle.a> dataresult = dynamic.get("DragonFight").read(EnderDragonBattle.a.CODEC); // CraftBukkit - decompile error
Logger logger = WorldDataServer.LOGGER;
private void setTagData(IRegistryCustom iregistrycustom, NBTTagCompound nbttagcompound, @Nullable NBTTagCompound nbttagcompound1) {
NBTTagList nbttaglist = new NBTTagList();
- Stream stream = this.knownServerBrands.stream().map(NBTTagString::valueOf);
+ Stream<NBTTagString> stream = this.knownServerBrands.stream().map(NBTTagString::valueOf); // CraftBukkit - decompile error
Objects.requireNonNull(nbttaglist);
stream.forEach(nbttaglist::add);
@@ -162,7 +190,7 @@
Objects.requireNonNull(logger);
@@ -189,7 +216,7 @@
nbttagcompound.put("Version", nbttagcompound2);
GameProfileSerializer.addCurrentDataVersion(nbttagcompound);
DynamicOps<NBTBase> dynamicops = RegistryOps.create(DynamicOpsNBT.INSTANCE, (HolderLookup.b) iregistrycustom);
@@ -69,7 +68,7 @@
Logger logger = WorldDataServer.LOGGER;
Objects.requireNonNull(logger);
@@ -214,6 +242,8 @@
@@ -241,11 +268,13 @@
nbttagcompound.putUUID("WanderingTraderId", this.wanderingTraderId);
}
@@ -77,8 +76,14 @@
+ world.getWorld().storeBukkitValues(nbttagcompound); // CraftBukkit - add pdc
}
@Override
@@ -331,6 +361,20 @@
private static NBTTagList stringCollectionToTag(Set<String> set) {
NBTTagList nbttaglist = new NBTTagList();
- Stream stream = set.stream().map(NBTTagString::valueOf);
+ Stream<NBTTagString> stream = set.stream().map(NBTTagString::valueOf); // CraftBukkit - decompile error
Objects.requireNonNull(nbttaglist);
stream.forEach(nbttaglist::add);
@@ -367,6 +396,20 @@
@Override
public void setThundering(boolean flag) {
@@ -99,7 +104,7 @@
this.thundering = flag;
}
@@ -351,6 +395,20 @@
@@ -387,6 +430,20 @@
@Override
public void setRaining(boolean flag) {
@@ -120,7 +125,7 @@
this.raining = flag;
}
@@ -417,6 +475,12 @@
@@ -453,6 +510,12 @@
@Override
public void setDifficulty(EnumDifficulty enumdifficulty) {
this.settings = this.settings.withDifficulty(enumdifficulty);
@@ -133,7 +138,7 @@
}
@Override
@@ -548,6 +612,14 @@
@@ -589,6 +652,14 @@
return this.settings.copy();
}

View File

@@ -0,0 +1,43 @@
--- a/net/minecraft/world/level/storage/loot/LootDataManager.java
+++ b/net/minecraft/world/level/storage/loot/LootDataManager.java
@@ -36,6 +36,7 @@
public static final LootDataId<LootTable> EMPTY_LOOT_TABLE_KEY = new LootDataId<>(LootDataType.TABLE, LootTables.EMPTY);
private Map<LootDataId<?>, ?> elements = Map.of();
private Multimap<LootDataType<?>, MinecraftKey> typeKeys = ImmutableMultimap.of();
+ public Map<?, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
public LootDataManager() {}
@@ -93,7 +94,7 @@
@Nullable
@Override
public <T> T getElement(LootDataId<T> lootdataid) {
- return map1.get(lootdataid);
+ return (T) map1.get(lootdataid); // CraftBukkit - decompile error
}
});
@@ -105,16 +106,21 @@
});
this.elements = map1;
this.typeKeys = com_google_common_collect_immutablemultimap_builder.build();
+ // CraftBukkit start - build a reversed registry map
+ ImmutableMap.Builder<Object, MinecraftKey> lootTableToKeyBuilder = ImmutableMap.builder();
+ this.elements.forEach((key, lootTable) -> lootTableToKeyBuilder.put((Object) lootTable, key.location()));
+ this.lootTableToKey = lootTableToKeyBuilder.build();
+ // CraftBukkit end
}
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

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/level/storage/loot/LootTable.java
+++ b/net/minecraft/world/level/storage/loot/LootTable.java
@@ -32,6 +32,13 @@
@@ -34,6 +34,13 @@
import org.apache.commons.lang3.ArrayUtils;
import org.slf4j.Logger;
@@ -14,16 +14,17 @@
public class LootTable {
static final Logger LOGGER = LogUtils.getLogger();
@@ -119,8 +126,21 @@
@@ -145,9 +152,22 @@
}
public void fill(IInventory iinventory, LootTableInfo loottableinfo) {
public void fill(IInventory iinventory, LootParams lootparams, long i) {
+ // CraftBukkit start
+ this.fillInventory(iinventory, loottableinfo, false);
+ this.fillInventory(iinventory, lootparams, i, false);
+ }
+
+ public void fillInventory(IInventory iinventory, LootTableInfo loottableinfo, boolean plugin) {
+ public void fillInventory(IInventory iinventory, LootParams lootparams, long i, boolean plugin) {
+ // CraftBukkit end
LootTableInfo loottableinfo = (new LootTableInfo.Builder(lootparams)).withOptionalRandomSeed(i).create(this.randomSequence);
ObjectArrayList<ItemStack> objectarraylist = this.getRandomItems(loottableinfo);
RandomSource randomsource = loottableinfo.getRandom();
+ // CraftBukkit start

View File

@@ -1,31 +0,0 @@
--- a/net/minecraft/world/level/storage/loot/LootTableRegistry.java
+++ b/net/minecraft/world/level/storage/loot/LootTableRegistry.java
@@ -22,6 +22,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
private static final Gson GSON = LootSerialization.createLootTableSerializer().create();
private Map<MinecraftKey, LootTable> tables = ImmutableMap.of();
+ public Map<LootTable, MinecraftKey> lootTableToKey = ImmutableMap.of(); // CraftBukkit
private final LootPredicateManager predicateManager;
public LootTableRegistry(LootPredicateManager lootpredicatemanager) {
@@ -57,7 +58,7 @@
LootPredicateManager lootpredicatemanager = this.predicateManager;
Objects.requireNonNull(this.predicateManager);
- Function function = lootpredicatemanager::get;
+ Function<MinecraftKey, net.minecraft.world.level.storage.loot.predicates.LootItemCondition> function = lootpredicatemanager::get; // CraftBukkit - decompile error
Objects.requireNonNull(immutablemap);
LootCollector lootcollector = new LootCollector(lootcontextparameterset, function, immutablemap::get);
@@ -69,6 +70,11 @@
LootTableRegistry.LOGGER.warn("Found validation problem in {}: {}", s, s1);
});
this.tables = immutablemap;
+ // CraftBukkit start - build a reversed registry map
+ ImmutableMap.Builder<LootTable, MinecraftKey> lootTableToKeyBuilder = ImmutableMap.builder();
+ this.tables.forEach((lootTable, key) -> lootTableToKeyBuilder.put(key, lootTable));
+ this.lootTableToKey = lootTableToKeyBuilder.build();
+ // CraftBukkit end
}
public static void validate(LootCollector lootcollector, MinecraftKey minecraftkey, LootTable loottable) {