2022-02-25 17:46:35 +01:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2022-06-03 06:42:00 +02:00
From: Jake Potrebic <jake.m.potrebic@gmail.com>
2022-02-25 17:46:35 +01:00
Date: Fri, 25 Feb 2022 07:14:48 -0800
2022-03-01 04:25:13 +01:00
Subject: [PATCH] CB fixes
2022-02-25 17:46:35 +01:00
2022-03-01 04:25:13 +01:00
* Missing Level -> LevelStem generic in StructureCheck
2022-06-03 06:42:00 +02:00
Need to use the right for injectDatafixingContext (Spottedleaf)
2022-02-25 17:46:35 +01:00
2024-07-01 10:16:07 +02:00
* Fix summon_entity effect attempting to add incorrect entity (granny)
2022-06-03 06:42:00 +02:00
* Removed incorrect parent perm for `minecraft.debugstick.always` (Machine_Maker)
2022-05-24 06:09:20 +02:00
2022-06-03 06:42:00 +02:00
* Fixed method signature of Marker#addPassenger (Machine_Maker)
2022-05-26 03:00:47 +02:00
2022-06-03 06:42:00 +02:00
* Removed unneeded UOE in CustomWorldChunkManager (extends BiomeSource) (Machine_Maker)
* Honor Server#getLootTable method contract (Machine_Maker)
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
2022-05-31 04:35:46 +02:00
2022-02-25 17:46:35 +01:00
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
2024-06-13 19:12:48 +02:00
index a696a0d168987aaa4e59c471a23eeb48d683c1b2..9d11fcb3df12182ae00ce73f7e30091fd199a341 100644
2022-02-25 17:46:35 +01:00
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
2024-06-13 19:12:48 +02:00
@@ -303,7 +303,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
2022-02-25 17:46:35 +01:00
2022-12-07 18:08:55 +01:00
long l = minecraftserver.getWorldData().worldGenOptions().seed();
2022-02-25 17:46:35 +01:00
2022-06-07 20:12:34 +02:00
- this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), resourcekey, chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer);
+ this.structureCheck = new StructureCheck(this.chunkSource.chunkScanner(), this.registryAccess(), minecraftserver.getStructureManager(), this.getTypeKey(), chunkgenerator, this.chunkSource.randomState(), this, chunkgenerator.getBiomeSource(), l, datafixer); // Paper - Fix missing CB diff
2022-12-07 18:08:55 +01:00
this.structureManager = new StructureManager(this, this.serverLevelData.worldGenOptions(), this.structureCheck); // CraftBukkit
2022-06-20 19:12:05 +02:00
if ((this.dimension() == Level.END && this.dimensionTypeRegistration().is(BuiltinDimensionTypes.END)) || env == org.bukkit.World.Environment.THE_END) { // CraftBukkit - Allow to create EnderDragonBattle in default and custom END
2022-12-07 18:08:55 +01:00
this.dragonFight = new EndDragonFight(this, this.serverLevelData.worldGenOptions().seed(), this.serverLevelData.endDragonFightData()); // CraftBukkit
2024-07-01 10:16:07 +02:00
diff --git a/src/main/java/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java b/src/main/java/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
index d927357d541cf206bb3019b2fda3473a77b44ec4..4601c7069ba82ccfe87e9dc304b6f3262f7bbfbf 100644
--- a/src/main/java/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
+++ b/src/main/java/net/minecraft/world/item/enchantment/effects/SummonEntityEffect.java
@@ -54,7 +54,7 @@ public record SummonEntityEffect(HolderSet<EntityType<?>> entityTypes, boolean j
// CraftBukkit start
world.strikeLightning(entity1, (context.itemStack().getItem() == Items.TRIDENT) ? LightningStrikeEvent.Cause.TRIDENT : LightningStrikeEvent.Cause.ENCHANTMENT);
} else {
- world.addFreshEntityWithPassengers(user, CreatureSpawnEvent.SpawnReason.ENCHANTMENT);
+ world.addFreshEntityWithPassengers(entity1, CreatureSpawnEvent.SpawnReason.ENCHANTMENT); // Paper - Fix typo when adding summoned entity
// CraftBukkit end
}
2022-02-25 17:46:35 +01:00
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
2024-04-23 20:03:16 +02:00
index 0dc7f88877020bddd5a84db51d349f52b673048e..aae73586265593ee7830fb8dd5c2e3d7560057f0 100644
2022-02-25 17:46:35 +01:00
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/StructureCheck.java
2024-04-23 20:03:16 +02:00
@@ -40,7 +40,7 @@ public class StructureCheck {
private final ChunkScanAccess storageAccess;
private final RegistryAccess registryAccess;
2022-06-07 20:12:34 +02:00
private final StructureTemplateManager structureTemplateManager;
2022-02-25 17:46:35 +01:00
- private final ResourceKey<Level> dimension;
+ private final ResourceKey<net.minecraft.world.level.dimension.LevelStem> dimension; // Paper - fix missing CB diff
private final ChunkGenerator chunkGenerator;
2022-06-07 20:12:34 +02:00
private final RandomState randomState;
2022-02-25 17:46:35 +01:00
private final LevelHeightAccessor heightAccessor;
2024-04-23 20:03:16 +02:00
@@ -54,7 +54,7 @@ public class StructureCheck {
2024-04-12 21:14:06 +02:00
ChunkScanAccess chunkIoWorker,
RegistryAccess registryManager,
StructureTemplateManager structureTemplateManager,
- ResourceKey<Level> worldKey,
+ ResourceKey<net.minecraft.world.level.dimension.LevelStem> worldKey, // Paper - fix missing CB diff
ChunkGenerator chunkGenerator,
RandomState noiseConfig,
LevelHeightAccessor world,
2023-10-10 19:35:49 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
2024-06-13 19:12:48 +02:00
index 85c7f3027978b1d7d6c31b7ad21b3377cdda5925..e34deaf398dc6722c3128bdd6b9bc16da2d33bf7 100644
2023-10-10 19:35:49 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftLootTable.java
2024-06-13 19:12:48 +02:00
@@ -187,4 +187,11 @@ public class CraftLootTable implements org.bukkit.loot.LootTable {
2023-10-10 19:35:49 +02:00
org.bukkit.loot.LootTable table = (org.bukkit.loot.LootTable) obj;
return table.getKey().equals(this.getKey());
}
+
+ // Paper start - satisfy equals/hashCode contract
+ @Override
+ public int hashCode() {
+ return java.util.Objects.hash(key);
+ }
+ // Paper end
}
2022-06-03 06:42:00 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2024-07-18 10:13:20 +02:00
index 751900e0c2a946ba4291174c81b2bdbdbe994e94..f04c0f8b3905b488aac221fedde335a54ad1ff58 100644
2022-06-03 06:42:00 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
2024-07-18 10:13:20 +02:00
@@ -2522,7 +2522,13 @@ public final class CraftServer implements Server {
2023-06-13 01:51:45 +02:00
Preconditions.checkArgument(key != null, "NamespacedKey key cannot be null");
2022-06-03 06:42:00 +02:00
2024-04-23 20:03:16 +02:00
ReloadableServerRegistries.Holder registry = this.getServer().reloadableRegistries();
- return new CraftLootTable(key, registry.getLootTable(CraftLootTable.bukkitKeyToMinecraft(key)));
2022-06-03 06:42:00 +02:00
+ // Paper start - honor method contract
2024-04-23 20:03:16 +02:00
+ final ResourceKey<net.minecraft.world.level.storage.loot.LootTable> lootTableKey = CraftLootTable.bukkitKeyToMinecraft(key);
+ final Optional<net.minecraft.world.level.storage.loot.LootTable> table = registry.get().lookup(Registries.LOOT_TABLE)
+ .flatMap(registryEntryLookup -> registryEntryLookup.get(lootTableKey))
+ .map(net.minecraft.core.Holder::value);
2024-01-27 20:21:18 +01:00
+ return table.map(lootTable -> new CraftLootTable(key, lootTable)).orElse(null);
2022-06-03 06:42:00 +02:00
+ // Paper end
}
2022-05-31 04:35:46 +02:00
@Override
2023-11-25 10:49:48 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
2024-07-18 10:13:20 +02:00
index dbcde37cfdeb6141c3f5c4f8b95d60fca91c7977..2122d7316f55ab5bec7058fe1b8ee3ceb42deea7 100644
2023-11-25 10:49:48 +01:00
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
2024-04-23 20:03:16 +02:00
@@ -123,6 +123,7 @@ public class Main {
2023-11-25 10:49:48 +01:00
this.acceptsAll(Main.asList("forceUpgrade"), "Whether to force a world upgrade");
this.acceptsAll(Main.asList("eraseCache"), "Whether to force cache erase during world upgrade");
2024-04-23 20:03:16 +02:00
this.acceptsAll(Main.asList("recreateRegionFiles"), "Whether to recreate region files during world upgrade");
2023-11-25 10:49:48 +01:00
+ this.accepts("safeMode", "Loads level with vanilla datapack only"); // Paper
this.acceptsAll(Main.asList("nogui"), "Disables the graphical console");
this.acceptsAll(Main.asList("nojline"), "Disables jline and emulates the vanilla console");
2024-01-26 21:34:40 +01:00
diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
index 905adf97c0d1f0d1c774a6835a5dffcfea884e58..c017ce2ca1bc535795c958a2e509af2adf88efa9 100644
--- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
+++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java
@@ -26,6 +26,7 @@ import org.bukkit.scheduler.BukkitWorker;
/**
* The fundamental concepts for this implementation:
+ * <ul>
* <li>Main thread owns {@link #head} and {@link #currentTick}, but it may be read from any thread</li>
* <li>Main thread exclusively controls {@link #temp} and {@link #pending}.
* They are never to be accessed outside of the main thread; alternatives exist to prevent locking.</li>
@@ -41,6 +42,7 @@ import org.bukkit.scheduler.BukkitWorker;
* <li>Sync tasks are only to be removed from runners on the main thread when coupled with a removal from pending and temp.</li>
* <li>Most of the design in this scheduler relies on queuing special tasks to perform any data changes on the main thread.
* When executed from inside a synchronous method, the scheduler will be updated before next execution by virtue of the frequent {@link #parsePending()} calls.</li>
+ * </ul>
*/
public class CraftScheduler implements BukkitScheduler {
2024-05-14 07:58:50 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
2024-07-06 21:19:14 +02:00
index cfb4cf66aa5f32a96a15886c6cf4a3946bd232ec..aa6a9dcd5528df38dddc0c661334c35658a19cee 100644
2024-05-14 07:58:50 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
2024-07-06 21:19:14 +02:00
@@ -240,7 +240,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
2024-05-14 07:58:50 +02:00
try {
nmsStack.applyComponents(new ItemParser(Commands.createValidationContext(MinecraftServer.getDefaultRegistryAccess())).parse(new StringReader(arguments)).components());
} catch (CommandSyntaxException ex) {
- Logger.getLogger(CraftMagicNumbers.class.getName()).log(Level.SEVERE, null, ex);
+ com.mojang.logging.LogUtils.getClassLogger().error("Exception modifying ItemStack", new Throwable(ex)); // Paper - show stack trace
}
stack.setItemMeta(CraftItemStack.getItemMeta(nmsStack));
2022-05-24 06:09:20 +02:00
diff --git a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
2023-11-11 21:25:45 +01:00
index 5ac25dab93fd4c9e9533c80d1ca3d93446d7a365..245ad120a36b6defca7e6889faae1ca5fc33d0c7 100644
2022-05-24 06:09:20 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/permissions/CraftDefaultPermissions.java
@@ -15,7 +15,7 @@ public final class CraftDefaultPermissions {
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.place", "Gives the user the ability to place restricted blocks with NBT in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".nbt.copy", "Gives the user the ability to copy NBT in creative", org.bukkit.permissions.PermissionDefault.TRUE, parent);
DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick", "Gives the user the ability to use the debug stick in creative", org.bukkit.permissions.PermissionDefault.OP, parent);
- DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE, parent);
+ DefaultPermissions.registerPermission(CraftDefaultPermissions.ROOT + ".debugstick.always", "Gives the user the ability to use the debug stick in all game modes", org.bukkit.permissions.PermissionDefault.FALSE/* , parent */); // Paper - should not have this parent, as it's not a "vanilla" utility
// Spigot end
parent.recalculatePermissibles();
}