From 6ef714345f585a5690823d77600bbcc3b2b825f8 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Sat, 2 Oct 2021 10:21:49 -0700 Subject: [PATCH] Updated Upstream (Bukkit/CraftBukkit) (#6638) --- patches/api/Added-Vanilla-Entity-Tags.patch | 18 +- ...tion-supression-of-EntityDismount-Ve.patch | 2 +- ...-get-a-BlockState-without-a-snapshot.patch | 70 ++---- .../server/Add-more-LimitedRegion-API.patch | 229 +----------------- .../server/Added-Vanilla-Entity-Tags.patch | 5 +- patches/server/Adventure.patch | 8 +- ...le-Keep-Spawn-Loaded-range-per-world.patch | 2 +- .../Configurable-fishing-time-ranges.patch | 2 +- ...lement-EntityTeleportEndGatewayEvent.patch | 2 +- ...-API-Replenishable-Lootables-Feature.patch | 8 +- patches/server/More-CommmandBlock-API.patch | 6 +- patches/server/More-Lidded-Block-API.patch | 6 +- .../PlayerTeleportEndGatewayEvent.patch | 2 +- ...ate-location-if-we-failed-to-read-it.patch | 19 +- patches/server/add-DragonEggFormEvent.patch | 2 +- ...entity-dismount-during-teleportation.patch | 2 +- work/Bukkit | 2 +- work/CraftBukkit | 2 +- 18 files changed, 80 insertions(+), 307 deletions(-) diff --git a/patches/api/Added-Vanilla-Entity-Tags.patch b/patches/api/Added-Vanilla-Entity-Tags.patch index c2254d97ad..9cbed09c8c 100644 --- a/patches/api/Added-Vanilla-Entity-Tags.patch +++ b/patches/api/Added-Vanilla-Entity-Tags.patch @@ -9,33 +9,45 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java @@ -0,0 +0,0 @@ public interface Tag extends Keyed { - * Vanilla fluid tag representing water and flowing water. + * Vanilla tag representing entities extra susceptible to freezing. */ - Tag FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class); + Tag ENTITY_TYPES_FREEZE_HURTS_EXTRA_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_hurts_extra_types"), EntityType.class); + // Paper start + /** -+ * Key for the build in entity registry ++ * Key for the built-in entity registry ++ * @deprecated use {@link #REGISTRY_ENTITY_TYPES} + */ ++ @Deprecated(forRemoval = true) + String REGISTRY_ENTITIES = "entities"; + /** + * Vanilla entity tag representing arrow entities. ++ * @deprecated use {@link #ENTITY_TYPES_ARROWS} + */ ++ @Deprecated(forRemoval = true) + Tag ARROWS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("arrows"), org.bukkit.entity.EntityType.class); + /** + * Vanilla entity tag representing entities that live in beehives ++ * @deprecated use {@link #ENTITY_TYPES_BEEHIVE_INHABITORS} + */ ++ @Deprecated(forRemoval = true) + Tag BEEHIVE_INHABITORS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("beehive_inhabitors"), org.bukkit.entity.EntityType.class); + /** + * Vanilla entity tag representing projectiles that impact ++ * @deprecated use {@link #ENTITY_TYPES_IMPACT_PROJECTILES} + */ ++ @Deprecated(forRemoval = true) + Tag IMPACT_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("impact_projectiles"), org.bukkit.entity.EntityType.class); + /** + * Vanilla entity tag for village raiders ++ * @deprecated use {@link #ENTITY_TYPES_RAIDERS} + */ ++ @Deprecated(forRemoval = true) + Tag RAIDERS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("raiders"), org.bukkit.entity.EntityType.class); + /** + * Vanilla entity tag for skeleton types ++ * @deprecated use {@link #ENTITY_TYPES_SKELETONS} + */ ++ @Deprecated(forRemoval = true) + Tag SKELETONS = Bukkit.getTag(REGISTRY_ENTITIES, NamespacedKey.minecraft("skeletons"), org.bukkit.entity.EntityType.class); + // Paper end diff --git a/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch b/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch index a25acb720e..ef12284ed5 100644 --- a/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch +++ b/patches/api/Support-cancellation-supression-of-EntityDismount-Ve.patch @@ -57,7 +57,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public boolean isCancellable() { + return isCancellable; -+ // paper end ++ // Paper end + } + @NotNull diff --git a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch index afd514dd77..0cbc48ae0e 100644 --- a/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch +++ b/patches/server/API-to-get-a-BlockState-without-a-snapshot.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.type = type; this.worldPosition = pos.immutable(); this.blockState = state; -+ persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); // Paper - always init ++ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY); // Paper - always init } // Paper start @@ -29,25 +29,22 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 // CraftBukkit start - read container public void load(CompoundTag nbt) { - this.persistentDataContainer = new CraftPersistentDataContainer(BlockEntity.DATA_TYPE_REGISTRY); -+ this.persistentDataContainer.clear(); ++ this.persistentDataContainer.clear(); // Paper - clear instead of init net.minecraft.nbt.Tag persistentDataTag = nbt.get("PublicBukkitValues"); if (persistentDataTag instanceof CompoundTag) { @@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { - } // CraftBukkit start - add method -+ // Paper start public InventoryHolder getOwner() { -- if (this.level == null) return null; ++ // Paper start + return getOwner(true); + } + public InventoryHolder getOwner(boolean useSnapshot) { + // Paper end -+ if (level == null) return null; + if (this.level == null) return null; // Spigot start org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); - if (block == null) { @@ -0,0 +0,0 @@ public abstract class BlockEntity implements net.minecraft.server.KeyedObject { return null; } @@ -65,69 +62,50 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @Override public BlockState getState() { -- Material material = this.getType(); -+ // Paper start - allow disabling the use of snapshots -+ return getState(true); ++ // Paper start ++ return this.getState(true); + } ++ ++ @Override + public BlockState getState(boolean useSnapshot) { + boolean prev = CraftBlockEntityState.DISABLE_SNAPSHOT; + CraftBlockEntityState.DISABLE_SNAPSHOT = !useSnapshot; + try { -+ return getState0(); + return CraftBlockStates.getBlockState(this); + } finally { + CraftBlockEntityState.DISABLE_SNAPSHOT = prev; + } -+ } -+ public BlockState getState0() { -+ // Paper end -+ Material material = getType(); - - switch (material) { - case ACACIA_SIGN: -diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 ---- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -@@ -0,0 +0,0 @@ public class CraftBlockEntityState extends CraftBlockStat - this.tileEntity = tileEntityClass.cast(getWorldHandle().getBlockEntity(this.getPosition())); - Preconditions.checkState(this.tileEntity != null, "Tile is null, asynchronous access? %s", block); - -+ // Paper start -+ this.snapshotDisabled = DISABLE_SNAPSHOT; -+ if (DISABLE_SNAPSHOT) { -+ this.snapshot = this.tileEntity; -+ } else { -+ this.snapshot = this.createSnapshot(this.tileEntity); -+ } - // copy tile entity data: -- this.snapshot = this.createSnapshot(tileEntity); -- this.load(snapshot); -+ if(this.snapshot != null) { -+ this.load(this.snapshot); -+ } + // Paper end } + @Override +diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java ++++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +@@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft + + private final T tileEntity; + private final T snapshot; + public final boolean snapshotDisabled; // Paper + public static boolean DISABLE_SNAPSHOT = false; // Paper -+ - public CraftBlockEntityState(Material material, T tileEntity) { - super(material); - this.tileEntityClass = (Class) tileEntity.getClass(); + public CraftBlockEntityState(World world, T tileEntity) { + super(world, tileEntity.getBlockPos(), tileEntity.getBlockState()); + this.tileEntity = tileEntity; -- + + // Paper start + this.snapshotDisabled = DISABLE_SNAPSHOT; + if (DISABLE_SNAPSHOT) { + this.snapshot = this.tileEntity; + } else { -+ this.snapshot = this.createSnapshot(this.tileEntity); ++ this.snapshot = this.createSnapshot(tileEntity); + } // copy tile entity data: - this.snapshot = this.createSnapshot(tileEntity); - this.load(snapshot); -+ if(this.snapshot != null) { ++ if (this.snapshot != null) { + this.load(this.snapshot); + } + // Paper end diff --git a/patches/server/Add-more-LimitedRegion-API.patch b/patches/server/Add-more-LimitedRegion-API.patch index 329d44247a..7aecd21af6 100644 --- a/patches/server/Add-more-LimitedRegion-API.patch +++ b/patches/server/Add-more-LimitedRegion-API.patch @@ -108,8 +108,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + public @NotNull T spawn(@NotNull Vector location, @NotNull Class clazz, @Nullable Consumer function, CreatureSpawnEvent.@NotNull SpawnReason reason) throws IllegalArgumentException { + net.minecraft.world.entity.Entity entity = getDelegate().getMinecraftWorld().getWorld().createEntity(location.toLocation(getWorld()), clazz); + Objects.requireNonNull(entity, "Cannot spawn null entity"); -+ if (entity instanceof Mob) { -+ ((Mob) entity).finalizeSpawn(getDelegate(), getDelegate().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null, null); ++ if (entity instanceof Mob mob) { ++ mob.finalizeSpawn(getDelegate(), getDelegate().getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.COMMAND, (SpawnGroupData) null, null); + } + + if (function != null) { @@ -219,25 +219,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBlockState.java @@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - return this.blockEntityTag != null; - } -+ // Paper start - Delegate to utility method @Override public BlockState getBlockState() { - Material stateMaterial = (this.material != Material.SHIELD) ? this.material : CraftMetaBlockState.shieldToBannerHack(this.blockEntityTag); // Only actually used for jigsaws - if (this.blockEntityTag != null) { - switch (this.material) { ++ // Paper start + return createBlockState(this.material, this.blockEntityTag); + } -+ + public static BlockState createBlockState(Material material, CompoundTag blockEntityTag) { + Material stateMaterial = (material != Material.SHIELD) ? material : CraftMetaBlockState.shieldToBannerHack(blockEntityTag); // Only actually used for jigsaws + if (blockEntityTag != null) { + switch (material) { ++ // Paper end case SHIELD: - this.blockEntityTag.putString("id", "banner"); -+ blockEntityTag.putString("id", "banner"); ++ blockEntityTag.putString("id", "banner"); // Paper break; case SHULKER_BOX: case WHITE_SHULKER_BOX: @@ -246,225 +244,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 case RED_SHULKER_BOX: case BLACK_SHULKER_BOX: - this.blockEntityTag.putString("id", "shulker_box"); -+ blockEntityTag.putString("id", "shulker_box"); ++ blockEntityTag.putString("id", "shulker_box"); // Paper break; case BEE_NEST: case BEEHIVE: - this.blockEntityTag.putString("id", "beehive"); -+ blockEntityTag.putString("id", "beehive"); ++ blockEntityTag.putString("id", "beehive"); // Paper break; } } - BlockPos blockposition = BlockPos.ZERO; - net.minecraft.world.level.block.state.BlockState iblockdata = CraftMagicNumbers.getBlock(stateMaterial).defaultBlockState(); -- BlockEntity te = (this.blockEntityTag == null) ? null : BlockEntity.loadStatic(blockposition, iblockdata, blockEntityTag); -+ BlockEntity te = (blockEntityTag == null) ? null : BlockEntity.loadStatic(blockposition, iblockdata, blockEntityTag); - -- switch (this.material) { -+ switch (material) { - case ACACIA_SIGN: - case ACACIA_WALL_SIGN: - case BIRCH_SIGN: -@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - if (te == null) { - te = new SignBlockEntity(blockposition, iblockdata); - } -- return new CraftSign(this.material, (SignBlockEntity) te); -+ return new CraftSign(material, (SignBlockEntity) te); - case CHEST: - case TRAPPED_CHEST: - if (te == null) { - te = new ChestBlockEntity(blockposition, iblockdata); - } -- return new CraftChest(this.material, (ChestBlockEntity) te); -+ return new CraftChest(material, (ChestBlockEntity) te); - case FURNACE: - if (te == null) { - te = new FurnaceBlockEntity(blockposition, iblockdata); - } -- return new CraftFurnaceFurnace(this.material, (FurnaceBlockEntity) te); -+ return new CraftFurnaceFurnace(material, (FurnaceBlockEntity) te); - case DISPENSER: - if (te == null) { - te = new DispenserBlockEntity(blockposition, iblockdata); - } -- return new CraftDispenser(this.material, (DispenserBlockEntity) te); -+ return new CraftDispenser(material, (DispenserBlockEntity) te); - case DROPPER: - if (te == null) { - te = new DropperBlockEntity(blockposition, iblockdata); - } -- return new CraftDropper(this.material, (DropperBlockEntity) te); -+ return new CraftDropper(material, (DropperBlockEntity) te); - case END_GATEWAY: - if (te == null) { - te = new TheEndGatewayBlockEntity(blockposition, iblockdata); - } -- return new CraftEndGateway(this.material, (TheEndGatewayBlockEntity) te); -+ return new CraftEndGateway(material, (TheEndGatewayBlockEntity) te); - case HOPPER: - if (te == null) { - te = new HopperBlockEntity(blockposition, iblockdata); - } -- return new CraftHopper(this.material, (HopperBlockEntity) te); -+ return new CraftHopper(material, (HopperBlockEntity) te); - case SPAWNER: - if (te == null) { - te = new SpawnerBlockEntity(blockposition, iblockdata); - } -- return new CraftCreatureSpawner(this.material, (SpawnerBlockEntity) te); -+ return new CraftCreatureSpawner(material, (SpawnerBlockEntity) te); - case JUKEBOX: - if (te == null) { - te = new JukeboxBlockEntity(blockposition, iblockdata); - } -- return new CraftJukebox(this.material, (JukeboxBlockEntity) te); -+ return new CraftJukebox(material, (JukeboxBlockEntity) te); - case BREWING_STAND: - if (te == null) { - te = new BrewingStandBlockEntity(blockposition, iblockdata); - } -- return new CraftBrewingStand(this.material, (BrewingStandBlockEntity) te); -+ return new CraftBrewingStand(material, (BrewingStandBlockEntity) te); - case CREEPER_HEAD: - case CREEPER_WALL_HEAD: - case DRAGON_HEAD: -@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - if (te == null) { - te = new SkullBlockEntity(blockposition, iblockdata); - } -- return new CraftSkull(this.material, (SkullBlockEntity) te); -+ return new CraftSkull(material, (SkullBlockEntity) te); - case COMMAND_BLOCK: - case REPEATING_COMMAND_BLOCK: - case CHAIN_COMMAND_BLOCK: - if (te == null) { - te = new CommandBlockEntity(blockposition, iblockdata); - } -- return new CraftCommandBlock(this.material, (CommandBlockEntity) te); -+ return new CraftCommandBlock(material, (CommandBlockEntity) te); - case BEACON: - if (te == null) { - te = new BeaconBlockEntity(blockposition, iblockdata); - } -- return new CraftBeacon(this.material, (BeaconBlockEntity) te); -+ return new CraftBeacon(material, (BeaconBlockEntity) te); - case SHIELD: - if (te == null) { - te = new BannerBlockEntity(blockposition, iblockdata); - } -- ((BannerBlockEntity) te).baseColor = (this.blockEntityTag == null) ? DyeColor.WHITE : DyeColor.byId(this.blockEntityTag.getInt(CraftMetaBanner.BASE.NBT)); -+ ((BannerBlockEntity) te).baseColor = (blockEntityTag == null) ? DyeColor.WHITE : DyeColor.byId(blockEntityTag.getInt(CraftMetaBanner.BASE.NBT)); - case BLACK_BANNER: - case BLACK_WALL_BANNER: - case BLUE_BANNER: -@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - if (te == null) { - te = new BannerBlockEntity(blockposition, iblockdata); - } -- return new CraftBanner(this.material == Material.SHIELD ? CraftMetaBlockState.shieldToBannerHack(this.blockEntityTag) : this.material, (BannerBlockEntity) te); -+ return new CraftBanner(material == Material.SHIELD ? CraftMetaBlockState.shieldToBannerHack(blockEntityTag) : material, (BannerBlockEntity) te); - case STRUCTURE_BLOCK: - if (te == null) { - te = new StructureBlockEntity(blockposition, iblockdata); - } -- return new CraftStructureBlock(this.material, (StructureBlockEntity) te); -+ return new CraftStructureBlock(material, (StructureBlockEntity) te); - case SHULKER_BOX: - case WHITE_SHULKER_BOX: - case ORANGE_SHULKER_BOX: -@@ -0,0 +0,0 @@ public class CraftMetaBlockState extends CraftMetaItem implements BlockStateMeta - if (te == null) { - te = new ShulkerBoxBlockEntity(blockposition, iblockdata); - } -- return new CraftShulkerBox(this.material, (ShulkerBoxBlockEntity) te); -+ return new CraftShulkerBox(material, (ShulkerBoxBlockEntity) te); - case ENCHANTING_TABLE: - if (te == null) { - te = new EnchantmentTableBlockEntity(blockposition, iblockdata); - } -- return new CraftEnchantingTable(this.material, (EnchantmentTableBlockEntity) te); -+ return new CraftEnchantingTable(material, (EnchantmentTableBlockEntity) te); - case ENDER_CHEST: - if (te == null) { - te = new EnderChestBlockEntity(blockposition, iblockdata); - } -- return new CraftEnderChest(this.material, (EnderChestBlockEntity) te); -+ return new CraftEnderChest(material, (EnderChestBlockEntity) te); - case DAYLIGHT_DETECTOR: - if (te == null) { - te = new DaylightDetectorBlockEntity(blockposition, iblockdata); - } -- return new CraftDaylightDetector(this.material, (DaylightDetectorBlockEntity) te); -+ return new CraftDaylightDetector(material, (DaylightDetectorBlockEntity) te); - case COMPARATOR: - if (te == null) { - te = new ComparatorBlockEntity(blockposition, iblockdata); - } -- return new CraftComparator(this.material, (ComparatorBlockEntity) te); -+ return new CraftComparator(material, (ComparatorBlockEntity) te); - case BARREL: - if (te == null) { - te = new BarrelBlockEntity(blockposition, iblockdata); - } -- return new CraftBarrel(this.material, (BarrelBlockEntity) te); -+ return new CraftBarrel(material, (BarrelBlockEntity) te); - case BELL: - if (te == null) { - te = new BellBlockEntity(blockposition, iblockdata); - } -- return new CraftBell(this.material, (BellBlockEntity) te); -+ return new CraftBell(material, (BellBlockEntity) te); - case BLAST_FURNACE: - if (te == null) { - te = new BlastFurnaceBlockEntity(blockposition, iblockdata); - } -- return new CraftBlastFurnace(this.material, (BlastFurnaceBlockEntity) te); -+ return new CraftBlastFurnace(material, (BlastFurnaceBlockEntity) te); - case CAMPFIRE: - case SOUL_CAMPFIRE: - if (te == null) { - te = new CampfireBlockEntity(blockposition, iblockdata); - } -- return new CraftCampfire(this.material, (CampfireBlockEntity) te); -+ return new CraftCampfire(material, (CampfireBlockEntity) te); - case JIGSAW: - if (te == null) { - te = new JigsawBlockEntity(blockposition, iblockdata); - } -- return new CraftJigsaw(this.material, (JigsawBlockEntity) te); -+ return new CraftJigsaw(material, (JigsawBlockEntity) te); - case LECTERN: - if (te == null) { - te = new LecternBlockEntity(blockposition, iblockdata); - } -- return new CraftLectern(this.material, (LecternBlockEntity) te); -+ return new CraftLectern(material, (LecternBlockEntity) te); - case SMOKER: - if (te == null) { - te = new SmokerBlockEntity(blockposition, iblockdata); - } -- return new CraftSmoker(this.material, (SmokerBlockEntity) te); -+ return new CraftSmoker(material, (SmokerBlockEntity) te); - case BEE_NEST: - case BEEHIVE: - if (te == null) { - te = new BeehiveBlockEntity(blockposition, iblockdata); - } -- return new CraftBeehive(this.material, (BeehiveBlockEntity) te); -+ return new CraftBeehive(material, (BeehiveBlockEntity) te); - case SCULK_SENSOR: - if (te == null) { - te = new SculkSensorBlockEntity(blockposition, iblockdata); - } -- return new CraftSculkSensor(this.material, (SculkSensorBlockEntity) te); -+ return new CraftSculkSensor(material, (SculkSensorBlockEntity) te); - default: -- throw new IllegalStateException("Missing blockState for " + this.material); -+ throw new IllegalStateException("Missing blockState for " + material); - } - } -+ // Paper end - - @Override - public void setBlockState(BlockState blockState) { diff --git a/patches/server/Added-Vanilla-Entity-Tags.patch b/patches/server/Added-Vanilla-Entity-Tags.patch index 1ac4368de4..a0c31830c9 100644 --- a/patches/server/Added-Vanilla-Entity-Tags.patch +++ b/patches/server/Added-Vanilla-Entity-Tags.patch @@ -22,6 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.TagCollection; + ++@Deprecated(forRemoval = true) +public class CraftEntityTag extends CraftTag, EntityType> { + + public CraftEntityTag(TagCollection> registry, ResourceLocation tag) { @@ -43,9 +44,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - Preconditions.checkArgument(clazz == org.bukkit.Fluid.class, "Fluid namespace must have fluid type"); + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity type namespace must have entity type"); - return (org.bukkit.Tag) new CraftFluidTag(FluidTags.getAllTags(), key); + return (org.bukkit.Tag) new CraftEntityTag(EntityTypeTags.getAllTags(), key); + // Paper start + case org.bukkit.Tag.REGISTRY_ENTITIES: + Preconditions.checkArgument(clazz == org.bukkit.entity.EntityType.class, "Entity namespace must have entitytype type"); diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index fe4d6acf5c..c0193f34f6 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -1976,7 +1976,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnchantingTable.java @@ -0,0 +0,0 @@ public class CraftEnchantingTable extends CraftBlockEntityState lines = null; // ArrayList for RandomAccess + // Paper end - public CraftSign(final Block block) { - super(block, SignBlockEntity.class); -@@ -0,0 +0,0 @@ public class CraftSign extends CraftBlockEntityState implements - super(material, te); + public CraftSign(World world, SignBlockEntity tileEntity) { + super(world, tileEntity); } + // Paper start diff --git a/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch b/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch index 18651a90e6..3db0ed6ee0 100644 --- a/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch +++ b/patches/server/Configurable-Keep-Spawn-Loaded-range-per-world.patch @@ -243,7 +243,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else { - // TODO: doesn't work well if spawn changed.... - this.world.getChunkSource().removeRegionTicket(TicketType.START, new ChunkPos(chunkcoordinates), 11, Unit.INSTANCE); -+ // TODO: doesn't work well if spawn changed.... // paper - resolved ++ // TODO: doesn't work well if spawn changed.... // Paper - resolved + this.world.removeTicketsForSpawn(this.world.paperConfig.keepLoadedRange, chunkcoordinates); } + // Paper end diff --git a/patches/server/Configurable-fishing-time-ranges.patch b/patches/server/Configurable-fishing-time-ranges.patch index bbf1a9c7ed..0afcaef990 100644 --- a/patches/server/Configurable-fishing-time-ranges.patch +++ b/patches/server/Configurable-fishing-time-ranges.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + minWaitTime = world.paperConfig.fishingMinTicks; + maxWaitTime = world.paperConfig.fishingMaxTicks; -+ // paper end ++ // Paper end } public FishingHook(EntityType type, Level world) { diff --git a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch b/patches/server/Implement-EntityTeleportEndGatewayEvent.patch index c58488a4f5..5868d2c1d4 100644 --- a/patches/server/Implement-EntityTeleportEndGatewayEvent.patch +++ b/patches/server/Implement-EntityTeleportEndGatewayEvent.patch @@ -18,7 +18,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + location.setPitch(bukkitEntity.getLocation().getPitch()); + location.setYaw(bukkitEntity.getLocation().getYaw()); + -+ com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(MCUtil.toLocation(world, blockEntity.getBlockPos()).getBlock())); ++ com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent event = new com.destroystokyo.paper.event.entity.EntityTeleportEndGatewayEvent(bukkitEntity, bukkitEntity.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(world.getWorld(), blockEntity)); + if (!event.callEvent()) { + return; + } diff --git a/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch index 57db3aad8a..9ad1a3a1cf 100644 --- a/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch +++ b/patches/server/LootTable-API-Replenishable-Lootables-Feature.patch @@ -654,8 +654,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 -public class CraftChest extends CraftLootable implements Chest { +public class CraftChest extends CraftLootable implements Chest, PaperLootableBlockInventory { // Paper - public CraftChest(final Block block) { - super(block, ChestBlockEntity.class); + public CraftChest(World world, ChestBlockEntity tileEntity) { + super(world, tileEntity); diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java @@ -667,8 +667,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 -public abstract class CraftLootable extends CraftContainer implements Nameable, Lootable { +public abstract class CraftLootable extends CraftContainer implements Nameable, Lootable, com.destroystokyo.paper.loottable.PaperLootableBlockInventory { // Paper - public CraftLootable(Block block, Class tileEntityClass) { - super(block, tileEntityClass); + public CraftLootable(World world, T tileEntity) { + super(world, tileEntity); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartChest.java diff --git a/patches/server/More-CommmandBlock-API.patch b/patches/server/More-CommmandBlock-API.patch index a60a7b0222..1499624bb9 100644 --- a/patches/server/More-CommmandBlock-API.patch +++ b/patches/server/More-CommmandBlock-API.patch @@ -47,15 +47,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java b index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCommandBlock.java -@@ -0,0 +0,0 @@ import org.bukkit.block.Block; +@@ -0,0 +0,0 @@ import org.bukkit.World; import org.bukkit.block.CommandBlock; import org.bukkit.craftbukkit.util.CraftChatMessage; -public class CraftCommandBlock extends CraftBlockEntityState implements CommandBlock { +public class CraftCommandBlock extends CraftBlockEntityState implements CommandBlock, io.papermc.paper.commands.PaperCommandBlockHolder { - public CraftCommandBlock(Block block) { - super(block, CommandBlockEntity.class); + public CraftCommandBlock(World world, CommandBlockEntity tileEntity) { + super(world, tileEntity); @@ -0,0 +0,0 @@ public class CraftCommandBlock extends CraftBlockEntityState public void name(net.kyori.adventure.text.Component name) { getSnapshot().getCommandBlock().setName(name == null ? new net.minecraft.network.chat.TextComponent("@") : io.papermc.paper.adventure.PaperAdventure.asVanilla(name)); diff --git a/patches/server/More-Lidded-Block-API.patch b/patches/server/More-Lidded-Block-API.patch index b68df38173..4cde4e2019 100644 --- a/patches/server/More-Lidded-Block-API.patch +++ b/patches/server/More-Lidded-Block-API.patch @@ -41,8 +41,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftEnderChest.java @@ -0,0 +0,0 @@ public class CraftEnderChest extends CraftBlockEntityState implem if (getTileEntity().opened && getWorldHandle() instanceof net.minecraft.world.level.Level) { - Level world = getTileEntity().getLevel(); + net.minecraft.world.level.Level world = getTileEntity().getLevel(); world.blockEvent(getPosition(), getTileEntity().getBlockState().getBlock(), 1, 0); - world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); + world.playSound(null, getPosition(), SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, world.random.nextFloat() * 0.1F + 0.9F); // Paper - More Lidded Block API (Wrong sound) diff --git a/patches/server/PlayerTeleportEndGatewayEvent.patch b/patches/server/PlayerTeleportEndGatewayEvent.patch index 5d924f0568..bc397f8ce6 100644 --- a/patches/server/PlayerTeleportEndGatewayEvent.patch +++ b/patches/server/PlayerTeleportEndGatewayEvent.patch @@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 location.setYaw(player.getLocation().getYaw()); - PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY); -+ PlayerTeleportEvent teleEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(player, player.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(net.minecraft.server.MCUtil.toLocation(worldserver, blockEntity.getBlockPos()).getBlock())); // Paper ++ PlayerTeleportEvent teleEvent = new com.destroystokyo.paper.event.player.PlayerTeleportEndGatewayEvent(player, player.getLocation(), location, new org.bukkit.craftbukkit.block.CraftEndGateway(worldserver.getWorld(), blockEntity)); // Paper Bukkit.getPluginManager().callEvent(teleEvent); if (teleEvent.isCancelled()) { return; diff --git a/patches/server/Show-blockstate-location-if-we-failed-to-read-it.patch b/patches/server/Show-blockstate-location-if-we-failed-to-read-it.patch index 07166c991d..7003b3ec47 100644 --- a/patches/server/Show-blockstate-location-if-we-failed-to-read-it.patch +++ b/patches/server/Show-blockstate-location-if-we-failed-to-read-it.patch @@ -8,16 +8,15 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.ja index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlockEntityState.java -@@ -0,0 +0,0 @@ public class CraftBlockEntityState extends CraftBlockStat - public CraftBlockEntityState(Block block, Class tileEntityClass) { - super(block); +@@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft -+ try {// Paper - show location on failure -+ - this.tileEntityClass = tileEntityClass; + this.tileEntity = tileEntity; - // get tile entity from block: -@@ -0,0 +0,0 @@ public class CraftBlockEntityState extends CraftBlockStat ++ try { // Paper - show location on failure + // Paper start + this.snapshotDisabled = DISABLE_SNAPSHOT; + if (DISABLE_SNAPSHOT) { +@@ -0,0 +0,0 @@ public abstract class CraftBlockEntityState extends Craft this.load(this.snapshot); } // Paper end @@ -26,9 +25,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (thr instanceof ThreadDeath) { + throw (ThreadDeath)thr; + } -+ throw new RuntimeException("Failed to read BlockState at: world: " + block.getWorld().getName() + " location: (" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")", thr); ++ throw new RuntimeException("Failed to read BlockState at: world: " + this.getWorld().getName() + " location: (" + this.getX() + ", " + this.getY() + ", " + this.getZ() + ")", thr); + } + // Paper end } - public final boolean snapshotDisabled; // Paper + public void refreshSnapshot() { diff --git a/patches/server/add-DragonEggFormEvent.patch b/patches/server/add-DragonEggFormEvent.patch index db6e96e172..6e1a0ebc83 100644 --- a/patches/server/add-DragonEggFormEvent.patch +++ b/patches/server/add-DragonEggFormEvent.patch @@ -15,7 +15,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start - DragonEggFormEvent + BlockPos eggPosition = this.level.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, EndPodiumFeature.END_PODIUM_LOCATION); + org.bukkit.craftbukkit.block.CraftBlock eggBlock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, eggPosition); -+ org.bukkit.craftbukkit.block.CraftBlockState eggState = new org.bukkit.craftbukkit.block.CraftBlockState(eggBlock); ++ org.bukkit.craftbukkit.block.CraftBlockState eggState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(this.level, eggPosition); + eggState.setData(Blocks.DRAGON_EGG.defaultBlockState()); + io.papermc.paper.event.block.DragonEggFormEvent eggEvent = new io.papermc.paper.event.block.DragonEggFormEvent(eggBlock, eggState, + new org.bukkit.craftbukkit.boss.CraftDragonBattle(this)); diff --git a/patches/server/force-entity-dismount-during-teleportation.patch b/patches/server/force-entity-dismount-during-teleportation.patch index 2224f223c2..9416c67f2f 100644 --- a/patches/server/force-entity-dismount-during-teleportation.patch +++ b/patches/server/force-entity-dismount-during-teleportation.patch @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + // Paper start + @Override public void stopRiding() { stopRiding(false); } + @Override public void stopRiding(boolean suppressCancellation) { -+ // paper end ++ // Paper end Entity entity = this.getVehicle(); - super.stopRiding(); diff --git a/work/Bukkit b/work/Bukkit index 44cfe1432d..19e985ecaf 160000 --- a/work/Bukkit +++ b/work/Bukkit @@ -1 +1 @@ -Subproject commit 44cfe1432dda2c12c919dcf63536d12cde650fe0 +Subproject commit 19e985ecaf424e77845a8e136b7e17b94e8a65ee diff --git a/work/CraftBukkit b/work/CraftBukkit index 1492826118..dc764e7a2f 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 149282611823e75c181316159665e9d2b54bf3de +Subproject commit dc764e7a2f9272e72a3f37c6770c9c0f7ea83d43