From 0cf731589a3b6923542cdfc36dbcee9c47c51076 Mon Sep 17 00:00:00 2001 From: Bjarne Koll Date: Mon, 7 Apr 2025 13:29:57 +0200 Subject: [PATCH 01/34] Bump to adventure 4.20.0 (#12391) * Update adventure to 4.19.0 The update only includes a new configuration for MiniMessage, specifically one to prevent it from emitting virtual components. As virtual components break the generated component tree, items quickly become unstackable with items generated before adventure 4.18. Plugin developers may construct their own mini message instance which will emit virtual components if they so choose. * Bump to adventure 4.20.0 --- paper-api/build.gradle.kts | 2 +- .../paper/adventure/providers/MiniMessageProviderImpl.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index e86b16b6c..f6ca09925 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -11,7 +11,7 @@ java { val annotationsVersion = "26.0.1" val bungeeCordChatVersion = "1.20-R0.2" -val adventureVersion = "4.18.0" +val adventureVersion = "4.20.0" val slf4jVersion = "2.0.9" val log4jVersion = "2.17.1" diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java b/paper-server/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java index 25fd6992c..61846abbe 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/providers/MiniMessageProviderImpl.java @@ -10,7 +10,7 @@ public class MiniMessageProviderImpl implements MiniMessage.Provider { @Override public @NotNull MiniMessage miniMessage() { - return MiniMessage.builder().build(); + return MiniMessage.builder().emitVirtuals(false).build(); } @Override From 0767902699165a1cdb1977f555acbd8245de7c47 Mon Sep 17 00:00:00 2001 From: Shane Bee Date: Fri, 11 Apr 2025 14:38:33 -0700 Subject: [PATCH 02/34] CraftBlock - fix applyBoneMeal false result (#12407) --- .../src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java index 5cb69d0b8..02e8a49d2 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -577,7 +577,7 @@ public class CraftBlock implements Block { } } - return result == InteractionResult.CONSUME && (event == null || !event.isCancelled()); // Paper - CONSUME is returned on success server-side (see BoneMealItem.applyBoneMeal and InteractionResult.sidedSuccess(boolean)) + return result == InteractionResult.SUCCESS && (event == null || !event.isCancelled()); } @Override From f00727c57e564f3a8cb875183a54142feb693db7 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 12 Apr 2025 17:26:44 +0200 Subject: [PATCH 03/34] 1.21.5 Co-authored-by: Bjarne Koll Co-authored-by: Jake Potrebic Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Co-authored-by: MiniDigger | Martin Co-authored-by: Nassim Jahnke Co-authored-by: Noah van der Aa Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Co-authored-by: Shane Freeder Co-authored-by: Spottedleaf Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com> Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com> --- .editorconfig | 4 +- .github/workflows/build.yml | 4 + .gitignore | 2 +- README.md | 4 +- build-data/paper.at | 84 +- build.gradle.kts | 2 +- gradle.properties | 6 +- paper-api-generator/build.gradle.kts | 37 - .../java/io/papermc/generator/Generators.java | 96 - .../main/java/io/papermc/generator/Main.java | 93 - .../generator/types/GeneratedKeyType.java | 204 - .../generator/types/GeneratedTagKeyType.java | 138 - .../papermc/generator/utils/Annotations.java | 65 - .../io/papermc/generator/utils/Javadocs.java | 27 - .../papermc/generator/utils/TagCollector.java | 79 - paper-api/build.gradle.kts | 66 +- .../paper/entity/ai/VanillaGoal.java | 2 +- .../paper/registry/keys/AttributeKeys.java | 2 +- .../registry/keys/BannerPatternKeys.java | 4 +- .../paper/registry/keys/BiomeKeys.java | 4 +- .../paper/registry/keys/BlockTypeKeys.java | 65 +- .../paper/registry/keys/CatVariantKeys.java | 10 +- .../registry/keys/ChickenVariantKeys.java | 61 + .../paper/registry/keys/CowVariantKeys.java | 61 + .../paper/registry/keys/DamageTypeKeys.java | 4 +- .../registry/keys/DataComponentTypeKeys.java | 706 +++ .../paper/registry/keys/EnchantmentKeys.java | 4 +- .../paper/registry/keys/FluidKeys.java | 2 +- .../paper/registry/keys/FrogVariantKeys.java | 10 +- .../paper/registry/keys/GameEventKeys.java | 4 +- .../paper/registry/keys/InstrumentKeys.java | 4 +- .../paper/registry/keys/ItemTypeKeys.java | 795 +-- .../paper/registry/keys/JukeboxSongKeys.java | 4 +- .../registry/keys/MapDecorationTypeKeys.java | 2 +- .../paper/registry/keys/MenuTypeKeys.java | 2 +- .../paper/registry/keys/MobEffectKeys.java | 2 +- .../registry/keys/PaintingVariantKeys.java | 4 +- .../paper/registry/keys/PigVariantKeys.java | 61 + .../paper/registry/keys/SoundEventKeys.java | 373 +- .../paper/registry/keys/StructureKeys.java | 4 +- .../registry/keys/StructureTypeKeys.java | 2 +- .../paper/registry/keys/TrimMaterialKeys.java | 4 +- .../paper/registry/keys/TrimPatternKeys.java | 4 +- .../registry/keys/VillagerProfessionKeys.java | 2 +- .../paper/registry/keys/VillagerTypeKeys.java | 2 +- .../registry/keys/WolfSoundVariantKeys.java | 89 + .../paper/registry/keys/WolfVariantKeys.java | 4 +- .../keys/tags/BannerPatternTagKeys.java | 4 +- .../registry/keys/tags/BiomeTagKeys.java | 18 +- .../registry/keys/tags/BlockTypeTagKeys.java | 53 +- .../registry/keys/tags/CatVariantTagKeys.java | 57 - .../registry/keys/tags/DamageTypeTagKeys.java | 4 +- .../keys/tags/EnchantmentTagKeys.java | 4 +- .../registry/keys/tags/EntityTypeTagKeys.java | 18 +- .../registry/keys/tags/FluidTagKeys.java | 4 +- .../registry/keys/tags/GameEventTagKeys.java | 4 +- .../registry/keys/tags/InstrumentTagKeys.java | 4 +- .../registry/keys/tags/ItemTypeTagKeys.java | 25 +- .../keys/tags/PaintingVariantTagKeys.java | 4 +- .../registry/keys/tags/StructureTagKeys.java | 19 +- .../java/co/aikar/timings/TimingHistory.java | 2 +- .../java/co/aikar/timings/TimingsManager.java | 6 +- .../destroystokyo/paper/NamespacedTag.java | 4 +- .../paper/entity/ai/GoalKey.java | 8 +- .../paper/event/block/BeaconEffectEvent.java | 4 +- .../paper/event/block/BlockDestroyEvent.java | 4 +- .../paper/event/block/TNTPrimeEvent.java | 4 +- .../event/player/PlayerHandshakeEvent.java | 52 +- .../paper/event/player/PlayerJumpEvent.java | 4 +- .../event/player/PlayerSetSpawnEvent.java | 2 +- .../paper/network/NetworkClient.java | 2 +- .../io/papermc/paper/InternalAPIBridge.java | 10 + .../paper/block/LockableTileState.java | 2 +- .../paper/brigadier/PaperBrigadier.java | 1 + .../datacomponent/DataComponentHolder.java | 48 + .../datacomponent/DataComponentTypes.java | 82 +- .../datacomponent/DataComponentView.java | 65 + .../datacomponent/item/BlocksAttacks.java | 68 + .../datacomponent/item/DyedItemColor.java | 8 +- .../paper/datacomponent/item/Equippable.java | 17 + .../item/ItemAdventurePredicate.java | 5 +- .../datacomponent/item/ItemArmorTrim.java | 9 +- .../item/ItemAttributeModifiers.java | 4 +- .../item/ItemComponentTypesBridge.java | 8 +- .../datacomponent/item/ItemEnchantments.java | 8 +- .../datacomponent/item/JukeboxPlayable.java | 4 +- .../datacomponent/item/ShownInTooltip.java | 55 - .../paper/datacomponent/item/Tool.java | 18 + .../datacomponent/item/TooltipDisplay.java | 46 + .../paper/datacomponent/item/Unbreakable.java | 34 - .../paper/datacomponent/item/Weapon.java | 54 + .../item/consumable/ItemUseAnimation.java | 5 +- .../event/block/BeaconActivatedEvent.java | 4 +- .../event/block/BeaconDeactivatedEvent.java | 4 +- .../event/block/BellRevealRaiderEvent.java | 4 +- .../event/block/BlockFailedDispenseEvent.java | 4 +- .../event/entity/EntityFertilizeEggEvent.java | 4 +- .../paper/event/player/AbstractChatEvent.java | 6 +- .../event/player/AsyncChatDecorateEvent.java | 2 +- .../player/PlayerClientLoadedWorldEvent.java | 4 +- .../papermc/paper/registry/RegistryKey.java | 47 +- .../paper/registry/event/RegistryEvents.java | 9 +- paper-api/src/main/java/org/bukkit/Art.java | 118 +- .../src/main/java/org/bukkit/Bukkit.java | 29 +- paper-api/src/main/java/org/bukkit/Chunk.java | 14 +- paper-api/src/main/java/org/bukkit/Color.java | 12 +- .../main/java/org/bukkit/EntityEffect.java | 24 +- .../src/main/java/org/bukkit/FeatureFlag.java | 41 +- paper-api/src/main/java/org/bukkit/Fluid.java | 28 +- .../src/main/java/org/bukkit/GameEvent.java | 230 +- .../src/main/java/org/bukkit/GameRule.java | 8 + .../src/main/java/org/bukkit/JukeboxSong.java | 59 +- .../src/main/java/org/bukkit/Material.java | 5456 +++++------------ .../main/java/org/bukkit/MusicInstrument.java | 20 +- .../src/main/java/org/bukkit/Nameable.java | 2 - .../main/java/org/bukkit/NamespacedKey.java | 2 +- .../main/java/org/bukkit/OfflinePlayer.java | 5 +- .../src/main/java/org/bukkit/Particle.java | 12 +- paper-api/src/main/java/org/bukkit/Raid.java | 3 + .../src/main/java/org/bukkit/Registry.java | 14 +- .../src/main/java/org/bukkit/Server.java | 17 +- paper-api/src/main/java/org/bukkit/Sound.java | 2185 ++++++- .../src/main/java/org/bukkit/Statistic.java | 145 +- paper-api/src/main/java/org/bukkit/Tag.java | 2217 +++---- .../main/java/org/bukkit/UnsafeValues.java | 8 +- paper-api/src/main/java/org/bukkit/World.java | 16 +- .../bukkit/attribute/AttributeModifier.java | 1 - .../src/main/java/org/bukkit/block/Bell.java | 12 +- .../src/main/java/org/bukkit/block/Biome.java | 192 +- .../src/main/java/org/bukkit/block/Block.java | 2 +- .../main/java/org/bukkit/block/BlockType.java | 5427 +++++++--------- .../main/java/org/bukkit/block/Campfire.java | 2 - .../java/org/bukkit/block/CommandBlock.java | 20 +- .../java/org/bukkit/block/Orientation.java | 20 + .../main/java/org/bukkit/block/TestBlock.java | 7 + .../org/bukkit/block/TestInstanceBlock.java | 7 + .../main/java/org/bukkit/block/TileState.java | 20 +- .../org/bukkit/block/banner/PatternType.java | 122 +- .../org/bukkit/block/data/Segmentable.java | 35 + .../block/data/type/CaveVinesPlant.java | 13 +- .../org/bukkit/block/data/type/Crafter.java | 9 +- .../bukkit/block/data/type/CreakingHeart.java | 36 +- .../bukkit/block/data/type/DecoratedPot.java | 19 +- .../org/bukkit/block/data/type/FlowerBed.java | 39 + .../org/bukkit/block/data/type/Jigsaw.java | 9 +- .../org/bukkit/block/data/type/Jukebox.java | 7 + .../bukkit/block/data/type/LeafLitter.java | 6 + .../org/bukkit/block/data/type/Lectern.java | 7 + .../bukkit/block/data/type/MossyCarpet.java | 9 +- .../bukkit/block/data/type/PinkPetals.java | 36 +- .../bukkit/block/data/type/SculkSensor.java | 27 +- .../org/bukkit/block/data/type/Switch.java | 13 +- .../org/bukkit/block/data/type/TestBlock.java | 32 + .../org/bukkit/block/data/type/Vault.java | 8 +- .../command/defaults/VersionCommand.java | 8 +- .../configuration/file/FileConfiguration.java | 6 +- .../java/org/bukkit/damage/DamageType.java | 149 +- .../enchantments/EnchantmentTarget.java | 3 + .../java/org/bukkit/entity/AbstractCow.java | 14 + .../org/bukkit/entity/AreaEffectCloud.java | 2 +- .../java/org/bukkit/entity/ArmorStand.java | 4 +- .../src/main/java/org/bukkit/entity/Boat.java | 5 +- .../src/main/java/org/bukkit/entity/Cat.java | 43 +- .../main/java/org/bukkit/entity/Chicken.java | 42 +- .../src/main/java/org/bukkit/entity/Cow.java | 43 +- .../java/org/bukkit/entity/Damageable.java | 2 - .../main/java/org/bukkit/entity/Dolphin.java | 9 +- .../main/java/org/bukkit/entity/Entity.java | 43 +- .../java/org/bukkit/entity/EntityType.java | 410 +- .../main/java/org/bukkit/entity/Evoker.java | 2 - .../java/org/bukkit/entity/FallingBlock.java | 2 +- .../src/main/java/org/bukkit/entity/Fox.java | 3 + .../src/main/java/org/bukkit/entity/Frog.java | 26 +- .../main/java/org/bukkit/entity/Ghast.java | 2 - .../src/main/java/org/bukkit/entity/Goat.java | 2 - .../java/org/bukkit/entity/HumanEntity.java | 17 +- .../org/bukkit/entity/LingeringPotion.java | 7 +- .../java/org/bukkit/entity/LivingEntity.java | 24 - .../java/org/bukkit/entity/MushroomCow.java | 2 +- .../main/java/org/bukkit/entity/Panda.java | 3 + .../main/java/org/bukkit/entity/Phantom.java | 17 +- .../src/main/java/org/bukkit/entity/Pig.java | 43 +- .../java/org/bukkit/entity/PigZombie.java | 19 +- .../main/java/org/bukkit/entity/Piglin.java | 2 - .../main/java/org/bukkit/entity/Player.java | 72 +- .../java/org/bukkit/entity/PolarBear.java | 2 - .../main/java/org/bukkit/entity/Ravager.java | 2 - .../main/java/org/bukkit/entity/Salmon.java | 12 +- .../main/java/org/bukkit/entity/Skeleton.java | 2 - .../java/org/bukkit/entity/SkeletonHorse.java | 10 +- .../main/java/org/bukkit/entity/Slime.java | 2 - .../main/java/org/bukkit/entity/Sniffer.java | 3 + .../java/org/bukkit/entity/SplashPotion.java | 7 +- .../java/org/bukkit/entity/TNTPrimed.java | 2 - .../main/java/org/bukkit/entity/Tadpole.java | 2 - .../java/org/bukkit/entity/TextDisplay.java | 2 - .../java/org/bukkit/entity/TropicalFish.java | 3 + .../main/java/org/bukkit/entity/Villager.java | 30 +- .../org/bukkit/entity/WanderingTrader.java | 2 - .../main/java/org/bukkit/entity/Warden.java | 2 - .../main/java/org/bukkit/entity/Wither.java | 2 - .../src/main/java/org/bukkit/entity/Wolf.java | 66 +- .../main/java/org/bukkit/entity/Zombie.java | 2 - .../org/bukkit/entity/memory/MemoryKey.java | 107 +- .../entity/minecart/ExplosiveMinecart.java | 2 +- .../java/org/bukkit/event/Cancellable.java | 8 +- .../src/main/java/org/bukkit/event/Event.java | 32 +- .../java/org/bukkit/event/EventException.java | 2 +- .../java/org/bukkit/event/EventHandler.java | 2 +- .../java/org/bukkit/event/EventPriority.java | 2 +- .../java/org/bukkit/event/HandlerList.java | 13 +- .../bukkit/event/block/BellResonateEvent.java | 17 +- .../org/bukkit/event/block/BellRingEvent.java | 14 +- .../bukkit/event/block/BlockBreakEvent.java | 34 +- .../bukkit/event/block/BlockBurnEvent.java | 15 +- .../event/block/BlockCanBuildEvent.java | 99 +- .../bukkit/event/block/BlockCookEvent.java | 48 +- .../event/block/BlockDamageAbortEvent.java | 12 +- .../bukkit/event/block/BlockDamageEvent.java | 61 +- .../event/block/BlockDispenseArmorEvent.java | 6 +- .../event/block/BlockDispenseEvent.java | 37 +- .../event/block/BlockDispenseLootEvent.java | 31 +- .../event/block/BlockDropItemEvent.java | 67 +- .../org/bukkit/event/block/BlockEvent.java | 7 +- .../org/bukkit/event/block/BlockExpEvent.java | 12 +- .../bukkit/event/block/BlockExplodeEvent.java | 46 +- .../bukkit/event/block/BlockFadeEvent.java | 21 +- .../event/block/BlockFertilizeEvent.java | 25 +- .../bukkit/event/block/BlockFormEvent.java | 11 +- .../bukkit/event/block/BlockFromToEvent.java | 33 +- .../bukkit/event/block/BlockGrowEvent.java | 20 +- .../bukkit/event/block/BlockIgniteEvent.java | 68 +- .../event/block/BlockMultiPlaceEvent.java | 6 +- .../bukkit/event/block/BlockPhysicsEvent.java | 35 +- .../bukkit/event/block/BlockPistonEvent.java | 33 +- .../event/block/BlockPistonExtendEvent.java | 23 +- .../event/block/BlockPistonRetractEvent.java | 18 +- .../bukkit/event/block/BlockPlaceEvent.java | 101 +- .../event/block/BlockReceiveGameEvent.java | 20 +- .../event/block/BlockRedstoneEvent.java | 14 +- .../event/block/BlockShearEntityEvent.java | 68 +- .../bukkit/event/block/BlockSpreadEvent.java | 14 +- .../bukkit/event/block/BrewingStartEvent.java | 35 +- .../event/block/CampfireStartEvent.java | 14 +- .../event/block/CauldronLevelChangeEvent.java | 35 +- .../bukkit/event/block/CrafterCraftEvent.java | 21 +- .../event/block/EntityBlockFormEvent.java | 5 +- .../event/block/FluidLevelChangeEvent.java | 22 +- .../event/block/InventoryBlockStartEvent.java | 13 +- .../bukkit/event/block/LeavesDecayEvent.java | 18 +- .../event/block/MoistureChangeEvent.java | 17 +- .../org/bukkit/event/block/NotePlayEvent.java | 103 +- .../bukkit/event/block/SculkBloomEvent.java | 20 +- .../bukkit/event/block/SignChangeEvent.java | 54 +- .../bukkit/event/block/SpongeAbsorbEvent.java | 17 +- .../org/bukkit/event/block/TNTPrimeEvent.java | 46 +- .../event/block/VaultDisplayItemEvent.java | 20 +- .../event/enchantment/EnchantItemEvent.java | 48 +- .../enchantment/PrepareItemEnchantEvent.java | 48 +- .../entity/AreaEffectCloudApplyEvent.java | 39 +- .../entity/ArrowBodyCountChangeEvent.java | 29 +- .../event/entity/BatToggleSleepEvent.java | 27 +- .../event/entity/CreatureSpawnEvent.java | 11 +- .../event/entity/CreeperPowerEvent.java | 48 +- .../entity/EnderDragonChangePhaseEvent.java | 24 +- .../event/entity/EntityAirChangeEvent.java | 19 +- .../event/entity/EntityBreakDoorEvent.java | 10 +- .../bukkit/event/entity/EntityBreedEvent.java | 42 +- .../event/entity/EntityChangeBlockEvent.java | 44 +- .../entity/EntityCombustByBlockEvent.java | 6 +- .../entity/EntityCombustByEntityEvent.java | 4 +- .../event/entity/EntityCombustEvent.java | 39 +- .../event/entity/EntityCreatePortalEvent.java | 47 +- .../entity/EntityDamageByBlockEvent.java | 14 +- .../entity/EntityDamageByEntityEvent.java | 35 +- .../event/entity/EntityDamageEvent.java | 156 +- .../bukkit/event/entity/EntityDeathEvent.java | 98 +- .../event/entity/EntityDismountEvent.java | 35 +- .../event/entity/EntityDropItemEvent.java | 19 +- .../event/entity/EntityEnterBlockEvent.java | 20 +- .../entity/EntityEnterLoveModeEvent.java | 24 +- .../org/bukkit/event/entity/EntityEvent.java | 9 +- .../event/entity/EntityExhaustionEvent.java | 40 +- .../event/entity/EntityExplodeEvent.java | 46 +- .../event/entity/EntityInteractEvent.java | 33 +- .../entity/EntityKnockbackByEntityEvent.java | 4 +- .../event/entity/EntityKnockbackEvent.java | 27 +- .../bukkit/event/entity/EntityMountEvent.java | 20 +- .../event/entity/EntityPickupItemEvent.java | 23 +- .../bukkit/event/entity/EntityPlaceEvent.java | 21 +- .../event/entity/EntityPortalEnterEvent.java | 41 +- .../event/entity/EntityPortalEvent.java | 79 +- .../event/entity/EntityPortalExitEvent.java | 12 +- .../event/entity/EntityPoseChangeEvent.java | 16 +- .../event/entity/EntityPotionEffectEvent.java | 34 +- .../event/entity/EntityRegainHealthEvent.java | 64 +- .../event/entity/EntityRemoveEvent.java | 15 +- .../event/entity/EntityResurrectEvent.java | 29 +- .../event/entity/EntityShootBowEvent.java | 74 +- .../bukkit/event/entity/EntitySpawnEvent.java | 33 +- .../event/entity/EntitySpellCastEvent.java | 25 +- .../bukkit/event/entity/EntityTameEvent.java | 38 +- .../event/entity/EntityTargetEvent.java | 45 +- .../entity/EntityTargetLivingEntityEvent.java | 9 +- .../event/entity/EntityTeleportEvent.java | 42 +- .../event/entity/EntityToggleGlideEvent.java | 27 +- .../event/entity/EntityToggleSwimEvent.java | 41 +- .../event/entity/EntityTransformEvent.java | 48 +- .../event/entity/EntityUnleashEvent.java | 31 +- .../bukkit/event/entity/ExpBottleEvent.java | 17 +- .../event/entity/ExplosionPrimeEvent.java | 47 +- .../event/entity/FireworkExplodeEvent.java | 48 +- .../event/entity/FoodLevelChangeEvent.java | 33 +- .../bukkit/event/entity/HorseJumpEvent.java | 45 +- .../bukkit/event/entity/ItemDespawnEvent.java | 41 +- .../bukkit/event/entity/ItemMergeEvent.java | 36 +- .../bukkit/event/entity/ItemSpawnEvent.java | 3 +- .../entity/LingeringPotionSplashEvent.java | 18 +- .../org/bukkit/event/entity/PigZapEvent.java | 54 +- .../event/entity/PigZombieAngerEvent.java | 32 +- .../event/entity/PiglinBarterEvent.java | 28 +- .../bukkit/event/entity/PlayerDeathEvent.java | 418 +- .../event/entity/PlayerLeashEntityEvent.java | 46 +- .../event/entity/PotionSplashEvent.java | 29 +- .../event/entity/ProjectileHitEvent.java | 71 +- .../event/entity/ProjectileLaunchEvent.java | 29 +- .../event/entity/SheepDyeWoolEvent.java | 11 +- .../event/entity/SheepRegrowWoolEvent.java | 36 +- .../bukkit/event/entity/SlimeSplitEvent.java | 38 +- .../event/entity/SpawnerSpawnEvent.java | 12 +- .../entity/StriderTemperatureChangeEvent.java | 19 +- .../event/entity/TrialSpawnerSpawnEvent.java | 6 +- .../entity/VillagerAcquireTradeEvent.java | 34 +- .../entity/VillagerCareerChangeEvent.java | 26 +- .../entity/VillagerReplenishTradeEvent.java | 36 +- .../hanging/HangingBreakByEntityEvent.java | 12 +- .../event/hanging/HangingBreakEvent.java | 36 +- .../bukkit/event/hanging/HangingEvent.java | 4 +- .../event/hanging/HangingPlaceEvent.java | 26 +- .../org/bukkit/event/inventory/BrewEvent.java | 48 +- .../inventory/BrewingStandFuelEvent.java | 20 +- .../org/bukkit/event/inventory/ClickType.java | 12 +- .../event/inventory/CraftItemEvent.java | 30 +- .../event/inventory/FurnaceBurnEvent.java | 38 +- .../event/inventory/FurnaceExtractEvent.java | 9 +- .../event/inventory/FurnaceSmeltEvent.java | 1 + .../inventory/FurnaceStartSmeltEvent.java | 13 +- .../inventory/HopperInventorySearchEvent.java | 15 +- .../event/inventory/InventoryClickEvent.java | 73 +- .../event/inventory/InventoryCloseEvent.java | 74 +- .../inventory/InventoryCreativeEvent.java | 9 +- .../event/inventory/InventoryDragEvent.java | 94 +- .../event/inventory/InventoryEvent.java | 16 +- .../inventory/InventoryInteractEvent.java | 30 +- .../inventory/InventoryMoveItemEvent.java | 25 +- .../event/inventory/InventoryOpenEvent.java | 81 +- .../inventory/InventoryPickupItemEvent.java | 24 +- .../event/inventory/PrepareAnvilEvent.java | 10 +- .../inventory/PrepareGrindstoneEvent.java | 9 +- .../PrepareInventoryResultEvent.java | 19 +- .../inventory/PrepareItemCraftEvent.java | 26 +- .../event/inventory/PrepareSmithingEvent.java | 7 +- .../event/inventory/SmithItemEvent.java | 3 + .../event/inventory/TradeSelectEvent.java | 30 +- .../event/player/AsyncPlayerChatEvent.java | 46 +- .../player/AsyncPlayerChatPreviewEvent.java | 14 +- .../player/AsyncPlayerPreLoginEvent.java | 102 +- .../player/PlayerAdvancementDoneEvent.java | 42 +- .../event/player/PlayerAnimationEvent.java | 27 +- .../PlayerArmorStandManipulateEvent.java | 16 +- .../player/PlayerAttemptPickupItemEvent.java | 4 +- .../event/player/PlayerBedEnterEvent.java | 229 +- .../event/player/PlayerBedLeaveEvent.java | 26 +- .../event/player/PlayerBucketEmptyEvent.java | 27 +- .../event/player/PlayerBucketEntityEvent.java | 28 +- .../event/player/PlayerBucketEvent.java | 112 +- .../event/player/PlayerBucketFillEvent.java | 27 +- .../event/player/PlayerBucketFishEvent.java | 14 +- .../player/PlayerChangedMainHandEvent.java | 18 +- .../event/player/PlayerChangedWorldEvent.java | 14 +- .../event/player/PlayerChannelEvent.java | 12 +- .../bukkit/event/player/PlayerChatEvent.java | 46 +- .../player/PlayerChatTabCompleteEvent.java | 20 +- .../player/PlayerCommandPreprocessEvent.java | 70 +- .../event/player/PlayerCommandSendEvent.java | 11 +- .../event/player/PlayerDropItemEvent.java | 20 +- .../event/player/PlayerEditBookEvent.java | 59 +- .../event/player/PlayerEggThrowEvent.java | 22 +- .../org/bukkit/event/player/PlayerEvent.java | 12 +- .../event/player/PlayerExpChangeEvent.java | 27 +- .../player/PlayerExpCooldownChangeEvent.java | 21 +- .../bukkit/event/player/PlayerFishEvent.java | 85 +- .../player/PlayerGameModeChangeEvent.java | 94 +- .../event/player/PlayerHarvestBlockEvent.java | 21 +- .../event/player/PlayerHideEntityEvent.java | 15 +- .../bukkit/event/player/PlayerInputEvent.java | 10 +- .../player/PlayerInteractAtEntityEvent.java | 21 +- .../player/PlayerInteractEntityEvent.java | 48 +- .../event/player/PlayerInteractEvent.java | 173 +- .../event/player/PlayerItemBreakEvent.java | 12 +- .../event/player/PlayerItemConsumeEvent.java | 46 +- .../event/player/PlayerItemDamageEvent.java | 37 +- .../event/player/PlayerItemHeldEvent.java | 21 +- .../event/player/PlayerItemMendEvent.java | 174 +- .../bukkit/event/player/PlayerJoinEvent.java | 44 +- .../bukkit/event/player/PlayerKickEvent.java | 176 +- .../event/player/PlayerLevelChangeEvent.java | 14 +- .../event/player/PlayerLinksSendEvent.java | 10 +- .../event/player/PlayerLocaleChangeEvent.java | 45 +- .../bukkit/event/player/PlayerLoginEvent.java | 181 +- .../bukkit/event/player/PlayerMoveEvent.java | 85 +- .../event/player/PlayerPickupArrowEvent.java | 4 +- .../event/player/PlayerPickupItemEvent.java | 41 +- .../event/player/PlayerPortalEvent.java | 86 +- .../event/player/PlayerPreLoginEvent.java | 72 +- .../bukkit/event/player/PlayerQuitEvent.java | 92 +- .../player/PlayerRecipeBookClickEvent.java | 27 +- .../PlayerRecipeBookSettingsChangeEvent.java | 19 +- .../player/PlayerRecipeDiscoverEvent.java | 20 +- .../player/PlayerRegisterChannelEvent.java | 2 + .../player/PlayerResourcePackStatusEvent.java | 40 +- .../event/player/PlayerRespawnEvent.java | 57 +- .../event/player/PlayerRiptideEvent.java | 20 +- .../event/player/PlayerShearEntityEvent.java | 82 +- .../event/player/PlayerShowEntityEvent.java | 15 +- .../event/player/PlayerSignOpenEvent.java | 18 +- .../event/player/PlayerSpawnChangeEvent.java | 75 +- .../player/PlayerStatisticIncrementEvent.java | 38 +- .../player/PlayerSwapHandItemsEvent.java | 33 +- .../player/PlayerTakeLecternBookEvent.java | 24 +- .../event/player/PlayerTeleportEvent.java | 102 +- .../event/player/PlayerToggleFlightEvent.java | 20 +- .../event/player/PlayerToggleSneakEvent.java | 20 +- .../event/player/PlayerToggleSprintEvent.java | 20 +- .../player/PlayerUnleashEntityEvent.java | 26 +- .../player/PlayerUnregisterChannelEvent.java | 2 + .../event/player/PlayerVelocityEvent.java | 36 +- .../java/org/bukkit/event/raid/RaidEvent.java | 4 +- .../bukkit/event/raid/RaidFinishEvent.java | 17 +- .../bukkit/event/raid/RaidSpawnWaveEvent.java | 38 +- .../org/bukkit/event/raid/RaidStopEvent.java | 12 +- .../bukkit/event/raid/RaidTriggerEvent.java | 20 +- .../event/server/BroadcastMessageEvent.java | 55 +- .../event/server/MapInitializeEvent.java | 12 +- .../event/server/PluginDisableEvent.java | 9 +- .../event/server/PluginEnableEvent.java | 9 +- .../org/bukkit/event/server/PluginEvent.java | 5 +- .../server/RemoteServerCommandEvent.java | 9 +- .../event/server/ServerCommandEvent.java | 59 +- .../event/server/ServerListPingEvent.java | 163 +- .../bukkit/event/server/ServerLoadEvent.java | 29 +- .../org/bukkit/event/server/ServiceEvent.java | 6 +- .../event/server/ServiceRegisterEvent.java | 9 +- .../event/server/ServiceUnregisterEvent.java | 9 +- .../bukkit/event/server/TabCompleteEvent.java | 82 +- .../vehicle/VehicleBlockCollisionEvent.java | 34 +- .../event/vehicle/VehicleCollisionEvent.java | 16 +- .../event/vehicle/VehicleCreateEvent.java | 12 +- .../event/vehicle/VehicleDamageEvent.java | 17 +- .../event/vehicle/VehicleDestroyEvent.java | 14 +- .../event/vehicle/VehicleEnterEvent.java | 18 +- .../vehicle/VehicleEntityCollisionEvent.java | 56 +- .../bukkit/event/vehicle/VehicleEvent.java | 5 +- .../event/vehicle/VehicleExitEvent.java | 32 +- .../event/vehicle/VehicleMoveEvent.java | 15 +- .../event/vehicle/VehicleUpdateEvent.java | 9 +- .../event/weather/LightningStrikeEvent.java | 38 +- .../event/weather/ThunderChangeEvent.java | 67 +- .../event/weather/WeatherChangeEvent.java | 69 +- .../bukkit/event/weather/WeatherEvent.java | 7 +- .../world/AsyncStructureGenerateEvent.java | 242 +- .../event/world/AsyncStructureSpawnEvent.java | 27 +- .../org/bukkit/event/world/ChunkEvent.java | 3 +- .../bukkit/event/world/ChunkLoadEvent.java | 14 +- .../event/world/ChunkPopulateEvent.java | 9 +- .../bukkit/event/world/ChunkUnloadEvent.java | 13 +- .../bukkit/event/world/EntitiesLoadEvent.java | 16 +- .../event/world/EntitiesUnloadEvent.java | 16 +- .../bukkit/event/world/GenericGameEvent.java | 24 +- .../bukkit/event/world/LootGenerateEvent.java | 52 +- .../bukkit/event/world/PortalCreateEvent.java | 36 +- .../bukkit/event/world/SpawnChangeEvent.java | 12 +- .../event/world/StructureGrowEvent.java | 31 +- .../org/bukkit/event/world/TimeSkipEvent.java | 17 +- .../org/bukkit/event/world/WorldEvent.java | 9 +- .../bukkit/event/world/WorldInitEvent.java | 9 +- .../bukkit/event/world/WorldLoadEvent.java | 9 +- .../bukkit/event/world/WorldSaveEvent.java | 9 +- .../bukkit/event/world/WorldUnloadEvent.java | 16 +- .../bukkit/generator/structure/Structure.java | 98 +- .../generator/structure/StructureType.java | 18 + .../org/bukkit/inventory/EquipmentSlot.java | 9 +- .../bukkit/inventory/EquipmentSlotGroup.java | 7 +- .../java/org/bukkit/inventory/Inventory.java | 2 +- .../java/org/bukkit/inventory/ItemFlag.java | 46 +- .../java/org/bukkit/inventory/ItemRarity.java | 34 +- .../java/org/bukkit/inventory/ItemStack.java | 62 +- .../java/org/bukkit/inventory/ItemType.java | 4900 ++++++++------- .../bukkit/inventory/SmithingTrimRecipe.java | 95 +- .../meta/EnchantmentStorageMeta.java | 20 +- .../org/bukkit/inventory/meta/ItemMeta.java | 20 +- .../meta/components/EquippableComponent.java | 14 + .../components/JukeboxPlayableComponent.java | 13 +- .../inventory/meta/trim/TrimMaterial.java | 69 +- .../inventory/meta/trim/TrimPattern.java | 110 +- .../inventory/recipe/CookingBookCategory.java | 3 + .../recipe/CraftingBookCategory.java | 3 + .../builder/LocationInventoryViewBuilder.java | 2 +- .../main/java/org/bukkit/map/MapCursor.java | 122 +- .../main/java/org/bukkit/map/MapPalette.java | 327 +- .../persistence/PersistentDataHolder.java | 2 +- .../org/bukkit/plugin/RegisteredListener.java | 3 +- .../org/bukkit/plugin/java/JavaPlugin.java | 6 +- .../bukkit/plugin/java/JavaPluginLoader.java | 18 +- .../org/bukkit/plugin/java/LibraryLoader.java | 108 +- .../java/org/bukkit/potion/PotionType.java | 78 +- .../org/bukkit/scoreboard/DisplaySlot.java | 53 +- .../org/bukkit/scoreboard/Scoreboard.java | 29 +- .../java/org/bukkit/structure/Palette.java | 4 +- .../java/org/bukkit/tag/DamageTypeTags.java | 200 +- .../org/bukkit/util/CachedServerIcon.java | 2 +- .../player/PlayerSpawnLocationEvent.java | 4 +- .../java/org/bukkit/BukkitMirrorTest.java | 60 - .../java/org/bukkit/NamespacedKeyTest.java | 14 - .../ConfigurationSectionTest.java | 40 - .../bukkit/entity/memory/MemoryKeyTest.java | 41 - paper-generator/.editorconfig | 3 + paper-generator/build.gradle.kts | 178 + .../java/io/papermc/generator/Generators.java | 23 + .../main/java/io/papermc/generator/Main.java | 145 + .../java/io/papermc/generator/Rewriters.java | 219 + .../registry/RegistryBootstrapper.java | 45 + .../generator/registry/RegistryEntries.java | 215 + .../generator/registry/RegistryEntry.java | 214 + .../generator/registry/RegistryKeyField.java | 7 + .../PaperPatternSourceSetRewriter.java | 71 + .../PatternSourceSetRewriter.java | 23 + .../rewriter/registration/RewriterHolder.java | 27 + .../generator/rewriter/types/Types.java | 28 + .../types/registry/EnumRegistryRewriter.java | 82 + .../types/registry/FeatureFlagRewriter.java | 61 + .../registry/PaperFeatureFlagMapping.java | 30 + .../registry/PaperRegistriesRewriter.java | 105 + .../registry/RegistryEventsRewriter.java | 33 + .../types/registry/RegistryFieldRewriter.java | 135 + .../types/registry/RegistryTagRewriter.java | 92 + .../rewriter/types/registry/TagRewriter.java | 91 + .../types/simple/BlockTypeRewriter.java | 27 + .../types/simple/CraftBlockDataMapping.java | 19 + .../simple/CraftBlockEntityStateMapping.java | 21 + .../types/simple/CraftPotionUtilRewriter.java | 32 + .../types/simple/EntityTypeRewriter.java | 175 + .../types/simple/ItemTypeRewriter.java | 27 + .../types/simple/MapPaletteRewriter.java | 41 + .../types/simple/MaterialRewriter.java | 104 + .../types/simple/MemoryKeyRewriter.java | 116 + .../types/simple/StatisticRewriter.java | 170 + .../rewriter/types/simple/package-info.java | 4 + .../trial/DataComponentTypesRewriter.java | 261 + .../types/simple/trial/ProtoConstant.java | 30 + .../trial/VillagerProfessionRewriter.java | 101 + .../types/simple/trial/package-info.java | 6 + .../generator/rewriter/utils/Annotations.java | 48 + .../utils/ScanOldGeneratedSourceCode.java | 110 + .../types/OverriddenClassGenerator.java | 50 + .../generator/types/SimpleEnumGenerator.java | 30 + .../generator/types/SimpleGenerator.java | 12 +- .../generator/types/SourceGenerator.java | 2 + .../io/papermc/generator/types/Types.java | 14 + .../CraftBlockDataBootstrapper.java | 23 + .../CraftBlockDataGenerator.java | 243 + .../property/EnumPropertyWriter.java | 46 + .../property/IntegerPropertyWriter.java | 44 + .../property/PropertyMaker.java | 25 + .../property/PropertyWriter.java | 88 + .../property/appender/AppenderBase.java | 13 + .../property/appender/EnumValuesAppender.java | 45 + .../property/appender/PropertyAppender.java | 12 + .../property/appender/PropertyAppenders.java | 33 + .../property/converter/Converter.java | 13 + .../property/converter/ConverterBase.java | 24 + .../property/converter/Converters.java | 25 + .../property/converter/NoteConverter.java | 37 + .../property/converter/RotationConverter.java | 45 + .../property/holder/DataHolderType.java | 7 + .../property/holder/DataPropertyMaker.java | 31 + .../property/holder/DataPropertyWriter.java | 164 + .../holder/DataPropertyWriterBase.java | 66 + .../holder/VirtualDataPropertyWriter.java | 99 + .../property/holder/VirtualField.java | 72 + .../holder/appender/ArrayAppender.java | 54 + .../holder/appender/DataAppender.java | 18 + .../holder/appender/DataAppenders.java | 24 + .../holder/appender/ListAppender.java | 61 + .../property/holder/appender/MapAppender.java | 85 + .../holder/converter/ArrayConverter.java | 32 + .../holder/converter/DataConverter.java | 18 + .../holder/converter/DataConverters.java | 25 + .../holder/converter/ListConverter.java | 32 + .../holder/converter/MapConverter.java | 45 + .../types/goal/MobGoalGenerator.java | 45 +- .../generator/types/goal/MobGoalNames.java | 290 +- .../types/registry/GeneratedKeyType.java | 133 + .../types/registry/GeneratedTagKeyType.java | 103 + .../papermc/generator/utils/Annotations.java | 48 + .../generator/utils/BlockEntityMapping.java | 37 + .../generator/utils/BlockStateMapping.java | 445 ++ .../papermc/generator/utils/ClassHelper.java | 72 + .../generator/utils/CommonVariable.java | 10 + .../papermc/generator/utils/Formatting.java | 52 +- .../io/papermc/generator/utils/Javadocs.java | 44 + .../generator/utils/NamingManager.java | 141 + .../experimental}/CollectingContext.java | 17 +- .../experimental/ExperimentalCollector.java | 132 + .../utils/experimental/FlagHolder.java | 16 + .../utils/experimental/FlagHolders.java | 24 + .../utils/experimental/SingleFlagHolder.java | 49 + .../generator/BlockStatePropertyTest.java | 74 + .../generator/MobGoalConverterTest.java | 12 +- .../generator/RegistryMigrationTest.java | 50 + .../wideners.at | 6 +- paper-server/build.gradle.kts | 54 +- ...002-Allow-Saving-of-Oversized-Chunks.patch | 14 +- .../0003-Entity-Activation-Range-2.0.patch | 110 +- .../patches/features/0004-Anti-Xray.patch | 163 +- ...ocity-compression-and-cipher-natives.patch | 6 +- ...ptimize-Collision-to-not-load-chunks.patch | 10 +- .../0008-Optimize-Voxel-Shape-Merging.patch | 6 +- ...e-Oversized-block-entities-in-chunks.patch | 14 +- ...010-optimize-dirt-and-snow-spreading.patch | 6 +- ...e-getChunkAt-calls-for-loaded-chunks.patch | 6 +- ...-Optimize-Bit-Operations-by-inlining.patch | 6 +- .../0013-Remove-streams-from-hot-code.patch | 36 +- ... 0015-Moonrise-optimisation-patches.patch} | 2638 ++++---- ...r-desync-when-new-players-are-added.patch} | 14 +- ...-Eigencraft-redstone-implementation.patch} | 24 +- ...ate-Current-redstone-implementation.patch} | 54 +- ...ove-exact-choice-recipe-ingredients.patch} | 6 +- ...data-to-disk-if-it-serializes-witho.patch} | 2 +- ...21-Entity-load-save-limit-per-chunk.patch} | 50 +- ...ulate-regionfile-header-if-it-is-co.patch} | 18 +- ...Incremental-chunk-and-player-saving.patch} | 22 +- ...=> 0024-Optimise-general-POI-access.patch} | 4 +- ...0025-Optional-per-player-mob-spawns.patch} | 56 +- ...g-PreCreatureSpawnEvent-with-per-pl.patch} | 16 +- ...pers.patch => 0027-Optimize-Hoppers.patch} | 40 +- ...nfiles-on-save-configuration-option.patch} | 0 ...on-checking-in-player-move-packet-ha.patch | 116 +- ...vement-for-vehicles-players-unaffect.patch | 34 - .../util/BaseChunkSystemHooks.java.patch | 18 +- .../YggdrasilGameProfileRepository.java.patch | 4 +- .../com/mojang/logging/LogUtils.java.patch | 3 +- .../mojang/math/OctahedralGroup.java.patch | 30 +- .../io/papermc/paper/FeatureHooks.java.patch | 22 +- .../net/minecraft/ChatFormatting.java.patch | 6 +- .../sources/net/minecraft/Util.java.patch | 14 +- .../commands/CommandSourceStack.java.patch | 14 +- .../minecraft/commands/Commands.java.patch | 16 +- .../net/minecraft/core/Direction.java.patch | 8 +- .../minecraft/core/MappedRegistry.java.patch | 8 +- .../net/minecraft/core/Rotations.java.patch | 38 +- .../net/minecraft/core/Vec3i.java.patch | 12 +- .../cauldron/CauldronInteraction.java.patch | 25 +- .../component/DataComponentPatch.java.patch | 86 +- .../core/component/DataComponents.java.patch | 10 +- .../BoatDispenseItemBehavior.java.patch | 15 +- .../DefaultDispenseItemBehavior.java.patch | 35 +- .../dispenser/DispenseItemBehavior.java.patch | 419 +- .../EquipmentDispenseItemBehavior.java.patch | 20 +- .../MinecartDispenseItemBehavior.java.patch | 15 +- .../ProjectileDispenseBehavior.java.patch | 31 +- .../ShearsDispenseItemBehavior.java.patch | 10 +- .../ShulkerBoxDispenseBehavior.java.patch | 12 +- .../registries/BuiltInRegistries.java.patch | 12 +- .../loot/packs/VanillaChestLoot.java.patch | 2 +- .../framework/GameTestInfo.java.patch | 2 +- .../framework/GameTestMainUtil.java.patch | 11 + .../framework/GameTestServer.java.patch | 12 +- .../framework/StructureUtils.java.patch | 2 +- .../gametest/framework/TestCommand.java.patch | 11 - .../TestEnvironmentDefinition.java.patch | 30 + .../net/minecraft/nbt/CompoundTag.java.patch | 98 +- .../net/minecraft/nbt/NbtIo.java.patch | 2 +- .../net/minecraft/nbt/NbtUtils.java.patch | 15 - .../net/minecraft/nbt/SnbtGrammar.java.patch | 21 + .../net/minecraft/nbt/TagParser.java.patch | 54 - .../network/FriendlyByteBuf.java.patch | 2 +- .../minecraft/network/HashedStack.java.patch | 33 + .../network/chat/ChatDecorator.java.patch | 2 +- .../chat/ComponentSerialization.java.patch | 6 +- .../network/chat/ComponentUtils.java.patch | 2 +- .../network/chat/PlayerChatMessage.java.patch | 4 +- .../chat/contents/NbtContents.java.patch | 12 +- .../network/codec/ByteBufCodecs.java.patch | 2 +- ...tboundContainerSetContentPacket.java.patch | 15 +- ...ClientboundLevelChunkPacketData.java.patch | 18 +- ...ientboundPlayerInfoUpdatePacket.java.patch | 2 +- .../ClientboundSetEntityDataPacket.java.patch | 2 +- .../ClientboundSetEquipmentPacket.java.patch | 2 +- .../ClientboundSetPlayerTeamPacket.java.patch | 10 +- .../ClientboundSystemChatPacket.java.patch | 2 +- ...ServerboundContainerClickPacket.java.patch | 20 - ...rboundSetCreativeModeSlotPacket.java.patch | 4 +- .../syncher/SynchedEntityData.java.patch | 9 - .../resources/RegistryDataLoader.java.patch | 14 +- .../resources/ResourceLocation.java.patch | 8 +- .../net/minecraft/server/Bootstrap.java.patch | 43 +- .../net/minecraft/server/Main.java.patch | 33 +- .../server/MinecraftServer.java.patch | 125 +- .../server/PlayerAdvancements.java.patch | 2 +- .../server/ServerScoreboard.java.patch | 26 +- .../net/minecraft/server/Services.java.patch | 6 +- .../server/commands/GiveCommand.java.patch | 9 - .../server/commands/OpCommand.java.patch | 11 - .../server/commands/PlaceCommand.java.patch | 2 +- .../commands/SetSpawnCommand.java.patch | 4 +- .../server/commands/SummonCommand.java.patch | 2 +- .../dedicated/DedicatedServer.java.patch | 65 +- .../server/dedicated/Settings.java.patch | 2 +- .../server/level/ChunkMap.java.patch | 83 +- .../server/level/DistanceManager.java.patch | 84 +- .../server/level/ServerChunkCache.java.patch | 54 +- .../server/level/ServerEntity.java.patch | 47 +- .../server/level/ServerLevel.java.patch | 253 +- .../server/level/ServerPlayer.java.patch | 563 +- .../level/ServerPlayerGameMode.java.patch | 29 +- .../minecraft/server/level/Ticket.java.patch | 41 + .../server/level/TicketType.java.patch | 48 +- .../server/level/WorldGenRegion.java.patch | 22 +- .../network/LegacyQueryHandler.java.patch | 6 +- .../ServerCommonPacketListenerImpl.java.patch | 8 +- .../ServerGamePacketListenerImpl.java.patch | 1215 ++-- ...rverHandshakePacketListenerImpl.java.patch | 15 +- .../ServerLoginPacketListenerImpl.java.patch | 16 +- .../players/GameProfileCache.java.patch | 39 +- .../players/OldUsersConverter.java.patch | 20 +- .../server/players/PlayerList.java.patch | 149 +- .../stats/ServerRecipeBook.java.patch | 6 +- .../stats/ServerStatsCounter.java.patch | 10 +- .../net/minecraft/util/SpawnUtil.java.patch | 2 +- .../util/datafix/DataFixers.java.patch | 12 +- .../util/parsing/packrat/Scope.java.patch | 39 + .../util/random/WeightedList.java.patch | 28 + .../util/worldupdate/WorldUpgrader.java.patch | 8 +- .../net/minecraft/world/BossEvent.java.patch | 4 +- .../world/CompoundContainer.java.patch | 9 +- .../net/minecraft/world/Container.java.patch | 12 +- .../world/RandomizableContainer.java.patch | 35 +- .../world/SimpleContainer.java.patch | 18 +- .../damagesource/DamageSource.java.patch | 4 +- .../world/effect/InfestedMobEffect.java.patch | 2 +- .../world/effect/MobEffect.java.patch | 2 +- .../world/effect/MobEffectInstance.java.patch | 19 +- .../world/effect/OozingMobEffect.java.patch | 2 +- .../world/entity/AgeableMob.java.patch | 29 +- .../world/entity/AreaEffectCloud.java.patch | 32 +- .../world/entity/ConversionType.java.patch | 8 + .../minecraft/world/entity/Display.java.patch | 11 - .../minecraft/world/entity/Entity.java.patch | 507 +- .../world/entity/EntityEquipment.java.patch | 14 + .../world/entity/EntitySelector.java.patch | 51 +- .../world/entity/EntityType.java.patch | 74 +- .../world/entity/ExperienceOrb.java.patch | 158 +- .../InsideBlockEffectApplier.java.patch | 66 + .../entity/InsideBlockEffectType.java.patch | 41 + .../world/entity/Interaction.java.patch | 4 +- .../world/entity/ItemBasedSteering.java.patch | 12 +- .../world/entity/Leashable.java.patch | 47 +- .../world/entity/LightningBolt.java.patch | 10 +- .../world/entity/LivingEntity.java.patch | 848 +-- .../net/minecraft/world/entity/Mob.java.patch | 288 +- .../world/entity/NeutralMob.java.patch | 56 +- .../entity/OminousItemSpawner.java.patch | 6 +- .../world/entity/TamableAnimal.java.patch | 19 +- .../attributes/AttributeInstance.java.patch | 2 +- .../ai/attributes/AttributeMap.java.patch | 4 +- .../AssignProfessionFromJobSite.java.patch | 8 +- .../entity/ai/behavior/RamTarget.java.patch | 12 +- .../ai/behavior/ResetProfession.java.patch | 30 +- .../behavior/VillagerGoalPackages.java.patch | 2 +- .../ai/behavior/VillagerMakeLove.java.patch | 4 +- .../entity/ai/goal/EatBlockGoal.java.patch | 4 +- .../world/entity/ai/goal/Goal.java.patch | 10 +- .../ai/goal/SitWhenOrderedToGoal.java.patch | 11 - .../target/DefendVillageTargetGoal.java.patch | 4 +- .../goal/target/HurtByTargetGoal.java.patch | 4 +- .../NearestAttackableTargetGoal.java.patch | 2 +- .../target/OwnerHurtByTargetGoal.java.patch | 2 +- .../target/OwnerHurtTargetGoal.java.patch | 2 +- .../ai/goal/target/TargetGoal.java.patch | 4 +- .../ai/gossip/GossipContainer.java.patch | 2 +- .../ai/navigation/PathNavigation.java.patch | 2 +- .../ai/sensing/TemptingSensor.java.patch | 25 +- .../entity/ai/village/VillageSiege.java.patch | 4 +- .../world/entity/ambient/Bat.java.patch | 8 +- ...{Cow.java.patch => AbstractCow.java.patch} | 8 +- .../world/entity/animal/Animal.java.patch | 38 +- .../world/entity/animal/Bee.java.patch | 45 +- .../world/entity/animal/Bucketable.java.patch | 4 +- .../world/entity/animal/Cat.java.patch | 35 +- .../world/entity/animal/Chicken.java.patch | 2 +- .../world/entity/animal/Dolphin.java.patch | 12 +- .../world/entity/animal/Fox.java.patch | 58 +- .../world/entity/animal/IronGolem.java.patch | 6 +- .../entity/animal/MushroomCow.java.patch | 12 +- .../world/entity/animal/Ocelot.java.patch | 4 +- .../world/entity/animal/Panda.java.patch | 14 +- .../world/entity/animal/Parrot.java.patch | 8 +- .../world/entity/animal/Pufferfish.java.patch | 6 +- .../world/entity/animal/Rabbit.java.patch | 6 +- .../world/entity/animal/SnowGolem.java.patch | 10 +- .../world/entity/animal/Turtle.java.patch | 26 +- .../entity/animal/WaterAnimal.java.patch | 2 +- .../entity/animal/allay/Allay.java.patch | 30 +- .../animal/armadillo/Armadillo.java.patch | 8 +- .../entity/animal/axolotl/Axolotl.java.patch | 14 +- .../entity/animal/camel/Camel.java.patch | 10 +- .../world/entity/animal/frog/Frog.java.patch | 2 +- .../entity/animal/frog/Tadpole.java.patch | 25 +- .../world/entity/animal/goat/Goat.java.patch | 8 +- .../horse/AbstractChestedHorse.java.patch | 2 +- .../animal/horse/AbstractHorse.java.patch | 130 +- .../entity/animal/horse/Llama.java.patch | 6 +- .../animal/horse/SkeletonHorse.java.patch | 2 +- .../animal/horse/SkeletonTrapGoal.java.patch | 2 +- .../animal/horse/TraderLlama.java.patch | 6 +- .../animal/{ => sheep}/Sheep.java.patch | 10 +- .../entity/animal/{ => wolf}/Wolf.java.patch | 25 +- .../boss/enderdragon/EndCrystal.java.patch | 24 +- .../boss/enderdragon/EnderDragon.java.patch | 53 +- .../DragonSittingFlamingPhase.java.patch | 8 +- .../phases/DragonStrafePlayerPhase.java.patch | 2 +- .../entity/boss/wither/WitherBoss.java.patch | 14 +- .../entity/decoration/ArmorStand.java.patch | 105 +- .../entity/decoration/ItemFrame.java.patch | 18 +- .../entity/decoration/Painting.java.patch | 2 +- .../entity/item/FallingBlockEntity.java.patch | 81 +- .../world/entity/item/ItemEntity.java.patch | 60 +- .../world/entity/item/PrimedTnt.java.patch | 55 +- .../monster/AbstractSkeleton.java.patch | 27 +- .../world/entity/monster/Bogged.java.patch | 8 +- .../world/entity/monster/Creeper.java.patch | 45 +- .../entity/monster/ElderGuardian.java.patch | 2 +- .../world/entity/monster/EnderMan.java.patch | 45 +- .../world/entity/monster/Endermite.java.patch | 2 +- .../world/entity/monster/Ghast.java.patch | 4 +- .../world/entity/monster/Phantom.java.patch | 41 +- .../world/entity/monster/Ravager.java.patch | 4 +- .../world/entity/monster/Shulker.java.patch | 12 +- .../world/entity/monster/Skeleton.java.patch | 2 +- .../world/entity/monster/Slime.java.patch | 77 +- .../monster/SpellcasterIllager.java.patch | 2 +- .../world/entity/monster/Strider.java.patch | 2 +- .../world/entity/monster/Vex.java.patch | 6 +- .../entity/monster/Vindicator.java.patch | 2 +- .../world/entity/monster/Witch.java.patch | 6 +- .../world/entity/monster/Zombie.java.patch | 64 +- .../entity/monster/ZombieVillager.java.patch | 56 +- .../entity/monster/ZombifiedPiglin.java.patch | 25 +- .../monster/creaking/Creaking.java.patch | 6 +- .../entity/monster/hoglin/Hoglin.java.patch | 6 +- .../monster/piglin/AbstractPiglin.java.patch | 6 +- .../entity/monster/piglin/Piglin.java.patch | 64 +- .../entity/monster/piglin/PiglinAi.java.patch | 46 +- .../entity/monster/warden/Warden.java.patch | 4 +- .../entity/npc/AbstractVillager.java.patch | 42 +- .../world/entity/npc/CatSpawner.java.patch | 22 +- .../entity/npc/InventoryCarrier.java.patch | 13 +- .../world/entity/npc/Villager.java.patch | 76 +- .../entity/npc/VillagerTrades.java.patch | 8 +- .../entity/npc/WanderingTrader.java.patch | 52 +- .../npc/WanderingTraderSpawner.java.patch | 75 +- .../world/entity/player/Inventory.java.patch | 62 +- .../world/entity/player/Player.java.patch | 226 +- .../entity/player/ProfilePublicKey.java.patch | 6 +- .../projectile/AbstractArrow.java.patch | 122 +- .../AbstractThrownPotion.java.patch | 109 + .../world/entity/projectile/Arrow.java.patch | 20 +- .../projectile/DragonFireball.java.patch | 2 +- .../entity/projectile/EvokerFangs.java.patch | 6 +- .../entity/projectile/EyeOfEnder.java.patch | 21 +- .../entity/projectile/Fireball.java.patch | 16 - .../FireworkRocketEntity.java.patch | 40 +- .../entity/projectile/FishingHook.java.patch | 67 +- .../projectile/LargeFireball.java.patch | 21 +- .../entity/projectile/LlamaSpit.java.patch | 2 +- .../entity/projectile/Projectile.java.patch | 42 +- .../projectile/ShulkerBullet.java.patch | 16 +- .../projectile/SpectralArrow.java.patch | 2 +- .../ThrowableItemProjectile.java.patch | 15 - .../projectile/ThrowableProjectile.java.patch | 2 +- .../entity/projectile/ThrownEgg.java.patch | 33 +- .../projectile/ThrownEnderpearl.java.patch | 14 +- .../ThrownExperienceBottle.java.patch | 4 +- .../ThrownLingeringPotion.java.patch | 27 + .../entity/projectile/ThrownPotion.java.patch | 193 - .../projectile/ThrownSplashPotion.java.patch | 65 + .../projectile/ThrownTrident.java.patch | 10 +- .../entity/projectile/WitherSkull.java.patch | 10 +- .../world/entity/raid/Raid.java.patch | 142 +- .../world/entity/raid/Raider.java.patch | 14 +- .../world/entity/raid/Raids.java.patch | 53 +- .../entity/variant/StructureCheck.java.patch | 11 + .../entity/vehicle/AbstractBoat.java.patch | 23 +- .../vehicle/AbstractChestBoat.java.patch | 15 +- .../vehicle/AbstractMinecart.java.patch | 45 +- .../AbstractMinecartContainer.java.patch | 23 +- .../entity/vehicle/ContainerEntity.java.patch | 35 +- .../entity/vehicle/MinecartTNT.java.patch | 69 +- .../vehicle/NewMinecartBehavior.java.patch | 2 +- .../vehicle/OldMinecartBehavior.java.patch | 8 +- .../minecraft/world/food/FoodData.java.patch | 6 +- .../AbstractContainerMenu.java.patch | 105 +- .../inventory/AbstractCraftingMenu.java.patch | 4 +- .../inventory/AbstractFurnaceMenu.java.patch | 14 +- .../world/inventory/AnvilMenu.java.patch | 20 +- .../world/inventory/BeaconMenu.java.patch | 20 +- .../inventory/BrewingStandMenu.java.patch | 16 +- .../inventory/CartographyTableMenu.java.patch | 16 +- .../world/inventory/ChestMenu.java.patch | 16 +- .../inventory/ContainerLevelAccess.java.patch | 2 +- .../ContainerSynchronizer.java.patch | 6 +- .../world/inventory/CrafterMenu.java.patch | 10 +- .../world/inventory/CraftingMenu.java.patch | 14 +- .../world/inventory/DispenserMenu.java.patch | 14 +- .../inventory/EnchantmentMenu.java.patch | 44 +- .../inventory/FurnaceResultSlot.java.patch | 2 +- .../world/inventory/GrindstoneMenu.java.patch | 12 +- .../world/inventory/HopperMenu.java.patch | 14 +- .../inventory/HorseInventoryMenu.java.patch | 18 +- .../world/inventory/InventoryMenu.java.patch | 26 +- .../world/inventory/LecternMenu.java.patch | 14 +- .../world/inventory/LoomMenu.java.patch | 18 +- .../inventory/MerchantContainer.java.patch | 8 +- .../world/inventory/MerchantMenu.java.patch | 12 +- .../inventory/MerchantResultSlot.java.patch | 4 +- .../PlayerEnderChestContainer.java.patch | 2 +- .../world/inventory/RemoteSlot.java.patch | 27 + .../inventory/ResultContainer.java.patch | 8 +- .../world/inventory/ShulkerBoxMenu.java.patch | 16 +- .../inventory/StonecutterMenu.java.patch | 10 +- .../TransientCraftingContainer.java.patch | 14 +- .../world/item/ArmorStandItem.java.patch | 2 +- .../minecraft/world/item/BlockItem.java.patch | 37 +- .../world/item/BucketItem.java.patch | 37 +- .../world/item/CrossbowItem.java.patch | 43 +- .../minecraft/world/item/EggItem.java.patch | 50 +- .../world/item/EndCrystalItem.java.patch | 4 +- .../world/item/EnderEyeItem.java.patch | 6 +- .../world/item/FireChargeItem.java.patch | 2 +- .../world/item/FireworkRocketItem.java.patch | 6 +- .../world/item/FishingRodItem.java.patch | 2 +- .../world/item/FlintAndSteelItem.java.patch | 2 +- .../world/item/HangingEntityItem.java.patch | 8 +- .../minecraft/world/item/ItemStack.java.patch | 140 +- .../world/item/LingeringPotionItem.java.patch | 7 +- .../minecraft/world/item/MaceItem.java.patch | 6 +- .../minecraft/world/item/MapItem.java.patch | 4 +- .../world/item/MobBucketItem.java.patch | 2 +- .../world/item/NameTagItem.java.patch | 2 +- .../world/item/PotionItem.java.patch | 2 +- .../item/ProjectileWeaponItem.java.patch | 2 +- .../world/item/ShovelItem.java.patch | 4 +- .../world/item/SpawnEggItem.java.patch | 8 +- .../world/item/SplashPotionItem.java.patch | 7 +- .../world/item/ThrowablePotionItem.java.patch | 10 +- .../world/item/TridentItem.java.patch | 20 +- .../world/item/WrittenBookItem.java.patch | 11 - .../item/alchemy/PotionContents.java.patch | 10 +- .../item/component/BlocksAttacks.java.patch | 18 + .../component/ChargedProjectiles.java.patch | 2 +- .../item/component/CustomData.java.patch | 10 +- .../ItemContainerContents.java.patch | 2 +- .../OminousBottleAmplifier.java.patch | 4 +- .../SuspiciousStewEffects.java.patch | 6 +- .../component/WrittenBookContent.java.patch | 11 + .../world/item/crafting/Recipe.java.patch | 2 +- .../SmithingTransformRecipe.java.patch | 25 +- .../crafting/SmithingTrimRecipe.java.patch | 42 +- .../item/crafting/TransmuteRecipe.java.patch | 4 +- .../item/crafting/TransmuteResult.java.patch | 17 + .../enchantment/ItemEnchantments.java.patch | 45 +- .../effects/ReplaceBlock.java.patch | 2 +- .../effects/ReplaceDisk.java.patch | 2 +- .../world/item/trading/Merchant.java.patch | 5 +- .../item/trading/MerchantOffer.java.patch | 6 +- .../world/level/BaseCommandBlock.java.patch | 8 +- .../world/level/BaseSpawner.java.patch | 74 +- .../world/level/BlockGetter.java.patch | 23 +- .../level/EmptyBlockAndTintGetter.java.patch | 4 +- .../world/level/EmptyBlockGetter.java.patch | 4 +- .../world/level/GameRules.java.patch | 74 +- .../minecraft/world/level/Level.java.patch | 232 +- .../world/level/LevelAccessor.java.patch | 2 +- .../world/level/LevelWriter.java.patch | 2 +- .../world/level/NaturalSpawner.java.patch | 78 +- .../level/PathNavigationRegion.java.patch | 28 +- .../world/level/ServerExplosion.java.patch | 66 +- .../world/level/StructureManager.java.patch | 12 +- .../world/level/TicketStorage.java.patch | 40 + .../world/level/biome/Biome.java.patch | 2 +- .../level/biome/MobSpawnSettings.java.patch | 55 +- .../block/AbstractCauldronBlock.java.patch | 2 +- .../world/level/block/AnvilBlock.java.patch | 2 +- .../level/block/BambooSaplingBlock.java.patch | 6 +- .../level/block/BambooStalkBlock.java.patch | 18 +- .../level/block/BaseFireBlock.java.patch | 30 +- .../block/BasePressurePlateBlock.java.patch | 17 +- .../world/level/block/BedBlock.java.patch | 8 +- .../world/level/block/BeehiveBlock.java.patch | 10 +- .../world/level/block/BellBlock.java.patch | 2 +- .../level/block/BigDripleafBlock.java.patch | 14 +- .../world/level/block/Block.java.patch | 50 +- .../level/block/BrewingStandBlock.java.patch | 2 +- .../level/block/BubbleColumnBlock.java.patch | 8 +- .../block/BuddingAmethystBlock.java.patch | 4 +- .../world/level/block/BushBlock.java.patch | 21 - .../world/level/block/ButtonBlock.java.patch | 16 +- .../world/level/block/CactusBlock.java.patch | 56 +- .../world/level/block/CakeBlock.java.patch | 6 +- .../level/block/CampfireBlock.java.patch | 10 +- .../level/block/CarvedPumpkinBlock.java.patch | 11 +- .../world/level/block/CaveVines.java.patch | 2 +- .../level/block/CaveVinesBlock.java.patch | 4 +- .../block/CeilingHangingSignBlock.java.patch | 2 +- .../block/ChangeOverTimeBlock.java.patch | 2 +- .../world/level/block/ChestBlock.java.patch | 12 +- .../level/block/ChorusFlowerBlock.java.patch | 24 +- .../world/level/block/CocoaBlock.java.patch | 14 +- .../world/level/block/CommandBlock.java.patch | 2 +- .../level/block/ComparatorBlock.java.patch | 6 +- .../level/block/ComposterBlock.java.patch | 20 +- .../level/block/CoralFanBlock.java.patch | 2 +- .../level/block/CoralPlantBlock.java.patch | 4 +- .../level/block/CoralWallFanBlock.java.patch | 2 +- .../world/level/block/CrafterBlock.java.patch | 20 +- .../world/level/block/CropBlock.java.patch | 18 +- .../block/DaylightDetectorBlock.java.patch | 2 +- .../level/block/DecoratedPotBlock.java.patch | 4 +- .../level/block/DetectorRailBlock.java.patch | 12 +- .../world/level/block/DiodeBlock.java.patch | 4 +- .../level/block/DispenserBlock.java.patch | 15 +- .../world/level/block/DoorBlock.java.patch | 2 +- .../level/block/DoublePlantBlock.java.patch | 2 +- .../world/level/block/DropperBlock.java.patch | 19 +- .../level/block/EndGatewayBlock.java.patch | 8 +- .../level/block/EndPortalBlock.java.patch | 14 +- .../level/block/EyeblossomBlock.java.patch | 4 +- .../world/level/block/FarmBlock.java.patch | 14 +- .../level/block/FenceGateBlock.java.patch | 4 +- .../world/level/block/FireBlock.java.patch | 131 +- .../level/block/FlowerPotBlock.java.patch | 4 +- .../level/block/FrogspawnBlock.java.patch | 10 +- .../level/block/GrindstoneBlock.java.patch | 2 +- .../block/GrowingPlantHeadBlock.java.patch | 2 +- .../world/level/block/HoneyBlock.java.patch | 4 +- .../world/level/block/HopperBlock.java.patch | 6 +- .../level/block/HugeMushroomBlock.java.patch | 2 +- .../level/block/InfestedBlock.java.patch | 2 +- .../level/block/LavaCauldronBlock.java.patch | 11 +- .../block/LayeredCauldronBlock.java.patch | 39 +- .../world/level/block/LeavesBlock.java.patch | 6 +- .../world/level/block/LecternBlock.java.patch | 20 +- .../world/level/block/LeverBlock.java.patch | 4 +- .../level/block/LightningRodBlock.java.patch | 4 +- .../world/level/block/LiquidBlock.java.patch | 4 +- .../block/MangrovePropaguleBlock.java.patch | 2 +- .../level/block/MultifaceSpreader.java.patch | 2 +- .../level/block/MushroomBlock.java.patch | 10 +- .../level/block/NetherPortalBlock.java.patch | 18 +- .../level/block/NetherWartBlock.java.patch | 6 +- .../world/level/block/NoteBlock.java.patch | 14 +- .../level/block/ObserverBlock.java.patch | 4 +- .../level/block/PitcherCropBlock.java.patch | 10 +- .../block/PointedDripstoneBlock.java.patch | 20 +- .../level/block/PowderSnowBlock.java.patch | 32 +- .../level/block/PoweredRailBlock.java.patch | 4 +- .../level/block/PressurePlateBlock.java.patch | 18 +- .../level/block/RedStoneOreBlock.java.patch | 6 +- .../level/block/RedstoneTorchBlock.java.patch | 8 +- .../level/block/RespawnAnchorBlock.java.patch | 16 +- .../level/block/RootedDirtBlock.java.patch | 2 +- .../world/level/block/SaplingBlock.java.patch | 21 +- .../level/block/ScaffoldingBlock.java.patch | 4 +- .../level/block/SculkSensorBlock.java.patch | 17 +- .../level/block/SculkShriekerBlock.java.patch | 4 +- .../level/block/SculkSpreader.java.patch | 20 +- .../level/block/ShulkerBoxBlock.java.patch | 8 +- .../world/level/block/SignBlock.java.patch | 9 +- .../level/block/SnifferEggBlock.java.patch | 6 +- .../level/block/SnowLayerBlock.java.patch | 2 +- .../world/level/block/SpawnerBlock.java.patch | 6 +- .../world/level/block/SpongeBlock.java.patch | 14 +- .../block/SpreadingSnowyDirtBlock.java.patch | 4 +- .../world/level/block/StemBlock.java.patch | 14 +- .../level/block/SugarCaneBlock.java.patch | 12 +- .../block/SweetBerryBushBlock.java.patch | 14 +- .../world/level/block/TntBlock.java.patch | 112 +- .../level/block/TrapDoorBlock.java.patch | 13 +- .../level/block/TripWireBlock.java.patch | 35 +- .../level/block/TripWireHookBlock.java.patch | 12 +- .../level/block/TurtleEggBlock.java.patch | 9 +- .../level/block/VegetationBlock.java.patch | 21 + .../world/level/block/VineBlock.java.patch | 36 +- .../block/WallHangingSignBlock.java.patch | 2 +- .../level/block/WaterlilyBlock.java.patch | 6 +- .../world/level/block/WebBlock.java.patch | 4 +- .../WeightedPressurePlateBlock.java.patch | 20 +- .../level/block/WitherRoseBlock.java.patch | 4 +- .../level/block/WitherSkullBlock.java.patch | 2 +- .../AbstractFurnaceBlockEntity.java.patch | 53 +- .../block/entity/BannerBlockEntity.java.patch | 45 +- .../block/entity/BarrelBlockEntity.java.patch | 7 +- .../BaseContainerBlockEntity.java.patch | 9 +- .../block/entity/BeaconBlockEntity.java.patch | 54 +- .../entity/BeehiveBlockEntity.java.patch | 87 +- .../level/block/entity/BlockEntity.java.patch | 70 +- .../entity/BrewingStandBlockEntity.java.patch | 23 +- .../entity/BrushableBlockEntity.java.patch | 17 +- .../entity/CampfireBlockEntity.java.patch | 29 +- .../block/entity/ChestBlockEntity.java.patch | 6 +- .../ChiseledBookShelfBlockEntity.java.patch | 12 +- .../entity/CommandBlockEntity.java.patch | 8 +- .../entity/ConduitBlockEntity.java.patch | 16 +- .../entity/CrafterBlockEntity.java.patch | 6 +- .../entity/DecoratedPotBlockEntity.java.patch | 26 +- .../entity/DispenserBlockEntity.java.patch | 7 +- .../block/entity/HopperBlockEntity.java.patch | 33 +- .../block/entity/JigsawBlockEntity.java.patch | 2 +- .../entity/JukeboxBlockEntity.java.patch | 10 +- .../entity/LecternBlockEntity.java.patch | 20 +- ...andomizableContainerBlockEntity.java.patch | 2 +- .../entity/SculkSensorBlockEntity.java.patch | 31 +- .../SculkShriekerBlockEntity.java.patch | 14 +- .../entity/ShulkerBoxBlockEntity.java.patch | 11 +- .../block/entity/SignBlockEntity.java.patch | 24 +- .../block/entity/SkullBlockEntity.java.patch | 8 +- .../block/entity/TestBlockEntity.java.patch | 10 + .../entity/TestInstanceBlockEntity.java.patch | 19 + .../TheEndGatewayBlockEntity.java.patch | 2 +- .../trialspawner/TrialSpawner.java.patch | 32 +- .../trialspawner/TrialSpawnerData.java.patch | 2 +- .../entity/vault/VaultBlockEntity.java.patch | 4 +- .../entity/vault/VaultServerData.java.patch | 6 +- .../level/block/grower/TreeGrower.java.patch | 55 +- .../block/piston/PistonBaseBlock.java.patch | 62 +- .../piston/PistonMovingBlockEntity.java.patch | 18 +- .../block/state/BlockBehaviour.java.patch | 41 +- .../world/level/border/WorldBorder.java.patch | 14 +- .../world/level/chunk/ChunkAccess.java.patch | 13 +- .../level/chunk/ChunkGenerator.java.patch | 18 +- .../level/chunk/EmptyLevelChunk.java.patch | 7 +- .../level/chunk/ImposterProtoChunk.java.patch | 7 +- .../world/level/chunk/LevelChunk.java.patch | 64 +- .../level/chunk/LevelChunkSection.java.patch | 2 +- .../world/level/chunk/ProtoChunk.java.patch | 13 +- .../world/level/chunk/UpgradeData.java.patch | 17 +- .../chunk/status/ChunkStatusTasks.java.patch | 7 +- .../chunk/storage/ChunkStorage.java.patch | 8 +- .../storage/SerializableChunkData.java.patch | 105 +- .../dimension/end/EndDragonFight.java.patch | 30 +- .../level/entity/EntityAccess.java.patch | 14 +- .../PersistentEntitySectionManager.java.patch | 30 +- .../gameevent/GameEventDispatcher.java.patch | 23 +- .../level/levelgen/PatrolSpawner.java.patch | 124 +- .../level/levelgen/PhantomSpawner.java.patch | 103 +- .../WorldGenerationContext.java.patch | 2 +- .../feature/EndPlatformFeature.java.patch | 23 +- .../levelgen/feature/SpikeFeature.java.patch | 2 +- .../LegacyStructureDataHandler.java.patch | 2 +- .../structure/StructureCheck.java.patch | 8 +- .../structure/StructurePiece.java.patch | 24 +- .../structure/StructureStart.java.patch | 2 +- .../placement/StructurePlacement.java.patch | 7 +- .../DesertPyramidStructure.java.patch | 5 +- .../structures/MineshaftPieces.java.patch | 2 +- .../NetherFortressPieces.java.patch | 2 +- .../structures/OceanRuinPieces.java.patch | 10 +- .../structures/ShipwreckPieces.java.patch | 2 +- .../structures/StrongholdPieces.java.patch | 2 +- .../structures/SwampHutPiece.java.patch | 4 +- .../StructureTemplate.java.patch | 51 +- .../level/material/FlowingFluid.java.patch | 8 +- .../level/material/FluidState.java.patch | 4 +- .../world/level/material/LavaFluid.java.patch | 59 +- .../level/material/WaterFluid.java.patch | 12 +- .../level/portal/PortalForcer.java.patch | 8 +- .../world/level/portal/PortalShape.java.patch | 2 +- .../DefaultRedstoneWireEvaluator.java.patch | 2 +- .../level/redstone/NeighborUpdater.java.patch | 15 +- .../maps/MapItemSavedData.java.patch | 227 +- .../storage/DimensionDataStorage.java.patch | 8 +- .../storage/LevelStorageSource.java.patch | 6 +- .../storage/PlayerDataStorage.java.patch | 15 +- .../level/storage/PrimaryLevelData.java.patch | 16 +- .../level/storage/loot/LootTable.java.patch | 6 +- .../ExplorationMapFunction.java.patch | 2 +- .../scores/ScoreboardSaveData.java.patch | 15 +- .../0015-Rewrite-dataconverter-system.patch | 0 .../block/impl/CraftAmethystCluster.java | 51 + .../craftbukkit/block/impl/CraftAnvil.java | 38 + .../block/impl/CraftAttachedStem.java | 38 + .../block/impl/CraftBambooStalk.java | 65 + .../craftbukkit/block/impl/CraftBanner.java | 35 + .../craftbukkit/block/impl/CraftBarrel.java | 51 + .../craftbukkit/block/impl/CraftBarrier.java | 27 + .../block/impl/CraftBaseCoralFan.java | 27 + .../block/impl/CraftBaseCoralPlant.java | 27 + .../block/impl/CraftBaseCoralWallFan.java | 51 + .../craftbukkit/block/impl/CraftBed.java | 65 + .../craftbukkit/block/impl/CraftBeehive.java | 56 + .../craftbukkit/block/impl/CraftBeetroot.java | 32 + .../craftbukkit/block/impl/CraftBell.java | 65 + .../block/impl/CraftBigDripleaf.java | 65 + .../block/impl/CraftBigDripleafStem.java | 52 + .../block/impl/CraftBlastFurnace.java | 51 + .../block/impl/CraftBrewingStand.java | 45 + .../block/impl/CraftBrushable.java | 32 + .../block/impl/CraftBubbleColumn.java | 27 + .../craftbukkit/block/impl/CraftButton.java | 66 + .../craftbukkit/block/impl/CraftCactus.java | 32 + .../craftbukkit/block/impl/CraftCake.java | 32 + .../impl/CraftCalibratedSculkSensor.java | 83 + .../craftbukkit/block/impl/CraftCampfire.java | 75 + .../craftbukkit/block/impl/CraftCandle.java | 62 + .../block/impl/CraftCandleCake.java | 27 + .../craftbukkit/block/impl/CraftCarrot.java | 32 + .../block/impl/CraftCarvedPumpkin.java | 38 + .../block/impl/CraftCaveVines.java | 45 + .../block/impl/CraftCaveVinesPlant.java | 27 + .../block/impl/CraftCeilingHangingSign.java | 60 + .../craftbukkit/block/impl/CraftChain.java | 50 + .../craftbukkit/block/impl/CraftChest.java | 65 + .../block/impl/CraftChiseledBookShelf.java | 70 + .../block/impl/CraftChorusFlower.java | 32 + .../block/impl/CraftChorusPlant.java | 58 + .../craftbukkit/block/impl/CraftCocoa.java | 56 + .../block/impl/CraftCommandBlock.java | 50 + .../block/impl/CraftComparator.java | 65 + .../block/impl/CraftComposter.java | 37 + .../craftbukkit/block/impl/CraftConduit.java | 27 + .../block/impl/CraftCopperBulb.java | 39 + .../craftbukkit/block/impl/CraftCoralFan.java | 27 + .../block/impl/CraftCoralPlant.java | 27 + .../block/impl/CraftCoralWallFan.java | 51 + .../craftbukkit/block/impl/CraftCrafter.java | 56 + .../block/impl/CraftCreakingHeart.java | 64 + .../craftbukkit/block/impl/CraftCrop.java | 32 + .../block/impl/CraftDaylightDetector.java | 45 + .../block/impl/CraftDecoratedPot.java | 63 + .../block/impl/CraftDetectorRail.java | 62 + .../block/impl/CraftDispenser.java | 51 + .../craftbukkit/block/impl/CraftDoor.java | 91 + .../block/impl/CraftDoublePlant.java | 30 + .../craftbukkit/block/impl/CraftDropper.java | 51 + .../block/impl/CraftEndPortalFrame.java | 51 + .../craftbukkit/block/impl/CraftEndRod.java | 38 + .../block/impl/CraftEnderChest.java | 51 + .../craftbukkit/block/impl/CraftFarm.java | 32 + .../craftbukkit/block/impl/CraftFence.java | 70 + .../block/impl/CraftFenceGate.java | 75 + .../craftbukkit/block/impl/CraftFire.java | 76 + .../block/impl/CraftFlowerBed.java | 61 + .../block/impl/CraftFrostedIce.java | 32 + .../craftbukkit/block/impl/CraftFurnace.java | 51 + .../block/impl/CraftGlazedTerracotta.java | 38 + .../block/impl/CraftGlowLichen.java | 76 + .../craftbukkit/block/impl/CraftGrass.java | 27 + .../block/impl/CraftGrindstone.java | 53 + .../block/impl/CraftHangingMoss.java | 27 + .../block/impl/CraftHangingRoots.java | 27 + .../craftbukkit/block/impl/CraftHay.java | 37 + .../block/impl/CraftHeavyCore.java | 27 + .../craftbukkit/block/impl/CraftHopper.java | 51 + .../block/impl/CraftHugeMushroom.java | 63 + .../impl/CraftInfestedRotatedPillar.java | 37 + .../craftbukkit/block/impl/CraftIronBars.java | 70 + .../craftbukkit/block/impl/CraftJigsaw.java | 30 + .../craftbukkit/block/impl/CraftJukebox.java | 27 + .../craftbukkit/block/impl/CraftKelp.java | 32 + .../craftbukkit/block/impl/CraftLadder.java | 51 + .../craftbukkit/block/impl/CraftLantern.java | 39 + .../block/impl/CraftLayeredCauldron.java | 37 + .../block/impl/CraftLeafLitter.java | 61 + .../craftbukkit/block/impl/CraftLectern.java | 63 + .../craftbukkit/block/impl/CraftLever.java | 66 + .../craftbukkit/block/impl/CraftLight.java | 50 + .../block/impl/CraftLightningRod.java | 63 + .../craftbukkit/block/impl/CraftLiquid.java | 37 + .../craftbukkit/block/impl/CraftLoom.java | 38 + .../block/impl/CraftMangroveLeaves.java | 62 + .../block/impl/CraftMangrovePropagule.java | 75 + .../block/impl/CraftMangroveRoots.java | 27 + .../block/impl/CraftMossyCarpet.java | 55 + .../block/impl/CraftMovingPiston.java | 52 + .../block/impl/CraftMultiface.java | 76 + .../craftbukkit/block/impl/CraftMycelium.java | 27 + .../block/impl/CraftNetherPortal.java | 38 + .../block/impl/CraftNetherWart.java | 32 + .../block/impl/CraftNoteBlock.java | 58 + .../craftbukkit/block/impl/CraftObserver.java | 51 + .../block/impl/CraftPiglinWallSkull.java | 51 + .../block/impl/CraftPistonBase.java | 51 + .../block/impl/CraftPistonHead.java | 65 + .../block/impl/CraftPitcherCrop.java | 48 + .../block/impl/CraftPlayerHead.java | 48 + .../block/impl/CraftPlayerWallHead.java | 51 + .../block/impl/CraftPointedDripstone.java | 65 + .../craftbukkit/block/impl/CraftPotato.java | 32 + .../block/impl/CraftPoweredRail.java | 62 + .../block/impl/CraftPressurePlate.java | 27 + .../craftbukkit/block/impl/CraftRail.java | 49 + .../block/impl/CraftRedStoneOre.java | 27 + .../block/impl/CraftRedStoneWire.java | 66 + .../block/impl/CraftRedstoneLamp.java | 27 + .../block/impl/CraftRedstoneTorch.java | 27 + .../block/impl/CraftRedstoneWallTorch.java | 51 + .../craftbukkit/block/impl/CraftRepeater.java | 86 + .../block/impl/CraftRespawnAnchor.java | 32 + .../block/impl/CraftRotatedPillar.java | 37 + .../craftbukkit/block/impl/CraftSapling.java | 32 + .../block/impl/CraftScaffolding.java | 57 + .../block/impl/CraftSculkCatalyst.java | 27 + .../block/impl/CraftSculkSensor.java | 61 + .../block/impl/CraftSculkShrieker.java | 51 + .../block/impl/CraftSculkVein.java | 76 + .../block/impl/CraftSeaPickle.java | 50 + .../block/impl/CraftShulkerBox.java | 38 + .../craftbukkit/block/impl/CraftSkull.java | 48 + .../craftbukkit/block/impl/CraftSlab.java | 43 + .../block/impl/CraftSmallDripleaf.java | 66 + .../craftbukkit/block/impl/CraftSmoker.java | 51 + .../block/impl/CraftSnifferEgg.java | 32 + .../block/impl/CraftSnowLayer.java | 37 + .../block/impl/CraftSnowyDirt.java | 27 + .../block/impl/CraftStainedGlassPane.java | 70 + .../craftbukkit/block/impl/CraftStair.java | 78 + .../block/impl/CraftStandingSign.java | 48 + .../craftbukkit/block/impl/CraftStem.java | 32 + .../block/impl/CraftStonecutter.java | 38 + .../block/impl/CraftStructureBlock.java | 29 + .../block/impl/CraftSugarCane.java | 32 + .../block/impl/CraftSweetBerryBush.java | 32 + .../block/impl/CraftTallFlower.java | 30 + .../block/impl/CraftTallSeagrass.java | 30 + .../craftbukkit/block/impl/CraftTarget.java | 32 + .../block/impl/CraftTestBlock.java | 29 + .../block/impl/CraftTintedParticleLeaves.java | 62 + .../craftbukkit/block/impl/CraftTnt.java | 27 + .../block/impl/CraftTorchflowerCrop.java | 32 + .../craftbukkit/block/impl/CraftTrapDoor.java | 88 + .../block/impl/CraftTrappedChest.java | 65 + .../block/impl/CraftTrialSpawner.java | 43 + .../craftbukkit/block/impl/CraftTripWire.java | 97 + .../block/impl/CraftTripWireHook.java | 63 + .../block/impl/CraftTurtleEgg.java | 54 + .../block/impl/CraftTwistingVines.java | 32 + .../impl/CraftUntintedParticleLeaves.java | 62 + .../craftbukkit/block/impl/CraftVault.java | 66 + .../craftbukkit/block/impl/CraftVine.java | 58 + .../craftbukkit/block/impl/CraftWall.java | 66 + .../block/impl/CraftWallBanner.java | 38 + .../block/impl/CraftWallHangingSign.java | 51 + .../craftbukkit/block/impl/CraftWallSign.java | 51 + .../block/impl/CraftWallSkull.java | 51 + .../block/impl/CraftWallTorch.java | 38 + .../impl/CraftWaterloggedTransparent.java | 27 + .../block/impl/CraftWeatheringCopperBulb.java | 39 + .../block/impl/CraftWeatheringCopperDoor.java | 91 + .../impl/CraftWeatheringCopperGrate.java | 27 + .../block/impl/CraftWeatheringCopperSlab.java | 43 + .../impl/CraftWeatheringCopperStair.java | 78 + .../impl/CraftWeatheringCopperTrapDoor.java | 88 + .../block/impl/CraftWeepingVines.java | 32 + .../impl/CraftWeightedPressurePlate.java | 32 + .../block/impl/CraftWitherSkull.java | 48 + .../block/impl/CraftWitherWallSkull.java | 51 + .../list/IteratorSafeOrderedReferenceSet.java | 32 +- .../common/misc/PositionCountingAreaMap.java | 14 +- .../common/misc/SingleUserAreaMap.java | 10 +- .../common/util/ChunkSystemHooks.java | 3 + .../java/com/destroystokyo/paper/Metrics.java | 7 +- .../paper/PaperVersionFetcher.java | 6 +- .../paper/entity/PaperPathfinder.java | 54 +- .../paper/entity/ai/MobGoalHelper.java | 194 +- .../{PaperVanillaGoal.java => PaperGoal.java} | 4 +- .../paper/entity/ai/PaperMobGoals.java | 16 +- .../loottable/PaperLootableInventoryData.java | 42 +- .../paper/profile/CraftPlayerProfile.java | 7 +- .../profile/PaperMinecraftSessionService.java | 2 +- .../paper/PaperServerInternalAPIBridge.java | 10 + .../advancement/PaperAdvancementDisplay.java | 2 +- .../paper/adventure/AdventureCodecs.java | 211 +- .../paper/adventure/ChatProcessor.java | 48 +- .../paper/adventure/PaperAdventure.java | 3 +- .../NBTLegacyHoverEventSerializer.java | 14 +- .../ChunkPacketBlockControllerAntiXray.java | 4 +- .../paper/block/fluid/PaperFluidData.java | 32 +- .../command/brigadier/PaperBrigadier.java | 2 +- .../PluginVanillaCommandWrapper.java | 13 +- .../command/subcommands/VersionCommand.java | 6 +- .../configuration/GlobalConfiguration.java | 2 +- .../configuration/WorldConfiguration.java | 7 +- .../datacomponent/DataComponentAdapters.java | 64 +- .../item/ItemComponentTypesBridgesImpl.java | 20 +- .../item/PaperBlocksAttacks.java | 119 + .../item/PaperDyedItemColor.java | 21 +- .../datacomponent/item/PaperEquippable.java | 21 +- .../item/PaperItemAdventurePredicate.java | 25 +- .../item/PaperItemArmorTrim.java | 21 +- .../item/PaperItemAttributeModifiers.java | 22 +- .../item/PaperItemEnchantments.java | 19 +- .../datacomponent/item/PaperItemTool.java | 16 +- .../item/PaperJukeboxPlayable.java | 21 +- .../item/PaperTooltipDisplay.java | 63 + .../datacomponent/item/PaperUnbreakable.java | 39 - .../paper/datacomponent/item/PaperWeapon.java | 52 + .../datapack/PaperDatapackRegistrar.java | 4 +- .../PaperPersistentDataContainerView.java | 4 +- .../paper/registry/HolderableBase.java | 39 + .../paper/registry/PaperRegistries.java | 24 +- .../data/PaperEnchantmentRegistryEntry.java | 2 +- .../java/io/papermc/paper/util/MCUtil.java | 12 - .../paper/util/MappingEnvironment.java | 2 +- .../ItemComponentSanitizer.java | 2 +- .../ItemObfuscationBinding.java | 5 +- .../ItemObfuscationSession.java | 3 +- .../OversizedItemComponentSanitizer.java | 3 +- .../world/flag/PaperFeatureDependent.java | 10 +- .../flag/PaperFeatureFlagProviderImpl.java | 9 +- .../java/org/bukkit/craftbukkit/CraftArt.java | 3 +- .../org/bukkit/craftbukkit/CraftChunk.java | 133 +- .../craftbukkit/CraftChunkSnapshot.java | 54 +- .../bukkit/craftbukkit/CraftCrashReport.java | 4 +- .../craftbukkit/CraftEquipmentSlot.java | 51 +- .../craftbukkit/CraftExplosionResult.java | 20 +- .../org/bukkit/craftbukkit/CraftFluid.java | 81 +- .../craftbukkit/CraftFluidCollisionMode.java | 17 +- .../bukkit/craftbukkit/CraftGameEvent.java | 2 - .../bukkit/craftbukkit/CraftHeightMap.java | 49 +- .../org/bukkit/craftbukkit/CraftInput.java | 33 +- .../bukkit/craftbukkit/CraftLootTable.java | 14 +- .../craftbukkit/CraftMusicInstrument.java | 7 +- .../craftbukkit/CraftOfflinePlayer.java | 145 +- .../org/bukkit/craftbukkit/CraftParticle.java | 3 +- .../org/bukkit/craftbukkit/CraftRaid.java | 12 +- .../craftbukkit/CraftRegionAccessor.java | 56 +- .../org/bukkit/craftbukkit/CraftRegistry.java | 4 +- .../org/bukkit/craftbukkit/CraftServer.java | 376 +- .../bukkit/craftbukkit/CraftServerLinks.java | 4 - .../org/bukkit/craftbukkit/CraftSound.java | 6 - .../bukkit/craftbukkit/CraftSoundGroup.java | 4 +- .../bukkit/craftbukkit/CraftStatistic.java | 142 +- .../org/bukkit/craftbukkit/CraftWorld.java | 71 +- .../java/org/bukkit/craftbukkit/Main.java | 42 +- .../advancement/CraftAdvancement.java | 5 +- .../advancement/CraftAdvancementDisplay.java | 2 +- .../craftbukkit/attribute/CraftAttribute.java | 1 - .../attribute/CraftAttributeInstance.java | 7 +- .../attribute/CraftAttributeMap.java | 35 +- .../craftbukkit/ban/CraftProfileBanEntry.java | 2 - .../craftbukkit/ban/CraftProfileBanList.java | 10 +- .../craftbukkit/block/CapturedBlockState.java | 67 +- .../bukkit/craftbukkit/block/CraftBanner.java | 40 +- .../bukkit/craftbukkit/block/CraftBarrel.java | 30 +- .../bukkit/craftbukkit/block/CraftBeacon.java | 29 +- .../bukkit/craftbukkit/block/CraftBed.java | 59 +- .../craftbukkit/block/CraftBeehive.java | 8 +- .../bukkit/craftbukkit/block/CraftBell.java | 28 +- .../bukkit/craftbukkit/block/CraftBiome.java | 137 +- .../craftbukkit/block/CraftBlastFurnace.java | 4 +- .../bukkit/craftbukkit/block/CraftBlock.java | 118 +- .../block/CraftBlockEntityState.java | 119 +- .../craftbukkit/block/CraftBlockState.java | 81 +- .../craftbukkit/block/CraftBlockStates.java | 226 +- .../craftbukkit/block/CraftBlockType.java | 101 +- .../craftbukkit/block/CraftBrewingStand.java | 6 +- .../block/CraftBrushableBlock.java | 10 +- .../block/CraftCalibratedSculkSensor.java | 4 +- .../craftbukkit/block/CraftCampfire.java | 23 +- .../bukkit/craftbukkit/block/CraftChest.java | 32 +- .../block/CraftChiseledBookshelf.java | 6 +- .../craftbukkit/block/CraftCommandBlock.java | 12 +- .../craftbukkit/block/CraftComparator.java | 4 +- .../craftbukkit/block/CraftConduit.java | 20 +- .../craftbukkit/block/CraftContainer.java | 27 +- .../craftbukkit/block/CraftCrafter.java | 6 +- .../craftbukkit/block/CraftCreakingHeart.java | 4 +- .../block/CraftCreatureSpawner.java | 30 +- .../block/CraftDaylightDetector.java | 4 +- .../craftbukkit/block/CraftDecoratedPot.java | 6 +- .../craftbukkit/block/CraftDispenser.java | 8 +- .../craftbukkit/block/CraftDropper.java | 6 +- .../block/CraftEnchantingTable.java | 16 +- .../craftbukkit/block/CraftEndGateway.java | 10 +- .../craftbukkit/block/CraftEndPortal.java | 4 +- .../craftbukkit/block/CraftEnderChest.java | 30 +- .../craftbukkit/block/CraftFurnace.java | 6 +- .../block/CraftFurnaceFurnace.java | 4 +- .../craftbukkit/block/CraftHangingSign.java | 4 +- .../bukkit/craftbukkit/block/CraftHopper.java | 6 +- .../bukkit/craftbukkit/block/CraftJigsaw.java | 4 +- .../craftbukkit/block/CraftJukebox.java | 30 +- .../craftbukkit/block/CraftLectern.java | 6 +- .../craftbukkit/block/CraftLootable.java | 10 +- .../craftbukkit/block/CraftMovingPiston.java | 12 +- .../craftbukkit/block/CraftSculkCatalyst.java | 16 +- .../craftbukkit/block/CraftSculkSensor.java | 4 +- .../craftbukkit/block/CraftSculkShrieker.java | 8 +- .../craftbukkit/block/CraftShulkerBox.java | 24 +- .../bukkit/craftbukkit/block/CraftSign.java | 22 +- .../bukkit/craftbukkit/block/CraftSkull.java | 16 +- .../bukkit/craftbukkit/block/CraftSmoker.java | 4 +- .../block/CraftStructureBlock.java | 18 +- .../block/CraftSuspiciousSand.java | 27 - .../craftbukkit/block/CraftTestBlock.java | 27 + .../block/CraftTestInstanceBlock.java | 27 + .../craftbukkit/block/CraftTrialSpawner.java | 16 +- .../block/CraftTrialSpawnerConfiguration.java | 61 +- .../bukkit/craftbukkit/block/CraftVault.java | 4 +- .../craftbukkit/block/data/CraftAgeable.java | 23 - .../block/data/CraftAnaloguePowerable.java | 23 - .../block/data/CraftAttachable.java | 18 - .../craftbukkit/block/data/CraftBisected.java | 18 - .../block/data/CraftBlockData.java | 257 +- .../block/data/CraftBrushable.java | 23 - .../block/data/CraftDirectional.java | 23 - .../block/data/CraftFaceAttachable.java | 18 - .../craftbukkit/block/data/CraftHangable.java | 18 - .../block/data/CraftHatchable.java | 23 - .../craftbukkit/block/data/CraftLevelled.java | 23 - .../block/data/CraftLightable.java | 18 - .../block/data/CraftMultipleFacing.java | 54 - .../craftbukkit/block/data/CraftOpenable.java | 18 - .../block/data/CraftOrientable.java | 23 - .../block/data/CraftPowerable.java | 18 - .../craftbukkit/block/data/CraftRail.java | 23 - .../block/data/CraftRotatable.java | 107 - .../craftbukkit/block/data/CraftSnowable.java | 18 - .../block/data/CraftWaterlogged.java | 18 - .../block/data/type/CraftBamboo.java | 19 - .../craftbukkit/block/data/type/CraftBed.java | 25 - .../block/data/type/CraftBeehive.java | 24 - .../block/data/type/CraftBell.java | 19 - .../block/data/type/CraftBigDripleaf.java | 19 - .../block/data/type/CraftBrewingStand.java | 39 - .../block/data/type/CraftBrushable.java | 24 - .../block/data/type/CraftBubbleColumn.java | 19 - .../block/data/type/CraftCake.java | 24 - .../block/data/type/CraftCampfire.java | 19 - .../block/data/type/CraftCandle.java | 24 - .../block/data/type/CraftCaveVinesPlant.java | 19 - .../block/data/type/CraftChest.java | 19 - .../data/type/CraftChiseledBookshelf.java | 40 - .../block/data/type/CraftCommandBlock.java | 19 - .../block/data/type/CraftComparator.java | 19 - .../block/data/type/CraftCrafter.java | 41 - .../block/data/type/CraftCreakingHeart.java | 30 - .../data/type/CraftDaylightDetector.java | 19 - .../block/data/type/CraftDispenser.java | 19 - .../block/data/type/CraftDoor.java | 19 - .../block/data/type/CraftEndPortalFrame.java | 19 - .../block/data/type/CraftFarmland.java | 24 - .../block/data/type/CraftGate.java | 19 - .../block/data/type/CraftHangingMoss.java | 19 - .../block/data/type/CraftHopper.java | 19 - .../block/data/type/CraftJigsaw.java | 19 - .../block/data/type/CraftJukebox.java | 14 - .../block/data/type/CraftLeaves.java | 30 - .../block/data/type/CraftLectern.java | 14 - .../block/data/type/CraftMossyCarpet.java | 32 - .../block/data/type/CraftNoteBlock.java | 30 - .../block/data/type/CraftPinkPetals.java | 24 - .../block/data/type/CraftPiston.java | 19 - .../block/data/type/CraftPistonHead.java | 19 - .../data/type/CraftPointedDripstone.java | 35 - .../block/data/type/CraftRedstoneWire.java | 53 - .../block/data/type/CraftRepeater.java | 40 - .../block/data/type/CraftRespawnAnchor.java | 24 - .../block/data/type/CraftSapling.java | 24 - .../block/data/type/CraftScaffolding.java | 35 - .../block/data/type/CraftSculkCatalyst.java | 19 - .../block/data/type/CraftSculkSensor.java | 19 - .../block/data/type/CraftSculkShrieker.java | 30 - .../block/data/type/CraftSeaPickle.java | 29 - .../block/data/type/CraftSlab.java | 19 - .../block/data/type/CraftSnow.java | 29 - .../block/data/type/CraftStairs.java | 19 - .../block/data/type/CraftStructureBlock.java | 19 - .../block/data/type/CraftSwitch.java | 19 - .../craftbukkit/block/data/type/CraftTNT.java | 19 - .../block/data/type/CraftTechnicalPiston.java | 19 - .../block/data/type/CraftTrialSpawner.java | 30 - .../block/data/type/CraftTripwire.java | 19 - .../block/data/type/CraftTurtleEgg.java | 29 - .../block/data/type/CraftVault.java | 40 - .../block/data/type/CraftWall.java | 32 - .../block/impl/CraftAmethystCluster.java | 48 - .../craftbukkit/block/impl/CraftAnvil.java | 34 - .../craftbukkit/block/impl/CraftBamboo.java | 67 - .../craftbukkit/block/impl/CraftBanner.java | 118 - .../block/impl/CraftBannerWall.java | 34 - .../craftbukkit/block/impl/CraftBarrel.java | 48 - .../craftbukkit/block/impl/CraftBarrier.java | 29 - .../craftbukkit/block/impl/CraftBed.java | 61 - .../craftbukkit/block/impl/CraftBeehive.java | 53 - .../craftbukkit/block/impl/CraftBeetroot.java | 34 - .../craftbukkit/block/impl/CraftBell.java | 62 - .../block/impl/CraftBigDripleaf.java | 62 - .../block/impl/CraftBigDripleafStem.java | 48 - .../block/impl/CraftBlastFurnace.java | 48 - .../block/impl/CraftBrewingStand.java | 49 - .../block/impl/CraftBrushable.java | 34 - .../block/impl/CraftBubbleColumn.java | 29 - .../block/impl/CraftButtonAbstract.java | 76 - .../craftbukkit/block/impl/CraftCactus.java | 34 - .../craftbukkit/block/impl/CraftCake.java | 34 - .../impl/CraftCalibratedSculkSensor.java | 81 - .../craftbukkit/block/impl/CraftCampfire.java | 76 - .../craftbukkit/block/impl/CraftCandle.java | 68 - .../block/impl/CraftCandleCake.java | 29 - .../craftbukkit/block/impl/CraftCarrots.java | 34 - .../block/impl/CraftCaveVines.java | 48 - .../block/impl/CraftCaveVinesPlant.java | 29 - .../block/impl/CraftCeilingHangingSign.java | 146 - .../craftbukkit/block/impl/CraftChain.java | 48 - .../craftbukkit/block/impl/CraftChest.java | 62 - .../block/impl/CraftChestTrapped.java | 62 - .../block/impl/CraftChiseledBookShelf.java | 69 - .../block/impl/CraftChorusFlower.java | 34 - .../block/impl/CraftChorusFruit.java | 65 - .../block/impl/CraftCobbleWall.java | 56 - .../craftbukkit/block/impl/CraftCocoa.java | 53 - .../craftbukkit/block/impl/CraftCommand.java | 48 - .../block/impl/CraftComposter.java | 41 - .../craftbukkit/block/impl/CraftConduit.java | 29 - .../block/impl/CraftCopperBulb.java | 43 - .../block/impl/CraftCoralDead.java | 29 - .../craftbukkit/block/impl/CraftCoralFan.java | 29 - .../block/impl/CraftCoralFanAbstract.java | 29 - .../block/impl/CraftCoralFanWall.java | 48 - .../block/impl/CraftCoralFanWallAbstract.java | 48 - .../block/impl/CraftCoralPlant.java | 29 - .../craftbukkit/block/impl/CraftCrafter.java | 51 - .../block/impl/CraftCreakingHeart.java | 59 - .../craftbukkit/block/impl/CraftCrops.java | 34 - .../block/impl/CraftDaylightDetector.java | 48 - .../block/impl/CraftDecoratedPot.java | 62 - .../craftbukkit/block/impl/CraftDirtSnow.java | 29 - .../block/impl/CraftDispenser.java | 48 - .../craftbukkit/block/impl/CraftDoor.java | 90 - .../craftbukkit/block/impl/CraftDropper.java | 48 - .../craftbukkit/block/impl/CraftEndRod.java | 34 - .../block/impl/CraftEnderChest.java | 48 - .../block/impl/CraftEnderPortalFrame.java | 48 - .../craftbukkit/block/impl/CraftFence.java | 79 - .../block/impl/CraftFenceGate.java | 76 - .../craftbukkit/block/impl/CraftFire.java | 84 - .../block/impl/CraftFloorSign.java | 132 - .../craftbukkit/block/impl/CraftFluids.java | 41 - .../block/impl/CraftFurnaceFurace.java | 48 - .../block/impl/CraftGlazedTerracotta.java | 34 - .../block/impl/CraftGlowLichen.java | 79 - .../craftbukkit/block/impl/CraftGrass.java | 29 - .../block/impl/CraftGrindstone.java | 48 - .../block/impl/CraftHangingMoss.java | 29 - .../block/impl/CraftHangingRoots.java | 29 - .../craftbukkit/block/impl/CraftHay.java | 34 - .../block/impl/CraftHeavyCore.java | 29 - .../craftbukkit/block/impl/CraftHopper.java | 48 - .../block/impl/CraftHugeMushroom.java | 65 - .../craftbukkit/block/impl/CraftIceFrost.java | 34 - .../impl/CraftInfestedRotatedPillar.java | 34 - .../craftbukkit/block/impl/CraftIronBars.java | 79 - .../craftbukkit/block/impl/CraftJigsaw.java | 29 - .../craftbukkit/block/impl/CraftJukeBox.java | 24 - .../craftbukkit/block/impl/CraftKelp.java | 34 - .../craftbukkit/block/impl/CraftLadder.java | 48 - .../craftbukkit/block/impl/CraftLantern.java | 43 - .../block/impl/CraftLayeredCauldron.java | 41 - .../craftbukkit/block/impl/CraftLeaves.java | 66 - .../craftbukkit/block/impl/CraftLectern.java | 57 - .../craftbukkit/block/impl/CraftLever.java | 76 - .../craftbukkit/block/impl/CraftLight.java | 55 - .../block/impl/CraftLightningRod.java | 62 - .../craftbukkit/block/impl/CraftLoom.java | 34 - .../block/impl/CraftMangroveLeaves.java | 66 - .../block/impl/CraftMangrovePropagule.java | 81 - .../block/impl/CraftMangroveRoots.java | 29 - .../block/impl/CraftMinecartDetector.java | 62 - .../block/impl/CraftMinecartTrack.java | 48 - .../block/impl/CraftMossyCarpet.java | 42 - .../block/impl/CraftMultiface.java | 79 - .../craftbukkit/block/impl/CraftMycel.java | 29 - .../block/impl/CraftNetherWart.java | 34 - .../craftbukkit/block/impl/CraftNote.java | 54 - .../craftbukkit/block/impl/CraftObserver.java | 48 - .../block/impl/CraftParticleLeaves.java | 66 - .../block/impl/CraftPiglinWallSkull.java | 48 - .../block/impl/CraftPinkPetals.java | 60 - .../craftbukkit/block/impl/CraftPiston.java | 48 - .../block/impl/CraftPistonExtension.java | 62 - .../block/impl/CraftPistonMoving.java | 48 - .../block/impl/CraftPitcherCrop.java | 48 - .../block/impl/CraftPointedDripstone.java | 59 - .../craftbukkit/block/impl/CraftPortal.java | 34 - .../craftbukkit/block/impl/CraftPotatoes.java | 34 - .../block/impl/CraftPoweredRail.java | 62 - .../block/impl/CraftPressurePlateBinary.java | 29 - .../impl/CraftPressurePlateWeighted.java | 34 - .../block/impl/CraftPumpkinCarved.java | 34 - .../block/impl/CraftRedstoneComparator.java | 62 - .../block/impl/CraftRedstoneLamp.java | 29 - .../block/impl/CraftRedstoneOre.java | 29 - .../block/impl/CraftRedstoneTorch.java | 29 - .../block/impl/CraftRedstoneTorchWall.java | 48 - .../block/impl/CraftRedstoneWire.java | 82 - .../craftbukkit/block/impl/CraftReed.java | 34 - .../craftbukkit/block/impl/CraftRepeater.java | 83 - .../block/impl/CraftRespawnAnchor.java | 34 - .../block/impl/CraftRotatable.java | 34 - .../craftbukkit/block/impl/CraftSapling.java | 34 - .../block/impl/CraftScaffolding.java | 59 - .../block/impl/CraftSculkCatalyst.java | 29 - .../block/impl/CraftSculkSensor.java | 62 - .../block/impl/CraftSculkShrieker.java | 54 - .../block/impl/CraftSculkVein.java | 79 - .../block/impl/CraftSeaPickle.java | 53 - .../block/impl/CraftShulkerBox.java | 34 - .../craftbukkit/block/impl/CraftSkull.java | 132 - .../block/impl/CraftSkullPlayer.java | 132 - .../block/impl/CraftSkullPlayerWall.java | 48 - .../block/impl/CraftSkullWall.java | 48 - .../block/impl/CraftSmallDripleaf.java | 62 - .../craftbukkit/block/impl/CraftSmoker.java | 48 - .../block/impl/CraftSnifferEgg.java | 34 - .../craftbukkit/block/impl/CraftSnow.java | 39 - .../craftbukkit/block/impl/CraftSoil.java | 34 - .../block/impl/CraftStainedGlassPane.java | 79 - .../craftbukkit/block/impl/CraftStairs.java | 76 - .../craftbukkit/block/impl/CraftStem.java | 34 - .../block/impl/CraftStemAttached.java | 34 - .../block/impl/CraftStepAbstract.java | 43 - .../block/impl/CraftStonecutter.java | 34 - .../block/impl/CraftStructure.java | 29 - .../block/impl/CraftSweetBerryBush.java | 34 - .../craftbukkit/block/impl/CraftTNT.java | 29 - .../block/impl/CraftTallPlant.java | 29 - .../block/impl/CraftTallPlantFlower.java | 29 - .../block/impl/CraftTallSeagrass.java | 29 - .../craftbukkit/block/impl/CraftTarget.java | 34 - .../block/impl/CraftTorchWall.java | 34 - .../block/impl/CraftTorchflowerCrop.java | 34 - .../craftbukkit/block/impl/CraftTrapdoor.java | 90 - .../block/impl/CraftTrialSpawner.java | 40 - .../craftbukkit/block/impl/CraftTripwire.java | 107 - .../block/impl/CraftTripwireHook.java | 62 - .../block/impl/CraftTurtleEgg.java | 58 - .../block/impl/CraftTwistingVines.java | 34 - .../craftbukkit/block/impl/CraftVault.java | 69 - .../craftbukkit/block/impl/CraftVine.java | 65 - .../block/impl/CraftWallHangingSign.java | 48 - .../craftbukkit/block/impl/CraftWallSign.java | 48 - .../impl/CraftWaterloggedTransparent.java | 29 - .../block/impl/CraftWeatheringCopperBulb.java | 43 - .../block/impl/CraftWeatheringCopperDoor.java | 90 - .../impl/CraftWeatheringCopperGrate.java | 29 - .../block/impl/CraftWeatheringCopperSlab.java | 43 - .../impl/CraftWeatheringCopperStair.java | 76 - .../impl/CraftWeatheringCopperTrapDoor.java | 90 - .../block/impl/CraftWeepingVines.java | 34 - .../block/impl/CraftWitherSkull.java | 132 - .../block/impl/CraftWitherSkullWall.java | 48 - .../craftbukkit/block/sign/CraftSignSide.java | 17 +- .../bukkit/craftbukkit/boss/CraftBossBar.java | 56 +- .../craftbukkit/boss/CraftDragonBattle.java | 28 +- .../command/BukkitCommandWrapper.java | 2 - .../command/ColouredConsoleSender.java | 95 - .../command/ConsoleCommandCompleter.java | 50 +- .../command/CraftBlockCommandSender.java | 12 +- .../command/CraftConsoleCommandSender.java | 4 - .../CraftRemoteConsoleCommandSender.java | 4 - .../command/ProxiedNativeCommandSender.java | 9 +- .../command/ServerCommandSender.java | 26 +- .../command/VanillaCommandWrapper.java | 25 +- .../ConfigSerializationUtil.java | 51 +- .../conversations/ConversationTracker.java | 4 +- .../craftbukkit/damage/CraftDamageSource.java | 2 +- .../damage/CraftDamageSourceBuilder.java | 3 +- .../craftbukkit/damage/CraftDamageType.java | 48 +- .../enchantments/CraftEnchantment.java | 12 +- .../entity/CraftAbstractArrow.java | 9 +- .../craftbukkit/entity/CraftAbstractCow.java | 19 + .../entity/CraftAbstractHorse.java | 17 +- .../entity/CraftAbstractSkeleton.java | 6 +- .../entity/CraftAbstractVillager.java | 4 +- .../craftbukkit/entity/CraftAgeable.java | 2 +- .../entity/CraftAreaEffectCloud.java | 2 - .../craftbukkit/entity/CraftArmorStand.java | 85 +- .../bukkit/craftbukkit/entity/CraftArrow.java | 2 - .../craftbukkit/entity/CraftAxolotl.java | 2 +- .../bukkit/craftbukkit/entity/CraftBat.java | 8 +- .../bukkit/craftbukkit/entity/CraftBee.java | 3 +- .../bukkit/craftbukkit/entity/CraftBoat.java | 2 - .../bukkit/craftbukkit/entity/CraftCat.java | 4 +- .../craftbukkit/entity/CraftChestBoat.java | 5 - .../craftbukkit/entity/CraftChicken.java | 71 +- .../bukkit/craftbukkit/entity/CraftCow.java | 45 +- .../craftbukkit/entity/CraftDolphin.java | 8 +- .../craftbukkit/entity/CraftEnderCrystal.java | 2 +- .../craftbukkit/entity/CraftEnderDragon.java | 10 +- .../entity/CraftEnderDragonPart.java | 2 - .../craftbukkit/entity/CraftEnderman.java | 2 - .../craftbukkit/entity/CraftEndermite.java | 3 +- .../craftbukkit/entity/CraftEntity.java | 208 +- .../entity/CraftEntityFactory.java | 2 +- .../entity/CraftEntitySnapshot.java | 10 +- .../craftbukkit/entity/CraftEntityTypes.java | 23 +- .../craftbukkit/entity/CraftEvoker.java | 8 +- .../entity/CraftExperienceOrb.java | 24 +- .../craftbukkit/entity/CraftFallingBlock.java | 10 +- .../craftbukkit/entity/CraftFireball.java | 12 +- .../craftbukkit/entity/CraftFirework.java | 24 +- .../craftbukkit/entity/CraftFishHook.java | 3 +- .../bukkit/craftbukkit/entity/CraftFox.java | 46 +- .../bukkit/craftbukkit/entity/CraftFrog.java | 4 +- .../bukkit/craftbukkit/entity/CraftGhast.java | 2 - .../bukkit/craftbukkit/entity/CraftGoat.java | 2 - .../bukkit/craftbukkit/entity/CraftHorse.java | 3 +- .../craftbukkit/entity/CraftHumanEntity.java | 107 +- .../bukkit/craftbukkit/entity/CraftItem.java | 11 +- .../craftbukkit/entity/CraftItemFrame.java | 6 - .../entity/CraftLightningStrike.java | 5 +- .../craftbukkit/entity/CraftLivingEntity.java | 118 +- .../bukkit/craftbukkit/entity/CraftLlama.java | 5 +- .../craftbukkit/entity/CraftLlamaSpit.java | 3 - .../craftbukkit/entity/CraftMinecart.java | 36 +- .../entity/CraftMinecartChest.java | 1 - .../entity/CraftMinecartCommand.java | 6 +- .../entity/CraftMinecartContainer.java | 5 - .../entity/CraftMinecartFurnace.java | 15 +- .../entity/CraftMinecartHopper.java | 7 +- .../entity/CraftMinecartMobSpawner.java | 6 +- .../craftbukkit/entity/CraftMinecartTNT.java | 5 +- .../bukkit/craftbukkit/entity/CraftMob.java | 14 +- .../craftbukkit/entity/CraftMushroomCow.java | 2 +- .../craftbukkit/entity/CraftOcelot.java | 1 - .../bukkit/craftbukkit/entity/CraftPanda.java | 1 - .../craftbukkit/entity/CraftParrot.java | 2 +- .../craftbukkit/entity/CraftPhantom.java | 21 +- .../bukkit/craftbukkit/entity/CraftPig.java | 49 +- .../craftbukkit/entity/CraftPiglin.java | 3 +- .../craftbukkit/entity/CraftPlayer.java | 196 +- .../craftbukkit/entity/CraftPolarBear.java | 2 - .../craftbukkit/entity/CraftProjectile.java | 4 - .../craftbukkit/entity/CraftRabbit.java | 4 +- .../craftbukkit/entity/CraftRaider.java | 2 +- .../craftbukkit/entity/CraftRavager.java | 3 +- .../craftbukkit/entity/CraftSalmon.java | 2 +- .../bukkit/craftbukkit/entity/CraftSheep.java | 6 +- .../entity/CraftShulkerBullet.java | 4 - .../craftbukkit/entity/CraftSkeleton.java | 4 +- .../entity/CraftSkeletonHorse.java | 12 - .../bukkit/craftbukkit/entity/CraftSlime.java | 6 +- .../craftbukkit/entity/CraftSniffer.java | 6 +- .../craftbukkit/entity/CraftStrider.java | 5 +- .../craftbukkit/entity/CraftTNTPrimed.java | 2 - .../craftbukkit/entity/CraftTadpole.java | 3 +- .../entity/CraftTameableAnimal.java | 15 +- .../craftbukkit/entity/CraftTextDisplay.java | 3 +- .../entity/CraftThrowableProjectile.java | 2 +- .../entity/CraftThrownLingeringPotion.java | 38 + .../craftbukkit/entity/CraftThrownPotion.java | 30 +- .../entity/CraftThrownSplashPotion.java | 38 + .../craftbukkit/entity/CraftTrident.java | 2 - .../craftbukkit/entity/CraftTropicalFish.java | 48 +- .../craftbukkit/entity/CraftTurtle.java | 7 +- .../bukkit/craftbukkit/entity/CraftVex.java | 6 +- .../craftbukkit/entity/CraftVillager.java | 48 +- .../entity/CraftVillagerZombie.java | 10 +- .../entity/CraftWanderingTrader.java | 7 +- .../craftbukkit/entity/CraftWarden.java | 2 - .../bukkit/craftbukkit/entity/CraftWitch.java | 20 +- .../craftbukkit/entity/CraftWither.java | 2 - .../bukkit/craftbukkit/entity/CraftWolf.java | 96 +- .../craftbukkit/entity/CraftZombie.java | 3 +- .../entity/memory/CraftMemoryKey.java | 2 +- .../entity/memory/CraftMemoryMapper.java | 17 +- .../craftbukkit/event/CraftEventFactory.java | 814 +-- .../craftbukkit/generator/CraftChunkData.java | 18 +- .../generator/CraftLimitedRegion.java | 2 +- .../craftbukkit/generator/CraftWorldInfo.java | 5 +- .../generator/CustomChunkGenerator.java | 8 +- .../generator/OldCraftChunkData.java | 1 - .../structure/CraftGeneratedStructure.java | 6 +- .../structure/CraftStructurePiece.java | 4 +- .../craftbukkit/help/CustomHelpTopic.java | 2 +- .../help/CustomIndexHelpTopic.java | 6 +- .../craftbukkit/help/HelpTopicAmendment.java | 4 + .../craftbukkit/help/HelpYamlReader.java | 10 +- .../craftbukkit/help/SimpleHelpMap.java | 13 +- .../inventory/CraftAbstractInventoryView.java | 2 +- .../inventory/CraftEntityEquipment.java | 22 +- .../craftbukkit/inventory/CraftInventory.java | 2 +- .../CraftInventoryAbstractHorse.java | 25 +- .../inventory/CraftInventoryCustom.java | 23 +- .../inventory/CraftInventoryDoubleChest.java | 14 +- .../inventory/CraftInventoryJukebox.java | 2 +- .../inventory/CraftInventoryLectern.java | 4 +- .../inventory/CraftInventoryPlayer.java | 95 +- .../inventory/CraftInventoryView.java | 10 +- .../inventory/CraftItemFactory.java | 3 +- .../craftbukkit/inventory/CraftItemMetas.java | 6 +- .../craftbukkit/inventory/CraftItemStack.java | 98 +- .../craftbukkit/inventory/CraftItemType.java | 109 +- .../craftbukkit/inventory/CraftMenuType.java | 52 +- .../inventory/CraftMerchantCustom.java | 10 +- .../inventory/CraftMerchantRecipe.java | 6 +- .../craftbukkit/inventory/CraftMetaArmor.java | 25 +- .../inventory/CraftMetaArmorStand.java | 74 +- .../inventory/CraftMetaAxolotlBucket.java | 47 +- .../inventory/CraftMetaBanner.java | 23 +- .../inventory/CraftMetaBlockState.java | 120 +- .../craftbukkit/inventory/CraftMetaBook.java | 46 +- .../inventory/CraftMetaBookSigned.java | 72 +- .../inventory/CraftMetaBundle.java | 26 +- .../inventory/CraftMetaCharge.java | 21 +- .../inventory/CraftMetaColorableArmor.java | 37 +- .../inventory/CraftMetaCompass.java | 68 +- .../inventory/CraftMetaCrossbow.java | 47 +- .../inventory/CraftMetaEnchantedBook.java | 54 +- .../inventory/CraftMetaEntityTag.java | 22 +- .../inventory/CraftMetaFirework.java | 41 +- .../craftbukkit/inventory/CraftMetaItem.java | 633 +- .../inventory/CraftMetaKnowledgeBook.java | 34 +- .../inventory/CraftMetaLeatherArmor.java | 69 +- .../craftbukkit/inventory/CraftMetaMap.java | 34 +- .../inventory/CraftMetaMusicInstrument.java | 23 +- .../inventory/CraftMetaOminousBottle.java | 17 +- .../inventory/CraftMetaPotion.java | 24 +- .../inventory/CraftMetaShield.java | 82 +- .../craftbukkit/inventory/CraftMetaSkull.java | 57 +- .../inventory/CraftMetaSpawnEgg.java | 45 +- .../inventory/CraftMetaSuspiciousStew.java | 33 +- .../CraftMetaTropicalFishBucket.java | 49 +- .../CraftSmithingTransformRecipe.java | 12 +- .../inventory/CraftSmithingTrimRecipe.java | 21 +- .../inventory/CraftTransmuteRecipe.java | 17 +- .../craftbukkit/inventory/RecipeIterator.java | 8 +- .../inventory/SerializableMeta.java | 22 +- .../CraftCustomModelDataComponent.java | 15 +- .../components/CraftEquippableComponent.java | 76 +- .../components/CraftFoodComponent.java | 12 +- .../inventory/components/CraftHolderUtil.java | 56 - .../components/CraftJukeboxComponent.java | 32 +- .../components/CraftToolComponent.java | 31 +- .../components/CraftUseCooldownComponent.java | 12 +- .../inventory/trim/CraftTrimMaterial.java | 48 +- .../inventory/trim/CraftTrimPattern.java | 48 +- ...java => CraftBlockInventoryConverter.java} | 129 +- .../util/CraftCustomInventoryConverter.java | 4 - .../inventory/util/CraftInventoryCreator.java | 68 +- .../inventory/util/CraftMenuBuilder.java | 38 - .../inventory/util/CraftMenus.java | 23 +- .../inventory/view/CraftAnvilView.java | 2 - .../inventory/view/CraftBrewingStandView.java | 2 - .../inventory/view/CraftEnchantmentView.java | 2 - ...aftAccessLocationInventoryViewBuilder.java | 6 - .../CraftBlockEntityInventoryViewBuilder.java | 2 +- .../bukkit/craftbukkit/legacy/CraftEvil.java | 1 - .../craftbukkit/legacy/CraftLegacy.java | 35 +- .../craftbukkit/legacy/FieldRename.java | 9 +- .../craftbukkit/legacy/enums/DummyEnum.java | 2 +- .../legacy/reroute/RerouteArgument.java | 22 +- .../legacy/reroute/RerouteReturn.java | 14 +- .../craftbukkit/map/CraftMapCanvas.java | 4 +- .../craftbukkit/map/CraftMapColorCache.java | 14 +- .../craftbukkit/map/CraftMapRenderer.java | 7 +- .../bukkit/craftbukkit/map/CraftMapView.java | 6 +- .../metadata/BlockMetadataStore.java | 8 +- .../metadata/EntityMetadataStore.java | 2 +- .../metadata/PlayerMetadataStore.java | 1 + .../metadata/WorldMetadataStore.java | 3 +- .../craftbukkit/packs/CraftDataPack.java | 11 +- .../CraftPersistentDataContainer.java | 25 +- .../CraftPersistentDataTypeRegistry.java | 257 +- .../potion/CraftPotionEffectType.java | 90 +- .../craftbukkit/potion/CraftPotionUtil.java | 36 +- .../profile/CraftPlayerProfile.java | 59 +- .../profile/CraftPlayerTextures.java | 45 +- .../profile/CraftProfileProperty.java | 29 +- .../CraftBlockProjectileSource.java | 76 +- .../craftbukkit/scoreboard/CraftCriteria.java | 29 +- .../scoreboard/CraftObjective.java | 80 +- .../craftbukkit/scoreboard/CraftScore.java | 54 +- .../scoreboard/CraftScoreboard.java | 104 +- .../scoreboard/CraftScoreboardComponent.java | 6 +- .../scoreboard/CraftScoreboardManager.java | 57 +- .../CraftScoreboardTranslations.java | 14 +- .../craftbukkit/scoreboard/CraftTeam.java | 197 +- .../craftbukkit/structure/CraftPalette.java | 2 +- .../craftbukkit/structure/CraftStructure.java | 8 +- .../structure/CraftStructureManager.java | 10 +- .../craftbukkit/tag}/CraftGameEventTag.java | 6 +- .../org/bukkit/craftbukkit/tag/CraftTag.java | 4 +- .../bukkit/craftbukkit/util/ApiVersion.java | 4 +- .../util/BlockStateListPopulator.java | 92 +- .../bukkit/craftbukkit/util/Commodore.java | 13 +- .../util/CraftBiomeSearchResult.java | 12 +- .../craftbukkit/util/CraftBlockVector.java | 4 +- .../craftbukkit/util/CraftChatMessage.java | 104 +- .../craftbukkit/util/CraftDimensionUtil.java | 2 +- .../bukkit/craftbukkit/util/CraftLegacy.java | 1 - .../craftbukkit/util/CraftLocation.java | 56 +- .../craftbukkit/util/CraftMagicNumbers.java | 216 +- .../util/CraftNBTTagConfigSerializer.java | 37 +- .../craftbukkit/util/CraftNamespacedKey.java | 5 +- .../craftbukkit/util/CraftRayTraceResult.java | 38 +- .../util/CraftStructureSearchResult.java | 12 +- .../util/CraftStructureTransformer.java | 6 +- .../bukkit/craftbukkit/util/CraftVector.java | 23 +- .../craftbukkit/util/DatFileFilter.java | 11 - .../util/DelegatedGeneratorAccess.java | 411 +- .../util/DummyGeneratorAccess.java | 24 +- .../craftbukkit/util/ForwardLogHandler.java | 2 +- .../bukkit/craftbukkit/util/Handleable.java | 3 + .../craftbukkit/util/LazyPlayerSet.java | 10 +- .../craftbukkit/util/RandomSourceWrapper.java | 12 +- .../util/ServerShutdownThread.java | 5 - .../util/TerminalCompletionHandler.java | 52 - .../util/TerminalConsoleWriterThread.java | 70 - .../util/TransformerGeneratorAccess.java | 68 +- .../craftbukkit/util/WeakCollection.java | 46 +- .../bukkit/craftbukkit/util/WorldUUID.java | 47 +- .../util/permissions/CommandPermissions.java | 1 + .../permissions/CraftDefaultPermissions.java | 2 - .../main/java/org/spigotmc/AsyncCatcher.java | 2 - .../java/org/spigotmc/RestartCommand.java | 1 - .../main/java/org/spigotmc/SpigotConfig.java | 2 +- .../java/org/spigotmc/SpigotWorldConfig.java | 20 +- .../java/org/spigotmc/WatchdogThread.java | 31 +- .../minecraft/datapacks/paper/pack.mcmeta | 2 +- .../paper/adventure/AdventureCodecsTest.java | 57 +- .../DFUCommandArgumentUpgraderCompatTest.java | 5 +- .../EntitySetItemSlotSilentOverrideTest.java | 3 +- .../item/EquipmentSlotGroupTest.java | 2 +- .../ItemStackDataComponentEqualsTest.java | 5 +- .../item/ItemStackDataComponentTest.java | 51 +- .../paper/scoreboard/DisplaySlotTest.java | 26 - .../block/BlockPlayerDestroyOverrideTest.java | 3 +- .../src/test/java/org/bukkit/ArtTest.java | 56 - .../src/test/java/org/bukkit/BiomeTest.java | 32 - .../org/bukkit/BlockDataConversionTest.java | 6 +- .../src/test/java/org/bukkit/ChatTest.java | 6 +- .../src/test/java/org/bukkit/EffectTest.java | 2 - .../test/java/org/bukkit/EnchantmentTest.java | 25 - .../java/org/bukkit/ExplosionResultTest.java | 2 +- .../test/java/org/bukkit/GameEventTest.java | 20 - .../test/java/org/bukkit/MaterialTest.java | 32 +- .../test/java/org/bukkit/PerMaterialTest.java | 266 +- .../java/org/bukkit/PotionEffectTypeTest.java | 2 +- .../src/test/java/org/bukkit/SoundTest.java | 21 +- .../bukkit/StatisticsAndAchievementsTest.java | 5 +- .../bukkit/block/banner/PatternTypeTest.java | 42 - .../craftbukkit/block/BlockStateTest.java | 5 +- .../craftbukkit/entity/EntityTypesTest.java | 6 +- ...n.java => CompositeSerializationTest.java} | 6 +- .../craftbukkit/inventory/ItemFlagsTest.java | 33 + .../craftbukkit/inventory/ItemTypeTest.java | 2 +- .../inventory/PlayerInventoryTest.java | 25 +- .../inventory/YamlSerializationTest.java | 130 + .../bukkit/craftbukkit/legacy/LegacyTest.java | 2 + .../legacy/MaterialReroutingTest.java | 2 +- .../PersistentDataContainerLegacyTest.java | 4 +- .../org/bukkit/entity/EntityTypesTest.java | 22 +- .../java/org/bukkit/entity/PandaGeneTest.java | 33 - .../entity/memory/CraftMemoryKeyTest.java | 78 - .../bukkit/event/EntityRemoveEventTest.java | 4 +- .../generator/structure/StructureTest.java | 53 - .../structure/StructureTypeTest.java | 53 - .../src/test/java/org/bukkit/map/MapTest.java | 52 - .../java/org/bukkit/potion/PotionTest.java | 18 - .../org/bukkit/support/DummyServerHelper.java | 8 + .../extension/AllFeaturesExtension.java | 3 - .../support/extension/LegacyExtension.java | 8 - .../support/extension/SlowExtension.java | 8 - .../extension/VanillaFeatureExtension.java | 8 - .../provider/ClassNodeArgumentProvider.java | 2 +- .../provider/RegistriesArgumentProvider.java | 18 +- .../support/suite/BundleFeatureTestSuite.java | 15 - .../bukkit/support/test/ClassNodeTest.java | 2 +- settings.gradle.kts | 6 +- 2092 files changed, 50551 insertions(+), 48729 deletions(-) delete mode 100644 paper-api-generator/build.gradle.kts delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/Generators.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/Main.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/utils/Javadocs.java delete mode 100644 paper-api-generator/src/main/java/io/papermc/generator/utils/TagCollector.java create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/ChickenVariantKeys.java create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/CowVariantKeys.java create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/PigVariantKeys.java create mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfSoundVariantKeys.java delete mode 100644 paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/CatVariantTagKeys.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentHolder.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentView.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java delete mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java delete mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java create mode 100644 paper-api/src/main/java/io/papermc/paper/datacomponent/item/Weapon.java create mode 100644 paper-api/src/main/java/org/bukkit/block/Orientation.java create mode 100644 paper-api/src/main/java/org/bukkit/block/TestBlock.java create mode 100644 paper-api/src/main/java/org/bukkit/block/TestInstanceBlock.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/Segmentable.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/type/FlowerBed.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/type/LeafLitter.java create mode 100644 paper-api/src/main/java/org/bukkit/block/data/type/TestBlock.java create mode 100644 paper-api/src/main/java/org/bukkit/entity/AbstractCow.java delete mode 100644 paper-api/src/test/java/org/bukkit/BukkitMirrorTest.java delete mode 100644 paper-api/src/test/java/org/bukkit/entity/memory/MemoryKeyTest.java create mode 100644 paper-generator/.editorconfig create mode 100644 paper-generator/build.gradle.kts create mode 100644 paper-generator/src/main/java/io/papermc/generator/Generators.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/Main.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/Rewriters.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/registry/RegistryBootstrapper.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntry.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/registry/RegistryKeyField.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PaperPatternSourceSetRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PatternSourceSetRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/registration/RewriterHolder.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/Types.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryEventsRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryTagRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/TagRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/BlockTypeRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockDataMapping.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/ItemTypeRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MapPaletteRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/package-info.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ProtoConstant.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/package-info.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/utils/Annotations.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/rewriter/utils/ScanOldGeneratedSourceCode.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/OverriddenClassGenerator.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/SimpleEnumGenerator.java rename {paper-api-generator => paper-generator}/src/main/java/io/papermc/generator/types/SimpleGenerator.java (78%) rename {paper-api-generator => paper-generator}/src/main/java/io/papermc/generator/types/SourceGenerator.java (76%) create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/Types.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataBootstrapper.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataGenerator.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/EnumPropertyWriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/IntegerPropertyWriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyMaker.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyWriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/AppenderBase.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/EnumValuesAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppenders.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/ConverterBase.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converters.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/NoteConverter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/RotationConverter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataHolderType.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyMaker.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriterBase.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualDataPropertyWriter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualField.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ArrayAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppenders.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ListAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/MapAppender.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ArrayConverter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverters.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ListConverter.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/MapConverter.java rename {paper-api-generator => paper-generator}/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java (76%) rename {paper-api-generator => paper-generator}/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java (50%) create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/Annotations.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/ClassHelper.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/CommonVariable.java rename {paper-api-generator => paper-generator}/src/main/java/io/papermc/generator/utils/Formatting.java (50%) create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/Javadocs.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/NamingManager.java rename {paper-api-generator/src/main/java/io/papermc/generator/utils => paper-generator/src/main/java/io/papermc/generator/utils/experimental}/CollectingContext.java (51%) create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/experimental/ExperimentalCollector.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolder.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java create mode 100644 paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java create mode 100644 paper-generator/src/test/java/io/papermc/generator/BlockStatePropertyTest.java rename {paper-api-generator => paper-generator}/src/test/java/io/papermc/generator/MobGoalConverterTest.java (74%) create mode 100644 paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java rename {paper-api-generator => paper-generator}/wideners.at (52%) rename paper-server/patches/features/{0016-Moonrise-optimisation-patches.patch => 0015-Moonrise-optimisation-patches.patch} (94%) rename paper-server/patches/features/{0017-Fix-entity-tracker-desync-when-new-players-are-added.patch => 0016-Fix-entity-tracker-desync-when-new-players-are-added.patch} (92%) rename paper-server/patches/features/{0018-Eigencraft-redstone-implementation.patch => 0017-Eigencraft-redstone-implementation.patch} (98%) rename paper-server/patches/features/{0019-Add-Alternate-Current-redstone-implementation.patch => 0018-Add-Alternate-Current-redstone-implementation.patch} (98%) rename paper-server/patches/features/{0020-Improve-exact-choice-recipe-ingredients.patch => 0019-Improve-exact-choice-recipe-ingredients.patch} (98%) rename paper-server/patches/features/{0021-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch => 0020-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch} (98%) rename paper-server/patches/features/{0022-Entity-load-save-limit-per-chunk.patch => 0021-Entity-load-save-limit-per-chunk.patch} (65%) rename paper-server/patches/features/{0023-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch => 0022-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch} (98%) rename paper-server/patches/features/{0024-Incremental-chunk-and-player-saving.patch => 0023-Incremental-chunk-and-player-saving.patch} (87%) rename paper-server/patches/features/{0025-Optimise-general-POI-access.patch => 0024-Optimise-general-POI-access.patch} (99%) rename paper-server/patches/features/{0026-Optional-per-player-mob-spawns.patch => 0025-Optional-per-player-mob-spawns.patch} (85%) rename paper-server/patches/features/{0027-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch => 0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch} (88%) rename paper-server/patches/features/{0028-Optimize-Hoppers.patch => 0027-Optimize-Hoppers.patch} (95%) rename paper-server/patches/features/{0030-Flush-regionfiles-on-save-configuration-option.patch => 0028-Flush-regionfiles-on-save-configuration-option.patch} (100%) delete mode 100644 paper-server/patches/features/0031-Do-not-record-movement-for-vehicles-players-unaffect.patch create mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/nbt/NbtUtils.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/nbt/TagParser.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/network/HashedStack.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/server/commands/OpCommand.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/server/level/Ticket.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/EntityEquipment.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch rename paper-server/patches/sources/net/minecraft/world/entity/animal/{Cow.java.patch => AbstractCow.java.patch} (81%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => sheep}/Sheep.java.patch (95%) rename paper-server/patches/sources/net/minecraft/world/entity/animal/{ => wolf}/Wolf.java.patch (92%) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/Fireball.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/variant/StructureCheck.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/inventory/RemoteSlot.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/item/WrittenBookItem.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/component/BlocksAttacks.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteResult.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch delete mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/BushBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/VegetationBlock.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch create mode 100644 paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch rename paper-server/patches/{features => unapplied}/0015-Rewrite-dataconverter-system.patch (100%) create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAttachedStem.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBambooStalk.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrier.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralFan.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralPlant.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralWallFan.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBed.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeehive.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBell.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrushable.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftButton.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCake.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCalibratedSculkSensor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarrot.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarvedPumpkin.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChain.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChest.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusPlant.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCommandBlock.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComparator.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCopperBulb.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralWallFan.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrafter.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrop.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDetectorRail.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoublePlant.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndPortalFrame.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFarm.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFence.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFire.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFrostedIce.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingMoss.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHay.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHeavyCore.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJukebox.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLever.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLight.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLiquid.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangrovePropagule.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveRoots.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMossyCarpet.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMovingPiston.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMycelium.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherPortal.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNoteBlock.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonBase.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonHead.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPitcherCrop.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerHead.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerWallHead.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotato.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlate.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRail.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneOre.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneWire.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWallTorch.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRotatedPillar.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkCatalyst.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkShrieker.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkVein.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSlab.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnifferEgg.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowLayer.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowyDirt.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStair.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStandingSign.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStem.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStructureBlock.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSugarCane.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallFlower.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTestBlock.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTnt.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrapDoor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrappedChest.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrialSpawner.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWire.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWireHook.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVault.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVine.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWall.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallBanner.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSkull.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallTorch.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWaterloggedTransparent.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperBulb.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperDoor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperGrate.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperTrapDoor.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeightedPressurePlate.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java create mode 100644 paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherWallSkull.java rename paper-server/src/main/java/com/destroystokyo/paper/entity/ai/{PaperVanillaGoal.java => PaperGoal.java} (89%) create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperBlocksAttacks.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperTooltipDisplay.java delete mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperUnbreakable.java create mode 100644 paper-server/src/main/java/io/papermc/paper/datacomponent/item/PaperWeapon.java create mode 100644 paper-server/src/main/java/io/papermc/paper/registry/HolderableBase.java rename paper-server/src/main/java/io/papermc/paper/util/{ => sanitizer}/ItemComponentSanitizer.java (99%) rename paper-server/src/main/java/io/papermc/paper/util/{ => sanitizer}/ItemObfuscationBinding.java (97%) rename paper-server/src/main/java/io/papermc/paper/util/{ => sanitizer}/ItemObfuscationSession.java (97%) rename paper-server/src/main/java/io/papermc/paper/util/{ => sanitizer}/OversizedItemComponentSanitizer.java (98%) delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftSuspiciousSand.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTestBlock.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/CraftTestInstanceBlock.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAgeable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAnaloguePowerable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftAttachable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBisected.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftBrushable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftDirectional.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftFaceAttachable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftHangable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftHatchable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLevelled.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftLightable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftMultipleFacing.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOpenable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftOrientable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftPowerable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRail.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftRotatable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftSnowable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/CraftWaterlogged.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBamboo.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBed.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBeehive.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBell.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBigDripleaf.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrewingStand.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBrushable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftBubbleColumn.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCake.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCampfire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCandle.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCaveVinesPlant.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChest.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftChiseledBookshelf.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCommandBlock.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftComparator.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCrafter.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftCreakingHeart.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDaylightDetector.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDispenser.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftDoor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftEndPortalFrame.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftFarmland.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftGate.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHangingMoss.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftHopper.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJigsaw.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftJukebox.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLeaves.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftLectern.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftMossyCarpet.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftNoteBlock.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPinkPetals.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPiston.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPistonHead.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftPointedDripstone.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRedstoneWire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRepeater.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftRespawnAnchor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSapling.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftScaffolding.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkCatalyst.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkSensor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSculkShrieker.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSeaPickle.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSlab.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSnow.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStairs.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftStructureBlock.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftSwitch.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTNT.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTechnicalPiston.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTrialSpawner.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTripwire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftTurtleEgg.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftVault.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/data/type/CraftWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBamboo.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBannerWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBarrier.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBed.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeehive.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBell.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBrushable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftButtonAbstract.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCake.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCalibratedSculkSensor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCarrots.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChain.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChest.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChestTrapped.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftChorusFruit.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCobbleWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCommand.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCopperBulb.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralDead.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFanAbstract.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFanWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralFanWallAbstract.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrafter.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftCrops.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDirtSnow.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftEnderPortalFrame.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFence.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFloorSign.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFluids.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftFurnaceFurace.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingMoss.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHay.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHeavyCore.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIceFrost.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftJukeBox.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLeaves.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLever.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLight.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangrovePropagule.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMangroveRoots.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartDetector.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMinecartTrack.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMossyCarpet.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftMycel.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftNote.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftParticleLeaves.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPinkPetals.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPiston.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonExtension.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPistonMoving.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPitcherCrop.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPortal.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPotatoes.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateBinary.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlateWeighted.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftPumpkinCarved.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneComparator.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneOre.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorchWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftReed.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftRotatable.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkCatalyst.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkShrieker.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSculkVein.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayer.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullPlayerWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSkullWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnifferEgg.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSnow.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSoil.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStairs.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStem.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStemAttached.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStepAbstract.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftStructure.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTNT.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlant.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallPlantFlower.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrapdoor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTrialSpawner.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwire.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTripwireHook.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVault.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftVine.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWaterloggedTransparent.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperBulb.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperDoor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperGrate.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperTrapDoor.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkullWall.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/command/ColouredConsoleSender.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractCow.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownLingeringPotion.java create mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftThrownSplashPotion.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/components/CraftHolderUtil.java rename paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/{CraftTileInventoryConverter.java => CraftBlockInventoryConverter.java} (56%) delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftMenuBuilder.java rename paper-server/src/main/java/{io/papermc/paper => org/bukkit/craftbukkit/tag}/CraftGameEventTag.java (92%) delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/DatFileFilter.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalCompletionHandler.java delete mode 100644 paper-server/src/main/java/org/bukkit/craftbukkit/util/TerminalConsoleWriterThread.java delete mode 100644 paper-server/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/ArtTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/BiomeTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/EnchantmentTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/GameEventTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/block/banner/PatternTypeTest.java rename paper-server/src/test/java/org/bukkit/craftbukkit/inventory/{CompositeSerialization.java => CompositeSerializationTest.java} (96%) create mode 100644 paper-server/src/test/java/org/bukkit/craftbukkit/inventory/ItemFlagsTest.java create mode 100644 paper-server/src/test/java/org/bukkit/craftbukkit/inventory/YamlSerializationTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/entity/PandaGeneTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/entity/memory/CraftMemoryKeyTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/generator/structure/StructureTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/generator/structure/StructureTypeTest.java delete mode 100644 paper-server/src/test/java/org/bukkit/support/suite/BundleFeatureTestSuite.java diff --git a/.editorconfig b/.editorconfig index 76c44f065..600eac0fb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,3 +1,5 @@ +root = true + [*] charset = utf-8 end_of_line = lf @@ -40,5 +42,5 @@ ij_java_use_fq_class_names = true [paper-server/src/minecraft/resources/data/**/*.json] indent_size = 2 -[paper-api/src/generated/java/**/*.java] +[paper-{server,api}/src/generated/java/**/*.java] ij_java_imports_layout = $*, |, * diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6449e1ba2..a7df53267 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,10 @@ jobs: steps: - if: ${{ github.event_name == 'push' }} uses: actions/checkout@v4 + with: + # todo remove me again after the update + ref: ${{ github.ref_name }} + fetch-depth: 0 - if: ${{ github.event_name == 'pull_request' }} uses: actions/checkout@v4 with: diff --git a/.gitignore b/.gitignore index 53a798d16..e46ae58b1 100644 --- a/.gitignore +++ b/.gitignore @@ -45,7 +45,7 @@ logs/ !gradle/wrapper/gradle-wrapper.jar test-plugin.settings.gradle.kts -paper-api-generator.settings.gradle.kts +paper-generator.settings.gradle.kts # Don't track patched vanilla submodules paper-server/src/minecraft/ diff --git a/README.md b/README.md index 3223166ba..d06d31464 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ How To (Plugin Developers) io.papermc.paper paper-api - 1.21.4-R0.1-SNAPSHOT + 1.21.5-R0.1-SNAPSHOT provided ``` @@ -53,7 +53,7 @@ repositories { } dependencies { - compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT") } java { diff --git a/build-data/paper.at b/build-data/paper.at index e5c60c62d..78f05d794 100644 --- a/build-data/paper.at +++ b/build-data/paper.at @@ -15,7 +15,8 @@ public net.minecraft.commands.CommandSourceStack source public net.minecraft.commands.arguments.DimensionArgument ERROR_INVALID_VALUE public net.minecraft.commands.arguments.blocks.BlockInput tag public net.minecraft.core.MappedRegistry validateWrite(Lnet/minecraft/resources/ResourceKey;)V -public net.minecraft.nbt.ListTag (Ljava/util/List;B)V +public net.minecraft.nbt.ListTag (Ljava/util/List;)V +public net.minecraft.nbt.ListTag identifyRawElementType()B public net.minecraft.nbt.TagParser readArrayTag()Lnet/minecraft/nbt/Tag; public net.minecraft.nbt.TagParser type(Ljava/lang/String;)Lnet/minecraft/nbt/Tag; public net.minecraft.network.Connection address @@ -37,9 +38,10 @@ public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket xRot public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket y public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket yRot public net.minecraft.network.protocol.game.ServerboundMovePlayerPacket z +public net.minecraft.network.syncher.SynchedEntityData getItem(Lnet/minecraft/network/syncher/EntityDataAccessor;)Lnet/minecraft/network/syncher/SynchedEntityData$DataItem; public net.minecraft.resources.RegistryOps lookupProvider public net.minecraft.resources.RegistryOps$HolderLookupAdapter -public net.minecraft.server.Main forceUpgrade(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lcom/mojang/datafixers/DataFixer;ZLjava/util/function/BooleanSupplier;Lnet/minecraft/core/RegistryAccess;Z)V +public net.minecraft.server.Main forceUpgrade(Lnet/minecraft/world/level/storage/LevelStorageSource$LevelStorageAccess;Lnet/minecraft/world/level/storage/WorldData;Lcom/mojang/datafixers/DataFixer;ZLjava/util/function/BooleanSupplier;Lnet/minecraft/core/RegistryAccess;Z)V public net.minecraft.server.MinecraftServer LOGGER public net.minecraft.server.MinecraftServer doRunTask(Lnet/minecraft/server/TickTask;)V public net.minecraft.server.MinecraftServer executor @@ -53,6 +55,7 @@ public net.minecraft.server.MinecraftServer$ReloadableResources public net.minecraft.server.RegistryLayer STATIC_ACCESS public net.minecraft.server.ReloadableServerResources public net.minecraft.server.ServerAdvancementManager advancements +public net.minecraft.server.Services USERID_CACHE_FILE public net.minecraft.server.dedicated.DedicatedServerProperties$WorldDimensionData public net.minecraft.server.dedicated.Settings getStringRaw(Ljava/lang/String;)Ljava/lang/String; public net.minecraft.server.dedicated.Settings properties @@ -72,15 +75,17 @@ public net.minecraft.server.level.ChunkMap setServerViewDistance(I)V public net.minecraft.server.level.ChunkMap toDrop public net.minecraft.server.level.ChunkMap updatingChunkMap public net.minecraft.server.level.ChunkMap visibleChunkMap +public net.minecraft.server.level.ChunkMap$DistanceManager public net.minecraft.server.level.ChunkMap$TrackedEntity public net.minecraft.server.level.ChunkMap$TrackedEntity seenBy public net.minecraft.server.level.ChunkMap$TrackedEntity serverEntity public net.minecraft.server.level.DistanceManager simulationDistance -public net.minecraft.server.level.DistanceManager tickets +public net.minecraft.server.level.DistanceManager ticketStorage public net.minecraft.server.level.ServerBossEvent broadcast(Ljava/util/function/Function;)V public net.minecraft.server.level.ServerBossEvent visible public net.minecraft.server.level.ServerChunkCache mainThread public net.minecraft.server.level.ServerChunkCache mainThreadProcessor +public net.minecraft.server.level.ServerChunkCache runDistanceManagerUpdates()Z public net.minecraft.server.level.ServerChunkCache spawnEnemies public net.minecraft.server.level.ServerChunkCache spawnFriendlies public net.minecraft.server.level.ServerChunkCache$MainThreadExecutor @@ -91,7 +96,7 @@ public net.minecraft.server.level.ServerLevel getEntities()Lnet/minecraft/world/ public net.minecraft.server.level.ServerLevel serverLevelData public net.minecraft.server.level.ServerPlayer completeUsingItem()V public net.minecraft.server.level.ServerPlayer containerSynchronizer -public net.minecraft.server.level.ServerPlayer findRespawnAndUseSpawnBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/core/BlockPos;FZZ)Ljava/util/Optional; +public net.minecraft.server.level.ServerPlayer findRespawnAndUseSpawnBlock(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/server/level/ServerPlayer$RespawnConfig;Z)Ljava/util/Optional; public net.minecraft.server.level.ServerPlayer initMenu(Lnet/minecraft/world/inventory/AbstractContainerMenu;)V public net.minecraft.server.level.ServerPlayer isChangingDimension public net.minecraft.server.level.ServerPlayer language @@ -104,6 +109,7 @@ public net.minecraft.server.level.ServerPlayer wardenSpawnTracker public net.minecraft.server.level.ServerPlayer$RespawnPosAngle public net.minecraft.server.level.ServerPlayerGameMode level public net.minecraft.server.level.Ticket key +public net.minecraft.server.level.TicketType register(Ljava/lang/String;JZLnet/minecraft/server/level/TicketType$TicketUse;)Lnet/minecraft/server/level/TicketType; public net.minecraft.server.network.ServerGamePacketListenerImpl isChatMessageIllegal(Ljava/lang/String;)Z public net.minecraft.server.network.ServerLoginPacketListenerImpl authenticatedProfile public net.minecraft.server.network.ServerLoginPacketListenerImpl connection @@ -116,12 +122,14 @@ public net.minecraft.server.packs.repository.Pack resources public net.minecraft.server.players.PlayerList playerIo public net.minecraft.server.players.PlayerList players public net.minecraft.server.players.PlayerList updateEntireScoreboard(Lnet/minecraft/server/ServerScoreboard;Lnet/minecraft/server/level/ServerPlayer;)V +public net.minecraft.server.players.PlayerList verifyChatTrusted(Lnet/minecraft/network/chat/PlayerChatMessage;)Z public net.minecraft.server.players.StoredUserEntry getUser()Ljava/lang/Object; public net.minecraft.stats.ServerRecipeBook known public net.minecraft.tags.TagEntry id public net.minecraft.tags.TagEntry required public net.minecraft.tags.TagEntry tag -public net.minecraft.util.datafix.fixes.BlockStateData register(ILjava/lang/String;[Ljava/lang/String;)V +public net.minecraft.util.datafix.fixes.BlockStateData register(ILcom/mojang/serialization/Dynamic;[Lcom/mojang/serialization/Dynamic;)V +public net.minecraft.util.datafix.fixes.EntityCustomNameToComponentFix fixCustomName(Lcom/mojang/serialization/DynamicOps;Ljava/lang/String;Ljava/lang/String;)Lcom/mojang/serialization/Dynamic; public net.minecraft.util.datafix.fixes.ItemIdFix ITEM_NAMES public net.minecraft.util.datafix.fixes.ItemSpawnEggFix ID_TO_ENTITY public net.minecraft.world.BossEvent color @@ -185,6 +193,9 @@ public net.minecraft.world.entity.Entity FLAG_INVISIBLE public net.minecraft.world.entity.Entity getEncodeId()Ljava/lang/String; public net.minecraft.world.entity.Entity getFireImmuneTicks()I public net.minecraft.world.entity.Entity getSharedFlag(I)Z +public net.minecraft.world.entity.Entity getSwimHighSpeedSplashSound()Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.Entity getSwimSound()Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.Entity getSwimSplashSound()Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.Entity hasVisualFire public net.minecraft.world.entity.Entity isAffectedByBlocks()Z public net.minecraft.world.entity.Entity isInBubbleColumn()Z @@ -201,6 +212,7 @@ public net.minecraft.world.entity.Entity teleportPassengers()V public net.minecraft.world.entity.Entity unsetRemoved()V public net.minecraft.world.entity.Entity wasTouchingWater public net.minecraft.world.entity.ExperienceOrb count +public net.minecraft.world.entity.ExperienceOrb setValue(I)V public net.minecraft.world.entity.ExperienceOrb value public net.minecraft.world.entity.GlowSquid setDarkTicks(I)V public net.minecraft.world.entity.Interaction attack @@ -227,16 +239,21 @@ public net.minecraft.world.entity.LivingEntity detectEquipmentUpdates()V public net.minecraft.world.entity.LivingEntity effectsDirty public net.minecraft.world.entity.LivingEntity entityEventForEquipmentBreak(Lnet/minecraft/world/entity/EquipmentSlot;)B public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.LivingEntity getFallDamageSound(I)Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.LivingEntity getHurtSound(Lnet/minecraft/world/damagesource/DamageSource;)Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.LivingEntity getSoundVolume()F public net.minecraft.world.entity.LivingEntity jumping public net.minecraft.world.entity.LivingEntity lastHurt public net.minecraft.world.entity.LivingEntity lastHurtByMob public net.minecraft.world.entity.LivingEntity lastHurtByMobTimestamp public net.minecraft.world.entity.LivingEntity lastHurtByPlayer +public net.minecraft.world.entity.LivingEntity lastHurtByPlayerMemoryTime public net.minecraft.world.entity.LivingEntity lastHurtByPlayerTime +public net.minecraft.world.entity.LivingEntity playSecondaryHurtSound(Lnet/minecraft/world/damagesource/DamageSource;)V public net.minecraft.world.entity.LivingEntity setLivingEntityFlag(IZ)V public net.minecraft.world.entity.LivingEntity useItemRemaining public net.minecraft.world.entity.Mob armorDropChances +public net.minecraft.world.entity.Mob getAmbientSound()Lnet/minecraft/sounds/SoundEvent; public net.minecraft.world.entity.Mob getEquipmentDropChance(Lnet/minecraft/world/entity/EquipmentSlot;)F public net.minecraft.world.entity.Mob handDropChances public net.minecraft.world.entity.Mob isSunBurnTick()Z @@ -266,47 +283,60 @@ public net.minecraft.world.entity.animal.Bee ticksWithoutNectarSinceExitingHive public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z public net.minecraft.world.entity.animal.Cat setCollarColor(Lnet/minecraft/world/item/DyeColor;)V public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V +public net.minecraft.world.entity.animal.Cat setVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.animal.Dolphin treasurePos public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_0 public net.minecraft.world.entity.animal.Fox DATA_TRUSTED_ID_1 public net.minecraft.world.entity.animal.Fox isDefending()Z public net.minecraft.world.entity.animal.Fox setDefending(Z)V public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V public net.minecraft.world.entity.animal.Fox setSleeping(Z)V +public net.minecraft.world.entity.animal.Fox setVariant(Lnet/minecraft/world/entity/animal/Fox$Variant;)V +public net.minecraft.world.entity.animal.MushroomCow setVariant(Lnet/minecraft/world/entity/animal/MushroomCow$Variant;)V public net.minecraft.world.entity.animal.MushroomCow stewEffects public net.minecraft.world.entity.animal.Ocelot isTrusting()Z public net.minecraft.world.entity.animal.Ocelot setTrusting(Z)V public net.minecraft.world.entity.animal.Panda getEatCounter()I public net.minecraft.world.entity.animal.Panda setEatCounter(I)V +public net.minecraft.world.entity.animal.Parrot setVariant(Lnet/minecraft/world/entity/animal/Parrot$Variant;)V +public net.minecraft.world.entity.animal.Pig setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.Pig steering public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks public net.minecraft.world.entity.animal.Rabbit registerGoals()V +public net.minecraft.world.entity.animal.Rabbit setVariant(Lnet/minecraft/world/entity/animal/Rabbit$Variant;)V +public net.minecraft.world.entity.animal.Salmon setVariant(Lnet/minecraft/world/entity/animal/Salmon$Variant;)V public net.minecraft.world.entity.animal.TropicalFish getPackedVariant()I public net.minecraft.world.entity.animal.TropicalFish setPackedVariant(I)V -public net.minecraft.world.entity.animal.Turtle getHomePos()Lnet/minecraft/core/BlockPos; -public net.minecraft.world.entity.animal.Turtle isGoingHome()Z -public net.minecraft.world.entity.animal.Turtle isTravelling()Z -public net.minecraft.world.entity.animal.Turtle setGoingHome(Z)V +public net.minecraft.world.entity.animal.Turtle goingHome +public net.minecraft.world.entity.animal.Turtle homePos public net.minecraft.world.entity.animal.Turtle setHasEgg(Z)V -public net.minecraft.world.entity.animal.Turtle setTravelling(Z)V -public net.minecraft.world.entity.animal.Wolf isWet -public net.minecraft.world.entity.animal.Wolf setCollarColor(Lnet/minecraft/world/item/DyeColor;)V public net.minecraft.world.entity.animal.allay.Allay canDuplicate()Z public net.minecraft.world.entity.animal.allay.Allay duplicateAllay()V public net.minecraft.world.entity.animal.allay.Allay duplicationCooldown public net.minecraft.world.entity.animal.allay.Allay jukeboxPos public net.minecraft.world.entity.animal.allay.Allay resetDuplicationCooldown()V +public net.minecraft.world.entity.animal.axolotl.Axolotl setVariant(Lnet/minecraft/world/entity/animal/axolotl/Axolotl$Variant;)V +public net.minecraft.world.entity.animal.frog.Frog setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.animal.frog.Tadpole age public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_LEFT_HORN public net.minecraft.world.entity.animal.goat.Goat DATA_HAS_RIGHT_HORN public net.minecraft.world.entity.animal.horse.AbstractHorse createInventory()V public net.minecraft.world.entity.animal.horse.AbstractHorse inventory +public net.minecraft.world.entity.animal.horse.AbstractHorse owner public net.minecraft.world.entity.animal.horse.Horse setVariantAndMarkings(Lnet/minecraft/world/entity/animal/horse/Variant;Lnet/minecraft/world/entity/animal/horse/Markings;)V +public net.minecraft.world.entity.animal.horse.Llama setVariant(Lnet/minecraft/world/entity/animal/horse/Llama$Variant;)V public net.minecraft.world.entity.animal.horse.SkeletonHorse trapTime public net.minecraft.world.entity.animal.sniffer.Sniffer calculateDigPosition()Ljava/util/Optional; public net.minecraft.world.entity.animal.sniffer.Sniffer canDig()Z public net.minecraft.world.entity.animal.sniffer.Sniffer getExploredPositions()Ljava/util/stream/Stream; public net.minecraft.world.entity.animal.sniffer.Sniffer getState()Lnet/minecraft/world/entity/animal/sniffer/Sniffer$State; public net.minecraft.world.entity.animal.sniffer.Sniffer storeExploredPosition(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/entity/animal/sniffer/Sniffer; +public net.minecraft.world.entity.animal.wolf.Wolf getSoundVariant()Lnet/minecraft/core/Holder; +public net.minecraft.world.entity.animal.wolf.Wolf getVariant()Lnet/minecraft/core/Holder; +public net.minecraft.world.entity.animal.wolf.Wolf isWet +public net.minecraft.world.entity.animal.wolf.Wolf setCollarColor(Lnet/minecraft/world/item/DyeColor;)V +public net.minecraft.world.entity.animal.wolf.Wolf setSoundVariant(Lnet/minecraft/core/Holder;)V +public net.minecraft.world.entity.animal.wolf.Wolf setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.boss.enderdragon.EnderDragon subEntities public net.minecraft.world.entity.boss.wither.WitherBoss bossEvent public net.minecraft.world.entity.decoration.ArmorStand bodyPose @@ -325,6 +355,7 @@ public net.minecraft.world.entity.decoration.ItemFrame DATA_ROTATION public net.minecraft.world.entity.decoration.ItemFrame dropChance public net.minecraft.world.entity.decoration.ItemFrame fixed public net.minecraft.world.entity.decoration.ItemFrame setDirection(Lnet/minecraft/core/Direction;)V +public net.minecraft.world.entity.decoration.Painting setVariant(Lnet/minecraft/core/Holder;)V public net.minecraft.world.entity.item.FallingBlockEntity (Lnet/minecraft/world/level/Level;DDDLnet/minecraft/world/level/block/state/BlockState;)V public net.minecraft.world.entity.item.FallingBlockEntity blockState public net.minecraft.world.entity.item.FallingBlockEntity cancelDrop @@ -347,8 +378,8 @@ public net.minecraft.world.entity.monster.Drowned waterNavigation public net.minecraft.world.entity.monster.EnderMan teleport()Z public net.minecraft.world.entity.monster.EnderMan teleportTowards(Lnet/minecraft/world/entity/Entity;)Z public net.minecraft.world.entity.monster.Endermite life -public net.minecraft.world.entity.monster.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/Sheep; -public net.minecraft.world.entity.monster.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/Sheep;)V +public net.minecraft.world.entity.monster.Evoker getWololoTarget()Lnet/minecraft/world/entity/animal/sheep/Sheep; +public net.minecraft.world.entity.monster.Evoker setWololoTarget(Lnet/minecraft/world/entity/animal/sheep/Sheep;)V public net.minecraft.world.entity.monster.Guardian randomStrollGoal public net.minecraft.world.entity.monster.Guardian setActiveAttackTarget(I)V public net.minecraft.world.entity.monster.Guardian$GuardianAttackGoal @@ -401,14 +432,25 @@ public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/mine public net.minecraft.world.entity.player.Abilities flyingSpeed public net.minecraft.world.entity.player.Abilities walkingSpeed public net.minecraft.world.entity.player.Inventory compartments +public net.minecraft.world.entity.player.Inventory equipment public net.minecraft.world.entity.player.Player DATA_PLAYER_MODE_CUSTOMISATION public net.minecraft.world.entity.player.Player closeContainer()V public net.minecraft.world.entity.player.Player enchantmentSeed public net.minecraft.world.entity.player.Player getFireImmuneTicks()I +public net.minecraft.world.entity.player.Player hurtDir public net.minecraft.world.entity.player.Player removeEntitiesOnShoulder()V public net.minecraft.world.entity.player.Player setShoulderEntityLeft(Lnet/minecraft/nbt/CompoundTag;)V public net.minecraft.world.entity.player.Player setShoulderEntityRight(Lnet/minecraft/nbt/CompoundTag;)V public net.minecraft.world.entity.player.Player sleepCounter +public net.minecraft.world.entity.projectile.AbstractArrow baseDamage +public net.minecraft.world.entity.projectile.AbstractArrow firedFromWeapon +public net.minecraft.world.entity.projectile.AbstractArrow getHitGroundSoundEvent()Lnet/minecraft/sounds/SoundEvent; +public net.minecraft.world.entity.projectile.AbstractArrow getPickupItem()Lnet/minecraft/world/item/ItemStack; +public net.minecraft.world.entity.projectile.AbstractArrow isInGround()Z +public net.minecraft.world.entity.projectile.AbstractArrow life +public net.minecraft.world.entity.projectile.AbstractArrow pickupItemStack +public net.minecraft.world.entity.projectile.AbstractArrow setPickupItemStack(Lnet/minecraft/world/item/ItemStack;)V +public net.minecraft.world.entity.projectile.AbstractArrow setPierceLevel(B)V public net.minecraft.world.entity.projectile.AbstractHurtingProjectile assignDirectionalMovement(Lnet/minecraft/world/phys/Vec3;D)V public net.minecraft.world.entity.projectile.Arrow NO_EFFECT_COLOR public net.minecraft.world.entity.projectile.Arrow getPotionContents()Lnet/minecraft/world/item/alchemy/PotionContents; @@ -449,6 +491,7 @@ public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaX public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaY public net.minecraft.world.entity.projectile.ShulkerBullet targetDeltaZ public net.minecraft.world.entity.projectile.SpectralArrow duration +public net.minecraft.world.entity.projectile.ThrowableItemProjectile getDefaultItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.entity.projectile.ThrownPotion isLingering()Z public net.minecraft.world.entity.projectile.ThrownTrident dealtDamage public net.minecraft.world.entity.projectile.windcharge.AbstractWindCharge explode(Lnet/minecraft/world/phys/Vec3;)V @@ -462,7 +505,6 @@ public net.minecraft.world.entity.raid.Raid ticksActive public net.minecraft.world.entity.raid.Raid totalHealth public net.minecraft.world.entity.raid.Raider$HoldGroundAttackGoal public net.minecraft.world.entity.raid.Raids raidMap -public net.minecraft.world.entity.vehicle.AbstractBoat getDropItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.entity.vehicle.AbstractBoat getStatus()Lnet/minecraft/world/entity/vehicle/AbstractBoat$Status; public net.minecraft.world.entity.vehicle.AbstractBoat status public net.minecraft.world.entity.vehicle.AbstractMinecartContainer lootTable @@ -473,6 +515,7 @@ public net.minecraft.world.entity.vehicle.MinecartTNT explode(D)V public net.minecraft.world.entity.vehicle.MinecartTNT explosionPowerBase public net.minecraft.world.entity.vehicle.MinecartTNT explosionSpeedFactor public net.minecraft.world.entity.vehicle.MinecartTNT fuse +public net.minecraft.world.entity.vehicle.VehicleEntity getDropItem()Lnet/minecraft/world/item/Item; public net.minecraft.world.flag.FeatureFlag mask public net.minecraft.world.flag.FeatureFlag universe public net.minecraft.world.flag.FeatureFlagRegistry names @@ -492,6 +535,8 @@ public net.minecraft.world.inventory.BrewingStandMenu brewingStandData public net.minecraft.world.inventory.CraftingMenu access public net.minecraft.world.inventory.DispenserMenu dispenser public net.minecraft.world.inventory.HorseInventoryMenu SLOT_BODY_ARMOR +public net.minecraft.world.inventory.HorseInventoryMenu SLOT_HORSE_INVENTORY_START +public net.minecraft.world.inventory.HorseInventoryMenu SLOT_SADDLE public net.minecraft.world.inventory.HorseInventoryMenu horse public net.minecraft.world.inventory.MerchantContainer selectionHint public net.minecraft.world.inventory.Slot slot @@ -504,7 +549,7 @@ public net.minecraft.world.item.ItemCooldowns tickCount public net.minecraft.world.item.ItemCooldowns$CooldownInstance public net.minecraft.world.item.ItemStackLinkedSet TYPE_AND_TAG public net.minecraft.world.item.JukeboxSongPlayer song -public net.minecraft.world.item.MapItem createNewSavedData(Lnet/minecraft/world/level/Level;IIIZZLnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/saveddata/maps/MapId; +public net.minecraft.world.item.MapItem createNewSavedData(Lnet/minecraft/server/level/ServerLevel;IIIZZLnet/minecraft/resources/ResourceKey;)Lnet/minecraft/world/level/saveddata/maps/MapId; public net.minecraft.world.item.StandingAndWallBlockItem wallBlock public net.minecraft.world.item.component.BundleContents$Mutable getMaxAmountToAdd(Lnet/minecraft/world/item/ItemStack;)I public net.minecraft.world.item.component.ItemContainerContents MAX_SIZE @@ -530,7 +575,9 @@ public net.minecraft.world.level.BaseSpawner spawnCount public net.minecraft.world.level.BaseSpawner spawnDelay public net.minecraft.world.level.BaseSpawner spawnPotentials public net.minecraft.world.level.BaseSpawner spawnRange +public net.minecraft.world.level.GameRules$Value deserialize(Ljava/lang/String;)V public net.minecraft.world.level.GameRules$Value onChanged(Lnet/minecraft/server/MinecraftServer;)V +public net.minecraft.world.level.Level blockEntityTickers public net.minecraft.world.level.Level getEntities()Lnet/minecraft/world/level/entity/LevelEntityGetter; public net.minecraft.world.level.Level levelData public net.minecraft.world.level.Level rainLevel @@ -538,6 +585,7 @@ public net.minecraft.world.level.Level thread public net.minecraft.world.level.Level thunderLevel public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES public net.minecraft.world.level.StructureManager level +public net.minecraft.world.level.TicketStorage tickets public net.minecraft.world.level.biome.Biome climateSettings public net.minecraft.world.level.biome.Biome getTemperature(Lnet/minecraft/core/BlockPos;I)F public net.minecraft.world.level.biome.Biome$ClimateSettings @@ -562,6 +610,7 @@ public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity cooking public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity getTotalCookTime(Lnet/minecraft/server/level/ServerLevel;Lnet/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity;)I public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity litTimeRemaining public net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity recipesUsed +public net.minecraft.world.level.block.entity.BannerBlockEntity name public net.minecraft.world.level.block.entity.BarrelBlockEntity openersCounter public net.minecraft.world.level.block.entity.BarrelBlockEntity playSound(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/sounds/SoundEvent;)V public net.minecraft.world.level.block.entity.BarrelBlockEntity updateBlockState(Lnet/minecraft/world/level/block/state/BlockState;Z)V @@ -650,6 +699,7 @@ public net.minecraft.world.level.chunk.LevelChunk level public net.minecraft.world.level.chunk.LevelChunk loaded public net.minecraft.world.level.chunk.LevelChunkSection states public net.minecraft.world.level.chunk.PalettedContainer registry +public net.minecraft.world.level.chunk.status.ChunkStatusTasks postLoadProtoChunk(Lnet/minecraft/server/level/ServerLevel;Ljava/util/List;)V public net.minecraft.world.level.chunk.storage.EntityStorage entityDeserializerQueue public net.minecraft.world.level.chunk.storage.EntityStorage level public net.minecraft.world.level.chunk.storage.RegionFileStorage regionCache @@ -682,6 +732,7 @@ public net.minecraft.world.level.levelgen.SurfaceRules$LazyCondition public net.minecraft.world.level.levelgen.SurfaceRules$LazyYCondition public net.minecraft.world.level.levelgen.SurfaceRules$SurfaceRule public net.minecraft.world.level.levelgen.SurfaceRules$VerticalGradientConditionSource +public net.minecraft.world.level.levelgen.structure.StructurePiece SHAPE_CHECK_BLOCKS public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement exclusionZone public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement frequency public net.minecraft.world.level.levelgen.structure.placement.StructurePlacement frequencyReductionMethod @@ -713,7 +764,6 @@ public-f net.minecraft.server.ReloadableServerResources commands public-f net.minecraft.server.dedicated.DedicatedServer serverLinks public-f net.minecraft.server.dedicated.DedicatedServer settings public-f net.minecraft.server.dedicated.DedicatedServerProperties pauseWhenEmptySeconds -public-f net.minecraft.server.level.TicketType timeout public-f net.minecraft.server.players.PlayerList maxPlayers public-f net.minecraft.world.entity.LivingEntity combatTracker public-f net.minecraft.world.entity.LivingEntity invulnerableDuration diff --git a/build.gradle.kts b/build.gradle.kts index fad7f3925..25783b207 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,7 +12,7 @@ import java.nio.file.Path import kotlin.random.Random plugins { - id("io.papermc.paperweight.core") version "2.0.0-beta.14" apply false + id("io.papermc.paperweight.core") version "2.0.0-beta.16" apply false } subprojects { diff --git a/gradle.properties b/gradle.properties index 27969fea1..01662126e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,9 @@ group=io.papermc.paper -version=1.21.4-R0.1-SNAPSHOT -mcVersion=1.21.4 +version=1.21.5-R0.1-SNAPSHOT +mcVersion=1.21.5 # Set to true while updating Minecraft version -updatingMinecraft=false +updatingMinecraft=true updateTaskListIssue=https://github.com/PaperMC/Paper/issues/11736 org.gradle.configuration-cache=true diff --git a/paper-api-generator/build.gradle.kts b/paper-api-generator/build.gradle.kts deleted file mode 100644 index 0eab98b0f..000000000 --- a/paper-api-generator/build.gradle.kts +++ /dev/null @@ -1,37 +0,0 @@ -import io.papermc.paperweight.util.defaultJavaLauncher - -plugins { - java - id("io.papermc.paperweight.source-generator") -} - -paperweight { - atFile.set(layout.projectDirectory.file("wideners.at")) -} - -dependencies { - minecraftJar(project(":paper-server", "mappedJarOutgoing")) - implementation(project(":paper-server", "macheMinecraftLibraries")) - - implementation("com.squareup:javapoet:1.13.0") - implementation(project(":paper-api")) - implementation("io.github.classgraph:classgraph:4.8.47") - implementation("org.jetbrains:annotations:26.0.1") - testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") - testRuntimeOnly("org.junit.platform:junit-platform-launcher") -} - -tasks.register("generate") { - dependsOn(tasks.check) - mainClass.set("io.papermc.generator.Main") - classpath(sourceSets.main.map { it.runtimeClasspath }) - args(rootProject.layout.projectDirectory.dir("paper-api/src/generated/java").asFile.absolutePath) - javaLauncher = javaToolchains.defaultJavaLauncher(project) -} - -tasks.test { - useJUnitPlatform() -} - -group = "io.papermc.paper" -version = "1.0-SNAPSHOT" diff --git a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java b/paper-api-generator/src/main/java/io/papermc/generator/Generators.java deleted file mode 100644 index 677a1d449..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/Generators.java +++ /dev/null @@ -1,96 +0,0 @@ -package io.papermc.generator; - -import io.papermc.generator.types.GeneratedKeyType; -import io.papermc.generator.types.GeneratedTagKeyType; -import io.papermc.generator.types.SourceGenerator; -import io.papermc.generator.types.goal.MobGoalGenerator; -import io.papermc.paper.registry.RegistryKey; -import net.minecraft.core.Registry; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import org.bukkit.Art; -import org.bukkit.Fluid; -import org.bukkit.GameEvent; -import org.bukkit.JukeboxSong; -import org.bukkit.MusicInstrument; -import org.bukkit.Sound; -import org.bukkit.attribute.Attribute; -import org.bukkit.block.Biome; -import org.bukkit.block.BlockType; -import org.bukkit.block.banner.PatternType; -import org.bukkit.damage.DamageType; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Cat; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Frog; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Wolf; -import org.bukkit.generator.structure.Structure; -import org.bukkit.generator.structure.StructureType; -import org.bukkit.inventory.ItemType; -import org.bukkit.inventory.MenuType; -import org.bukkit.inventory.meta.trim.TrimMaterial; -import org.bukkit.inventory.meta.trim.TrimPattern; -import org.bukkit.map.MapCursor; -import org.bukkit.potion.PotionEffectType; - -public interface Generators { - - SourceGenerator[] API = { - // built-ins - simpleKey("GameEventKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT, true), - simpleKey("StructureTypeKeys", StructureType.class, Registries.STRUCTURE_TYPE, RegistryKey.STRUCTURE_TYPE, false), - simpleKey("MobEffectKeys", PotionEffectType.class, Registries.MOB_EFFECT, RegistryKey.MOB_EFFECT, false), - simpleKey("BlockTypeKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK, false), - simpleKey("ItemTypeKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM, false), - simpleKey("CatVariantKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT, false), - simpleKey("FrogVariantKeys", Frog.Variant.class, Registries.FROG_VARIANT, RegistryKey.FROG_VARIANT, false), - simpleKey("VillagerProfessionKeys", Villager.Profession.class, Registries.VILLAGER_PROFESSION, RegistryKey.VILLAGER_PROFESSION, false), - simpleKey("VillagerTypeKeys", Villager.Type.class, Registries.VILLAGER_TYPE, RegistryKey.VILLAGER_TYPE, false), - simpleKey("MapDecorationTypeKeys", MapCursor.Type.class, Registries.MAP_DECORATION_TYPE, RegistryKey.MAP_DECORATION_TYPE, false), - simpleKey("MenuTypeKeys", MenuType.class, Registries.MENU, RegistryKey.MENU, false), - simpleKey("AttributeKeys", Attribute.class, Registries.ATTRIBUTE, RegistryKey.ATTRIBUTE, false), - simpleKey("FluidKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID, false), - simpleKey("SoundEventKeys", Sound.class, Registries.SOUND_EVENT, RegistryKey.SOUND_EVENT, false), - - // data-driven - simpleKey("BiomeKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME, true), - simpleKey("StructureKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE, true), - simpleKey("TrimMaterialKeys", TrimMaterial.class, Registries.TRIM_MATERIAL, RegistryKey.TRIM_MATERIAL, true), - simpleKey("TrimPatternKeys", TrimPattern.class, Registries.TRIM_PATTERN, RegistryKey.TRIM_PATTERN, true), - simpleKey("DamageTypeKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE, true), - simpleKey("WolfVariantKeys", Wolf.Variant.class, Registries.WOLF_VARIANT, RegistryKey.WOLF_VARIANT, true), - simpleKey("EnchantmentKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT, true), - simpleKey("JukeboxSongKeys", JukeboxSong.class, Registries.JUKEBOX_SONG, RegistryKey.JUKEBOX_SONG, true), - simpleKey("BannerPatternKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN, true), - simpleKey("PaintingVariantKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT, true), - simpleKey("InstrumentKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT, true), - - // tags - simpleTagKey("GameEventTagKeys", GameEvent.class, Registries.GAME_EVENT, RegistryKey.GAME_EVENT), - simpleTagKey("BlockTypeTagKeys", BlockType.class, Registries.BLOCK, RegistryKey.BLOCK), - simpleTagKey("ItemTypeTagKeys", ItemType.class, Registries.ITEM, RegistryKey.ITEM), - simpleTagKey("CatVariantTagKeys", Cat.Type.class, Registries.CAT_VARIANT, RegistryKey.CAT_VARIANT), - simpleTagKey("FluidTagKeys", Fluid.class, Registries.FLUID, RegistryKey.FLUID), - - simpleTagKey("BiomeTagKeys", Biome.class, Registries.BIOME, RegistryKey.BIOME), - simpleTagKey("StructureTagKeys", Structure.class, Registries.STRUCTURE, RegistryKey.STRUCTURE), - simpleTagKey("DamageTypeTagKeys", DamageType.class, Registries.DAMAGE_TYPE, RegistryKey.DAMAGE_TYPE), - simpleTagKey("EnchantmentTagKeys", Enchantment.class, Registries.ENCHANTMENT, RegistryKey.ENCHANTMENT), - simpleTagKey("BannerPatternTagKeys", PatternType.class, Registries.BANNER_PATTERN, RegistryKey.BANNER_PATTERN), - simpleTagKey("PaintingVariantTagKeys", Art.class, Registries.PAINTING_VARIANT, RegistryKey.PAINTING_VARIANT), - simpleTagKey("InstrumentTagKeys", MusicInstrument.class, Registries.INSTRUMENT, RegistryKey.INSTRUMENT), - - // api only - simpleTagKey("EntityTypeTagKeys", EntityType.class, Registries.ENTITY_TYPE, RegistryKey.ENTITY_TYPE), - new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai") - }; - - private static SourceGenerator simpleKey(final String className, final Class apiType, final ResourceKey> registryKey, final RegistryKey apiRegistryKey, final boolean publicCreateKeyMethod) { - return new GeneratedKeyType<>(className, apiType, "io.papermc.paper.registry.keys", registryKey, apiRegistryKey, publicCreateKeyMethod); - } - - private static SourceGenerator simpleTagKey(final String className, final Class apiType, final ResourceKey> registryKey, final RegistryKey apiRegistryKey) { - return new GeneratedTagKeyType<>(className, apiType, "io.papermc.paper.registry.keys.tags", registryKey, apiRegistryKey, true); - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/Main.java b/paper-api-generator/src/main/java/io/papermc/generator/Main.java deleted file mode 100644 index 129009f51..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/Main.java +++ /dev/null @@ -1,93 +0,0 @@ -package io.papermc.generator; - -import com.google.common.util.concurrent.MoreExecutors; -import com.mojang.logging.LogUtils; -import io.papermc.generator.types.SourceGenerator; -import io.papermc.generator.utils.TagCollector; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.List; -import java.util.Map; -import net.minecraft.SharedConstants; -import net.minecraft.commands.Commands; -import net.minecraft.core.HolderLookup; -import net.minecraft.core.LayeredRegistryAccess; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.RegistryDataLoader; -import net.minecraft.server.Bootstrap; -import net.minecraft.server.RegistryLayer; -import net.minecraft.server.ReloadableServerResources; -import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.repository.Pack; -import net.minecraft.server.packs.repository.PackRepository; -import net.minecraft.server.packs.repository.ServerPacksSource; -import net.minecraft.server.packs.resources.MultiPackResourceManager; -import net.minecraft.tags.TagKey; -import net.minecraft.tags.TagLoader; -import net.minecraft.world.flag.FeatureFlags; -import org.apache.commons.io.file.PathUtils; -import org.slf4j.Logger; - -public final class Main { - - private static final Logger LOGGER = LogUtils.getLogger(); - public static final RegistryAccess.Frozen REGISTRY_ACCESS; - public static final Map, String> EXPERIMENTAL_TAGS; - - static { - SharedConstants.tryDetectVersion(); - Bootstrap.bootStrap(); - Bootstrap.validate(); - - final PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository(); - resourceRepository.reload(); - final MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList()); - LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); - final List> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC)); - final List> worldGenLayer = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags); - final RegistryAccess.Frozen frozenWorldgenRegistries = RegistryDataLoader.load(resourceManager, worldGenLayer, RegistryDataLoader.WORLDGEN_REGISTRIES); - layers = layers.replaceFrom(RegistryLayer.WORLDGEN, frozenWorldgenRegistries); - REGISTRY_ACCESS = layers.compositeAccess().freeze(); - final ReloadableServerResources reloadableServerResources = ReloadableServerResources.loadResources( - resourceManager, - layers, - pendingTags, - FeatureFlags.VANILLA_SET, - Commands.CommandSelection.DEDICATED, - 0, - MoreExecutors.directExecutor(), - MoreExecutors.directExecutor() - ).join(); - reloadableServerResources.updateStaticRegistryTags(); - EXPERIMENTAL_TAGS = TagCollector.grabExperimental(resourceManager); - } - - private Main() { - } - - public static void main(final String[] args) { - LOGGER.info("Running API generators..."); - generate(Paths.get(args[0]), Generators.API); - // LOGGER.info("Running Server generators..."); - // generate(Paths.get(args[1]), Generators.SERVER); - } - - private static void generate(Path output, SourceGenerator[] generators) { - try { - if (Files.exists(output)) { - PathUtils.deleteDirectory(output); - } - Files.createDirectories(output); - - for (final SourceGenerator generator : generators) { - generator.writeToFile(output); - } - - LOGGER.info("Files written to {}", output.toAbsolutePath()); - } catch (final Exception ex) { - throw new RuntimeException(ex); - } - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java deleted file mode 100644 index a0a214920..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedKeyType.java +++ /dev/null @@ -1,204 +0,0 @@ -package io.papermc.generator.types; - -import com.google.common.collect.Sets; -import com.squareup.javapoet.FieldSpec; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.ParameterSpec; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import io.papermc.generator.Main; -import io.papermc.generator.utils.Annotations; -import io.papermc.generator.utils.CollectingContext; -import io.papermc.generator.utils.Formatting; -import io.papermc.generator.utils.Javadocs; -import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.registry.TypedKey; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.Collections; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; -import java.util.stream.Collectors; -import javax.lang.model.SourceVersion; -import net.kyori.adventure.key.Key; -import net.minecraft.core.Holder; -import net.minecraft.core.HolderLookup; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistrySetBuilder; -import net.minecraft.core.registries.Registries; -import net.minecraft.data.registries.VanillaRegistries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.world.flag.FeatureElement; -import net.minecraft.world.flag.FeatureFlags; -import org.bukkit.MinecraftExperimental; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.checkerframework.framework.qual.DefaultQualifier; - -import static com.squareup.javapoet.TypeSpec.classBuilder; -import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; -import static io.papermc.generator.utils.Annotations.experimentalAnnotations; -import static java.util.Objects.requireNonNull; -import static javax.lang.model.element.Modifier.FINAL; -import static javax.lang.model.element.Modifier.PRIVATE; -import static javax.lang.model.element.Modifier.PUBLIC; -import static javax.lang.model.element.Modifier.STATIC; - -@DefaultQualifier(NonNull.class) -public class GeneratedKeyType extends SimpleGenerator { - - private static final Map>, RegistrySetBuilder.RegistryBootstrap> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream() - .collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap)); - - private static final Map>, RegistrySetBuilder.RegistryBootstrap> EXPERIMENTAL_REGISTRY_ENTRIES = Map.of(); // Update for Experimental API - private static final Map, String> REGISTRY_KEY_FIELD_NAMES; - static { - final Map, String> map = new HashMap<>(); - try { - for (final Field field : RegistryKey.class.getFields()) { - if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) { - continue; - } - map.put((RegistryKey) field.get(null), field.getName()); - } - REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map); - } catch (final ReflectiveOperationException ex) { - throw new RuntimeException(ex); - } - } - - private static final String CREATE_JAVADOC = """ - Creates a key for {@link $T} in the registry {@code $L}. - - @param key the value's key in the registry - @return a new typed key - """; - - private final Class apiType; - private final ResourceKey> registryKey; - private final RegistryKey apiRegistryKey; - private final boolean publicCreateKeyMethod; - - public GeneratedKeyType(final String keysClassName, final Class apiType, final String pkg, final ResourceKey> registryKey, final RegistryKey apiRegistryKey, final boolean publicCreateKeyMethod) { - super(keysClassName, pkg); - this.apiType = apiType; - this.registryKey = registryKey; - this.apiRegistryKey = apiRegistryKey; - this.publicCreateKeyMethod = publicCreateKeyMethod; - } - - private MethodSpec.Builder createMethod(final TypeName returnType) { - final TypeName keyType = TypeName.get(Key.class); - - final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); - final MethodSpec.Builder create = MethodSpec.methodBuilder("create") - .addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) - .addParameter(keyParam) - .addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam) - .returns(returnType); - if (this.publicCreateKeyMethod) { - create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString()); - } - return create; - } - - private TypeSpec.Builder keyHolderType() { - return classBuilder(this.className) - .addModifiers(PUBLIC, FINAL) - .addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey)) - .addAnnotations(Annotations.CLASS_HEADER) - .addMethod(MethodSpec.constructorBuilder() - .addModifiers(PRIVATE) - .build() - ); - } - - @Deprecated - private static final Map JUKEBOX_SONG_NAMES = Map.of( - "5", "FIVE", - "11", "ELEVEN", - "13", "THIRTEEN" - ); - - @Override - protected TypeSpec getTypeSpec() { - final TypeName typedKey = ParameterizedTypeName.get(TypedKey.class, this.apiType); - - final TypeSpec.Builder typeBuilder = this.keyHolderType(); - final MethodSpec.Builder createMethod = this.createMethod(typedKey); - - final Registry registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey); - final Set> experimental = this.collectExperimentalKeys(registry); - - boolean allExperimental = true; - for (final Holder.Reference reference : registry.listElements().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) { - final ResourceKey key = reference.key(); - final String keyPath = key.location().getPath(); - String fieldName = Formatting.formatKeyAsField(keyPath); - if (!SourceVersion.isIdentifier(fieldName) && this.registryKey.equals(Registries.JUKEBOX_SONG) && JUKEBOX_SONG_NAMES.containsKey(fieldName)) { - fieldName = JUKEBOX_SONG_NAMES.get(fieldName); - } - - final FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL) - .initializer("$N(key($S))", createMethod.build(), keyPath) - .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString()); - if (experimental.contains(key)) { - fieldBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API - } else { - allExperimental = false; - } - typeBuilder.addField(fieldBuilder.build()); - } - if (allExperimental) { - typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API - createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API - } - return typeBuilder.addMethod(createMethod.build()).build(); - } - - // todo at some point this should be per feature data pack not all merged - private Set> collectExperimentalKeys(final Registry registry) { - if (FeatureElement.FILTERED_REGISTRIES.contains(registry.key())) { - return this.collectExperimentalKeysBuiltIn(registry); - } else { - return this.collectExperimentalKeysDataDriven(registry); - } - } - - private Set> collectExperimentalKeysBuiltIn(final Registry registry) { - final HolderLookup.RegistryLookup filteredLookup = registry.filterElements(v -> { - return v instanceof final FeatureElement featureElement && FeatureFlags.isExperimental(featureElement.requiredFeatures()); // Update for Experimental API - }); - return filteredLookup.listElementIds().collect(Collectors.toUnmodifiableSet()); - } - - @SuppressWarnings("unchecked") - private Set> collectExperimentalKeysDataDriven(final Registry registry) { - final RegistrySetBuilder.@Nullable RegistryBootstrap experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap) EXPERIMENTAL_REGISTRY_ENTRIES.get(this.registryKey); - if (experimentalBootstrap == null) { - return Collections.emptySet(); - } - final Set> experimental = Collections.newSetFromMap(new IdentityHashMap<>()); - final CollectingContext experimentalCollector = new CollectingContext<>(experimental, registry); - experimentalBootstrap.run(experimentalCollector); - - final RegistrySetBuilder.@Nullable RegistryBootstrap vanillaBootstrap = (RegistrySetBuilder.RegistryBootstrap) VANILLA_REGISTRY_ENTRIES.get(this.registryKey); - if (vanillaBootstrap != null) { - final Set> vanilla = Collections.newSetFromMap(new IdentityHashMap<>()); - final CollectingContext vanillaCollector = new CollectingContext<>(vanilla, registry); - vanillaBootstrap.run(vanillaCollector); - return Sets.difference(experimental, vanilla); - } - return experimental; - } - - @Override - protected JavaFile.Builder file(final JavaFile.Builder builder) { - return builder - .addStaticImport(Key.class, "key"); - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java b/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java deleted file mode 100644 index 60e15ea64..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/GeneratedTagKeyType.java +++ /dev/null @@ -1,138 +0,0 @@ -package io.papermc.generator.types; - -import com.squareup.javapoet.FieldSpec; -import com.squareup.javapoet.JavaFile; -import com.squareup.javapoet.MethodSpec; -import com.squareup.javapoet.ParameterSpec; -import com.squareup.javapoet.ParameterizedTypeName; -import com.squareup.javapoet.TypeName; -import com.squareup.javapoet.TypeSpec; -import io.papermc.generator.Main; -import io.papermc.generator.utils.Annotations; -import io.papermc.generator.utils.Formatting; -import io.papermc.generator.utils.Javadocs; -import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.registry.tag.TagKey; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; -import net.kyori.adventure.key.Key; -import net.minecraft.core.Registry; -import net.minecraft.resources.ResourceKey; -import org.bukkit.MinecraftExperimental; - -import static com.squareup.javapoet.TypeSpec.classBuilder; -import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; -import static io.papermc.generator.utils.Annotations.experimentalAnnotations; -import static java.util.Objects.requireNonNull; -import static javax.lang.model.element.Modifier.FINAL; -import static javax.lang.model.element.Modifier.PRIVATE; -import static javax.lang.model.element.Modifier.PUBLIC; -import static javax.lang.model.element.Modifier.STATIC; - -public class GeneratedTagKeyType extends SimpleGenerator { - - private static final Map, String> REGISTRY_KEY_FIELD_NAMES; - static { - final Map, String> map = new HashMap<>(); - try { - for (final Field field : RegistryKey.class.getFields()) { - if (!Modifier.isStatic(field.getModifiers()) || !Modifier.isFinal(field.getModifiers()) || field.getType() != RegistryKey.class) { - continue; - } - map.put((RegistryKey) field.get(null), field.getName()); - } - REGISTRY_KEY_FIELD_NAMES = Map.copyOf(map); - } catch (final ReflectiveOperationException ex) { - throw new RuntimeException(ex); - } - } - - private static final String CREATE_JAVADOC = """ - Creates a tag key for {@link $T} in the registry {@code $L}. - - @param key the tag key's key - @return a new tag key - """; - - private final Class apiType; - private final ResourceKey> registryKey; - private final RegistryKey apiRegistryKey; - private final boolean publicCreateKeyMethod; - - public GeneratedTagKeyType(final String keysClassName, final Class apiType, final String pkg, final ResourceKey> registryKey, final RegistryKey apiRegistryKey, final boolean publicCreateKeyMethod) { - super(keysClassName, pkg); - this.apiType = apiType; - this.registryKey = registryKey; - this.apiRegistryKey = apiRegistryKey; - this.publicCreateKeyMethod = publicCreateKeyMethod; - } - - private MethodSpec.Builder createMethod(final TypeName returnType) { - final TypeName keyType = TypeName.get(Key.class); - - final ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); - final MethodSpec.Builder create = MethodSpec.methodBuilder("create") - .addModifiers(this.publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) - .addParameter(keyParam) - .addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, requireNonNull(REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey), "Missing field for " + this.apiRegistryKey), keyParam) - .returns(returnType); - if (this.publicCreateKeyMethod) { - create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental - create.addJavadoc(CREATE_JAVADOC, this.apiType, this.registryKey.location().toString()); - } - return create; - } - - private TypeSpec.Builder keyHolderType() { - return classBuilder(this.className) - .addModifiers(PUBLIC, FINAL) - .addJavadoc(Javadocs.getVersionDependentClassHeader("{@link $T#$L}"), RegistryKey.class, REGISTRY_KEY_FIELD_NAMES.get(this.apiRegistryKey)) - .addAnnotations(Annotations.CLASS_HEADER) - .addMethod(MethodSpec.constructorBuilder() - .addModifiers(PRIVATE) - .build() - ); - } - - @Override - protected TypeSpec getTypeSpec() { - final TypeName tagKey = ParameterizedTypeName.get(TagKey.class, this.apiType); - - final TypeSpec.Builder typeBuilder = this.keyHolderType(); - final MethodSpec.Builder createMethod = this.createMethod(tagKey); - - final Registry registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey); - - final AtomicBoolean allExperimental = new AtomicBoolean(true); - registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(nmsTagKey -> nmsTagKey.location().getPath())).forEach(nmsTagKey -> { - final String fieldName = Formatting.formatKeyAsField(nmsTagKey.location().getPath()); - final FieldSpec.Builder fieldBuilder = FieldSpec.builder(tagKey, fieldName, PUBLIC, STATIC, FINAL) - .initializer("$N(key($S))", createMethod.build(), nmsTagKey.location().getPath()) - .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), "#" + nmsTagKey.location()); - final String featureFlagName = Main.EXPERIMENTAL_TAGS.get(nmsTagKey); - if (featureFlagName != null) { - fieldBuilder.addAnnotations(experimentalAnnotations(MinecraftExperimental.Requires.valueOf(featureFlagName.toUpperCase(Locale.ENGLISH)))); // Update for Experimental API - } else { - allExperimental.set(false); - } - typeBuilder.addField(fieldBuilder.build()); - }); - if (allExperimental.get()) { - typeBuilder.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API - createMethod.addAnnotations(experimentalAnnotations(null)); // Update for Experimental API - } else { - typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API - } - return typeBuilder.addMethod(createMethod.build()).build(); - } - - @Override - protected JavaFile.Builder file(final JavaFile.Builder builder) { - return builder - .addStaticImport(Key.class, "key"); - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java b/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java deleted file mode 100644 index 977e4a133..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/Annotations.java +++ /dev/null @@ -1,65 +0,0 @@ -package io.papermc.generator.utils; - -import com.squareup.javapoet.AnnotationSpec; -import java.util.ArrayList; -import java.util.List; - -import io.papermc.paper.generated.GeneratedFrom; -import net.minecraft.SharedConstants; -import org.bukkit.MinecraftExperimental; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Nullable; -import org.jspecify.annotations.NullMarked; - -public final class Annotations { - - public static List experimentalAnnotations(final MinecraftExperimental.@Nullable Requires requiredFeatureFlag) { - final List annotationSpecs = new ArrayList<>(); - annotationSpecs.add(AnnotationSpec.builder(ApiStatus.Experimental.class).build()); - if (requiredFeatureFlag != null) { - annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class) - .addMember("value", "$T.$L", MinecraftExperimental.Requires.class, requiredFeatureFlag.name()) - .build()); - } else { - annotationSpecs.add(AnnotationSpec.builder(MinecraftExperimental.class).build()); - } - return annotationSpecs; - } - - public static AnnotationSpec deprecatedVersioned(final @Nullable String version, final boolean forRemoval) { - final AnnotationSpec.Builder annotationSpec = AnnotationSpec.builder(Deprecated.class); - if (forRemoval) { - annotationSpec.addMember("forRemoval", "$L", true); - } - if (version != null) { - annotationSpec.addMember("since", "$S", version); - } - - return annotationSpec.build(); - } - - public static AnnotationSpec scheduledRemoval(final @Nullable String version) { - return AnnotationSpec.builder(ApiStatus.ScheduledForRemoval.class) - .addMember("inVersion", "$S", version) - .build(); - } - - @ApiStatus.Experimental - public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build(); - public static final AnnotationSpec NULL_MARKED = AnnotationSpec.builder(NullMarked.class).build(); - private static final AnnotationSpec SUPPRESS_WARNINGS = AnnotationSpec.builder(SuppressWarnings.class) - .addMember("value", "$S", "unused") - .addMember("value", "$S", "SpellCheckingInspection") - .build(); - private static final AnnotationSpec GENERATED_FROM = AnnotationSpec.builder(GeneratedFrom.class) - .addMember("value", "$S", SharedConstants.getCurrentVersion().getName()) - .build(); - public static final Iterable CLASS_HEADER = List.of( - SUPPRESS_WARNINGS, - GENERATED_FROM, - NULL_MARKED - ); - - private Annotations() { - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/Javadocs.java b/paper-api-generator/src/main/java/io/papermc/generator/utils/Javadocs.java deleted file mode 100644 index 33536c831..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/Javadocs.java +++ /dev/null @@ -1,27 +0,0 @@ -package io.papermc.generator.utils; - -public final class Javadocs { - - public static String getVersionDependentClassHeader(String headerIdentifier) { - return """ - Vanilla keys for %s. - - @apiNote The fields provided here are a direct representation of - what is available from the vanilla game source. They may be - changed (including removals) on any Minecraft version - bump, so cross-version compatibility is not provided on the - same level as it is on most of the other API. - """.formatted(headerIdentifier); - } - - public static String getVersionDependentField(String headerIdentifier) { - return """ - %s - - @apiNote This field is version-dependant and may be removed in future Minecraft versions - """.formatted(headerIdentifier); - } - - private Javadocs() { - } -} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/TagCollector.java b/paper-api-generator/src/main/java/io/papermc/generator/utils/TagCollector.java deleted file mode 100644 index 546e136b4..000000000 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/TagCollector.java +++ /dev/null @@ -1,79 +0,0 @@ -package io.papermc.generator.utils; - -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import com.mojang.logging.LogUtils; -import io.papermc.generator.Main; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.Map; -import java.util.Set; -import java.util.function.BiConsumer; -import net.minecraft.core.Registry; -import net.minecraft.core.RegistryAccess; -import net.minecraft.core.registries.Registries; -import net.minecraft.resources.ResourceKey; -import net.minecraft.server.packs.PackResources; -import net.minecraft.server.packs.PackType; -import net.minecraft.server.packs.repository.BuiltInPackSource; -import net.minecraft.server.packs.resources.MultiPackResourceManager; -import net.minecraft.tags.TagKey; -import org.slf4j.Logger; - -// collect all the tags by grabbing the json from the data-packs -// another (probably) way is to hook into the data generator like the typed keys generator -public final class TagCollector { - - private static final Logger LOGGER = LogUtils.getLogger(); - - public static Map, String> grabExperimental(final MultiPackResourceManager resourceManager) { - Map, String> result = new IdentityHashMap<>(); - - // collect all vanilla tags - Multimap>, String> vanillaTags = HashMultimap.create(); - PackResources vanillaPack = resourceManager.listPacks() - .filter(packResources -> packResources.packId().equals(BuiltInPackSource.VANILLA_ID)) - .findFirst() - .orElseThrow(); - collectFromPack(vanillaPack, (entry, path) -> vanillaTags.put(entry.key(), path)); - - // then distinct with other data-pack tags to know for sure newly created tags and so experimental one - resourceManager.listPacks().forEach(pack -> { - String packId = pack.packId(); - if (packId.equals(BuiltInPackSource.VANILLA_ID)) return; - - collectFromPack(pack, (entry, path) -> { - if (vanillaTags.get(entry.key()).contains(path)) { - return; - } - - result.put(entry.value().listTagIds() - .filter(tagKey -> tagKey.location().getPath().equals(path)) - .findFirst() - .orElseThrow(), packId); - }); - }); - return Collections.unmodifiableMap(result); - } - - private static void collectFromPack(PackResources pack, BiConsumer, String> output) { - Set namespaces = pack.getNamespaces(PackType.SERVER_DATA); - - for (String namespace : namespaces) { - Main.REGISTRY_ACCESS.registries().forEach(entry -> { - // this is probably expensive but can't find another way around and data-pack loader has similar logic - // the issue is that registry key can have parent/key (and custom folder too) but tag key can also have parent/key so parsing become a mess - // without having at least one of the two values - String tagDir = Registries.tagsDirPath(entry.key()); - pack.listResources(PackType.SERVER_DATA, namespace, tagDir, (id, supplier) -> { - Formatting.formatTagKey(tagDir, id.getPath()).ifPresentOrElse(path -> output.accept(entry, path), () -> { - LOGGER.warn("Unable to parse the path: {}/{}/{}.json in the data-pack {} into a tag key", namespace, tagDir, id.getPath(), pack.packId()); - }); - }); - }); - } - } - - private TagCollector() { - } -} diff --git a/paper-api/build.gradle.kts b/paper-api/build.gradle.kts index f6ca09925..461e8b87c 100644 --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts @@ -10,8 +10,10 @@ java { } val annotationsVersion = "26.0.1" -val bungeeCordChatVersion = "1.20-R0.2" -val adventureVersion = "4.20.0" +// Keep in sync with paper-server adventure-text-serializer-ansi dep +val adventureVersion = "4.21.0-mc1215-SNAPSHOT" // FIXME move to release asap +val adventureJavadocVersion = "4.20.0" // Fixme remove me +val bungeeCordChatVersion = "1.21-R0.2-deprecated+build.21" val slf4jVersion = "2.0.9" val log4jVersion = "2.17.1" @@ -56,17 +58,19 @@ dependencies { api("com.mojang:brigadier:1.3.10") // Deprecate bungeecord-chat in favor of adventure - api("net.md-5:bungeecord-chat:$bungeeCordChatVersion-deprecated+build.19") { + api("net.md-5:bungeecord-chat:$bungeeCordChatVersion") { exclude("com.google.guava", "guava") } - apiAndDocs(platform("net.kyori:adventure-bom:$adventureVersion")) - apiAndDocs("net.kyori:adventure-api") - apiAndDocs("net.kyori:adventure-text-minimessage") - apiAndDocs("net.kyori:adventure-text-serializer-gson") - apiAndDocs("net.kyori:adventure-text-serializer-legacy") - apiAndDocs("net.kyori:adventure-text-serializer-plain") - apiAndDocs("net.kyori:adventure-text-logger-slf4j") + // FIXME remove me when we are using a release again + val adventureGroup = "io.papermc.adventure" + apiAndDocs(platform("$adventureGroup:adventure-bom:$adventureVersion")) + apiAndDocs("$adventureGroup:adventure-api") + apiAndDocs("$adventureGroup:adventure-text-minimessage") + apiAndDocs("$adventureGroup:adventure-text-serializer-gson") + apiAndDocs("$adventureGroup:adventure-text-serializer-legacy") + apiAndDocs("$adventureGroup:adventure-text-serializer-plain") + apiAndDocs("$adventureGroup:adventure-text-logger-slf4j") api("org.apache.maven:maven-resolver-provider:3.9.6") // make API dependency for Paper Plugins compileOnly("org.apache.maven.resolver:maven-resolver-connector-basic:1.9.18") @@ -93,16 +97,16 @@ dependencies { testRuntimeOnly("org.junit.platform:junit-platform-launcher") } -val generatedApiPath: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath() +val generatedDir: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath() idea { module { - generatedSourceDirs.add(generatedApiPath.toFile()) + generatedSourceDirs.add(generatedDir.toFile()) } } sourceSets { main { java { - srcDir(generatedApiPath) + srcDir(generatedDir) } } } @@ -179,13 +183,13 @@ tasks.withType { "https://javadoc.io/doc/org.joml/joml/1.10.8/", "https://www.javadoc.io/doc/com.google.code.gson/gson/2.11.0", "https://jspecify.dev/docs/api/", - "https://jd.advntr.dev/api/$adventureVersion/", - "https://jd.advntr.dev/key/$adventureVersion/", - "https://jd.advntr.dev/text-minimessage/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-gson/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-legacy/$adventureVersion/", - "https://jd.advntr.dev/text-serializer-plain/$adventureVersion/", - "https://jd.advntr.dev/text-logger-slf4j/$adventureVersion/", + "https://jd.advntr.dev/api/$adventureJavadocVersion/", + "https://jd.advntr.dev/key/$adventureJavadocVersion/", + "https://jd.advntr.dev/text-minimessage/$adventureJavadocVersion/", + "https://jd.advntr.dev/text-serializer-gson/$adventureJavadocVersion/", + "https://jd.advntr.dev/text-serializer-legacy/$adventureJavadocVersion/", + "https://jd.advntr.dev/text-serializer-plain/$adventureJavadocVersion/", + "https://jd.advntr.dev/text-logger-slf4j/$adventureJavadocVersion/", "https://javadoc.io/doc/org.slf4j/slf4j-api/$slf4jVersion/", "https://javadoc.io/doc/org.apache.logging.log4j/log4j-api/$log4jVersion/", "https://javadoc.io/doc/org.apache.maven.resolver/maven-resolver-api/1.7.3", @@ -228,21 +232,23 @@ tasks.compileTestJava { options.compilerArgs.add("-parameters") } -val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { +val scanJarForBadCalls by tasks.registering(io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") jarToScan.set(tasks.jar.flatMap { it.archiveFile }) classpath.from(configurations.compileClasspath) } tasks.check { - dependsOn(scanJar) + dependsOn(scanJarForBadCalls) } -val scanJarForOldGeneratedCode = tasks.register("scanJarForOldGeneratedCode", io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) { - mcVersion.set(providers.gradleProperty("mcVersion")) - annotation.set("Lio/papermc/paper/generated/GeneratedFrom;") - jarToScan.set(tasks.jar.flatMap { it.archiveFile }) - classpath.from(configurations.compileClasspath) -} -tasks.check { - dependsOn(scanJarForOldGeneratedCode) +if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) { + val scanJarForOldGeneratedCode by tasks.registering(io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) { + mcVersion.set(providers.gradleProperty("mcVersion")) + annotation.set("Lio/papermc/paper/generated/GeneratedFrom;") + jarToScan.set(tasks.jar.flatMap { it.archiveFile }) + classpath.from(configurations.compileClasspath) + } + tasks.check { + dependsOn(scanJarForOldGeneratedCode) + } } diff --git a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java index f15a7b447..12207256a 100644 --- a/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java +++ b/paper-api/src/generated/java/com/destroystokyo/paper/entity/ai/VanillaGoal.java @@ -66,8 +66,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public interface VanillaGoal extends Goal { GoalKey RANDOM_STAND = create("random_stand", AbstractHorse.class); diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java index 3eef52b64..07e690dd9 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/AttributeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class AttributeKeys { /** * {@code minecraft:armor} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BannerPatternKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BannerPatternKeys.java index bc1f64a8b..a06d5f5f5 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BannerPatternKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BannerPatternKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class BannerPatternKeys { /** * {@code minecraft:base} @@ -330,7 +330,7 @@ public final class BannerPatternKeys { } /** - * Creates a key for {@link PatternType} in the registry {@code minecraft:banner_pattern}. + * Creates a typed key for {@link PatternType} in the registry {@code minecraft:banner_pattern}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java index e87e00879..1cdf88b0d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BiomeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class BiomeKeys { /** * {@code minecraft:badlands} @@ -484,7 +484,7 @@ public final class BiomeKeys { } /** - * Creates a key for {@link Biome} in the registry {@code minecraft:worldgen/biome}. + * Creates a typed key for {@link Biome} in the registry {@code minecraft:worldgen/biome}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java index f0504b152..df46efb8f 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/BlockTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class BlockTypeKeys { /** * {@code minecraft:acacia_button} @@ -1061,6 +1061,13 @@ public final class BlockTypeKeys { */ public static final TypedKey BUDDING_AMETHYST = create(key("budding_amethyst")); + /** + * {@code minecraft:bush} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BUSH = create(key("bush")); + /** * {@code minecraft:cactus} * @@ -1068,6 +1075,13 @@ public final class BlockTypeKeys { */ public static final TypedKey CACTUS = create(key("cactus")); + /** + * {@code minecraft:cactus_flower} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CACTUS_FLOWER = create(key("cactus_flower")); + /** * {@code minecraft:cake} * @@ -2685,6 +2699,13 @@ public final class BlockTypeKeys { */ public static final TypedKey FIRE_CORAL_WALL_FAN = create(key("fire_coral_wall_fan")); + /** + * {@code minecraft:firefly_bush} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREFLY_BUSH = create(key("firefly_bush")); + /** * {@code minecraft:fletching_table} * @@ -3406,6 +3427,13 @@ public final class BlockTypeKeys { */ public static final TypedKey LAVA_CAULDRON = create(key("lava_cauldron")); + /** + * {@code minecraft:leaf_litter} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LEAF_LITTER = create(key("leaf_litter")); + /** * {@code minecraft:lectern} * @@ -6080,6 +6108,13 @@ public final class BlockTypeKeys { */ public static final TypedKey SEAGRASS = create(key("seagrass")); + /** + * {@code minecraft:short_dry_grass} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHORT_DRY_GRASS = create(key("short_dry_grass")); + /** * {@code minecraft:short_grass} * @@ -6731,6 +6766,13 @@ public final class BlockTypeKeys { */ public static final TypedKey SWEET_BERRY_BUSH = create(key("sweet_berry_bush")); + /** + * {@code minecraft:tall_dry_grass} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TALL_DRY_GRASS = create(key("tall_dry_grass")); + /** * {@code minecraft:tall_grass} * @@ -6759,6 +6801,20 @@ public final class BlockTypeKeys { */ public static final TypedKey TERRACOTTA = create(key("terracotta")); + /** + * {@code minecraft:test_block} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEST_BLOCK = create(key("test_block")); + + /** + * {@code minecraft:test_instance_block} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEST_INSTANCE_BLOCK = create(key("test_instance_block")); + /** * {@code minecraft:tinted_glass} * @@ -7557,6 +7613,13 @@ public final class BlockTypeKeys { */ public static final TypedKey WHITE_WOOL = create(key("white_wool")); + /** + * {@code minecraft:wildflowers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WILDFLOWERS = create(key("wildflowers")); + /** * {@code minecraft:wither_rose} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/CatVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/CatVariantKeys.java index 607aa1aee..4e82c1a5d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/CatVariantKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/CatVariantKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class CatVariantKeys { /** * {@code minecraft:all_black} @@ -105,7 +105,13 @@ public final class CatVariantKeys { private CatVariantKeys() { } - private static TypedKey create(final Key key) { + /** + * Creates a typed key for {@link Cat.Type} in the registry {@code minecraft:cat_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.CAT_VARIANT, key); } } diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ChickenVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ChickenVariantKeys.java new file mode 100644 index 000000000..580b3dd8f --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ChickenVariantKeys.java @@ -0,0 +1,61 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.Chicken; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#CHICKEN_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedFrom("1.21.5") +public final class ChickenVariantKeys { + /** + * {@code minecraft:cold} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COLD = create(key("cold")); + + /** + * {@code minecraft:temperate} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEMPERATE = create(key("temperate")); + + /** + * {@code minecraft:warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WARM = create(key("warm")); + + private ChickenVariantKeys() { + } + + /** + * Creates a typed key for {@link Chicken.Variant} in the registry {@code minecraft:chicken_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.CHICKEN_VARIANT, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/CowVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/CowVariantKeys.java new file mode 100644 index 000000000..2dddd4dc8 --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/CowVariantKeys.java @@ -0,0 +1,61 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.Cow; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#COW_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedFrom("1.21.5") +public final class CowVariantKeys { + /** + * {@code minecraft:cold} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COLD = create(key("cold")); + + /** + * {@code minecraft:temperate} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEMPERATE = create(key("temperate")); + + /** + * {@code minecraft:warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WARM = create(key("warm")); + + private CowVariantKeys() { + } + + /** + * Creates a typed key for {@link Cow.Variant} in the registry {@code minecraft:cow_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.COW_VARIANT, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java index 47e9afe54..0a0463977 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DamageTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class DamageTypeKeys { /** * {@code minecraft:arrow} @@ -372,7 +372,7 @@ public final class DamageTypeKeys { } /** - * Creates a key for {@link DamageType} in the registry {@code minecraft:damage_type}. + * Creates a typed key for {@link DamageType} in the registry {@code minecraft:damage_type}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java new file mode 100644 index 000000000..768e6b30e --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/DataComponentTypeKeys.java @@ -0,0 +1,706 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.datacomponent.DataComponentType; +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#DATA_COMPONENT_TYPE}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedFrom("1.21.5") +public final class DataComponentTypeKeys { + /** + * {@code minecraft:attribute_modifiers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ATTRIBUTE_MODIFIERS = create(key("attribute_modifiers")); + + /** + * {@code minecraft:axolotl/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey AXOLOTL_VARIANT = create(key("axolotl/variant")); + + /** + * {@code minecraft:banner_patterns} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BANNER_PATTERNS = create(key("banner_patterns")); + + /** + * {@code minecraft:base_color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BASE_COLOR = create(key("base_color")); + + /** + * {@code minecraft:bees} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BEES = create(key("bees")); + + /** + * {@code minecraft:block_entity_data} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_ENTITY_DATA = create(key("block_entity_data")); + + /** + * {@code minecraft:block_state} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_STATE = create(key("block_state")); + + /** + * {@code minecraft:blocks_attacks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCKS_ATTACKS = create(key("blocks_attacks")); + + /** + * {@code minecraft:break_sound} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BREAK_SOUND = create(key("break_sound")); + + /** + * {@code minecraft:bucket_entity_data} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BUCKET_ENTITY_DATA = create(key("bucket_entity_data")); + + /** + * {@code minecraft:bundle_contents} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BUNDLE_CONTENTS = create(key("bundle_contents")); + + /** + * {@code minecraft:can_break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAN_BREAK = create(key("can_break")); + + /** + * {@code minecraft:can_place_on} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAN_PLACE_ON = create(key("can_place_on")); + + /** + * {@code minecraft:cat/collar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAT_COLLAR = create(key("cat/collar")); + + /** + * {@code minecraft:cat/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CAT_VARIANT = create(key("cat/variant")); + + /** + * {@code minecraft:charged_projectiles} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHARGED_PROJECTILES = create(key("charged_projectiles")); + + /** + * {@code minecraft:chicken/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CHICKEN_VARIANT = create(key("chicken/variant")); + + /** + * {@code minecraft:consumable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CONSUMABLE = create(key("consumable")); + + /** + * {@code minecraft:container} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CONTAINER = create(key("container")); + + /** + * {@code minecraft:container_loot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CONTAINER_LOOT = create(key("container_loot")); + + /** + * {@code minecraft:cow/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COW_VARIANT = create(key("cow/variant")); + + /** + * {@code minecraft:creative_slot_lock} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CREATIVE_SLOT_LOCK = create(key("creative_slot_lock")); + + /** + * {@code minecraft:custom_data} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CUSTOM_DATA = create(key("custom_data")); + + /** + * {@code minecraft:custom_model_data} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CUSTOM_MODEL_DATA = create(key("custom_model_data")); + + /** + * {@code minecraft:custom_name} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CUSTOM_NAME = create(key("custom_name")); + + /** + * {@code minecraft:damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DAMAGE = create(key("damage")); + + /** + * {@code minecraft:damage_resistant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DAMAGE_RESISTANT = create(key("damage_resistant")); + + /** + * {@code minecraft:death_protection} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DEATH_PROTECTION = create(key("death_protection")); + + /** + * {@code minecraft:debug_stick_state} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DEBUG_STICK_STATE = create(key("debug_stick_state")); + + /** + * {@code minecraft:dyed_color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DYED_COLOR = create(key("dyed_color")); + + /** + * {@code minecraft:enchantable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENCHANTABLE = create(key("enchantable")); + + /** + * {@code minecraft:enchantment_glint_override} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENCHANTMENT_GLINT_OVERRIDE = create(key("enchantment_glint_override")); + + /** + * {@code minecraft:enchantments} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENCHANTMENTS = create(key("enchantments")); + + /** + * {@code minecraft:entity_data} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_DATA = create(key("entity_data")); + + /** + * {@code minecraft:equippable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EQUIPPABLE = create(key("equippable")); + + /** + * {@code minecraft:firework_explosion} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREWORK_EXPLOSION = create(key("firework_explosion")); + + /** + * {@code minecraft:fireworks} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREWORKS = create(key("fireworks")); + + /** + * {@code minecraft:food} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FOOD = create(key("food")); + + /** + * {@code minecraft:fox/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FOX_VARIANT = create(key("fox/variant")); + + /** + * {@code minecraft:frog/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FROG_VARIANT = create(key("frog/variant")); + + /** + * {@code minecraft:glider} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLIDER = create(key("glider")); + + /** + * {@code minecraft:horse/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HORSE_VARIANT = create(key("horse/variant")); + + /** + * {@code minecraft:instrument} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INSTRUMENT = create(key("instrument")); + + /** + * {@code minecraft:intangible_projectile} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey INTANGIBLE_PROJECTILE = create(key("intangible_projectile")); + + /** + * {@code minecraft:item_model} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_MODEL = create(key("item_model")); + + /** + * {@code minecraft:item_name} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_NAME = create(key("item_name")); + + /** + * {@code minecraft:jukebox_playable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey JUKEBOX_PLAYABLE = create(key("jukebox_playable")); + + /** + * {@code minecraft:llama/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LLAMA_VARIANT = create(key("llama/variant")); + + /** + * {@code minecraft:lock} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LOCK = create(key("lock")); + + /** + * {@code minecraft:lodestone_tracker} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LODESTONE_TRACKER = create(key("lodestone_tracker")); + + /** + * {@code minecraft:lore} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LORE = create(key("lore")); + + /** + * {@code minecraft:map_color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAP_COLOR = create(key("map_color")); + + /** + * {@code minecraft:map_decorations} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAP_DECORATIONS = create(key("map_decorations")); + + /** + * {@code minecraft:map_id} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAP_ID = create(key("map_id")); + + /** + * {@code minecraft:map_post_processing} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAP_POST_PROCESSING = create(key("map_post_processing")); + + /** + * {@code minecraft:max_damage} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_DAMAGE = create(key("max_damage")); + + /** + * {@code minecraft:max_stack_size} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAX_STACK_SIZE = create(key("max_stack_size")); + + /** + * {@code minecraft:mooshroom/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOOSHROOM_VARIANT = create(key("mooshroom/variant")); + + /** + * {@code minecraft:note_block_sound} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey NOTE_BLOCK_SOUND = create(key("note_block_sound")); + + /** + * {@code minecraft:ominous_bottle_amplifier} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey OMINOUS_BOTTLE_AMPLIFIER = create(key("ominous_bottle_amplifier")); + + /** + * {@code minecraft:painting/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PAINTING_VARIANT = create(key("painting/variant")); + + /** + * {@code minecraft:parrot/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PARROT_VARIANT = create(key("parrot/variant")); + + /** + * {@code minecraft:pig/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PIG_VARIANT = create(key("pig/variant")); + + /** + * {@code minecraft:pot_decorations} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POT_DECORATIONS = create(key("pot_decorations")); + + /** + * {@code minecraft:potion_contents} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POTION_CONTENTS = create(key("potion_contents")); + + /** + * {@code minecraft:potion_duration_scale} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey POTION_DURATION_SCALE = create(key("potion_duration_scale")); + + /** + * {@code minecraft:profile} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROFILE = create(key("profile")); + + /** + * {@code minecraft:provides_banner_patterns} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROVIDES_BANNER_PATTERNS = create(key("provides_banner_patterns")); + + /** + * {@code minecraft:provides_trim_material} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PROVIDES_TRIM_MATERIAL = create(key("provides_trim_material")); + + /** + * {@code minecraft:rabbit/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RABBIT_VARIANT = create(key("rabbit/variant")); + + /** + * {@code minecraft:rarity} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RARITY = create(key("rarity")); + + /** + * {@code minecraft:recipes} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey RECIPES = create(key("recipes")); + + /** + * {@code minecraft:repair_cost} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey REPAIR_COST = create(key("repair_cost")); + + /** + * {@code minecraft:repairable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey REPAIRABLE = create(key("repairable")); + + /** + * {@code minecraft:salmon/size} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SALMON_SIZE = create(key("salmon/size")); + + /** + * {@code minecraft:sheep/color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHEEP_COLOR = create(key("sheep/color")); + + /** + * {@code minecraft:shulker/color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHULKER_COLOR = create(key("shulker/color")); + + /** + * {@code minecraft:stored_enchantments} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey STORED_ENCHANTMENTS = create(key("stored_enchantments")); + + /** + * {@code minecraft:suspicious_stew_effects} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SUSPICIOUS_STEW_EFFECTS = create(key("suspicious_stew_effects")); + + /** + * {@code minecraft:tool} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TOOL = create(key("tool")); + + /** + * {@code minecraft:tooltip_display} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TOOLTIP_DISPLAY = create(key("tooltip_display")); + + /** + * {@code minecraft:tooltip_style} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TOOLTIP_STYLE = create(key("tooltip_style")); + + /** + * {@code minecraft:trim} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TRIM = create(key("trim")); + + /** + * {@code minecraft:tropical_fish/base_color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TROPICAL_FISH_BASE_COLOR = create(key("tropical_fish/base_color")); + + /** + * {@code minecraft:tropical_fish/pattern} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TROPICAL_FISH_PATTERN = create(key("tropical_fish/pattern")); + + /** + * {@code minecraft:tropical_fish/pattern_color} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TROPICAL_FISH_PATTERN_COLOR = create(key("tropical_fish/pattern_color")); + + /** + * {@code minecraft:unbreakable} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey UNBREAKABLE = create(key("unbreakable")); + + /** + * {@code minecraft:use_cooldown} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey USE_COOLDOWN = create(key("use_cooldown")); + + /** + * {@code minecraft:use_remainder} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey USE_REMAINDER = create(key("use_remainder")); + + /** + * {@code minecraft:villager/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey VILLAGER_VARIANT = create(key("villager/variant")); + + /** + * {@code minecraft:weapon} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WEAPON = create(key("weapon")); + + /** + * {@code minecraft:wolf/collar} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOLF_COLLAR = create(key("wolf/collar")); + + /** + * {@code minecraft:wolf/sound_variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOLF_SOUND_VARIANT = create(key("wolf/sound_variant")); + + /** + * {@code minecraft:wolf/variant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WOLF_VARIANT = create(key("wolf/variant")); + + /** + * {@code minecraft:writable_book_content} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WRITABLE_BOOK_CONTENT = create(key("writable_book_content")); + + /** + * {@code minecraft:written_book_content} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WRITTEN_BOOK_CONTENT = create(key("written_book_content")); + + private DataComponentTypeKeys() { + } + + private static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.DATA_COMPONENT_TYPE, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java index ec7837c8e..7ee0bc9af 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/EnchantmentKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class EnchantmentKeys { /** * {@code minecraft:aqua_affinity} @@ -323,7 +323,7 @@ public final class EnchantmentKeys { } /** - * Creates a key for {@link Enchantment} in the registry {@code minecraft:enchantment}. + * Creates a typed key for {@link Enchantment} in the registry {@code minecraft:enchantment}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/FluidKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/FluidKeys.java index faf98ef6d..a8ae49ddd 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/FluidKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/FluidKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class FluidKeys { /** * {@code minecraft:empty} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/FrogVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/FrogVariantKeys.java index b70f508eb..b3025b407 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/FrogVariantKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/FrogVariantKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class FrogVariantKeys { /** * {@code minecraft:cold} @@ -49,7 +49,13 @@ public final class FrogVariantKeys { private FrogVariantKeys() { } - private static TypedKey create(final Key key) { + /** + * Creates a typed key for {@link Frog.Variant} in the registry {@code minecraft:frog_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { return TypedKey.create(RegistryKey.FROG_VARIANT, key); } } diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java index 3477ccb14..c4116b607 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/GameEventKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class GameEventKeys { /** * {@code minecraft:block_activate} @@ -449,7 +449,7 @@ public final class GameEventKeys { } /** - * Creates a key for {@link GameEvent} in the registry {@code minecraft:game_event}. + * Creates a typed key for {@link GameEvent} in the registry {@code minecraft:game_event}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/InstrumentKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/InstrumentKeys.java index 391d9b059..d5c9c9448 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/InstrumentKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/InstrumentKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class InstrumentKeys { /** * {@code minecraft:admire_goat_horn} @@ -85,7 +85,7 @@ public final class InstrumentKeys { } /** - * Creates a key for {@link MusicInstrument} in the registry {@code minecraft:instrument}. + * Creates a typed key for {@link MusicInstrument} in the registry {@code minecraft:instrument}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java index 75f9a1cc6..eb25a7ee0 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/ItemTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class ItemTypeKeys { /** * {@code minecraft:acacia_boat} @@ -900,6 +900,13 @@ public final class ItemTypeKeys { */ public static final TypedKey BLUE_DYE = create(key("blue_dye")); + /** + * {@code minecraft:blue_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLUE_EGG = create(key("blue_egg")); + /** * {@code minecraft:blue_glazed_terracotta} * @@ -1173,6 +1180,13 @@ public final class ItemTypeKeys { */ public static final TypedKey BROWN_DYE = create(key("brown_dye")); + /** + * {@code minecraft:brown_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BROWN_EGG = create(key("brown_egg")); + /** * {@code minecraft:brown_glazed_terracotta} * @@ -1285,6 +1299,13 @@ public final class ItemTypeKeys { */ public static final TypedKey BURN_POTTERY_SHERD = create(key("burn_pottery_sherd")); + /** + * {@code minecraft:bush} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BUSH = create(key("bush")); + /** * {@code minecraft:cactus} * @@ -1292,6 +1313,13 @@ public final class ItemTypeKeys { */ public static final TypedKey CACTUS = create(key("cactus")); + /** + * {@code minecraft:cactus_flower} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CACTUS_FLOWER = create(key("cactus_flower")); + /** * {@code minecraft:cake} * @@ -2917,18 +2945,130 @@ public final class ItemTypeKeys { public static final TypedKey DIRT_PATH = create(key("dirt_path")); /** - * {@code minecraft:field_masoned_banner_pattern} + * {@code minecraft:dolphin_spawn_egg} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FIELD_MASONED_BANNER_PATTERN = create(key("field_masoned_banner_pattern")); + public static final TypedKey DOLPHIN_SPAWN_EGG = create(key("dolphin_spawn_egg")); /** - * {@code minecraft:fletching_table} + * {@code minecraft:donkey_spawn_egg} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FLETCHING_TABLE = create(key("fletching_table")); + public static final TypedKey DONKEY_SPAWN_EGG = create(key("donkey_spawn_egg")); + + /** + * {@code minecraft:dragon_breath} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DRAGON_BREATH = create(key("dragon_breath")); + + /** + * {@code minecraft:dragon_head} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DRAGON_HEAD = create(key("dragon_head")); + + /** + * {@code minecraft:drowned_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey DROWNED_SPAWN_EGG = create(key("drowned_spawn_egg")); + + /** + * {@code minecraft:elder_guardian_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ELDER_GUARDIAN_SPAWN_EGG = create(key("elder_guardian_spawn_egg")); + + /** + * {@code minecraft:enchanted_book} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENCHANTED_BOOK = create(key("enchanted_book")); + + /** + * {@code minecraft:end_crystal} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey END_CRYSTAL = create(key("end_crystal")); + + /** + * {@code minecraft:ender_dragon_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENDER_DRAGON_SPAWN_EGG = create(key("ender_dragon_spawn_egg")); + + /** + * {@code minecraft:ender_eye} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENDER_EYE = create(key("ender_eye")); + + /** + * {@code minecraft:enderman_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENDERMAN_SPAWN_EGG = create(key("enderman_spawn_egg")); + + /** + * {@code minecraft:endermite_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENDERMITE_SPAWN_EGG = create(key("endermite_spawn_egg")); + + /** + * {@code minecraft:evoker_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EVOKER_SPAWN_EGG = create(key("evoker_spawn_egg")); + + /** + * {@code minecraft:experience_bottle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey EXPERIENCE_BOTTLE = create(key("experience_bottle")); + + /** + * {@code minecraft:fermented_spider_eye} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FERMENTED_SPIDER_EYE = create(key("fermented_spider_eye")); + + /** + * {@code minecraft:fire_charge} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIRE_CHARGE = create(key("fire_charge")); + + /** + * {@code minecraft:firework_rocket} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREWORK_ROCKET = create(key("firework_rocket")); + + /** + * {@code minecraft:firework_star} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIREWORK_STAR = create(key("firework_star")); /** * {@code minecraft:flow_banner_pattern} @@ -2945,39 +3085,242 @@ public final class ItemTypeKeys { public static final TypedKey FLOWER_BANNER_PATTERN = create(key("flower_banner_pattern")); /** - * {@code minecraft:glow_berries} + * {@code minecraft:flower_pot} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GLOW_BERRIES = create(key("glow_berries")); + public static final TypedKey FLOWER_POT = create(key("flower_pot")); /** - * {@code minecraft:goat_horn} + * {@code minecraft:fox_spawn_egg} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GOAT_HORN = create(key("goat_horn")); + public static final TypedKey FOX_SPAWN_EGG = create(key("fox_spawn_egg")); /** - * {@code minecraft:grindstone} + * {@code minecraft:frog_spawn_egg} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GRINDSTONE = create(key("grindstone")); + public static final TypedKey FROG_SPAWN_EGG = create(key("frog_spawn_egg")); /** - * {@code minecraft:honeycomb} + * {@code minecraft:ghast_spawn_egg} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey HONEYCOMB = create(key("honeycomb")); + public static final TypedKey GHAST_SPAWN_EGG = create(key("ghast_spawn_egg")); /** - * {@code minecraft:lantern} + * {@code minecraft:glass_bottle} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LANTERN = create(key("lantern")); + public static final TypedKey GLASS_BOTTLE = create(key("glass_bottle")); + + /** + * {@code minecraft:glistering_melon_slice} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLISTERING_MELON_SLICE = create(key("glistering_melon_slice")); + + /** + * {@code minecraft:glow_item_frame} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLOW_ITEM_FRAME = create(key("glow_item_frame")); + + /** + * {@code minecraft:glow_squid_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLOW_SQUID_SPAWN_EGG = create(key("glow_squid_spawn_egg")); + + /** + * {@code minecraft:goat_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOAT_SPAWN_EGG = create(key("goat_spawn_egg")); + + /** + * {@code minecraft:gold_nugget} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLD_NUGGET = create(key("gold_nugget")); + + /** + * {@code minecraft:golden_carrot} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_CARROT = create(key("golden_carrot")); + + /** + * {@code minecraft:golden_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GOLDEN_HORSE_ARMOR = create(key("golden_horse_armor")); + + /** + * {@code minecraft:gray_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GRAY_BANNER = create(key("gray_banner")); + + /** + * {@code minecraft:green_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GREEN_BANNER = create(key("green_banner")); + + /** + * {@code minecraft:guardian_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GUARDIAN_SPAWN_EGG = create(key("guardian_spawn_egg")); + + /** + * {@code minecraft:hoglin_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HOGLIN_SPAWN_EGG = create(key("hoglin_spawn_egg")); + + /** + * {@code minecraft:horse_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HORSE_SPAWN_EGG = create(key("horse_spawn_egg")); + + /** + * {@code minecraft:husk_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HUSK_SPAWN_EGG = create(key("husk_spawn_egg")); + + /** + * {@code minecraft:iron_golem_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_GOLEM_SPAWN_EGG = create(key("iron_golem_spawn_egg")); + + /** + * {@code minecraft:iron_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey IRON_HORSE_ARMOR = create(key("iron_horse_armor")); + + /** + * {@code minecraft:item_frame} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ITEM_FRAME = create(key("item_frame")); + + /** + * {@code minecraft:lead} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LEAD = create(key("lead")); + + /** + * {@code minecraft:leather_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LEATHER_HORSE_ARMOR = create(key("leather_horse_armor")); + + /** + * {@code minecraft:light_blue_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIGHT_BLUE_BANNER = create(key("light_blue_banner")); + + /** + * {@code minecraft:light_gray_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIGHT_GRAY_BANNER = create(key("light_gray_banner")); + + /** + * {@code minecraft:lime_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LIME_BANNER = create(key("lime_banner")); + + /** + * {@code minecraft:llama_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LLAMA_SPAWN_EGG = create(key("llama_spawn_egg")); + + /** + * {@code minecraft:mace} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MACE = create(key("mace")); + + /** + * {@code minecraft:magenta_banner} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAGENTA_BANNER = create(key("magenta_banner")); + + /** + * {@code minecraft:magma_cream} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAGMA_CREAM = create(key("magma_cream")); + + /** + * {@code minecraft:magma_cube_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAGMA_CUBE_SPAWN_EGG = create(key("magma_cube_spawn_egg")); + + /** + * {@code minecraft:map} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MAP = create(key("map")); + + /** + * {@code minecraft:mooshroom_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MOOSHROOM_SPAWN_EGG = create(key("mooshroom_spawn_egg")); + + /** + * {@code minecraft:mule_spawn_egg} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey MULE_SPAWN_EGG = create(key("mule_spawn_egg")); /** * {@code minecraft:music_disc_5} @@ -3000,27 +3343,6 @@ public final class ItemTypeKeys { */ public static final TypedKey DISPENSER = create(key("dispenser")); - /** - * {@code minecraft:dolphin_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey DOLPHIN_SPAWN_EGG = create(key("dolphin_spawn_egg")); - - /** - * {@code minecraft:donkey_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey DONKEY_SPAWN_EGG = create(key("donkey_spawn_egg")); - - /** - * {@code minecraft:dragon_breath} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey DRAGON_BREATH = create(key("dragon_breath")); - /** * {@code minecraft:dragon_egg} * @@ -3028,13 +3350,6 @@ public final class ItemTypeKeys { */ public static final TypedKey DRAGON_EGG = create(key("dragon_egg")); - /** - * {@code minecraft:dragon_head} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey DRAGON_HEAD = create(key("dragon_head")); - /** * {@code minecraft:dried_kelp} * @@ -3063,13 +3378,6 @@ public final class ItemTypeKeys { */ public static final TypedKey DROPPER = create(key("dropper")); - /** - * {@code minecraft:drowned_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey DROWNED_SPAWN_EGG = create(key("drowned_spawn_egg")); - /** * {@code minecraft:dune_armor_trim_smithing_template} * @@ -3091,13 +3399,6 @@ public final class ItemTypeKeys { */ public static final TypedKey EGG = create(key("egg")); - /** - * {@code minecraft:elder_guardian_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ELDER_GUARDIAN_SPAWN_EGG = create(key("elder_guardian_spawn_egg")); - /** * {@code minecraft:elytra} * @@ -3126,13 +3427,6 @@ public final class ItemTypeKeys { */ public static final TypedKey EMERALD_ORE = create(key("emerald_ore")); - /** - * {@code minecraft:enchanted_book} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENCHANTED_BOOK = create(key("enchanted_book")); - /** * {@code minecraft:enchanted_golden_apple} * @@ -3147,13 +3441,6 @@ public final class ItemTypeKeys { */ public static final TypedKey ENCHANTING_TABLE = create(key("enchanting_table")); - /** - * {@code minecraft:end_crystal} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey END_CRYSTAL = create(key("end_crystal")); - /** * {@code minecraft:end_portal_frame} * @@ -3210,20 +3497,6 @@ public final class ItemTypeKeys { */ public static final TypedKey ENDER_CHEST = create(key("ender_chest")); - /** - * {@code minecraft:ender_dragon_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENDER_DRAGON_SPAWN_EGG = create(key("ender_dragon_spawn_egg")); - - /** - * {@code minecraft:ender_eye} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENDER_EYE = create(key("ender_eye")); - /** * {@code minecraft:ender_pearl} * @@ -3231,34 +3504,6 @@ public final class ItemTypeKeys { */ public static final TypedKey ENDER_PEARL = create(key("ender_pearl")); - /** - * {@code minecraft:enderman_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENDERMAN_SPAWN_EGG = create(key("enderman_spawn_egg")); - - /** - * {@code minecraft:endermite_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENDERMITE_SPAWN_EGG = create(key("endermite_spawn_egg")); - - /** - * {@code minecraft:evoker_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey EVOKER_SPAWN_EGG = create(key("evoker_spawn_egg")); - - /** - * {@code minecraft:experience_bottle} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey EXPERIENCE_BOTTLE = create(key("experience_bottle")); - /** * {@code minecraft:explorer_pottery_sherd} * @@ -3350,13 +3595,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FEATHER = create(key("feather")); - /** - * {@code minecraft:fermented_spider_eye} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FERMENTED_SPIDER_EYE = create(key("fermented_spider_eye")); - /** * {@code minecraft:fern} * @@ -3364,6 +3602,13 @@ public final class ItemTypeKeys { */ public static final TypedKey FERN = create(key("fern")); + /** + * {@code minecraft:field_masoned_banner_pattern} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FIELD_MASONED_BANNER_PATTERN = create(key("field_masoned_banner_pattern")); + /** * {@code minecraft:filled_map} * @@ -3371,13 +3616,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FILLED_MAP = create(key("filled_map")); - /** - * {@code minecraft:fire_charge} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FIRE_CHARGE = create(key("fire_charge")); - /** * {@code minecraft:fire_coral} * @@ -3400,18 +3638,11 @@ public final class ItemTypeKeys { public static final TypedKey FIRE_CORAL_FAN = create(key("fire_coral_fan")); /** - * {@code minecraft:firework_rocket} + * {@code minecraft:firefly_bush} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey FIREWORK_ROCKET = create(key("firework_rocket")); - - /** - * {@code minecraft:firework_star} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FIREWORK_STAR = create(key("firework_star")); + public static final TypedKey FIREFLY_BUSH = create(key("firefly_bush")); /** * {@code minecraft:fishing_rod} @@ -3420,6 +3651,13 @@ public final class ItemTypeKeys { */ public static final TypedKey FISHING_ROD = create(key("fishing_rod")); + /** + * {@code minecraft:fletching_table} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey FLETCHING_TABLE = create(key("fletching_table")); + /** * {@code minecraft:flint} * @@ -3448,13 +3686,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FLOW_POTTERY_SHERD = create(key("flow_pottery_sherd")); - /** - * {@code minecraft:flower_pot} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FLOWER_POT = create(key("flower_pot")); - /** * {@code minecraft:flowering_azalea} * @@ -3469,13 +3700,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FLOWERING_AZALEA_LEAVES = create(key("flowering_azalea_leaves")); - /** - * {@code minecraft:fox_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FOX_SPAWN_EGG = create(key("fox_spawn_egg")); - /** * {@code minecraft:friend_pottery_sherd} * @@ -3483,13 +3707,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FRIEND_POTTERY_SHERD = create(key("friend_pottery_sherd")); - /** - * {@code minecraft:frog_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey FROG_SPAWN_EGG = create(key("frog_spawn_egg")); - /** * {@code minecraft:frogspawn} * @@ -3511,13 +3728,6 @@ public final class ItemTypeKeys { */ public static final TypedKey FURNACE_MINECART = create(key("furnace_minecart")); - /** - * {@code minecraft:ghast_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GHAST_SPAWN_EGG = create(key("ghast_spawn_egg")); - /** * {@code minecraft:ghast_tear} * @@ -3539,13 +3749,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GLASS = create(key("glass")); - /** - * {@code minecraft:glass_bottle} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GLASS_BOTTLE = create(key("glass_bottle")); - /** * {@code minecraft:glass_pane} * @@ -3553,13 +3756,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GLASS_PANE = create(key("glass_pane")); - /** - * {@code minecraft:glistering_melon_slice} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GLISTERING_MELON_SLICE = create(key("glistering_melon_slice")); - /** * {@code minecraft:globe_banner_pattern} * @@ -3567,6 +3763,13 @@ public final class ItemTypeKeys { */ public static final TypedKey GLOBE_BANNER_PATTERN = create(key("globe_banner_pattern")); + /** + * {@code minecraft:glow_berries} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GLOW_BERRIES = create(key("glow_berries")); + /** * {@code minecraft:glow_ink_sac} * @@ -3574,13 +3777,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GLOW_INK_SAC = create(key("glow_ink_sac")); - /** - * {@code minecraft:glow_item_frame} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GLOW_ITEM_FRAME = create(key("glow_item_frame")); - /** * {@code minecraft:glow_lichen} * @@ -3588,13 +3784,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GLOW_LICHEN = create(key("glow_lichen")); - /** - * {@code minecraft:glow_squid_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GLOW_SQUID_SPAWN_EGG = create(key("glow_squid_spawn_egg")); - /** * {@code minecraft:glowstone} * @@ -3610,11 +3799,11 @@ public final class ItemTypeKeys { public static final TypedKey GLOWSTONE_DUST = create(key("glowstone_dust")); /** - * {@code minecraft:goat_spawn_egg} + * {@code minecraft:goat_horn} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GOAT_SPAWN_EGG = create(key("goat_spawn_egg")); + public static final TypedKey GOAT_HORN = create(key("goat_horn")); /** * {@code minecraft:gold_block} @@ -3630,13 +3819,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLD_INGOT = create(key("gold_ingot")); - /** - * {@code minecraft:gold_nugget} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GOLD_NUGGET = create(key("gold_nugget")); - /** * {@code minecraft:gold_ore} * @@ -3665,13 +3847,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_BOOTS = create(key("golden_boots")); - /** - * {@code minecraft:golden_carrot} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GOLDEN_CARROT = create(key("golden_carrot")); - /** * {@code minecraft:golden_chestplate} * @@ -3693,13 +3868,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GOLDEN_HOE = create(key("golden_hoe")); - /** - * {@code minecraft:golden_horse_armor} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GOLDEN_HORSE_ARMOR = create(key("golden_horse_armor")); - /** * {@code minecraft:golden_leggings} * @@ -3770,13 +3938,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GRAVEL = create(key("gravel")); - /** - * {@code minecraft:gray_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GRAY_BANNER = create(key("gray_banner")); - /** * {@code minecraft:gray_bed} * @@ -3868,13 +4029,6 @@ public final class ItemTypeKeys { */ public static final TypedKey GRAY_WOOL = create(key("gray_wool")); - /** - * {@code minecraft:green_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey GREEN_BANNER = create(key("green_banner")); - /** * {@code minecraft:green_bed} * @@ -3967,11 +4121,11 @@ public final class ItemTypeKeys { public static final TypedKey GREEN_WOOL = create(key("green_wool")); /** - * {@code minecraft:guardian_spawn_egg} + * {@code minecraft:grindstone} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey GUARDIAN_SPAWN_EGG = create(key("guardian_spawn_egg")); + public static final TypedKey GRINDSTONE = create(key("grindstone")); /** * {@code minecraft:gunpowder} @@ -4043,13 +4197,6 @@ public final class ItemTypeKeys { */ public static final TypedKey HEAVY_WEIGHTED_PRESSURE_PLATE = create(key("heavy_weighted_pressure_plate")); - /** - * {@code minecraft:hoglin_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey HOGLIN_SPAWN_EGG = create(key("hoglin_spawn_egg")); - /** * {@code minecraft:honey_block} * @@ -4064,6 +4211,13 @@ public final class ItemTypeKeys { */ public static final TypedKey HONEY_BOTTLE = create(key("honey_bottle")); + /** + * {@code minecraft:honeycomb} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey HONEYCOMB = create(key("honeycomb")); + /** * {@code minecraft:honeycomb_block} * @@ -4106,13 +4260,6 @@ public final class ItemTypeKeys { */ public static final TypedKey HORN_CORAL_FAN = create(key("horn_coral_fan")); - /** - * {@code minecraft:horse_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey HORSE_SPAWN_EGG = create(key("horse_spawn_egg")); - /** * {@code minecraft:host_armor_trim_smithing_template} * @@ -4127,13 +4274,6 @@ public final class ItemTypeKeys { */ public static final TypedKey HOWL_POTTERY_SHERD = create(key("howl_pottery_sherd")); - /** - * {@code minecraft:husk_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey HUSK_SPAWN_EGG = create(key("husk_spawn_egg")); - /** * {@code minecraft:ice} * @@ -4239,13 +4379,6 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_DOOR = create(key("iron_door")); - /** - * {@code minecraft:iron_golem_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey IRON_GOLEM_SPAWN_EGG = create(key("iron_golem_spawn_egg")); - /** * {@code minecraft:iron_helmet} * @@ -4260,13 +4393,6 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_HOE = create(key("iron_hoe")); - /** - * {@code minecraft:iron_horse_armor} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey IRON_HORSE_ARMOR = create(key("iron_horse_armor")); - /** * {@code minecraft:iron_ingot} * @@ -4323,13 +4449,6 @@ public final class ItemTypeKeys { */ public static final TypedKey IRON_TRAPDOOR = create(key("iron_trapdoor")); - /** - * {@code minecraft:item_frame} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ITEM_FRAME = create(key("item_frame")); - /** * {@code minecraft:jack_o_lantern} * @@ -4491,6 +4610,13 @@ public final class ItemTypeKeys { */ public static final TypedKey LADDER = create(key("ladder")); + /** + * {@code minecraft:lantern} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey LANTERN = create(key("lantern")); + /** * {@code minecraft:lapis_block} * @@ -4534,11 +4660,11 @@ public final class ItemTypeKeys { public static final TypedKey LAVA_BUCKET = create(key("lava_bucket")); /** - * {@code minecraft:lead} + * {@code minecraft:leaf_litter} * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - public static final TypedKey LEAD = create(key("lead")); + public static final TypedKey LEAF_LITTER = create(key("leaf_litter")); /** * {@code minecraft:leather} @@ -4568,13 +4694,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LEATHER_HELMET = create(key("leather_helmet")); - /** - * {@code minecraft:leather_horse_armor} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey LEATHER_HORSE_ARMOR = create(key("leather_horse_armor")); - /** * {@code minecraft:leather_leggings} * @@ -4603,13 +4722,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LIGHT = create(key("light")); - /** - * {@code minecraft:light_blue_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey LIGHT_BLUE_BANNER = create(key("light_blue_banner")); - /** * {@code minecraft:light_blue_bed} * @@ -4701,13 +4813,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LIGHT_BLUE_WOOL = create(key("light_blue_wool")); - /** - * {@code minecraft:light_gray_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey LIGHT_GRAY_BANNER = create(key("light_gray_banner")); - /** * {@code minecraft:light_gray_bed} * @@ -4834,13 +4939,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LILY_PAD = create(key("lily_pad")); - /** - * {@code minecraft:lime_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey LIME_BANNER = create(key("lime_banner")); - /** * {@code minecraft:lime_bed} * @@ -4939,13 +5037,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LINGERING_POTION = create(key("lingering_potion")); - /** - * {@code minecraft:llama_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey LLAMA_SPAWN_EGG = create(key("llama_spawn_egg")); - /** * {@code minecraft:lodestone} * @@ -4960,20 +5051,6 @@ public final class ItemTypeKeys { */ public static final TypedKey LOOM = create(key("loom")); - /** - * {@code minecraft:mace} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MACE = create(key("mace")); - - /** - * {@code minecraft:magenta_banner} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MAGENTA_BANNER = create(key("magenta_banner")); - /** * {@code minecraft:magenta_bed} * @@ -5072,20 +5149,6 @@ public final class ItemTypeKeys { */ public static final TypedKey MAGMA_BLOCK = create(key("magma_block")); - /** - * {@code minecraft:magma_cream} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MAGMA_CREAM = create(key("magma_cream")); - - /** - * {@code minecraft:magma_cube_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MAGMA_CUBE_SPAWN_EGG = create(key("magma_cube_spawn_egg")); - /** * {@code minecraft:mangrove_boat} * @@ -5212,13 +5275,6 @@ public final class ItemTypeKeys { */ public static final TypedKey MANGROVE_WOOD = create(key("mangrove_wood")); - /** - * {@code minecraft:map} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MAP = create(key("map")); - /** * {@code minecraft:medium_amethyst_bud} * @@ -5275,13 +5331,6 @@ public final class ItemTypeKeys { */ public static final TypedKey MOJANG_BANNER_PATTERN = create(key("mojang_banner_pattern")); - /** - * {@code minecraft:mooshroom_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MOOSHROOM_SPAWN_EGG = create(key("mooshroom_spawn_egg")); - /** * {@code minecraft:moss_block} * @@ -5401,13 +5450,6 @@ public final class ItemTypeKeys { */ public static final TypedKey MUDDY_MANGROVE_ROOTS = create(key("muddy_mangrove_roots")); - /** - * {@code minecraft:mule_spawn_egg} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey MULE_SPAWN_EGG = create(key("mule_spawn_egg")); - /** * {@code minecraft:mushroom_stem} * @@ -7676,6 +7718,13 @@ public final class ItemTypeKeys { */ public static final TypedKey SHIELD = create(key("shield")); + /** + * {@code minecraft:short_dry_grass} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SHORT_DRY_GRASS = create(key("short_dry_grass")); + /** * {@code minecraft:short_grass} * @@ -8551,6 +8600,13 @@ public final class ItemTypeKeys { */ public static final TypedKey TADPOLE_SPAWN_EGG = create(key("tadpole_spawn_egg")); + /** + * {@code minecraft:tall_dry_grass} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TALL_DRY_GRASS = create(key("tall_dry_grass")); + /** * {@code minecraft:tall_grass} * @@ -8572,6 +8628,20 @@ public final class ItemTypeKeys { */ public static final TypedKey TERRACOTTA = create(key("terracotta")); + /** + * {@code minecraft:test_block} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEST_BLOCK = create(key("test_block")); + + /** + * {@code minecraft:test_instance_block} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEST_INSTANCE_BLOCK = create(key("test_instance_block")); + /** * {@code minecraft:tide_armor_trim_smithing_template} * @@ -9475,6 +9545,13 @@ public final class ItemTypeKeys { */ public static final TypedKey WILD_ARMOR_TRIM_SMITHING_TEMPLATE = create(key("wild_armor_trim_smithing_template")); + /** + * {@code minecraft:wildflowers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WILDFLOWERS = create(key("wildflowers")); + /** * {@code minecraft:wind_charge} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java index d86ad9bf2..75ec65473 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/JukeboxSongKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class JukeboxSongKeys { /** * {@code minecraft:11} @@ -162,7 +162,7 @@ public final class JukeboxSongKeys { } /** - * Creates a key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}. + * Creates a typed key for {@link JukeboxSong} in the registry {@code minecraft:jukebox_song}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java index fbf67d675..4c01a72cb 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MapDecorationTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class MapDecorationTypeKeys { /** * {@code minecraft:banner_black} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MenuTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MenuTypeKeys.java index 06c94936f..4f0f99494 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MenuTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MenuTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class MenuTypeKeys { /** * {@code minecraft:anvil} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java index 58b9c179f..c3d211d27 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/MobEffectKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class MobEffectKeys { /** * {@code minecraft:absorption} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/PaintingVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/PaintingVariantKeys.java index 119dca483..c7d6e1e53 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/PaintingVariantKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/PaintingVariantKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class PaintingVariantKeys { /** * {@code minecraft:alban} @@ -379,7 +379,7 @@ public final class PaintingVariantKeys { } /** - * Creates a key for {@link Art} in the registry {@code minecraft:painting_variant}. + * Creates a typed key for {@link Art} in the registry {@code minecraft:painting_variant}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/PigVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/PigVariantKeys.java new file mode 100644 index 000000000..ea29ff799 --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/PigVariantKeys.java @@ -0,0 +1,61 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.Pig; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#PIG_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedFrom("1.21.5") +public final class PigVariantKeys { + /** + * {@code minecraft:cold} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey COLD = create(key("cold")); + + /** + * {@code minecraft:temperate} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey TEMPERATE = create(key("temperate")); + + /** + * {@code minecraft:warm} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey WARM = create(key("warm")); + + private PigVariantKeys() { + } + + /** + * Creates a typed key for {@link Pig.Variant} in the registry {@code minecraft:pig_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.PIG_VARIANT, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java index 9cc0ae85b..6493f649a 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/SoundEventKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class SoundEventKeys { /** * {@code minecraft:ambient.basalt_deltas.additions} @@ -879,6 +879,20 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE = create(key("block.bubble_column.whirlpool_inside")); + /** + * {@code minecraft:block.cactus_flower.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CACTUS_FLOWER_BREAK = create(key("block.cactus_flower.break")); + + /** + * {@code minecraft:block.cactus_flower.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_CACTUS_FLOWER_PLACE = create(key("block.cactus_flower.place")); + /** * {@code minecraft:block.cake.add_candle} * @@ -1726,6 +1740,13 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_CROP_BREAK = create(key("block.crop.break")); + /** + * {@code minecraft:block.deadbush.idle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_DEADBUSH_IDLE = create(key("block.deadbush.idle")); + /** * {@code minecraft:block.decorated_pot.break} * @@ -2048,6 +2069,13 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_FIRE_EXTINGUISH = create(key("block.fire.extinguish")); + /** + * {@code minecraft:block.firefly_bush.idle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_FIREFLY_BUSH_IDLE = create(key("block.firefly_bush.idle")); + /** * {@code minecraft:block.flowering_azalea.break} * @@ -2510,6 +2538,41 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_HONEY_BLOCK_STEP = create(key("block.honey_block.step")); + /** + * {@code minecraft:block.iron.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_IRON_BREAK = create(key("block.iron.break")); + + /** + * {@code minecraft:block.iron.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_IRON_FALL = create(key("block.iron.fall")); + + /** + * {@code minecraft:block.iron.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_IRON_HIT = create(key("block.iron.hit")); + + /** + * {@code minecraft:block.iron.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_IRON_PLACE = create(key("block.iron.place")); + + /** + * {@code minecraft:block.iron.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_IRON_STEP = create(key("block.iron.step")); + /** * {@code minecraft:block.iron_door.close} * @@ -2643,6 +2706,41 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_LAVA_POP = create(key("block.lava.pop")); + /** + * {@code minecraft:block.leaf_litter.break} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_LEAF_LITTER_BREAK = create(key("block.leaf_litter.break")); + + /** + * {@code minecraft:block.leaf_litter.fall} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_LEAF_LITTER_FALL = create(key("block.leaf_litter.fall")); + + /** + * {@code minecraft:block.leaf_litter.hit} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_LEAF_LITTER_HIT = create(key("block.leaf_litter.hit")); + + /** + * {@code minecraft:block.leaf_litter.place} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_LEAF_LITTER_PLACE = create(key("block.leaf_litter.place")); + + /** + * {@code minecraft:block.leaf_litter.step} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_LEAF_LITTER_STEP = create(key("block.leaf_litter.step")); + /** * {@code minecraft:block.lever.click} * @@ -3994,6 +4092,13 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_SAND_HIT = create(key("block.sand.hit")); + /** + * {@code minecraft:block.sand.idle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SAND_IDLE = create(key("block.sand.idle")); + /** * {@code minecraft:block.sand.place} * @@ -4008,6 +4113,13 @@ public final class SoundEventKeys { */ public static final TypedKey BLOCK_SAND_STEP = create(key("block.sand.step")); + /** + * {@code minecraft:block.sand.wind} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BLOCK_SAND_WIND = create(key("block.sand.wind")); + /** * {@code minecraft:block.scaffolding.break} * @@ -10217,13 +10329,6 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_WOLF_GROWL = create(key("entity.wolf.growl")); - /** - * {@code minecraft:entity.wolf.howl} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TypedKey ENTITY_WOLF_HOWL = create(key("entity.wolf.howl")); - /** * {@code minecraft:entity.wolf.hurt} * @@ -10259,6 +10364,258 @@ public final class SoundEventKeys { */ public static final TypedKey ENTITY_WOLF_WHINE = create(key("entity.wolf.whine")); + /** + * {@code minecraft:entity.wolf_angry.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_AMBIENT = create(key("entity.wolf_angry.ambient")); + + /** + * {@code minecraft:entity.wolf_angry.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_DEATH = create(key("entity.wolf_angry.death")); + + /** + * {@code minecraft:entity.wolf_angry.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_GROWL = create(key("entity.wolf_angry.growl")); + + /** + * {@code minecraft:entity.wolf_angry.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_HURT = create(key("entity.wolf_angry.hurt")); + + /** + * {@code minecraft:entity.wolf_angry.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_PANT = create(key("entity.wolf_angry.pant")); + + /** + * {@code minecraft:entity.wolf_angry.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_ANGRY_WHINE = create(key("entity.wolf_angry.whine")); + + /** + * {@code minecraft:entity.wolf_big.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_AMBIENT = create(key("entity.wolf_big.ambient")); + + /** + * {@code minecraft:entity.wolf_big.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_DEATH = create(key("entity.wolf_big.death")); + + /** + * {@code minecraft:entity.wolf_big.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_GROWL = create(key("entity.wolf_big.growl")); + + /** + * {@code minecraft:entity.wolf_big.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_HURT = create(key("entity.wolf_big.hurt")); + + /** + * {@code minecraft:entity.wolf_big.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_PANT = create(key("entity.wolf_big.pant")); + + /** + * {@code minecraft:entity.wolf_big.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_BIG_WHINE = create(key("entity.wolf_big.whine")); + + /** + * {@code minecraft:entity.wolf_cute.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_AMBIENT = create(key("entity.wolf_cute.ambient")); + + /** + * {@code minecraft:entity.wolf_cute.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_DEATH = create(key("entity.wolf_cute.death")); + + /** + * {@code minecraft:entity.wolf_cute.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_GROWL = create(key("entity.wolf_cute.growl")); + + /** + * {@code minecraft:entity.wolf_cute.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_HURT = create(key("entity.wolf_cute.hurt")); + + /** + * {@code minecraft:entity.wolf_cute.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_PANT = create(key("entity.wolf_cute.pant")); + + /** + * {@code minecraft:entity.wolf_cute.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_CUTE_WHINE = create(key("entity.wolf_cute.whine")); + + /** + * {@code minecraft:entity.wolf_grumpy.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_AMBIENT = create(key("entity.wolf_grumpy.ambient")); + + /** + * {@code minecraft:entity.wolf_grumpy.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_DEATH = create(key("entity.wolf_grumpy.death")); + + /** + * {@code minecraft:entity.wolf_grumpy.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_GROWL = create(key("entity.wolf_grumpy.growl")); + + /** + * {@code minecraft:entity.wolf_grumpy.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_HURT = create(key("entity.wolf_grumpy.hurt")); + + /** + * {@code minecraft:entity.wolf_grumpy.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_PANT = create(key("entity.wolf_grumpy.pant")); + + /** + * {@code minecraft:entity.wolf_grumpy.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_GRUMPY_WHINE = create(key("entity.wolf_grumpy.whine")); + + /** + * {@code minecraft:entity.wolf_puglin.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_AMBIENT = create(key("entity.wolf_puglin.ambient")); + + /** + * {@code minecraft:entity.wolf_puglin.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_DEATH = create(key("entity.wolf_puglin.death")); + + /** + * {@code minecraft:entity.wolf_puglin.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_GROWL = create(key("entity.wolf_puglin.growl")); + + /** + * {@code minecraft:entity.wolf_puglin.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_HURT = create(key("entity.wolf_puglin.hurt")); + + /** + * {@code minecraft:entity.wolf_puglin.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_PANT = create(key("entity.wolf_puglin.pant")); + + /** + * {@code minecraft:entity.wolf_puglin.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_PUGLIN_WHINE = create(key("entity.wolf_puglin.whine")); + + /** + * {@code minecraft:entity.wolf_sad.ambient} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_AMBIENT = create(key("entity.wolf_sad.ambient")); + + /** + * {@code minecraft:entity.wolf_sad.death} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_DEATH = create(key("entity.wolf_sad.death")); + + /** + * {@code minecraft:entity.wolf_sad.growl} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_GROWL = create(key("entity.wolf_sad.growl")); + + /** + * {@code minecraft:entity.wolf_sad.hurt} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_HURT = create(key("entity.wolf_sad.hurt")); + + /** + * {@code minecraft:entity.wolf_sad.pant} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_PANT = create(key("entity.wolf_sad.pant")); + + /** + * {@code minecraft:entity.wolf_sad.whine} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ENTITY_WOLF_SAD_WHINE = create(key("entity.wolf_sad.whine")); + /** * {@code minecraft:entity.zoglin.ambient} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureKeys.java index 9919f556b..fb06b1cdd 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class StructureKeys { /** * {@code minecraft:ancient_city} @@ -267,7 +267,7 @@ public final class StructureKeys { } /** - * Creates a key for {@link Structure} in the registry {@code minecraft:worldgen/structure}. + * Creates a typed key for {@link Structure} in the registry {@code minecraft:worldgen/structure}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureTypeKeys.java index 79be3249e..940d54486 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/StructureTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class StructureTypeKeys { /** * {@code minecraft:buried_treasure} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimMaterialKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimMaterialKeys.java index c9a975907..6bea6ac6c 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimMaterialKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimMaterialKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class TrimMaterialKeys { /** * {@code minecraft:amethyst} @@ -106,7 +106,7 @@ public final class TrimMaterialKeys { } /** - * Creates a key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}. + * Creates a typed key for {@link TrimMaterial} in the registry {@code minecraft:trim_material}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimPatternKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimPatternKeys.java index a7f2c6341..94ce37d29 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimPatternKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/TrimPatternKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class TrimPatternKeys { /** * {@code minecraft:bolt} @@ -155,7 +155,7 @@ public final class TrimPatternKeys { } /** - * Creates a key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}. + * Creates a typed key for {@link TrimPattern} in the registry {@code minecraft:trim_pattern}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerProfessionKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerProfessionKeys.java index 860e770d4..95416da96 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerProfessionKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerProfessionKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class VillagerProfessionKeys { /** * {@code minecraft:armorer} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerTypeKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerTypeKeys.java index 1b9a669d4..9c629dcda 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerTypeKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/VillagerTypeKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class VillagerTypeKeys { /** * {@code minecraft:desert} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfSoundVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfSoundVariantKeys.java new file mode 100644 index 000000000..4bcdeb3d0 --- /dev/null +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfSoundVariantKeys.java @@ -0,0 +1,89 @@ +package io.papermc.paper.registry.keys; + +import static net.kyori.adventure.key.Key.key; + +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import net.kyori.adventure.key.Key; +import org.bukkit.entity.Wolf; +import org.jspecify.annotations.NullMarked; + +/** + * Vanilla keys for {@link RegistryKey#WOLF_SOUND_VARIANT}. + * + * @apiNote The fields provided here are a direct representation of + * what is available from the vanilla game source. They may be + * changed (including removals) on any Minecraft version + * bump, so cross-version compatibility is not provided on the + * same level as it is on most of the other API. + */ +@SuppressWarnings({ + "unused", + "SpellCheckingInspection" +}) +@NullMarked +@GeneratedFrom("1.21.5") +public final class WolfSoundVariantKeys { + /** + * {@code minecraft:angry} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey ANGRY = create(key("angry")); + + /** + * {@code minecraft:big} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey BIG = create(key("big")); + + /** + * {@code minecraft:classic} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CLASSIC = create(key("classic")); + + /** + * {@code minecraft:cute} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey CUTE = create(key("cute")); + + /** + * {@code minecraft:grumpy} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey GRUMPY = create(key("grumpy")); + + /** + * {@code minecraft:puglin} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey PUGLIN = create(key("puglin")); + + /** + * {@code minecraft:sad} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TypedKey SAD = create(key("sad")); + + private WolfSoundVariantKeys() { + } + + /** + * Creates a typed key for {@link Wolf.SoundVariant} in the registry {@code minecraft:wolf_sound_variant}. + * + * @param key the value's key in the registry + * @return a new typed key + */ + public static TypedKey create(final Key key) { + return TypedKey.create(RegistryKey.WOLF_SOUND_VARIANT, key); + } +} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfVariantKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfVariantKeys.java index 7962d0fae..c291debdd 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfVariantKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/WolfVariantKeys.java @@ -22,8 +22,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") public final class WolfVariantKeys { /** * {@code minecraft:ashen} @@ -92,7 +92,7 @@ public final class WolfVariantKeys { } /** - * Creates a key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}. + * Creates a typed key for {@link Wolf.Variant} in the registry {@code minecraft:wolf_variant}. * * @param key the value's key in the registry * @return a new typed key diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BannerPatternTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BannerPatternTagKeys.java index 5e1c93327..a62b2e1ef 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BannerPatternTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BannerPatternTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#BANNER_PATTERN}. + * Vanilla tag keys for {@link RegistryKey#BANNER_PATTERN}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class BannerPatternTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java index acc82a5df..96d90dd15 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BiomeTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#BIOME}. + * Vanilla tag keys for {@link RegistryKey#BIOME}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class BiomeTagKeys { /** @@ -447,6 +447,13 @@ public final class BiomeTagKeys { */ public static final TagKey SNOW_GOLEM_MELTS = create(key("snow_golem_melts")); + /** + * {@code #minecraft:spawns_cold_variant_farm_animals} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPAWNS_COLD_VARIANT_FARM_ANIMALS = create(key("spawns_cold_variant_farm_animals")); + /** * {@code #minecraft:spawns_cold_variant_frogs} * @@ -468,6 +475,13 @@ public final class BiomeTagKeys { */ public static final TagKey SPAWNS_SNOW_FOXES = create(key("spawns_snow_foxes")); + /** + * {@code #minecraft:spawns_warm_variant_farm_animals} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SPAWNS_WARM_VARIANT_FARM_ANIMALS = create(key("spawns_warm_variant_farm_animals")); + /** * {@code #minecraft:spawns_warm_variant_frogs} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java index af2a45f63..0ba91ccde 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/BlockTypeTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#BLOCK}. + * Vanilla tag keys for {@link RegistryKey#BLOCK}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class BlockTypeTagKeys { /** @@ -223,6 +223,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey CAMEL_SAND_STEP_SOUND_BLOCKS = create(key("camel_sand_step_sound_blocks")); + /** + * {@code #minecraft:camels_spawnable_on} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAMELS_SPAWNABLE_ON = create(key("camels_spawnable_on")); + /** * {@code #minecraft:campfires} * @@ -377,13 +384,6 @@ public final class BlockTypeTagKeys { */ public static final TagKey DARK_OAK_LOGS = create(key("dark_oak_logs")); - /** - * {@code #minecraft:dead_bush_may_place_on} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey DEAD_BUSH_MAY_PLACE_ON = create(key("dead_bush_may_place_on")); - /** * {@code #minecraft:deepslate_ore_replaceables} * @@ -440,6 +440,20 @@ public final class BlockTypeTagKeys { */ public static final TagKey DRIPSTONE_REPLACEABLE_BLOCKS = create(key("dripstone_replaceable_blocks")); + /** + * {@code #minecraft:dry_vegetation_may_place_on} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey DRY_VEGETATION_MAY_PLACE_ON = create(key("dry_vegetation_may_place_on")); + + /** + * {@code #minecraft:edible_for_sheep} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey EDIBLE_FOR_SHEEP = create(key("edible_for_sheep")); + /** * {@code #minecraft:emerald_ores} * @@ -895,6 +909,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey PLANKS = create(key("planks")); + /** + * {@code #minecraft:plays_ambient_desert_block_sounds} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey PLAYS_AMBIENT_DESERT_BLOCK_SOUNDS = create(key("plays_ambient_desert_block_sounds")); + /** * {@code #minecraft:polar_bears_spawnable_on_alternate} * @@ -951,6 +972,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey REPLACEABLE = create(key("replaceable")); + /** + * {@code #minecraft:replaceable_by_mushrooms} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey REPLACEABLE_BY_MUSHROOMS = create(key("replaceable_by_mushrooms")); + /** * {@code #minecraft:replaceable_by_trees} * @@ -1147,6 +1175,13 @@ public final class BlockTypeTagKeys { */ public static final TagKey SWORD_EFFICIENT = create(key("sword_efficient")); + /** + * {@code #minecraft:sword_instantly_mines} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey SWORD_INSTANTLY_MINES = create(key("sword_instantly_mines")); + /** * {@code #minecraft:terracotta} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/CatVariantTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/CatVariantTagKeys.java deleted file mode 100644 index 17a43aa9e..000000000 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/CatVariantTagKeys.java +++ /dev/null @@ -1,57 +0,0 @@ -package io.papermc.paper.registry.keys.tags; - -import static net.kyori.adventure.key.Key.key; - -import io.papermc.paper.generated.GeneratedFrom; -import io.papermc.paper.registry.RegistryKey; -import io.papermc.paper.registry.tag.TagKey; -import net.kyori.adventure.key.Key; -import org.bukkit.entity.Cat; -import org.jetbrains.annotations.ApiStatus; -import org.jspecify.annotations.NullMarked; - -/** - * Vanilla keys for {@link RegistryKey#CAT_VARIANT}. - * - * @apiNote The fields provided here are a direct representation of - * what is available from the vanilla game source. They may be - * changed (including removals) on any Minecraft version - * bump, so cross-version compatibility is not provided on the - * same level as it is on most of the other API. - */ -@SuppressWarnings({ - "unused", - "SpellCheckingInspection" -}) -@GeneratedFrom("1.21.4") -@NullMarked -@ApiStatus.Experimental -public final class CatVariantTagKeys { - /** - * {@code #minecraft:default_spawns} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey DEFAULT_SPAWNS = create(key("default_spawns")); - - /** - * {@code #minecraft:full_moon_spawns} - * - * @apiNote This field is version-dependant and may be removed in future Minecraft versions - */ - public static final TagKey FULL_MOON_SPAWNS = create(key("full_moon_spawns")); - - private CatVariantTagKeys() { - } - - /** - * Creates a tag key for {@link Cat.Type} in the registry {@code minecraft:cat_variant}. - * - * @param key the tag key's key - * @return a new tag key - */ - @ApiStatus.Experimental - public static TagKey create(final Key key) { - return TagKey.create(RegistryKey.CAT_VARIANT, key); - } -} diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java index d70cb0397..cf56bc908 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/DamageTypeTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#DAMAGE_TYPE}. + * Vanilla tag keys for {@link RegistryKey#DAMAGE_TYPE}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class DamageTypeTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java index cf5a921cd..09137b46c 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EnchantmentTagKeys.java @@ -12,7 +12,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#ENCHANTMENT}. + * Vanilla tag keys for {@link RegistryKey#ENCHANTMENT}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -24,8 +24,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class EnchantmentTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java index 5a671ff8b..e1afd736a 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/EntityTypeTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#ENTITY_TYPE}. + * Vanilla tag keys for {@link RegistryKey#ENTITY_TYPE}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class EntityTypeTagKeys { /** @@ -83,6 +83,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_BREATHE_UNDER_WATER = create(key("can_breathe_under_water")); + /** + * {@code #minecraft:can_equip_saddle} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_EQUIP_SADDLE = create(key("can_equip_saddle")); + /** * {@code #minecraft:can_turn_in_boats} * @@ -90,6 +97,13 @@ public final class EntityTypeTagKeys { */ public static final TagKey CAN_TURN_IN_BOATS = create(key("can_turn_in_boats")); + /** + * {@code #minecraft:can_wear_horse_armor} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey CAN_WEAR_HORSE_ARMOR = create(key("can_wear_horse_armor")); + /** * {@code #minecraft:deflects_projectiles} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/FluidTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/FluidTagKeys.java index 4a33d3e87..4e2fc7c7a 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/FluidTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/FluidTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#FLUID}. + * Vanilla tag keys for {@link RegistryKey#FLUID}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class FluidTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/GameEventTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/GameEventTagKeys.java index 3cb6d6e1e..3c2b29d66 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/GameEventTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/GameEventTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#GAME_EVENT}. + * Vanilla tag keys for {@link RegistryKey#GAME_EVENT}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class GameEventTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/InstrumentTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/InstrumentTagKeys.java index 527fb7761..e276c3dd5 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/InstrumentTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/InstrumentTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#INSTRUMENT}. + * Vanilla tag keys for {@link RegistryKey#INSTRUMENT}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class InstrumentTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java index bf43d9af9..4f973490e 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/ItemTypeTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#ITEM}. + * Vanilla tag keys for {@link RegistryKey#ITEM}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class ItemTypeTagKeys { /** @@ -118,6 +118,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey BOATS = create(key("boats")); + /** + * {@code #minecraft:book_cloning_target} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey BOOK_CLONING_TARGET = create(key("book_cloning_target")); + /** * {@code #minecraft:bookshelf_books} * @@ -349,6 +356,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey DYEABLE = create(key("dyeable")); + /** + * {@code #minecraft:eggs} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey EGGS = create(key("eggs")); + /** * {@code #minecraft:emerald_ores} * @@ -510,6 +524,13 @@ public final class ItemTypeTagKeys { */ public static final TagKey FISHES = create(key("fishes")); + /** + * {@code #minecraft:flowers} + * + * @apiNote This field is version-dependant and may be removed in future Minecraft versions + */ + public static final TagKey FLOWERS = create(key("flowers")); + /** * {@code #minecraft:foot_armor} * diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/PaintingVariantTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/PaintingVariantTagKeys.java index 50dac36d1..607d2dd8d 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/PaintingVariantTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/PaintingVariantTagKeys.java @@ -11,7 +11,7 @@ import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#PAINTING_VARIANT}. + * Vanilla tag keys for {@link RegistryKey#PAINTING_VARIANT}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -23,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class PaintingVariantTagKeys { /** diff --git a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/StructureTagKeys.java b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/StructureTagKeys.java index 5043b933d..085522c72 100644 --- a/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/StructureTagKeys.java +++ b/paper-api/src/generated/java/io/papermc/paper/registry/keys/tags/StructureTagKeys.java @@ -6,13 +6,12 @@ import io.papermc.paper.generated.GeneratedFrom; import io.papermc.paper.registry.RegistryKey; import io.papermc.paper.registry.tag.TagKey; import net.kyori.adventure.key.Key; -import org.bukkit.MinecraftExperimental; import org.bukkit.generator.structure.Structure; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; /** - * Vanilla keys for {@link RegistryKey#STRUCTURE}. + * Vanilla tag keys for {@link RegistryKey#STRUCTURE}. * * @apiNote The fields provided here are a direct representation of * what is available from the vanilla game source. They may be @@ -24,8 +23,8 @@ import org.jspecify.annotations.NullMarked; "unused", "SpellCheckingInspection" }) -@GeneratedFrom("1.21.4") @NullMarked +@GeneratedFrom("1.21.5") @ApiStatus.Experimental public final class StructureTagKeys { /** @@ -75,8 +74,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_DESERT_VILLAGE_MAPS = create(key("on_desert_village_maps")); /** @@ -84,8 +81,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_JUNGLE_EXPLORER_MAPS = create(key("on_jungle_explorer_maps")); /** @@ -100,8 +95,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_PLAINS_VILLAGE_MAPS = create(key("on_plains_village_maps")); /** @@ -109,8 +102,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_SAVANNA_VILLAGE_MAPS = create(key("on_savanna_village_maps")); /** @@ -118,8 +109,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_SNOWY_VILLAGE_MAPS = create(key("on_snowy_village_maps")); /** @@ -127,8 +116,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_SWAMP_EXPLORER_MAPS = create(key("on_swamp_explorer_maps")); /** @@ -136,8 +123,6 @@ public final class StructureTagKeys { * * @apiNote This field is version-dependant and may be removed in future Minecraft versions */ - @ApiStatus.Experimental - @MinecraftExperimental(MinecraftExperimental.Requires.TRADE_REBALANCE) public static final TagKey ON_TAIGA_VILLAGE_MAPS = create(key("on_taiga_village_maps")); /** diff --git a/paper-api/src/main/java/co/aikar/timings/TimingHistory.java b/paper-api/src/main/java/co/aikar/timings/TimingHistory.java index 6f6eb1a2e..c8287776a 100644 --- a/paper-api/src/main/java/co/aikar/timings/TimingHistory.java +++ b/paper-api/src/main/java/co/aikar/timings/TimingHistory.java @@ -289,7 +289,7 @@ public class TimingHistory { final TicksRecord ticksRecord = new TicksRecord(); final PingRecord pingRecord = new PingRecord(); final TimingData fst = TimingsManager.FULL_SERVER_TICK.minuteData.clone(); - final double tps = 1E9 / ( System.nanoTime() - lastMinuteTime ) * ticksRecord.timed; + final double tps = 1E9 / (System.nanoTime() - lastMinuteTime) * ticksRecord.timed; final double usedMemory = TimingsManager.FULL_SERVER_TICK.avgUsedMemory; final double freeMemory = TimingsManager.FULL_SERVER_TICK.avgFreeMemory; final double loadAvg = ManagementFactory.getOperatingSystemMXBean().getSystemLoadAverage(); diff --git a/paper-api/src/main/java/co/aikar/timings/TimingsManager.java b/paper-api/src/main/java/co/aikar/timings/TimingsManager.java index e72ad05ab..83a70358e 100644 --- a/paper-api/src/main/java/co/aikar/timings/TimingsManager.java +++ b/paper-api/src/main/java/co/aikar/timings/TimingsManager.java @@ -153,9 +153,9 @@ public final class TimingsManager { public static Timing getCommandTiming(@Nullable String pluginName, @NotNull Command command) { Plugin plugin = null; final Server server = Bukkit.getServer(); - if (!( server == null || pluginName == null || - "minecraft".equals(pluginName) || "bukkit".equals(pluginName) || - "spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName) + if (!(server == null || pluginName == null || + "minecraft".equals(pluginName) || "bukkit".equals(pluginName) || + "spigot".equalsIgnoreCase(pluginName) || "paper".equals(pluginName) )) { plugin = server.getPluginManager().getPlugin(pluginName); } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/NamespacedTag.java b/paper-api/src/main/java/com/destroystokyo/paper/NamespacedTag.java index 495b2d5f5..a7b76f32c 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/NamespacedTag.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/NamespacedTag.java @@ -32,10 +32,10 @@ public final class NamespacedTag implements com.destroystokyo.paper.Namespaced { * compatibility measures. */ public static final String BUKKIT = "bukkit"; - // + private static final Pattern VALID_NAMESPACE = Pattern.compile("[a-z0-9._-]+"); private static final Pattern VALID_KEY = Pattern.compile("[a-z0-9/._-]+"); - // + private final String namespace; private final String key; diff --git a/paper-api/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java b/paper-api/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java index fb626065c..7f9272bcc 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/entity/ai/GoalKey.java @@ -1,6 +1,6 @@ package com.destroystokyo.paper.entity.ai; -import com.google.common.base.Objects; +import java.util.Objects; import java.util.StringJoiner; import org.bukkit.NamespacedKey; import org.bukkit.entity.Mob; @@ -36,13 +36,13 @@ public final class GoalKey { if (this == o) return true; if (o == null || this.getClass() != o.getClass()) return false; GoalKey goalKey = (GoalKey) o; - return Objects.equal(this.entityClass, goalKey.entityClass) && - Objects.equal(this.namespacedKey, goalKey.namespacedKey); + return Objects.equals(this.entityClass, goalKey.entityClass) && + Objects.equals(this.namespacedKey, goalKey.namespacedKey); } @Override public int hashCode() { - return Objects.hashCode(this.entityClass, this.namespacedKey); + return Objects.hash(this.entityClass, this.namespacedKey); } @Override diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java index 741d0e73b..9e9f90283 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/block/BeaconEffectEvent.java @@ -24,8 +24,8 @@ public class BeaconEffectEvent extends BlockEvent implements Cancellable { private boolean cancelled; @ApiStatus.Internal - public BeaconEffectEvent(final Block block, final PotionEffect effect, final Player player, final boolean primary) { - super(block); + public BeaconEffectEvent(final Block beacon, final PotionEffect effect, final Player player, final boolean primary) { + super(beacon); this.effect = effect; this.player = player; this.primary = primary; diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java index 78084f4c9..d375bebfd 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/block/BlockDestroyEvent.java @@ -11,7 +11,7 @@ import org.jspecify.annotations.NullMarked; /** * Fired anytime the server intends to 'destroy' a block through some triggering reason. * This does not fire anytime a block is set to air, but only with more direct triggers such - * as physics updates, pistons, Entities changing blocks, commands set to "Destroy". + * as physics updates, pistons, entities changing blocks, commands set to "Destroy". *

* This event is associated with the game playing a sound effect at the block in question, when * something can be described as "intend to destroy what is there", @@ -39,7 +39,7 @@ public class BlockDestroyEvent extends BlockExpEvent implements Cancellable { } /** - * Get the effect that will be played when the block is broken. + * Gets the effect that will be played when the block is broken. * * @return block break effect */ diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java index b17bdd323..86fca3906 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/block/TNTPrimeEvent.java @@ -33,8 +33,8 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable { private boolean cancelled; @ApiStatus.Internal - public TNTPrimeEvent(@NotNull Block theBlock, @NotNull PrimeReason reason, @Nullable Entity primerEntity) { - super(theBlock); + public TNTPrimeEvent(@NotNull Block block, @NotNull PrimeReason reason, @Nullable Entity primerEntity) { + super(block); this.reason = reason; this.primerEntity = primerEntity; } diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java index aea04fb35..c1b298825 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerHandshakeEvent.java @@ -50,32 +50,6 @@ public class PlayerHandshakeEvent extends Event implements Cancellable { this.cancelled = cancelled; } - /** - * Determines if this event is cancelled. - *

- * When this event is cancelled, custom handshake logic will not - * be processed. - * - * @return {@code true} if this event is cancelled, {@code false} otherwise - */ - @Override - public boolean isCancelled() { - return this.cancelled; - } - - /** - * Sets if this event is cancelled. - *

- * When this event is cancelled, custom handshake logic will not - * be processed. - * - * @param cancel {@code true} if this event is cancelled, {@code false} otherwise - */ - @Override - public void setCancelled(final boolean cancel) { - this.cancelled = cancel; - } - /** * Gets the original handshake string. * @@ -246,6 +220,32 @@ public class PlayerHandshakeEvent extends Event implements Cancellable { this.failMessage(LegacyComponentSerializer.legacySection().deserialize(failMessage)); } + /** + * Determines if this event is cancelled. + *

+ * When this event is cancelled, custom handshake logic will not + * be processed. + * + * @return {@code true} if this event is cancelled, {@code false} otherwise + */ + @Override + public boolean isCancelled() { + return this.cancelled; + } + + /** + * Sets if this event is cancelled. + *

+ * When this event is cancelled, custom handshake logic will not + * be processed. + * + * @param cancel {@code true} if this event is cancelled, {@code false} otherwise + */ + @Override + public void setCancelled(final boolean cancel) { + this.cancelled = cancel; + } + @Override public HandlerList getHandlers() { return HANDLER_LIST; diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java index e3d4c3f91..620aeb4d5 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerJumpEvent.java @@ -37,7 +37,7 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable { /** * {@inheritDoc} *

- * If a jump event is cancelled, the player will be moved or + * If this event is cancelled, the player will be moved or * teleported back to the Location as defined by {@link #getFrom()}. This will not * fire an event * @@ -51,7 +51,7 @@ public class PlayerJumpEvent extends PlayerEvent implements Cancellable { /** * {@inheritDoc} *

- * If a jump event is cancelled, the player will be moved or + * If this event is cancelled, the player will be moved or * teleported back to the Location as defined by {@link #getFrom()}. This will not * fire an event * diff --git a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java index 1688c2c4e..85276dfc9 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/event/player/PlayerSetSpawnEvent.java @@ -109,7 +109,7 @@ public class PlayerSetSpawnEvent extends PlayerEvent implements Cancellable { /** * Gets the notification message that will be sent to the player - * if {@link #willNotifyPlayer()} returns true. + * if {@link #willNotifyPlayer()} returns {@code true}. * * @return {@code null} if no notification */ diff --git a/paper-api/src/main/java/com/destroystokyo/paper/network/NetworkClient.java b/paper-api/src/main/java/com/destroystokyo/paper/network/NetworkClient.java index c84ce3fc8..207929a23 100644 --- a/paper-api/src/main/java/com/destroystokyo/paper/network/NetworkClient.java +++ b/paper-api/src/main/java/com/destroystokyo/paper/network/NetworkClient.java @@ -21,7 +21,7 @@ public interface NetworkClient { * Returns the protocol version of the client. * * @return The client's protocol version, or {@code -1} if unknown - * @see List of protocol + * @see List of protocol * version numbers */ int getProtocolVersion(); diff --git a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java index 511da534a..861c42cbf 100644 --- a/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/InternalAPIBridge.java @@ -1,6 +1,7 @@ package io.papermc.paper; import net.kyori.adventure.util.Services; +import org.bukkit.block.Biome; import org.bukkit.damage.DamageEffect; import org.jetbrains.annotations.ApiStatus; import org.jspecify.annotations.NullMarked; @@ -35,5 +36,14 @@ public interface InternalAPIBridge { * @return the damage effect. */ DamageEffect getDamageEffect(String key); + + /** + * Constructs the legacy custom biome instance for the biome enum. + * + * @return the created biome. + */ + @Deprecated(forRemoval = true, since = "1.21.5") + @ApiStatus.ScheduledForRemoval(inVersion = "1.22") + Biome constructLegacyCustomBiome(); } diff --git a/paper-api/src/main/java/io/papermc/paper/block/LockableTileState.java b/paper-api/src/main/java/io/papermc/paper/block/LockableTileState.java index f309961e0..720cee3f1 100644 --- a/paper-api/src/main/java/io/papermc/paper/block/LockableTileState.java +++ b/paper-api/src/main/java/io/papermc/paper/block/LockableTileState.java @@ -5,7 +5,7 @@ import org.bukkit.block.Lockable; import org.bukkit.block.TileState; /** - * Interface for tile entities that are lockable. + * Interface for block entities that are lockable. */ public interface LockableTileState extends TileState, Lockable, Nameable { } diff --git a/paper-api/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java b/paper-api/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java index 9df877082..404598a17 100644 --- a/paper-api/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java +++ b/paper-api/src/main/java/io/papermc/paper/brigadier/PaperBrigadier.java @@ -9,6 +9,7 @@ import org.checkerframework.checker.nullness.qual.NonNull; /** * Helper methods to bridge the gaps between Brigadier and Paper-MojangAPI. + * * @deprecated for removal. See {@link MessageComponentSerializer} for a direct replacement of functionality found in * this class. * As a general entrypoint to brigadier on paper, see {@link io.papermc.paper.command.brigadier.Commands}. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentHolder.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentHolder.java new file mode 100644 index 000000000..8bef6143e --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentHolder.java @@ -0,0 +1,48 @@ +package io.papermc.paper.datacomponent; + +import org.bukkit.Utility; +import org.bukkit.persistence.PersistentDataContainer; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; + +/** + * This represents an object capable of holding and mutating data components. + * + * @see PersistentDataContainer + */ +@NullMarked +@ApiStatus.NonExtendable +public interface DataComponentHolder extends DataComponentView { + + /** + * Sets the value of the data component type for this holder. + * + * @param type the data component type + * @param valueBuilder value builder + * @param value type + */ + @Utility + @org.jetbrains.annotations.ApiStatus.Experimental + public void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued type, final @NotNull io.papermc.paper.datacomponent.DataComponentBuilder valueBuilder); + + /** + * Sets the value of the data component type for this holder. + * + * @param type the data component type + * @param value value to set + * @param value type + */ + @org.jetbrains.annotations.ApiStatus.Experimental + public void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull Valued type, final @NotNull T value); + + /** + * Marks this non-valued data component type as present in this itemstack. + * + * @param type the data component type + */ + @org.jetbrains.annotations.ApiStatus.Experimental + public void setData(final io.papermc.paper.datacomponent.DataComponentType.@NotNull NonValued type); + + // TODO: Do we even want to have the concept of overriding here? Not sure what is going on with entity components +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java index aa7127163..5d0717198 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentTypes.java @@ -2,6 +2,7 @@ package io.papermc.paper.datacomponent; import io.papermc.paper.datacomponent.item.BannerPatternLayers; import io.papermc.paper.datacomponent.item.BlockItemDataProperties; +import io.papermc.paper.datacomponent.item.BlocksAttacks; import io.papermc.paper.datacomponent.item.BundleContents; import io.papermc.paper.datacomponent.item.ChargedProjectiles; import io.papermc.paper.datacomponent.item.Consumable; @@ -32,21 +33,42 @@ import io.papermc.paper.datacomponent.item.ResolvableProfile; import io.papermc.paper.datacomponent.item.SeededContainerLoot; import io.papermc.paper.datacomponent.item.SuspiciousStewEffects; import io.papermc.paper.datacomponent.item.Tool; -import io.papermc.paper.datacomponent.item.Unbreakable; +import io.papermc.paper.datacomponent.item.TooltipDisplay; import io.papermc.paper.datacomponent.item.UseCooldown; import io.papermc.paper.datacomponent.item.UseRemainder; +import io.papermc.paper.datacomponent.item.Weapon; import io.papermc.paper.datacomponent.item.WritableBookContent; import io.papermc.paper.datacomponent.item.WrittenBookContent; import io.papermc.paper.item.MapPostProcessing; import java.util.List; +import io.papermc.paper.registry.tag.TagKey; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.Component; +import org.bukkit.Art; import org.bukkit.DyeColor; import org.bukkit.FireworkEffect; import org.bukkit.MusicInstrument; import org.bukkit.NamespacedKey; import org.bukkit.Registry; +import org.bukkit.block.banner.PatternType; +import org.bukkit.entity.Axolotl; +import org.bukkit.entity.Cat; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.Fox; +import org.bukkit.entity.Frog; +import org.bukkit.entity.Horse; +import org.bukkit.entity.Llama; +import org.bukkit.entity.MushroomCow; +import org.bukkit.entity.Parrot; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Rabbit; +import org.bukkit.entity.Salmon; +import org.bukkit.entity.TropicalFish; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; import org.bukkit.inventory.ItemRarity; +import org.bukkit.inventory.meta.trim.TrimMaterial; import org.checkerframework.checker.index.qual.NonNegative; import org.checkerframework.checker.index.qual.Positive; import org.checkerframework.common.value.qual.IntRange; @@ -88,7 +110,7 @@ public final class DataComponentTypes { /** * If set, the item will not lose any durability when used. */ - public static final DataComponentType.Valued UNBREAKABLE = valued("unbreakable"); + public static final DataComponentType.NonValued UNBREAKABLE = unvalued("unbreakable"); /** * Custom name override for an item (as set by renaming with an Anvil). * @@ -144,15 +166,7 @@ public final class DataComponentTypes { * Controls the minecraft:custom_model_data property in the item model. */ public static final DataComponentType.Valued CUSTOM_MODEL_DATA = valued("custom_model_data"); - /** - * If set, disables 'additional' tooltip part which comes from the item type - * (e.g. content of a shulker). - */ - public static final DataComponentType.NonValued HIDE_ADDITIONAL_TOOLTIP = unvalued("hide_additional_tooltip"); - /** - * If set, it will completely hide whole item tooltip (that includes item name). - */ - public static final DataComponentType.NonValued HIDE_TOOLTIP = unvalued("hide_tooltip"); + public static final DataComponentType.Valued TOOLTIP_DISPLAY = valued("tooltip_display"); /** * The additional experience cost required to modify an item in an Anvil. * If not present, has an implicit default value of: {@code 0}. @@ -188,12 +202,14 @@ public final class DataComponentTypes { * Controls the behavior of the item as a tool. */ public static final DataComponentType.Valued TOOL = valued("tool"); + public static final DataComponentType.Valued WEAPON = valued("weapon"); public static final DataComponentType.Valued ENCHANTABLE = valued("enchantable"); public static final DataComponentType.Valued EQUIPPABLE = valued("equippable"); public static final DataComponentType.Valued REPAIRABLE = valued("repairable"); public static final DataComponentType.NonValued GLIDER = unvalued("glider"); public static final DataComponentType.Valued TOOLTIP_STYLE = valued("tooltip_style"); public static final DataComponentType.Valued DEATH_PROTECTION = valued("death_protection"); + public static final DataComponentType.Valued BLOCKS_ATTACKS = valued("blocks_attacks"); /** * Stores list of enchantments and their levels for an Enchanted Book. * Unlike {@link #ENCHANTMENTS}, the effects provided by enchantments @@ -243,6 +259,7 @@ public final class DataComponentTypes { * or potion applied to a Tipped Arrow. */ public static final DataComponentType.Valued POTION_CONTENTS = valued("potion_contents"); + public static final DataComponentType.Valued POTION_DURATION_SCALE = valued("potion_duration_scale"); /** * Holds the effects that will be applied when consuming Suspicious Stew. */ @@ -267,11 +284,14 @@ public final class DataComponentTypes { * Holds the instrument type used by a Goat Horn. */ public static final DataComponentType.Valued INSTRUMENT = valued("instrument"); + // this is a either holder, but due to legacy item loading + public static final DataComponentType.Valued PROVIDES_TRIM_MATERIAL = valued("provides_trim_material"); /** * Controls the amplifier amount for an Ominous Bottle's Bad Omen effect. */ public static final DataComponentType.Valued OMINOUS_BOTTLE_AMPLIFIER = valued("ominous_bottle_amplifier"); public static final DataComponentType.Valued JUKEBOX_PLAYABLE = valued("jukebox_playable"); + public static final DataComponentType.Valued> PROVIDES_BANNER_PATTERNS = valued("provides_banner_patterns"); /** * List of recipes that should be unlocked when using the Knowledge Book item. */ @@ -329,14 +349,50 @@ public final class DataComponentTypes { * Holds the unresolved loot table and seed of a container-like block. */ public static final DataComponentType.Valued CONTAINER_LOOT = valued("container_loot"); + public static final DataComponentType.Valued BREAK_SOUND = valued("break_sound"); + public static final DataComponentType.Valued VILLAGER_VARIANT = valued("villager/variant"); + public static final DataComponentType.Valued WOLF_VARIANT = valued("wolf/variant"); + public static final DataComponentType.Valued WOLF_SOUND_VARIANT = valued("wolf/sound_variant"); + public static final DataComponentType.Valued WOLF_COLLAR = valued("wolf/collar"); + public static final DataComponentType.Valued FOX_VARIANT = valued("fox/variant"); + public static final DataComponentType.Valued SALMON_SIZE = valued("salmon/size"); + public static final DataComponentType.Valued PARROT_VARIANT = valued("parrot/variant"); + public static final DataComponentType.Valued TROPICAL_FISH_PATTERN = valued("tropical_fish/pattern"); + public static final DataComponentType.Valued TROPICAL_FISH_BASE_COLOR = valued("tropical_fish/base_color"); + public static final DataComponentType.Valued TROPICAL_FISH_PATTERN_COLOR = valued("tropical_fish/pattern_color"); + public static final DataComponentType.Valued MOOSHROOM_VARIANT = valued("mooshroom/variant"); + public static final DataComponentType.Valued RABBIT_VARIANT = valued("rabbit/variant"); + public static final DataComponentType.Valued PIG_VARIANT = valued("pig/variant"); + public static final DataComponentType.Valued COW_VARIANT = valued("cow/variant"); + // TODO: This is a eitherholder? Why specifically the chicken?? Oh wait this is prolly for chicken egg cause legacy item loading + public static final DataComponentType.Valued CHICKEN_VARIANT = valued("chicken/variant"); + public static final DataComponentType.Valued FROG_VARIANT = valued("frog/variant"); + public static final DataComponentType.Valued HORSE_VARIANT = valued("horse/variant"); + public static final DataComponentType.Valued PAINTING_VARIANT = valued("painting/variant"); + public static final DataComponentType.Valued LLAMA_VARIANT = valued("llama/variant"); + public static final DataComponentType.Valued AXOLOTL_VARIANT = valued("axolotl/variant"); + public static final DataComponentType.Valued CAT_VARIANT = valued("cat/variant"); + public static final DataComponentType.Valued CAT_COLLAR = valued("cat/collar"); + public static final DataComponentType.Valued SHEEP_COLOR = valued("sheep/color"); + public static final DataComponentType.Valued SHULKER_COLOR = valued("shulker/color"); + private static DataComponentType.NonValued unvalued(final String name) { - return (DataComponentType.NonValued) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug."); + final DataComponentType dataComponentType = requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " unvalued data component type couldn't be found, this is a bug."); + if (dataComponentType instanceof DataComponentType.NonValued) { + return (DataComponentType.NonValued) dataComponentType; + } + throw new IllegalStateException(name + " is not a valid unvalued type, it is a " + dataComponentType.getClass().getTypeName()); } @SuppressWarnings("unchecked") private static DataComponentType.Valued valued(final String name) { - return (DataComponentType.Valued) requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " valued data component type couldn't be found, this is a bug."); + DataComponentType dataComponentType = requireNonNull(Registry.DATA_COMPONENT_TYPE.get(NamespacedKey.minecraft(name)), name + " valued data component type couldn't be found, this is a bug."); + if (dataComponentType instanceof DataComponentType.Valued) { + return (DataComponentType.Valued) dataComponentType; + } + throw new IllegalStateException(name + " is not a valid valued type, it is a " + dataComponentType.getClass().getTypeName()); + } private DataComponentTypes() { diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentView.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentView.java new file mode 100644 index 000000000..f06829efc --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/DataComponentView.java @@ -0,0 +1,65 @@ +package io.papermc.paper.datacomponent; + +import org.bukkit.Utility; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; + +/** + * This represents a view of a data component holder. No + * methods on this interface mutate the holder. + * + * @see DataComponentHolder + */ +@NullMarked +@ApiStatus.NonExtendable +public interface DataComponentView { + // Paper start - data component API + /** + * Gets the value for the data component type on this stack. + * + * @param type the data component type + * @param the value type + * @return the value for the data component type, or {@code null} if not set or marked as removed + * @see #hasData(io.papermc.paper.datacomponent.DataComponentType) for DataComponentType.NonValued + */ + @Contract(pure = true) + @ApiStatus.Experimental + public @Nullable T getData(final DataComponentType.@NotNull Valued type); + + /** + * Gets the value for the data component type on this holder with + * a fallback value. + * + * @param type the data component type + * @param fallback the fallback value if the value isn't present + * @param the value type + * @return the value for the data component type or the fallback value + */ + @Utility + @Contract(value = "_, !null -> !null", pure = true) + @ApiStatus.Experimental + public @Nullable T getDataOrDefault(final DataComponentType.@NotNull Valued type, final @Nullable T fallback); + + /** + * Checks if the data component type is set on this holder. + * + * @param type the data component type + * @return {@code true} if set, {@code false} otherwise + */ + @Contract(pure = true) + @ApiStatus.Experimental + boolean hasData(final io.papermc.paper.datacomponent.@NotNull DataComponentType type); + + // Not applicable to entities + // /** + // * Gets all the data component types set on this holder. + // * + // * @return an immutable set of data component types + // */ + // @Contract("-> new") + // @ApiStatus.Experimental + // java.util.@Unmodifiable Set getDataTypes(); +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java new file mode 100644 index 000000000..bf53d0e0b --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/BlocksAttacks.java @@ -0,0 +1,68 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import io.papermc.paper.registry.tag.TagKey; +import net.kyori.adventure.key.Key; +import org.bukkit.damage.DamageType; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +// TODO +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface BlocksAttacks { + + @Contract(value = "-> new", pure = true) + static Builder blocksAttacks() { + return ItemComponentTypesBridge.bridge().blocksAttacks(); + } + + float blockDelaySeconds(); + + float disableCooldownScale(); + + //List damageReductions(); + + //ItemDamageFunction itemDamage(); + + @Nullable TagKey bypassedBy(); + + @Nullable Key blockSound(); + + @Nullable Key disableSound(); + + /** + * Builder for {@link BlocksAttacks}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder blockDelaySeconds(float delay); + + @Contract(value = "_ -> this", mutates = "this") + Builder disableCooldownScale(float scale); + + //@Contract(value = "_ -> this", mutates = "this") + //Builder addDamageReduction(DamageReduction reduction); + + //@Contract(value = "_ -> this", mutates = "this") + //Builder damageReductions(List reductions); + + //@Contract(value = "_ -> this", mutates = "this") + //Builder itemDamage(ItemDamageFunction function); + + @Contract(value = "_ -> this", mutates = "this") + Builder bypassedBy(@Nullable TagKey bypassedBy); + + @Contract(value = "_ -> this", mutates = "this") + Builder blockSound(@Nullable Key sound); + + @Contract(value = "_ -> this", mutates = "this") + Builder disableSound(@Nullable Key sound); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java index d80581fc8..73f4c73da 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/DyedItemColor.java @@ -13,11 +13,11 @@ import org.jspecify.annotations.NullMarked; @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface DyedItemColor extends ShownInTooltip { +public interface DyedItemColor { @Contract(value = "_, _ -> new", pure = true) - static DyedItemColor dyedItemColor(final Color color, final boolean showInTooltip) { - return dyedItemColor().color(color).showInTooltip(showInTooltip).build(); + static DyedItemColor dyedItemColor(final Color color) { + return dyedItemColor().color(color).build(); } @Contract(value = "-> new", pure = true) @@ -38,7 +38,7 @@ public interface DyedItemColor extends ShownInTooltip { */ @ApiStatus.Experimental @ApiStatus.NonExtendable - interface Builder extends ShownInTooltip.Builder, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Sets the color of this builder. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java index d21a1cd40..673d33f52 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Equippable.java @@ -96,6 +96,14 @@ public interface Equippable extends BuildableDataComponent { +public interface ItemAdventurePredicate { @Contract(value = "_ -> new", pure = true) static ItemAdventurePredicate itemAdventurePredicate(final List predicates) { @@ -41,7 +42,7 @@ public interface ItemAdventurePredicate extends ShownInTooltip, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Adds a block predicate to this builder. * diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java index 0309ae59a..bae6ad862 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemArmorTrim.java @@ -13,12 +13,7 @@ import org.jspecify.annotations.NullMarked; @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface ItemArmorTrim extends ShownInTooltip { - - @Contract(value = "_, _ -> new", pure = true) - static ItemArmorTrim itemArmorTrim(final ArmorTrim armorTrim, final boolean showInTooltip) { - return itemArmorTrim(armorTrim).showInTooltip(showInTooltip).build(); - } +public interface ItemArmorTrim { @Contract(value = "_ -> new", pure = true) static ItemArmorTrim.Builder itemArmorTrim(final ArmorTrim armorTrim) { @@ -38,7 +33,7 @@ public interface ItemArmorTrim extends ShownInTooltip { */ @ApiStatus.Experimental @ApiStatus.NonExtendable - interface Builder extends ShownInTooltip.Builder, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Sets the armor trim for this builder. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java index 56a3e678c..0c7b58529 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemAttributeModifiers.java @@ -17,7 +17,7 @@ import org.jspecify.annotations.NullMarked; @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface ItemAttributeModifiers extends ShownInTooltip { +public interface ItemAttributeModifiers { @Contract(value = "-> new", pure = true) static ItemAttributeModifiers.Builder itemAttributes() { @@ -69,7 +69,7 @@ public interface ItemAttributeModifiers extends ShownInTooltip, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Adds a modifier to this builder. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java index 12df050d3..071662780 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemComponentTypesBridge.java @@ -34,8 +34,6 @@ interface ItemComponentTypesBridge { PotDecorations.Builder potDecorations(); - Unbreakable.Builder unbreakable(); - ItemLore.Builder lore(); ItemEnchantments.Builder enchantments(); @@ -109,4 +107,10 @@ interface ItemComponentTypesBridge { DeathProtection.Builder deathProtection(); OminousBottleAmplifier ominousBottleAmplifier(int amplifier); + + BlocksAttacks.Builder blocksAttacks(); + + TooltipDisplay.Builder tooltipDisplay(); + + Weapon.Builder weapon(); } diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java index fca271ea1..a36266df0 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ItemEnchantments.java @@ -17,11 +17,11 @@ import org.jspecify.annotations.NullMarked; @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface ItemEnchantments extends ShownInTooltip { +public interface ItemEnchantments { @Contract(value = "_, _ -> new", pure = true) - static ItemEnchantments itemEnchantments(final Map enchantments, final boolean showInTooltip) { - return itemEnchantments().addAll(enchantments).showInTooltip(showInTooltip).build(); + static ItemEnchantments itemEnchantments(final Map enchantments) { + return itemEnchantments().addAll(enchantments).build(); } @Contract(value = "-> new", pure = true) @@ -42,7 +42,7 @@ public interface ItemEnchantments extends ShownInTooltip { */ @ApiStatus.Experimental @ApiStatus.NonExtendable - interface Builder extends ShownInTooltip.Builder, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Adds an enchantment with the given level to this component. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java index c59942df7..d9c5f3fe0 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/JukeboxPlayable.java @@ -13,7 +13,7 @@ import org.jspecify.annotations.NullMarked; @NullMarked @ApiStatus.Experimental @ApiStatus.NonExtendable -public interface JukeboxPlayable extends ShownInTooltip { +public interface JukeboxPlayable { @Contract(value = "_ -> new", pure = true) static JukeboxPlayable.Builder jukeboxPlayable(final JukeboxSong song) { @@ -28,7 +28,7 @@ public interface JukeboxPlayable extends ShownInTooltip { */ @ApiStatus.Experimental @ApiStatus.NonExtendable - interface Builder extends ShownInTooltip.Builder, DataComponentBuilder { + interface Builder extends DataComponentBuilder { /** * Sets the jukebox song. diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java deleted file mode 100644 index 130722121..000000000 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/ShownInTooltip.java +++ /dev/null @@ -1,55 +0,0 @@ -package io.papermc.paper.datacomponent.item; - -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Contract; -import org.jspecify.annotations.NullMarked; - -/** - * Holds the state of whether a data component should be shown - * in an item's tooltip. - * - * @param the data component type - */ -@NullMarked -@ApiStatus.Experimental -@ApiStatus.NonExtendable -public interface ShownInTooltip { - - /** - * Gets if the data component should be shown in the item's tooltip. - * - * @return {@code true} to show in the tooltip - */ - @Contract(pure = true) - boolean showInTooltip(); - - /** - * Returns a copy of this data component with the specified - * show-in-tooltip state. - * - * @param showInTooltip {@code true} to show in the tooltip - * @return the new data component - */ - @Contract(value = "_ -> new", pure = true) - T showInTooltip(boolean showInTooltip); - - /** - * A builder for creating a {@link ShownInTooltip} data component. - * - * @param builder type - */ - @ApiStatus.Experimental - @ApiStatus.NonExtendable - interface Builder { - - /** - * Sets if the data component should be shown in the item's tooltip. - * - * @param showInTooltip {@code true} to show in the tooltip - * @return the builder for chaining - * @see #showInTooltip() - */ - @Contract(value = "_ -> this", mutates = "this") - B showInTooltip(boolean showInTooltip); - } -} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Tool.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Tool.java index 4e87feb83..fd606beac 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Tool.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Tool.java @@ -71,6 +71,14 @@ public interface Tool { @Contract(pure = true) @Unmodifiable List rules(); + /** + * Whether this tool can destroy blocks in creative mode. + * + * @return whether this tool can destroy blocks in creative mode + */ + @Contract(pure = true) + boolean canDestroyBlocksInCreative(); + @ApiStatus.Experimental @ApiStatus.NonExtendable interface Rule { @@ -136,6 +144,16 @@ public interface Tool { @Contract(value = "_ -> this", mutates = "this") Builder addRule(Rule rule); + /** + * Controls whether this tool can destroy blocks in creative mode. + * + * @param canDestroyBlocksInCreative whether this tool can destroy blocks in creative mode + * @return the builder for chaining + * @see #canDestroyBlocksInCreative() + */ + @Contract(value = "_ -> this", mutates = "this") + Builder canDestroyBlocksInCreative(boolean canDestroyBlocksInCreative); + /** * Adds rules to the tool that control the breaking speed / damage per block if matched. * diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java new file mode 100644 index 000000000..85aaae68a --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/TooltipDisplay.java @@ -0,0 +1,46 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import io.papermc.paper.datacomponent.DataComponentType; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; + +import java.util.Set; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface TooltipDisplay { + + /** + * Returns a new builder for creating a TooltipDisplay. + * + * @return a builder + */ + @Contract(value = "-> new", pure = true) + static Builder tooltipDisplay() { + return ItemComponentTypesBridge.bridge().tooltipDisplay(); + } + + boolean hideTooltip(); + + Set hiddenComponents(); + + /** + * Builder for {@link TooltipDisplay}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + @Contract(value = "_ -> this", mutates = "this") + Builder hideTooltip(boolean hide); + + @Contract(value = "_ -> this", mutates = "this") + Builder addHiddenComponents(DataComponentType... components); + + @Contract(value = "_ -> this", mutates = "this") + Builder hiddenComponents(Set components); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java deleted file mode 100644 index 498eb479d..000000000 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Unbreakable.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.papermc.paper.datacomponent.item; - -import io.papermc.paper.datacomponent.DataComponentBuilder; -import org.jetbrains.annotations.ApiStatus; -import org.jetbrains.annotations.Contract; -import org.jspecify.annotations.NullMarked; - -/** - * If set, the item will not lose any durability when used. - * @see io.papermc.paper.datacomponent.DataComponentTypes#UNBREAKABLE - */ -@NullMarked -@ApiStatus.Experimental -@ApiStatus.NonExtendable -public interface Unbreakable extends ShownInTooltip { - - @Contract(value = "_ -> new", pure = true) - static Unbreakable unbreakable(final boolean showInTooltip) { - return unbreakable().showInTooltip(showInTooltip).build(); - } - - @Contract(value = "-> new", pure = true) - static Unbreakable.Builder unbreakable() { - return ItemComponentTypesBridge.bridge().unbreakable(); - } - - /** - * Builder for {@link Unbreakable}. - */ - @ApiStatus.Experimental - @ApiStatus.NonExtendable - interface Builder extends ShownInTooltip.Builder, DataComponentBuilder { - } -} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Weapon.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Weapon.java new file mode 100644 index 000000000..856120108 --- /dev/null +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/Weapon.java @@ -0,0 +1,54 @@ +package io.papermc.paper.datacomponent.item; + +import io.papermc.paper.datacomponent.DataComponentBuilder; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +@NullMarked +@ApiStatus.Experimental +@ApiStatus.NonExtendable +public interface Weapon { + + /** + * Returns a new builder for creating a Weapon. + * + * @return a builder instance. + */ + static Builder weapon() { + return ItemComponentTypesBridge.bridge().weapon(); + } + + /** + * The damage that the weapon deals per attack. + */ + int itemDamagePerAttack(); + + /** + * The number of seconds that blocking is disabled. + */ + float disableBlockingForSeconds(); + + /** + * Builder for {@link Weapon}. + */ + @ApiStatus.Experimental + @ApiStatus.NonExtendable + interface Builder extends DataComponentBuilder { + + /** + * Sets the damage per attack. + * + * @param damage the damage value. + * @return the builder for chaining. + */ + Builder itemDamagePerAttack(int damage); + + /** + * Sets the disable blocking duration (in seconds). + * + * @param seconds the duration in seconds. + * @return the builder for chaining. + */ + Builder disableBlockingForSeconds(float seconds); + } +} diff --git a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java index f8ffefc1e..a454338a6 100644 --- a/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java +++ b/paper-api/src/main/java/io/papermc/paper/datacomponent/item/consumable/ItemUseAnimation.java @@ -4,6 +4,8 @@ package io.papermc.paper.datacomponent.item.consumable; * Represents the hand animation that is used when a player is consuming this item. */ public enum ItemUseAnimation { + // Start generate - ItemUseAnimation + // @GeneratedFrom 1.21.5 NONE, EAT, DRINK, @@ -14,5 +16,6 @@ public enum ItemUseAnimation { SPYGLASS, TOOT_HORN, BRUSH, - BUNDLE + BUNDLE; + // End generate - ItemUseAnimation } diff --git a/paper-api/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java b/paper-api/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java index 380538656..fa7f9bae2 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/block/BeaconActivatedEvent.java @@ -17,8 +17,8 @@ public class BeaconActivatedEvent extends BlockEvent { private static final HandlerList HANDLER_LIST = new HandlerList(); @ApiStatus.Internal - public BeaconActivatedEvent(final Block block) { - super(block); + public BeaconActivatedEvent(final Block beacon) { + super(beacon); } /** diff --git a/paper-api/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java b/paper-api/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java index 4e5b2b241..e13555eac 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/block/BeaconDeactivatedEvent.java @@ -18,8 +18,8 @@ public class BeaconDeactivatedEvent extends BlockEvent { private static final HandlerList HANDLER_LIST = new HandlerList(); @ApiStatus.Internal - public BeaconDeactivatedEvent(final Block block) { - super(block); + public BeaconDeactivatedEvent(final Block beacon) { + super(beacon); } /** diff --git a/paper-api/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java b/paper-api/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java index 4781529aa..4c3e895a7 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/block/BellRevealRaiderEvent.java @@ -22,8 +22,8 @@ public class BellRevealRaiderEvent extends BlockEvent implements Cancellable { private boolean cancelled; @ApiStatus.Internal - public BellRevealRaiderEvent(@NotNull Block theBlock, @NotNull Raider raider) { - super(theBlock); + public BellRevealRaiderEvent(@NotNull Block bell, @NotNull Raider raider) { + super(bell); this.raider = raider; } diff --git a/paper-api/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java b/paper-api/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java index 483139950..885451136 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/block/BlockFailedDispenseEvent.java @@ -17,8 +17,8 @@ public class BlockFailedDispenseEvent extends BlockEvent { private boolean shouldPlayEffect = true; @ApiStatus.Internal - public BlockFailedDispenseEvent(final Block theBlock) { - super(theBlock); + public BlockFailedDispenseEvent(final Block block) { + super(block); } /** diff --git a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java index a96c28678..0107f62e4 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/entity/EntityFertilizeEggEvent.java @@ -31,7 +31,6 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable private static final HandlerList HANDLER_LIST = new HandlerList(); - private final LivingEntity mother; private final LivingEntity father; private final @Nullable Player breeder; private final @Nullable ItemStack bredWith; @@ -42,7 +41,6 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable @ApiStatus.Internal public EntityFertilizeEggEvent(final LivingEntity mother, final LivingEntity father, final @Nullable Player breeder, final @Nullable ItemStack bredWith, final int experience) { super(mother); - this.mother = mother; this.father = father; this.breeder = breeder; this.bredWith = bredWith; @@ -61,7 +59,7 @@ public class EntityFertilizeEggEvent extends EntityEvent implements Cancellable * @return The "mother" entity. */ public LivingEntity getMother() { - return this.mother; + return this.getEntity(); } /** diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java index 9a95d2031..f2339d5a1 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/AbstractChatEvent.java @@ -39,9 +39,9 @@ public abstract class AbstractChatEvent extends PlayerEvent implements Cancellab /** * Gets a set of {@link Audience audiences} that this chat message will be displayed to. - * - *

The set returned may auto-populate on access. Any listener accessing the returned set should be aware that - * it may reduce performance for a lazy set implementation.

+ *

+ * The set returned may auto-populate on access. Any listener accessing the returned set should be aware that + * it may reduce performance for a lazy set implementation. * * @return a mutable set of {@link Audience audiences} who will receive the chat message */ diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java index 9e5ea0cd0..effea35d1 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/AsyncChatDecorateEvent.java @@ -42,7 +42,7 @@ public class AsyncChatDecorateEvent extends ServerEvent implements Cancellable { * Gets the player (if available) associated with this event. *

* Certain commands request decorations without a player context - * which is why this is possibly null. + * which is why this is possibly {@code null}. * * @return the player or {@code null} */ diff --git a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerClientLoadedWorldEvent.java b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerClientLoadedWorldEvent.java index 1b97997ee..a5dbd39f4 100644 --- a/paper-api/src/main/java/io/papermc/paper/event/player/PlayerClientLoadedWorldEvent.java +++ b/paper-api/src/main/java/io/papermc/paper/event/player/PlayerClientLoadedWorldEvent.java @@ -20,8 +20,8 @@ public class PlayerClientLoadedWorldEvent extends PlayerEvent { private final boolean timeout; @ApiStatus.Internal - public PlayerClientLoadedWorldEvent(final Player who, final boolean timeout) { - super(who); + public PlayerClientLoadedWorldEvent(final Player player, final boolean timeout) { + super(player); this.timeout = timeout; } diff --git a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java index 49e508c4e..4050f7135 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/RegistryKey.java @@ -19,8 +19,11 @@ import org.bukkit.block.banner.PatternType; import org.bukkit.damage.DamageType; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Cat; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; import org.bukkit.entity.EntityType; import org.bukkit.entity.Frog; +import org.bukkit.entity.Pig; import org.bukkit.entity.Villager; import org.bukkit.entity.Wolf; import org.bukkit.entity.memory.MemoryKey; @@ -79,20 +82,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { RegistryKey BLOCK = create("block"); /** * @apiNote use preferably only in the context of registry entries. + * @see io.papermc.paper.registry.data * @see io.papermc.paper.registry.keys.ItemTypeKeys */ @ApiStatus.Experimental // Paper - already required for registry builders RegistryKey ITEM = create("item"); - /** - * Built-in registry for cat variants. - * @see io.papermc.paper.registry.keys.CatVariantKeys - */ - RegistryKey CAT_VARIANT = create("cat_variant"); - /** - * Built-in registry for frog variants. - * @see io.papermc.paper.registry.keys.FrogVariantKeys - */ - RegistryKey FROG_VARIANT = create("frog_variant"); /** * Built-in registry for villager professions. * @see io.papermc.paper.registry.keys.VillagerProfessionKeys @@ -130,7 +124,7 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { RegistryKey SOUND_EVENT = create("sound_event"); /** * Built-in registry for data component types. - * + * @see io.papermc.paper.registry.keys.DataComponentTypeKeys */ RegistryKey DATA_COMPONENT_TYPE = create("data_component_type"); @@ -169,6 +163,11 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.WolfVariantKeys */ RegistryKey WOLF_VARIANT = create("wolf_variant"); + /** + * Data-driven registry for wolf sound variants. + * @see io.papermc.paper.registry.keys.WolfSoundVariantKeys + */ + RegistryKey WOLF_SOUND_VARIANT = create("wolf_sound_variant"); /** * Data-driven registry for enchantments. * @see io.papermc.paper.registry.keys.EnchantmentKeys @@ -194,6 +193,32 @@ public sealed interface RegistryKey extends Keyed permits RegistryKeyImpl { * @see io.papermc.paper.registry.keys.InstrumentKeys */ RegistryKey INSTRUMENT = create("instrument"); + /** + * Data-driven registry for cat variants. + * @see io.papermc.paper.registry.keys.CatVariantKeys + */ + RegistryKey CAT_VARIANT = create("cat_variant"); + /** + * Data-driven registry for frog variants. + * @see io.papermc.paper.registry.keys.FrogVariantKeys + */ + RegistryKey FROG_VARIANT = create("frog_variant"); + /** + * Data-driven registry for chicken variants. + * @see io.papermc.paper.registry.keys.ChickenVariantKeys + */ + RegistryKey CHICKEN_VARIANT = create("chicken_variant"); + /** + * Data-driven registry for cow variants. + * @see io.papermc.paper.registry.keys.CowVariantKeys + */ + RegistryKey COW_VARIANT = create("cow_variant"); + /** + * Data-driven registry for pig variants. + * @see io.papermc.paper.registry.keys.PigVariantKeys + */ + RegistryKey PIG_VARIANT = create("pig_variant"); + /* ******************* * diff --git a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java index d15581579..71b245606 100644 --- a/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java +++ b/paper-api/src/main/java/io/papermc/paper/registry/event/RegistryEvents.java @@ -24,11 +24,14 @@ import static io.papermc.paper.registry.event.RegistryEventProviderImpl.create; @NullMarked public final class RegistryEvents { + // Start generate - RegistryEvents + // @GeneratedFrom 1.21.5 public static final RegistryEventProvider GAME_EVENT = create(RegistryKey.GAME_EVENT); - public static final RegistryEventProvider ENCHANTMENT = create(RegistryKey.ENCHANTMENT); - public static final RegistryEventProvider PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT); - public static final RegistryEventProvider BANNER_PATTERN = create(RegistryKey.BANNER_PATTERN); public static final RegistryEventProvider DAMAGE_TYPE = create(RegistryKey.DAMAGE_TYPE); + public static final RegistryEventProvider ENCHANTMENT = create(RegistryKey.ENCHANTMENT); + public static final RegistryEventProvider BANNER_PATTERN = create(RegistryKey.BANNER_PATTERN); + public static final RegistryEventProvider PAINTING_VARIANT = create(RegistryKey.PAINTING_VARIANT); + // End generate - RegistryEvents private RegistryEvents() { } diff --git a/paper-api/src/main/java/org/bukkit/Art.java b/paper-api/src/main/java/org/bukkit/Art.java index bb8755c26..d6f8e471c 100644 --- a/paper-api/src/main/java/org/bukkit/Art.java +++ b/paper-api/src/main/java/org/bukkit/Art.java @@ -35,57 +35,109 @@ public interface Art extends OldEnum, Keyed { return InlinedRegistryBuilderProvider.instance().createPaintingVariant(value); } - Art KEBAB = getArt("kebab"); - Art AZTEC = getArt("aztec"); + // Start generate - Art + // @GeneratedFrom 1.21.5 Art ALBAN = getArt("alban"); + + Art AZTEC = getArt("aztec"); + Art AZTEC2 = getArt("aztec2"); - Art BOMB = getArt("bomb"); - Art PLANT = getArt("plant"); - Art WASTELAND = getArt("wasteland"); - Art POOL = getArt("pool"); - Art COURBET = getArt("courbet"); - Art SEA = getArt("sea"); - Art SUNSET = getArt("sunset"); - Art CREEBET = getArt("creebet"); - Art WANDERER = getArt("wanderer"); - Art GRAHAM = getArt("graham"); - Art MATCH = getArt("match"); - Art BUST = getArt("bust"); - Art STAGE = getArt("stage"); - Art VOID = getArt("void"); - Art SKULL_AND_ROSES = getArt("skull_and_roses"); - Art WITHER = getArt("wither"); - Art FIGHTERS = getArt("fighters"); - Art POINTER = getArt("pointer"); - Art PIGSCENE = getArt("pigscene"); - Art BURNING_SKULL = getArt("burning_skull"); - Art SKELETON = getArt("skeleton"); - Art DONKEY_KONG = getArt("donkey_kong"); - Art EARTH = getArt("earth"); - Art WIND = getArt("wind"); - Art WATER = getArt("water"); - Art FIRE = getArt("fire"); - Art BAROQUE = getArt("baroque"); - Art HUMBLE = getArt("humble"); - Art MEDITATIVE = getArt("meditative"); - Art PRAIRIE_RIDE = getArt("prairie_ride"); - Art UNPACKED = getArt("unpacked"); + Art BACKYARD = getArt("backyard"); + + Art BAROQUE = getArt("baroque"); + + Art BOMB = getArt("bomb"); + Art BOUQUET = getArt("bouquet"); + + Art BURNING_SKULL = getArt("burning_skull"); + + Art BUST = getArt("bust"); + Art CAVEBIRD = getArt("cavebird"); + Art CHANGING = getArt("changing"); + Art COTAN = getArt("cotan"); + + Art COURBET = getArt("courbet"); + + Art CREEBET = getArt("creebet"); + + Art DONKEY_KONG = getArt("donkey_kong"); + + Art EARTH = getArt("earth"); + Art ENDBOSS = getArt("endboss"); + Art FERN = getArt("fern"); + + Art FIGHTERS = getArt("fighters"); + Art FINDING = getArt("finding"); + + Art FIRE = getArt("fire"); + + Art GRAHAM = getArt("graham"); + + Art HUMBLE = getArt("humble"); + + Art KEBAB = getArt("kebab"); + Art LOWMIST = getArt("lowmist"); + + Art MATCH = getArt("match"); + + Art MEDITATIVE = getArt("meditative"); + Art ORB = getArt("orb"); + Art OWLEMONS = getArt("owlemons"); + Art PASSAGE = getArt("passage"); + + Art PIGSCENE = getArt("pigscene"); + + Art PLANT = getArt("plant"); + + Art POINTER = getArt("pointer"); + Art POND = getArt("pond"); + + Art POOL = getArt("pool"); + + Art PRAIRIE_RIDE = getArt("prairie_ride"); + + Art SEA = getArt("sea"); + + Art SKELETON = getArt("skeleton"); + + Art SKULL_AND_ROSES = getArt("skull_and_roses"); + + Art STAGE = getArt("stage"); + Art SUNFLOWERS = getArt("sunflowers"); + + Art SUNSET = getArt("sunset"); + Art TIDES = getArt("tides"); + Art UNPACKED = getArt("unpacked"); + + Art VOID = getArt("void"); + + Art WANDERER = getArt("wanderer"); + + Art WASTELAND = getArt("wasteland"); + + Art WATER = getArt("water"); + + Art WIND = getArt("wind"); + + Art WITHER = getArt("wither"); + // End generate - Art + @NotNull private static Art getArt(@NotNull String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.PAINTING_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); diff --git a/paper-api/src/main/java/org/bukkit/Bukkit.java b/paper-api/src/main/java/org/bukkit/Bukkit.java index 4eb723afa..ee791bf62 100644 --- a/paper-api/src/main/java/org/bukkit/Bukkit.java +++ b/paper-api/src/main/java/org/bukkit/Bukkit.java @@ -14,6 +14,7 @@ import java.util.Set; import java.util.UUID; import java.util.function.Consumer; import java.util.logging.Logger; +import net.kyori.adventure.text.Component; import org.bukkit.Warning.WarningState; import org.bukkit.advancement.Advancement; import org.bukkit.block.data.BlockData; @@ -189,8 +190,8 @@ public final class Bukkit { * uses. Normal and immediate iterator use without consequences that * affect the collection are fully supported. The effects following * (non-exhaustive) {@link Entity#teleport(Location) teleportation}, - * {@link Player#setHealth(double) death}, and {@link Player#kickPlayer( - * String) kicking} are undefined. Any use of this collection from + * {@link Player#setHealth(double) death}, and {@link Player#kick( + * Component) kicking} are undefined. Any use of this collection from * asynchronous threads is unsafe. *

* For safe consequential iteration or mimicking the old array behavior, @@ -468,7 +469,7 @@ public final class Bukkit { * * @param message the message * @return the number of players - * @deprecated in favour of {@link Server#broadcast(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link Server#broadcast(Component)} */ @Deprecated // Paper public static int broadcastMessage(@NotNull String message) { @@ -480,7 +481,7 @@ public final class Bukkit { * Sends the component to all online players. * * @param component the component to send - * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} + * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link Component} */ @Deprecated public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent component) { @@ -491,7 +492,7 @@ public final class Bukkit { * Sends an array of components as a single message to all online players. * * @param components the components to send - * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link net.kyori.adventure.text.Component} + * @deprecated use {@code sendMessage} methods on {@link #getServer()} that accept {@link Component} */ @Deprecated public static void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { @@ -1463,7 +1464,7 @@ public final class Bukkit { /** * Broadcast a message to all players. *

- * This is the same as calling {@link #broadcast(net.kyori.adventure.text.Component, + * This is the same as calling {@link #broadcast(Component, * java.lang.String)} with the {@link Server#BROADCAST_CHANNEL_USERS} permission. * * @param message the message @@ -1493,7 +1494,7 @@ public final class Bukkit { * @param permission the required permission {@link Permissible * permissibles} must have to receive the broadcast * @return number of message recipients - * @deprecated in favour of {@link #broadcast(net.kyori.adventure.text.Component, String)} + * @deprecated in favour of {@link #broadcast(Component, String)} */ @Deprecated // Paper public static int broadcast(@NotNull String message, @NotNull String permission) { @@ -1740,7 +1741,7 @@ public final class Bukkit { * @return a command sender */ @NotNull - public static CommandSender createCommandSender(final @NotNull java.util.function.Consumer feedback) { + public static CommandSender createCommandSender(final @NotNull java.util.function.Consumer feedback) { return server.createCommandSender(feedback); } // Paper end @@ -1864,7 +1865,7 @@ public final class Bukkit { * @return The new inventory. * @throws IllegalArgumentException if the {@link InventoryType} cannot be * viewed. - * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, Component)} * * @see InventoryType#isCreatable() */ @@ -1916,7 +1917,7 @@ public final class Bukkit { * viewed * @return a new inventory * @throws IllegalArgumentException if the size is not a multiple of 9 - * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #createInventory(InventoryHolder, InventoryType, Component)} */ @Deprecated // Paper @NotNull @@ -1945,7 +1946,7 @@ public final class Bukkit { * @param title the title of the corresponding merchant inventory, displayed * when the merchant inventory is viewed * @return a new merchant - * @deprecated in favour of {@link #createMerchant(net.kyori.adventure.text.Component)}. The title parameter is + * @deprecated in favour of {@link #createMerchant(Component)}. The title parameter is * no-longer needed when used with {@link MenuType#MERCHANT} and {@link MenuType.Typed#builder()} */ @NotNull @@ -2082,7 +2083,7 @@ public final class Bukkit { * * @return the server's MOTD */ - @NotNull public static net.kyori.adventure.text.Component motd() { + @NotNull public static Component motd() { return server.motd(); } @@ -2121,7 +2122,7 @@ public final class Bukkit { * Set the message that is displayed on the server list. * * @param motd The message to be displayed - * @deprecated in favour of {@link #motd(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #motd(Component)} */ @Deprecated // Paper public static void setMotd(@NotNull String motd) { @@ -2695,7 +2696,7 @@ public final class Bukkit { * @return the default message */ @NotNull - public static net.kyori.adventure.text.Component permissionMessage() { + public static Component permissionMessage() { return server.permissionMessage(); } diff --git a/paper-api/src/main/java/org/bukkit/Chunk.java b/paper-api/src/main/java/org/bukkit/Chunk.java index d43427734..9f8414f85 100644 --- a/paper-api/src/main/java/org/bukkit/Chunk.java +++ b/paper-api/src/main/java/org/bukkit/Chunk.java @@ -136,9 +136,9 @@ public interface Chunk extends PersistentDataHolder { @NotNull Entity @NotNull [] getEntities(); /** - * Get a list of all tile entities in the chunk. + * Get a list of all block entities in the chunk. * - * @return The tile entities. + * @return The block entities. */ @NotNull // Paper start @@ -147,20 +147,20 @@ public interface Chunk extends PersistentDataHolder { } /** - * Get a list of all tile entities in the chunk. + * Get a list of all block entities in the chunk. * * @param useSnapshot Take snapshots or direct references - * @return The tile entities. + * @return The block entities. */ @NotNull BlockState @NotNull [] getTileEntities(boolean useSnapshot); /** - * Get a list of all tile entities that match a given predicate in the chunk. + * Get a list of all block entities that match a given predicate in the chunk. * - * @param blockPredicate The predicate of blocks to return tile entities for + * @param blockPredicate The predicate of blocks to return block entities for * @param useSnapshot Take snapshots or direct references - * @return The tile entities. + * @return The block entities. */ @NotNull Collection getTileEntities(java.util.function.@NotNull Predicate blockPredicate, boolean useSnapshot); diff --git a/paper-api/src/main/java/org/bukkit/Color.java b/paper-api/src/main/java/org/bukkit/Color.java index f8edb964c..cf6427bec 100644 --- a/paper-api/src/main/java/org/bukkit/Color.java +++ b/paper-api/src/main/java/org/bukkit/Color.java @@ -146,7 +146,7 @@ public final class Color implements ConfigurationSerializable { * @param blue integer from 0-255 * @param green integer from 0-255 * @param red integer from 0-255 - * @return a new Color object for the red, green, blue + * @return a new Color object for the blue, green, red * @throws IllegalArgumentException if any value is strictly {@literal >255 or <0} */ @NotNull @@ -225,7 +225,7 @@ public final class Color implements ConfigurationSerializable { * Creates a new Color object with specified component * * @param alpha the alpha component, from 0 to 255 - * @return a new color object with the red component + * @return a new color object with the alpha component */ @NotNull public Color setAlpha(int alpha) { @@ -264,8 +264,8 @@ public final class Color implements ConfigurationSerializable { /** * Creates a new Color object with specified component * - * @param green the red component, from 0 to 255 - * @return a new color object with the red component + * @param green the green component, from 0 to 255 + * @return a new color object with the green component */ @NotNull public Color setGreen(int green) { @@ -284,8 +284,8 @@ public final class Color implements ConfigurationSerializable { /** * Creates a new Color object with specified component * - * @param blue the red component, from 0 to 255 - * @return a new color object with the red component + * @param blue the blue component, from 0 to 255 + * @return a new color object with the blue component */ @NotNull public Color setBlue(int blue) { diff --git a/paper-api/src/main/java/org/bukkit/EntityEffect.java b/paper-api/src/main/java/org/bukkit/EntityEffect.java index 35641226d..cbf1d7a67 100644 --- a/paper-api/src/main/java/org/bukkit/EntityEffect.java +++ b/paper-api/src/main/java/org/bukkit/EntityEffect.java @@ -247,11 +247,17 @@ public enum EntityEffect { // 22-28 player internal flags /** * Shield blocks attack. + * + * @deprecated replaced by the {@code blocks_attacks} item data component */ + @Deprecated(since = "1.21.5", forRemoval = true) SHIELD_BLOCK(29, LivingEntity.class), /** * Shield breaks. + * + * @deprecated replaced by the {@code blocks_attacks} item data component */ + @Deprecated(since = "1.21.5", forRemoval = true) SHIELD_BREAK(30, LivingEntity.class), // 31 - unused /** @@ -359,7 +365,7 @@ public enum EntityEffect { */ BREAK_EQUIPMENT_MAIN_HAND(47, LivingEntity.class), /** - * Entity breaks item in off hand. + * Entity breaks item in off-hand. * * @see org.bukkit.inventory.EquipmentSlot#OFF_HAND */ @@ -458,11 +464,19 @@ public enum EntityEffect { */ BREAK_EQUIPMENT_BODY(65, LivingEntity.class), /** - * A creaking transient shaking when being hit. - * Does not apply to plain creaking entities as they are not invulnerable like the transient ones spawned by the - * creaking heart. + * A creaking shaking when being hit. */ - SHAKE(66, Creaking.class); + SHAKE(66, Creaking.class), + /** + * Drown particles for entities. + */ + DROWN_PARTICLES(67, LivingEntity.class), + /** + * Entity breaks item in saddle slot. + * + * @see org.bukkit.inventory.EquipmentSlot#SADDLE + */ + BREAK_EQUIPMENT_SADDLE(68, LivingEntity.class); private final byte data; private final Set> applicableClasses; diff --git a/paper-api/src/main/java/org/bukkit/FeatureFlag.java b/paper-api/src/main/java/org/bukkit/FeatureFlag.java index a1e093c40..fafcec1db 100644 --- a/paper-api/src/main/java/org/bukkit/FeatureFlag.java +++ b/paper-api/src/main/java/org/bukkit/FeatureFlag.java @@ -14,19 +14,19 @@ import org.jetbrains.annotations.ApiStatus; */ public interface FeatureFlag extends Keyed { - // Paper start - overhaul FeatureFlag API - /** - * The {@code vanilla} feature flag. - */ - FeatureFlag VANILLA = create("vanilla"); + // Start generate - FeatureFlag + // @GeneratedFrom 1.21.5 + @ApiStatus.Experimental + FeatureFlag MINECART_IMPROVEMENTS = create("minecart_improvements"); - /** - * AVAILABLE BETWEEN VERSIONS: 1.19.3 - 1.21.1 - * - * @deprecated not available since 1.21.2 - */ - @Deprecated(since = "1.21.2") - FeatureFlag BUNDLE = deprecated("bundle"); + @ApiStatus.Experimental + FeatureFlag REDSTONE_EXPERIMENTS = create("redstone_experiments"); + + @ApiStatus.Experimental + FeatureFlag TRADE_REBALANCE = create("trade_rebalance"); + + FeatureFlag VANILLA = create("vanilla"); + // End generate - FeatureFlag /** * AVAILABLE BETWEEN VERSIONS: 1.19 - 1.19.4 @@ -37,9 +37,6 @@ public interface FeatureFlag extends Keyed { @Deprecated(since = "1.20") FeatureFlag UPDATE_1_20 = deprecated("update_1_20"); - @ApiStatus.Experimental // Paper - add missing annotation - FeatureFlag TRADE_REBALANCE = create("trade_rebalance"); - /** * AVAILABLE BETWEEN VERSIONS: 1.20.5 - 1.20.6 * @@ -48,6 +45,14 @@ public interface FeatureFlag extends Keyed { @Deprecated(since = "1.21") FeatureFlag UPDATE_121 = deprecated("update_1_21"); + /** + * AVAILABLE BETWEEN VERSIONS: 1.19.3 - 1.21.1 + * + * @deprecated not available since 1.21.2 + */ + @Deprecated(since = "1.21.2") + FeatureFlag BUNDLE = deprecated("bundle"); + /** * AVAILABLE BETWEEN VERSIONS: 1.21.2 - 1.21.3 * @@ -56,12 +61,6 @@ public interface FeatureFlag extends Keyed { @Deprecated(since = "1.21.4") FeatureFlag WINTER_DROP = deprecated("winter_drop"); - @ApiStatus.Experimental // Paper - add missing annotation - FeatureFlag REDSTONE_EXPERIMENTS = create("redstone_experiments"); - - @ApiStatus.Experimental // Paper - add missing annotation - FeatureFlag MINECART_IMPROVEMENTS = create("minecart_improvements"); - /** * An index of all feature flags. */ diff --git a/paper-api/src/main/java/org/bukkit/Fluid.java b/paper-api/src/main/java/org/bukkit/Fluid.java index 45a095f16..ad12f82e2 100644 --- a/paper-api/src/main/java/org/bukkit/Fluid.java +++ b/paper-api/src/main/java/org/bukkit/Fluid.java @@ -12,27 +12,19 @@ import org.jetbrains.annotations.NotNull; */ public interface Fluid extends OldEnum, Keyed { - /** - * No fluid. - */ + // Start generate - Fluid + // @GeneratedFrom 1.21.5 Fluid EMPTY = getFluid("empty"); - /** - * Stationary water. - */ - Fluid WATER = getFluid("water"); - /** - * Flowing water. - */ - Fluid FLOWING_WATER = getFluid("flowing_water"); - /** - * Stationary lava. - */ - Fluid LAVA = getFluid("lava"); - /** - * Flowing lava. - */ + Fluid FLOWING_LAVA = getFluid("flowing_lava"); + Fluid FLOWING_WATER = getFluid("flowing_water"); + + Fluid LAVA = getFluid("lava"); + + Fluid WATER = getFluid("water"); + // End generate - Fluid + @NotNull private static Fluid getFluid(@NotNull String key) { return Registry.FLUID.getOrThrow(NamespacedKey.minecraft(key)); diff --git a/paper-api/src/main/java/org/bukkit/GameEvent.java b/paper-api/src/main/java/org/bukkit/GameEvent.java index ac2601db7..2e08337e6 100644 --- a/paper-api/src/main/java/org/bukkit/GameEvent.java +++ b/paper-api/src/main/java/org/bukkit/GameEvent.java @@ -11,107 +11,229 @@ import org.jetbrains.annotations.Nullable; */ public abstract class GameEvent implements Keyed { + // Start generate - GameEvent + // @GeneratedFrom 1.21.5 public static final GameEvent BLOCK_ACTIVATE = getEvent("block_activate"); + public static final GameEvent BLOCK_ATTACH = getEvent("block_attach"); + public static final GameEvent BLOCK_CHANGE = getEvent("block_change"); + public static final GameEvent BLOCK_CLOSE = getEvent("block_close"); + public static final GameEvent BLOCK_DEACTIVATE = getEvent("block_deactivate"); + public static final GameEvent BLOCK_DESTROY = getEvent("block_destroy"); + public static final GameEvent BLOCK_DETACH = getEvent("block_detach"); + public static final GameEvent BLOCK_OPEN = getEvent("block_open"); + public static final GameEvent BLOCK_PLACE = getEvent("block_place"); - @Deprecated(since = "1.19") - public static final GameEvent BLOCK_PRESS = getEvent("block_activate"); - @Deprecated(since = "1.19") - public static final GameEvent BLOCK_SWITCH = getEvent("block_activate"); - @Deprecated(since = "1.19") - public static final GameEvent BLOCK_UNPRESS = getEvent("block_deactivate"); - @Deprecated(since = "1.19") - public static final GameEvent BLOCK_UNSWITCH = getEvent("block_deactivate"); + public static final GameEvent CONTAINER_CLOSE = getEvent("container_close"); + public static final GameEvent CONTAINER_OPEN = getEvent("container_open"); - @Deprecated(since = "1.20") - public static final GameEvent DISPENSE_FAIL = getEvent("block_activate"); + public static final GameEvent DRINK = getEvent("drink"); - @Deprecated(since = "1.19") - public static final GameEvent DRINKING_FINISH = getEvent("drink"); + public static final GameEvent EAT = getEvent("eat"); - @Deprecated(since = "1.19") - public static final GameEvent ELYTRA_FREE_FALL = getEvent("elytra_glide"); + public static final GameEvent ELYTRA_GLIDE = getEvent("elytra_glide"); - public static final GameEvent ENTITY_DAMAGE = getEvent("entity_damage"); - @Deprecated(since = "1.19") - public static final GameEvent ENTITY_DAMAGED = getEvent("entity_damage"); - public static final GameEvent ENTITY_DIE = getEvent("entity_die"); - public static final GameEvent ENTITY_DISMOUNT = getEvent("entity_dismount"); - @Deprecated(since = "1.19") - public static final GameEvent ENTITY_DYING = getEvent("entity_die"); - public static final GameEvent ENTITY_INTERACT = getEvent("entity_interact"); - public static final GameEvent ENTITY_MOUNT = getEvent("entity_mount"); - @Deprecated(since = "1.19") - public static final GameEvent ENTITY_KILLED = getEvent("entity_die"); - public static final GameEvent ENTITY_PLACE = getEvent("entity_place"); + public static final GameEvent ENTITY_ACTION = getEvent("entity_action"); - @Deprecated(since = "1.20.2") - public static final GameEvent ENTITY_ROAR = getEvent("entity_action"); - @Deprecated(since = "1.20.2") - public static final GameEvent ENTITY_SHAKE = getEvent("entity_action"); + + public static final GameEvent ENTITY_DAMAGE = getEvent("entity_damage"); + + public static final GameEvent ENTITY_DIE = getEvent("entity_die"); + + public static final GameEvent ENTITY_DISMOUNT = getEvent("entity_dismount"); + + public static final GameEvent ENTITY_INTERACT = getEvent("entity_interact"); + + public static final GameEvent ENTITY_MOUNT = getEvent("entity_mount"); + + public static final GameEvent ENTITY_PLACE = getEvent("entity_place"); + public static final GameEvent EQUIP = getEvent("equip"); + public static final GameEvent EXPLODE = getEvent("explode"); + public static final GameEvent FLAP = getEvent("flap"); + public static final GameEvent FLUID_PICKUP = getEvent("fluid_pickup"); + public static final GameEvent FLUID_PLACE = getEvent("fluid_place"); + public static final GameEvent HIT_GROUND = getEvent("hit_ground"); + public static final GameEvent INSTRUMENT_PLAY = getEvent("instrument_play"); + public static final GameEvent ITEM_INTERACT_FINISH = getEvent("item_interact_finish"); + public static final GameEvent ITEM_INTERACT_START = getEvent("item_interact_start"); + public static final GameEvent JUKEBOX_PLAY = getEvent("jukebox_play"); + public static final GameEvent JUKEBOX_STOP_PLAY = getEvent("jukebox_stop_play"); + public static final GameEvent LIGHTNING_STRIKE = getEvent("lightning_strike"); - @Deprecated(since = "1.19") - public static final GameEvent MOB_INTERACT = getEvent("entity_interact"); + public static final GameEvent NOTE_BLOCK_PLAY = getEvent("note_block_play"); - @Deprecated(since = "1.20") - public static final GameEvent PISTON_CONTRACT = getEvent("block_deactivate"); - @Deprecated(since = "1.20") - public static final GameEvent PISTON_EXTEND = getEvent("block_activate"); + public static final GameEvent PRIME_FUSE = getEvent("prime_fuse"); + public static final GameEvent PROJECTILE_LAND = getEvent("projectile_land"); + public static final GameEvent PROJECTILE_SHOOT = getEvent("projectile_shoot"); - @Deprecated(since = "1.19") - public static final GameEvent RAVAGER_ROAR = getEvent("entity_action"); - @Deprecated(since = "1.19") - public static final GameEvent RING_BELL = getEvent("block_change"); - public static final GameEvent SCULK_SENSOR_TENDRILS_CLICKING = getEvent("sculk_sensor_tendrils_clicking"); - public static final GameEvent SHEAR = getEvent("shear"); - public static final GameEvent SHRIEK = getEvent("shriek"); - @Deprecated(since = "1.19") - public static final GameEvent SHULKER_CLOSE = getEvent("container_close"); - @Deprecated(since = "1.19") - public static final GameEvent SHULKER_OPEN = getEvent("container_open"); - public static final GameEvent SPLASH = getEvent("splash"); - public static final GameEvent STEP = getEvent("step"); - public static final GameEvent SWIM = getEvent("swim"); - public static final GameEvent TELEPORT = getEvent("teleport"); - public static final GameEvent UNEQUIP = getEvent("unequip"); - @Deprecated(since = "1.19") - public static final GameEvent WOLF_SHAKING = getEvent("entity_action"); + public static final GameEvent RESONATE_1 = getEvent("resonate_1"); + public static final GameEvent RESONATE_2 = getEvent("resonate_2"); + public static final GameEvent RESONATE_3 = getEvent("resonate_3"); + public static final GameEvent RESONATE_4 = getEvent("resonate_4"); + public static final GameEvent RESONATE_5 = getEvent("resonate_5"); + public static final GameEvent RESONATE_6 = getEvent("resonate_6"); + public static final GameEvent RESONATE_7 = getEvent("resonate_7"); + public static final GameEvent RESONATE_8 = getEvent("resonate_8"); + public static final GameEvent RESONATE_9 = getEvent("resonate_9"); + public static final GameEvent RESONATE_10 = getEvent("resonate_10"); + public static final GameEvent RESONATE_11 = getEvent("resonate_11"); + public static final GameEvent RESONATE_12 = getEvent("resonate_12"); + public static final GameEvent RESONATE_13 = getEvent("resonate_13"); + public static final GameEvent RESONATE_14 = getEvent("resonate_14"); + public static final GameEvent RESONATE_15 = getEvent("resonate_15"); + public static final GameEvent SCULK_SENSOR_TENDRILS_CLICKING = getEvent("sculk_sensor_tendrils_clicking"); + + public static final GameEvent SHEAR = getEvent("shear"); + + public static final GameEvent SHRIEK = getEvent("shriek"); + + public static final GameEvent SPLASH = getEvent("splash"); + + public static final GameEvent STEP = getEvent("step"); + + public static final GameEvent SWIM = getEvent("swim"); + + public static final GameEvent TELEPORT = getEvent("teleport"); + + public static final GameEvent UNEQUIP = getEvent("unequip"); + // End generate - GameEvent + /** + * @deprecated in favor of {@link #BLOCK_ACTIVATE} + */ + @Deprecated(since = "1.19") + public static final GameEvent BLOCK_PRESS = BLOCK_ACTIVATE; + /** + * @deprecated in favor of {@link #BLOCK_ACTIVATE} + */ + @Deprecated(since = "1.19") + public static final GameEvent BLOCK_SWITCH = BLOCK_ACTIVATE; + /** + * @deprecated in favor of {@link #BLOCK_DEACTIVATE} + */ + @Deprecated(since = "1.19") + public static final GameEvent BLOCK_UNPRESS = BLOCK_DEACTIVATE; + /** + * @deprecated in favor of {@link #BLOCK_DEACTIVATE} + */ + @Deprecated(since = "1.19") + public static final GameEvent BLOCK_UNSWITCH = BLOCK_DEACTIVATE; + /** + * @deprecated in favor of {@link #BLOCK_ACTIVATE} + */ + @Deprecated(since = "1.20") + public static final GameEvent DISPENSE_FAIL = BLOCK_ACTIVATE; + /** + * @deprecated in favor of {@link #DRINK} + */ + @Deprecated(since = "1.19") + public static final GameEvent DRINKING_FINISH = DRINK; + /** + * @deprecated in favor of {@link #ELYTRA_GLIDE} + */ + @Deprecated(since = "1.19") + public static final GameEvent ELYTRA_FREE_FALL = ELYTRA_GLIDE; + /** + * @deprecated in favor of {@link #ENTITY_DAMAGE} + */ + @Deprecated(since = "1.19") + public static final GameEvent ENTITY_DAMAGED = ENTITY_DAMAGE; + /** + * @deprecated in favor of {@link #ENTITY_DIE} + */ + @Deprecated(since = "1.19") + public static final GameEvent ENTITY_DYING = ENTITY_DIE; + /** + * @deprecated in favor of {@link #ENTITY_DIE} + */ + @Deprecated(since = "1.19") + public static final GameEvent ENTITY_KILLED = ENTITY_DIE; + /** + * @deprecated in favor of {@link #ENTITY_ACTION} + */ + @Deprecated(since = "1.20.2") + public static final GameEvent ENTITY_ROAR = ENTITY_ACTION; + /** + * @deprecated in favor of {@link #ENTITY_ACTION} + */ + @Deprecated(since = "1.20.2") + public static final GameEvent ENTITY_SHAKE = ENTITY_ACTION; + /** + * @deprecated in favor of {@link #ENTITY_INTERACT} + */ + @Deprecated(since = "1.19") + public static final GameEvent MOB_INTERACT = ENTITY_INTERACT; + /** + * @deprecated in favor of {@link #BLOCK_DEACTIVATE} + */ + @Deprecated(since = "1.20") + public static final GameEvent PISTON_CONTRACT = BLOCK_DEACTIVATE; + /** + * @deprecated in favor of {@link #BLOCK_ACTIVATE} + */ + @Deprecated(since = "1.20") + public static final GameEvent PISTON_EXTEND = BLOCK_ACTIVATE; + /** + * @deprecated in favor of {@link #ENTITY_ACTION} + */ + @Deprecated(since = "1.19") + public static final GameEvent RAVAGER_ROAR = ENTITY_ACTION; + /** + * @deprecated in favor of {@link #BLOCK_CHANGE} + */ + @Deprecated(since = "1.19") + public static final GameEvent RING_BELL = BLOCK_CHANGE; + /** + * @deprecated in favor of {@link #CONTAINER_CLOSE} + */ + @Deprecated(since = "1.19") + public static final GameEvent SHULKER_CLOSE = CONTAINER_CLOSE; + /** + * @deprecated in favor of {@link #CONTAINER_OPEN} + */ + @Deprecated(since = "1.19") + public static final GameEvent SHULKER_OPEN = CONTAINER_OPEN; + /** + * @deprecated in favor of {@link #ENTITY_ACTION} + */ + @Deprecated(since = "1.19") + public static final GameEvent WOLF_SHAKING = ENTITY_ACTION; + /** * Returns a {@link GameEvent} by a {@link NamespacedKey}. * diff --git a/paper-api/src/main/java/org/bukkit/GameRule.java b/paper-api/src/main/java/org/bukkit/GameRule.java index 89f1820ae..cf81c86c6 100644 --- a/paper-api/src/main/java/org/bukkit/GameRule.java +++ b/paper-api/src/main/java/org/bukkit/GameRule.java @@ -220,6 +220,14 @@ public final class GameRule implements net.kyori.adventure.translation.Transl * Whether ender pearls will vanish on player death. */ public static final GameRule ENDER_PEARLS_VANISH_ON_DEATH = new GameRule<>("enderPearlsVanishOnDeath", Boolean.class); + /** + * Whether fire will still propagate far away from players (8 chunks). + */ + public static final GameRule ALLOW_FIRE_TICKS_AWAY_FROM_PLAYER = new GameRule<>("allowFireTicksAwayFromPlayer", Boolean.class); + /** + * Whether primed tnt explodes. + */ + public static final GameRule TNT_EXPLODES = new GameRule<>("tntExplodes", Boolean.class); // Numerical rules /** diff --git a/paper-api/src/main/java/org/bukkit/JukeboxSong.java b/paper-api/src/main/java/org/bukkit/JukeboxSong.java index 7e3dca502..5a20983a6 100644 --- a/paper-api/src/main/java/org/bukkit/JukeboxSong.java +++ b/paper-api/src/main/java/org/bukkit/JukeboxSong.java @@ -11,25 +11,46 @@ import org.jetbrains.annotations.NotNull; @ApiStatus.Experimental public interface JukeboxSong extends Keyed, Translatable { - public static final JukeboxSong THIRTEEN = get("13"); - public static final JukeboxSong CAT = get("cat"); - public static final JukeboxSong BLOCKS = get("blocks"); - public static final JukeboxSong CHIRP = get("chirp"); - public static final JukeboxSong FAR = get("far"); - public static final JukeboxSong MALL = get("mall"); - public static final JukeboxSong MELLOHI = get("mellohi"); - public static final JukeboxSong STAL = get("stal"); - public static final JukeboxSong STRAD = get("strad"); - public static final JukeboxSong WARD = get("ward"); - public static final JukeboxSong ELEVEN = get("11"); - public static final JukeboxSong WAIT = get("wait"); - public static final JukeboxSong PIGSTEP = get("pigstep"); - public static final JukeboxSong OTHERSIDE = get("otherside"); - public static final JukeboxSong FIVE = get("5"); - public static final JukeboxSong RELIC = get("relic"); - public static final JukeboxSong PRECIPICE = get("precipice"); - public static final JukeboxSong CREATOR = get("creator"); - public static final JukeboxSong CREATOR_MUSIC_BOX = get("creator_music_box"); + // Start generate - JukeboxSong + // @GeneratedFrom 1.21.5 + JukeboxSong ELEVEN = get("11"); + + JukeboxSong THIRTEEN = get("13"); + + JukeboxSong FIVE = get("5"); + + JukeboxSong BLOCKS = get("blocks"); + + JukeboxSong CAT = get("cat"); + + JukeboxSong CHIRP = get("chirp"); + + JukeboxSong CREATOR = get("creator"); + + JukeboxSong CREATOR_MUSIC_BOX = get("creator_music_box"); + + JukeboxSong FAR = get("far"); + + JukeboxSong MALL = get("mall"); + + JukeboxSong MELLOHI = get("mellohi"); + + JukeboxSong OTHERSIDE = get("otherside"); + + JukeboxSong PIGSTEP = get("pigstep"); + + JukeboxSong PRECIPICE = get("precipice"); + + JukeboxSong RELIC = get("relic"); + + JukeboxSong STAL = get("stal"); + + JukeboxSong STRAD = get("strad"); + + JukeboxSong WAIT = get("wait"); + + JukeboxSong WARD = get("ward"); + // End generate - JukeboxSong @NotNull private static JukeboxSong get(@NotNull String key) { diff --git a/paper-api/src/main/java/org/bukkit/Material.java b/paper-api/src/main/java/org/bukkit/Material.java index d43ce5dbf..5a1b9f818 100644 --- a/paper-api/src/main/java/org/bukkit/Material.java +++ b/paper-api/src/main/java/org/bukkit/Material.java @@ -4,6 +4,8 @@ import com.google.common.base.Preconditions; import com.google.common.base.Suppliers; import com.google.common.collect.Maps; import com.google.common.collect.Multimap; +import io.papermc.paper.datacomponent.DataComponentTypes; +import io.papermc.paper.datacomponent.item.Equippable; import java.lang.reflect.Constructor; import java.util.Locale; import java.util.Map; @@ -64,6 +66,7 @@ import org.bukkit.block.data.type.EnderChest; import org.bukkit.block.data.type.Farmland; import org.bukkit.block.data.type.Fence; import org.bukkit.block.data.type.Fire; +import org.bukkit.block.data.type.FlowerBed; import org.bukkit.block.data.type.Furnace; import org.bukkit.block.data.type.Gate; import org.bukkit.block.data.type.GlassPane; @@ -76,6 +79,7 @@ import org.bukkit.block.data.type.Jigsaw; import org.bukkit.block.data.type.Jukebox; import org.bukkit.block.data.type.Ladder; import org.bukkit.block.data.type.Lantern; +import org.bukkit.block.data.type.LeafLitter; import org.bukkit.block.data.type.Leaves; import org.bukkit.block.data.type.Lectern; import org.bukkit.block.data.type.Light; @@ -112,6 +116,7 @@ import org.bukkit.block.data.type.StructureBlock; import org.bukkit.block.data.type.Switch; import org.bukkit.block.data.type.TNT; import org.bukkit.block.data.type.TechnicalPiston; +import org.bukkit.block.data.type.TestBlock; import org.bukkit.block.data.type.TrapDoor; import org.bukkit.block.data.type.TrialSpawner; import org.bukkit.block.data.type.Tripwire; @@ -138,3682 +143,1560 @@ import org.jetbrains.annotations.Nullable; @SuppressWarnings({"DeprecatedIsStillUsed", "deprecation"}) // Paper public enum Material implements Keyed, Translatable, net.kyori.adventure.translation.Translatable { // Paper // - AIR(9648, 64), // Paper - air stacks to 64 - STONE(22948), - GRANITE(21091), - POLISHED_GRANITE(5477), - DIORITE(24688), - POLISHED_DIORITE(31615), - ANDESITE(25975), - POLISHED_ANDESITE(8335), - /** - * BlockData: {@link Orientable} - */ - DEEPSLATE(26842, Orientable.class), - COBBLED_DEEPSLATE(8021), - POLISHED_DEEPSLATE(31772), - CALCITE(20311), - TUFF(24364), - /** - * BlockData: {@link Slab} - */ - TUFF_SLAB(19305, Slab.class), - /** - * BlockData: {@link Stairs} - */ - TUFF_STAIRS(11268, Stairs.class), - /** - * BlockData: {@link Wall} - */ - TUFF_WALL(24395, Wall.class), - CHISELED_TUFF(15831), - POLISHED_TUFF(17801), - /** - * BlockData: {@link Slab} - */ - POLISHED_TUFF_SLAB(31096, Slab.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_TUFF_STAIRS(7964, Stairs.class), - /** - * BlockData: {@link Wall} - */ - POLISHED_TUFF_WALL(28886, Wall.class), - TUFF_BRICKS(26276), - /** - * BlockData: {@link Slab} - */ - TUFF_BRICK_SLAB(11843, Slab.class), - /** - * BlockData: {@link Stairs} - */ - TUFF_BRICK_STAIRS(30753, Stairs.class), - /** - * BlockData: {@link Wall} - */ - TUFF_BRICK_WALL(11761, Wall.class), - CHISELED_TUFF_BRICKS(8601), - DRIPSTONE_BLOCK(26227), - /** - * BlockData: {@link Snowable} - */ - GRASS_BLOCK(28346, Snowable.class), - DIRT(10580), - COARSE_DIRT(15411), - /** - * BlockData: {@link Snowable} - */ - PODZOL(24068, Snowable.class), - ROOTED_DIRT(11410), - MUD(32418), - CRIMSON_NYLIUM(18139), - WARPED_NYLIUM(26396), - COBBLESTONE(32147), - OAK_PLANKS(14905), - SPRUCE_PLANKS(14593), - BIRCH_PLANKS(29322), - JUNGLE_PLANKS(26445), - ACACIA_PLANKS(31312), - CHERRY_PLANKS(8354), - DARK_OAK_PLANKS(20869), - PALE_OAK_PLANKS(21660), - MANGROVE_PLANKS(7078), - BAMBOO_PLANKS(8520), - CRIMSON_PLANKS(18812), - WARPED_PLANKS(16045), - BAMBOO_MOSAIC(10715), - /** - * BlockData: {@link Sapling} - */ - OAK_SAPLING(9636, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - SPRUCE_SAPLING(19874, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - BIRCH_SAPLING(31533, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - JUNGLE_SAPLING(17951, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - ACACIA_SAPLING(20806, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - CHERRY_SAPLING(25204, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - DARK_OAK_SAPLING(14933, Sapling.class), - /** - * BlockData: {@link Sapling} - */ - PALE_OAK_SAPLING(15508, Sapling.class), - /** - * BlockData: {@link MangrovePropagule} - */ - MANGROVE_PROPAGULE(18688, MangrovePropagule.class), - BEDROCK(23130), - SAND(11542), - /** - * BlockData: {@link Brushable} - */ - SUSPICIOUS_SAND(18410, Brushable.class), - /** - * BlockData: {@link Brushable} - */ - SUSPICIOUS_GRAVEL(7353, Brushable.class), - RED_SAND(16279), - GRAVEL(7804), - COAL_ORE(30965), - DEEPSLATE_COAL_ORE(16823), - IRON_ORE(19834), - DEEPSLATE_IRON_ORE(26021), - COPPER_ORE(32666), - DEEPSLATE_COPPER_ORE(6588), - GOLD_ORE(32625), - DEEPSLATE_GOLD_ORE(13582), - /** - * BlockData: {@link Lightable} - */ - REDSTONE_ORE(10887, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - DEEPSLATE_REDSTONE_ORE(6331, Lightable.class), - EMERALD_ORE(16630), - DEEPSLATE_EMERALD_ORE(5299), - LAPIS_ORE(22934), - DEEPSLATE_LAPIS_ORE(13598), - DIAMOND_ORE(9292), - DEEPSLATE_DIAMOND_ORE(17792), - NETHER_GOLD_ORE(4185), - NETHER_QUARTZ_ORE(4807), - ANCIENT_DEBRIS(18198), - COAL_BLOCK(27968), - RAW_IRON_BLOCK(32210), - RAW_COPPER_BLOCK(17504), - RAW_GOLD_BLOCK(23246), - /** - * BlockData: {@link Waterlogged} - */ - HEAVY_CORE(15788, Waterlogged.class), - AMETHYST_BLOCK(18919), - BUDDING_AMETHYST(13963), - IRON_BLOCK(24754), - COPPER_BLOCK(12880), - GOLD_BLOCK(27392), - DIAMOND_BLOCK(5944), - NETHERITE_BLOCK(6527), - EXPOSED_COPPER(28488), - WEATHERED_COPPER(19699), - OXIDIZED_COPPER(19490), - CHISELED_COPPER(12143), - EXPOSED_CHISELED_COPPER(4570), - WEATHERED_CHISELED_COPPER(30876), - OXIDIZED_CHISELED_COPPER(27719), - CUT_COPPER(32519), - EXPOSED_CUT_COPPER(18000), - WEATHERED_CUT_COPPER(21158), - OXIDIZED_CUT_COPPER(5382), - /** - * BlockData: {@link Stairs} - */ - CUT_COPPER_STAIRS(25925, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - EXPOSED_CUT_COPPER_STAIRS(31621, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - WEATHERED_CUT_COPPER_STAIRS(5851, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - OXIDIZED_CUT_COPPER_STAIRS(25379, Stairs.class), - /** - * BlockData: {@link Slab} - */ - CUT_COPPER_SLAB(28988, Slab.class), - /** - * BlockData: {@link Slab} - */ - EXPOSED_CUT_COPPER_SLAB(26694, Slab.class), - /** - * BlockData: {@link Slab} - */ - WEATHERED_CUT_COPPER_SLAB(4602, Slab.class), - /** - * BlockData: {@link Slab} - */ - OXIDIZED_CUT_COPPER_SLAB(29642, Slab.class), - WAXED_COPPER_BLOCK(14638), - WAXED_EXPOSED_COPPER(27989), - WAXED_WEATHERED_COPPER(5960), - WAXED_OXIDIZED_COPPER(25626), - WAXED_CHISELED_COPPER(7500), - WAXED_EXPOSED_CHISELED_COPPER(30658), - WAXED_WEATHERED_CHISELED_COPPER(5970), - WAXED_OXIDIZED_CHISELED_COPPER(7735), - WAXED_CUT_COPPER(11030), - WAXED_EXPOSED_CUT_COPPER(30043), - WAXED_WEATHERED_CUT_COPPER(13823), - WAXED_OXIDIZED_CUT_COPPER(22582), - /** - * BlockData: {@link Stairs} - */ - WAXED_CUT_COPPER_STAIRS(23125, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - WAXED_EXPOSED_CUT_COPPER_STAIRS(15532, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - WAXED_WEATHERED_CUT_COPPER_STAIRS(29701, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - WAXED_OXIDIZED_CUT_COPPER_STAIRS(9842, Stairs.class), - /** - * BlockData: {@link Slab} - */ - WAXED_CUT_COPPER_SLAB(6271, Slab.class), - /** - * BlockData: {@link Slab} - */ - WAXED_EXPOSED_CUT_COPPER_SLAB(22091, Slab.class), - /** - * BlockData: {@link Slab} - */ - WAXED_WEATHERED_CUT_COPPER_SLAB(20035, Slab.class), - /** - * BlockData: {@link Slab} - */ - WAXED_OXIDIZED_CUT_COPPER_SLAB(11202, Slab.class), - /** - * BlockData: {@link Orientable} - */ - OAK_LOG(26723, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - SPRUCE_LOG(9726, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - BIRCH_LOG(26727, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - JUNGLE_LOG(20721, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - ACACIA_LOG(8385, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - CHERRY_LOG(20847, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - PALE_OAK_LOG(13346, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - DARK_OAK_LOG(14831, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - MANGROVE_LOG(23890, Orientable.class), - /** - * BlockData: {@link Waterlogged} - */ - MANGROVE_ROOTS(22124, Waterlogged.class), - /** - * BlockData: {@link Orientable} - */ - MUDDY_MANGROVE_ROOTS(23244, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - CRIMSON_STEM(27920, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - WARPED_STEM(28920, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - BAMBOO_BLOCK(20770, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_OAK_LOG(20523, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_SPRUCE_LOG(6140, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_BIRCH_LOG(8838, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_JUNGLE_LOG(15476, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_ACACIA_LOG(18167, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_CHERRY_LOG(18061, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_DARK_OAK_LOG(6492, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_PALE_OAK_LOG(25375, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_MANGROVE_LOG(15197, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_CRIMSON_STEM(16882, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_WARPED_STEM(15627, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_OAK_WOOD(31455, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_SPRUCE_WOOD(6467, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_BIRCH_WOOD(22350, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_JUNGLE_WOOD(30315, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_ACACIA_WOOD(27193, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_CHERRY_WOOD(19647, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_DARK_OAK_WOOD(16000, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_PALE_OAK_WOOD(20330, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_MANGROVE_WOOD(4828, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_CRIMSON_HYPHAE(27488, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_WARPED_HYPHAE(7422, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - STRIPPED_BAMBOO_BLOCK(14799, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - OAK_WOOD(7378, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - SPRUCE_WOOD(32328, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - BIRCH_WOOD(20913, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - JUNGLE_WOOD(10341, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - ACACIA_WOOD(9541, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - CHERRY_WOOD(9826, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - PALE_OAK_WOOD(29429, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - DARK_OAK_WOOD(16995, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - MANGROVE_WOOD(25484, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - CRIMSON_HYPHAE(6550, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - WARPED_HYPHAE(18439, Orientable.class), - /** - * BlockData: {@link Leaves} - */ - OAK_LEAVES(4385, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - SPRUCE_LEAVES(20039, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - BIRCH_LEAVES(12601, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - JUNGLE_LEAVES(5133, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - ACACIA_LEAVES(16606, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - CHERRY_LEAVES(20856, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - DARK_OAK_LEAVES(22254, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - PALE_OAK_LEAVES(6408, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - MANGROVE_LEAVES(15310, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - AZALEA_LEAVES(23001, Leaves.class), - /** - * BlockData: {@link Leaves} - */ - FLOWERING_AZALEA_LEAVES(7139, Leaves.class), - SPONGE(15860), - WET_SPONGE(9043), - GLASS(6195), - TINTED_GLASS(19154), - LAPIS_BLOCK(14485), - SANDSTONE(13141), - CHISELED_SANDSTONE(31763), - CUT_SANDSTONE(6118), - COBWEB(9469), - SHORT_GRASS(16335), - FERN(15794), - AZALEA(29386), - FLOWERING_AZALEA(28270), - DEAD_BUSH(22888), - SEAGRASS(23942), - /** - * BlockData: {@link SeaPickle} - */ - SEA_PICKLE(19562, SeaPickle.class), - WHITE_WOOL(8624), - ORANGE_WOOL(23957), - MAGENTA_WOOL(11853), - LIGHT_BLUE_WOOL(21073), - YELLOW_WOOL(29507), - LIME_WOOL(10443), - PINK_WOOL(7611), - GRAY_WOOL(27209), - LIGHT_GRAY_WOOL(22936), - CYAN_WOOL(12221), - PURPLE_WOOL(11922), - BLUE_WOOL(15738), - BROWN_WOOL(32638), - GREEN_WOOL(25085), - RED_WOOL(11621), - BLACK_WOOL(16693), - DANDELION(30558), - OPEN_EYEBLOSSOM(31238), - CLOSED_EYEBLOSSOM(29262), - POPPY(12851), - BLUE_ORCHID(13432), - ALLIUM(6871), - AZURE_BLUET(17608), - RED_TULIP(16781), - ORANGE_TULIP(26038), - WHITE_TULIP(31495), - PINK_TULIP(27319), - OXEYE_DAISY(11709), - CORNFLOWER(15405), - LILY_OF_THE_VALLEY(7185), - WITHER_ROSE(8619), - TORCHFLOWER(4501), - /** - * BlockData: {@link Bisected} - */ - PITCHER_PLANT(28172, Bisected.class), - SPORE_BLOSSOM(20627), - BROWN_MUSHROOM(9665), - RED_MUSHROOM(19728), - CRIMSON_FUNGUS(26268), - WARPED_FUNGUS(19799), - CRIMSON_ROOTS(14064), - WARPED_ROOTS(13932), - NETHER_SPROUTS(10431), - /** - * BlockData: {@link Ageable} - */ - WEEPING_VINES(29267, Ageable.class), - /** - * BlockData: {@link Ageable} - */ - TWISTING_VINES(27283, Ageable.class), - /** - * BlockData: {@link Ageable} - */ - SUGAR_CANE(7726, Ageable.class), - /** - * BlockData: {@link Ageable} - */ - KELP(21916, Ageable.class), - /** - * BlockData: {@link PinkPetals} - */ - PINK_PETALS(10420, PinkPetals.class), - MOSS_CARPET(8221), - MOSS_BLOCK(9175), - /** - * BlockData: {@link MossyCarpet} - */ - PALE_MOSS_CARPET(24824, MossyCarpet.class), - /** - * BlockData: {@link HangingMoss} - */ - PALE_HANGING_MOSS(13108, HangingMoss.class), - PALE_MOSS_BLOCK(5318), - /** - * BlockData: {@link Waterlogged} - */ - HANGING_ROOTS(15498, Waterlogged.class), - /** - * BlockData: {@link BigDripleaf} - */ - BIG_DRIPLEAF(26173, BigDripleaf.class), - /** - * BlockData: {@link SmallDripleaf} - */ - SMALL_DRIPLEAF(17540, SmallDripleaf.class), - /** - * BlockData: {@link Bamboo} - */ - BAMBOO(18728, Bamboo.class), - /** - * BlockData: {@link Slab} - */ - OAK_SLAB(12002, Slab.class), - /** - * BlockData: {@link Slab} - */ - SPRUCE_SLAB(28798, Slab.class), - /** - * BlockData: {@link Slab} - */ - BIRCH_SLAB(13807, Slab.class), - /** - * BlockData: {@link Slab} - */ - JUNGLE_SLAB(19117, Slab.class), - /** - * BlockData: {@link Slab} - */ - ACACIA_SLAB(23730, Slab.class), - /** - * BlockData: {@link Slab} - */ - CHERRY_SLAB(16673, Slab.class), - /** - * BlockData: {@link Slab} - */ - DARK_OAK_SLAB(28852, Slab.class), - /** - * BlockData: {@link Slab} - */ - PALE_OAK_SLAB(22048, Slab.class), - /** - * BlockData: {@link Slab} - */ - MANGROVE_SLAB(13704, Slab.class), - /** - * BlockData: {@link Slab} - */ - BAMBOO_SLAB(17798, Slab.class), - /** - * BlockData: {@link Slab} - */ - BAMBOO_MOSAIC_SLAB(22118, Slab.class), - /** - * BlockData: {@link Slab} - */ - CRIMSON_SLAB(4691, Slab.class), - /** - * BlockData: {@link Slab} - */ - WARPED_SLAB(27150, Slab.class), - /** - * BlockData: {@link Slab} - */ - STONE_SLAB(19838, Slab.class), - /** - * BlockData: {@link Slab} - */ - SMOOTH_STONE_SLAB(24129, Slab.class), - /** - * BlockData: {@link Slab} - */ - SANDSTONE_SLAB(29830, Slab.class), - /** - * BlockData: {@link Slab} - */ - CUT_SANDSTONE_SLAB(30944, Slab.class), - /** - * BlockData: {@link Slab} - */ - PETRIFIED_OAK_SLAB(18658, Slab.class), - /** - * BlockData: {@link Slab} - */ - COBBLESTONE_SLAB(6340, Slab.class), - /** - * BlockData: {@link Slab} - */ - BRICK_SLAB(26333, Slab.class), - /** - * BlockData: {@link Slab} - */ - STONE_BRICK_SLAB(19676, Slab.class), - /** - * BlockData: {@link Slab} - */ - MUD_BRICK_SLAB(10611, Slab.class), - /** - * BlockData: {@link Slab} - */ - NETHER_BRICK_SLAB(26586, Slab.class), - /** - * BlockData: {@link Slab} - */ - QUARTZ_SLAB(4423, Slab.class), - /** - * BlockData: {@link Slab} - */ - RED_SANDSTONE_SLAB(17550, Slab.class), - /** - * BlockData: {@link Slab} - */ - CUT_RED_SANDSTONE_SLAB(7220, Slab.class), - /** - * BlockData: {@link Slab} - */ - PURPUR_SLAB(11487, Slab.class), - /** - * BlockData: {@link Slab} - */ - PRISMARINE_SLAB(31323, Slab.class), - /** - * BlockData: {@link Slab} - */ - PRISMARINE_BRICK_SLAB(25624, Slab.class), - /** - * BlockData: {@link Slab} - */ - DARK_PRISMARINE_SLAB(7577, Slab.class), - SMOOTH_QUARTZ(14415), - SMOOTH_RED_SANDSTONE(25180), - SMOOTH_SANDSTONE(30039), - SMOOTH_STONE(21910), - BRICKS(14165), - BOOKSHELF(10069), - /** - * BlockData: {@link ChiseledBookshelf} - */ - CHISELED_BOOKSHELF(8099, ChiseledBookshelf.class), - /** - * BlockData: {@link DecoratedPot} - */ - DECORATED_POT(8720, DecoratedPot.class), - MOSSY_COBBLESTONE(21900), - OBSIDIAN(32723), - TORCH(6063), - /** - * BlockData: {@link Directional} - */ - END_ROD(24832, Directional.class), - /** - * BlockData: {@link MultipleFacing} - */ - CHORUS_PLANT(28243, MultipleFacing.class), - /** - * BlockData: {@link Ageable} - */ - CHORUS_FLOWER(28542, Ageable.class), - PURPUR_BLOCK(7538), - /** - * BlockData: {@link Orientable} - */ - PURPUR_PILLAR(26718, Orientable.class), - /** - * BlockData: {@link Stairs} - */ - PURPUR_STAIRS(8921, Stairs.class), - SPAWNER(7018), - /** - * BlockData: {@link CreakingHeart} - */ - CREAKING_HEART(11442, CreakingHeart.class), - /** - * BlockData: {@link Chest} - */ - CHEST(22969, Chest.class), - CRAFTING_TABLE(20706), - /** - * BlockData: {@link Farmland} - */ - FARMLAND(31166, Farmland.class), - /** - * BlockData: {@link Furnace} - */ - FURNACE(8133, Furnace.class), - /** - * BlockData: {@link Ladder} - */ - LADDER(23599, Ladder.class), - /** - * BlockData: {@link Stairs} - */ - COBBLESTONE_STAIRS(24715, Stairs.class), - /** - * BlockData: {@link Snow} - */ - SNOW(14146, Snow.class), - ICE(30428), - SNOW_BLOCK(19913), - /** - * BlockData: {@link Ageable} - */ - CACTUS(12191, Ageable.class), - CLAY(27880), - /** - * BlockData: {@link Jukebox} - */ - JUKEBOX(19264, Jukebox.class), - /** - * BlockData: {@link Fence} - */ - OAK_FENCE(6442, Fence.class), - /** - * BlockData: {@link Fence} - */ - SPRUCE_FENCE(25416, Fence.class), - /** - * BlockData: {@link Fence} - */ - BIRCH_FENCE(17347, Fence.class), - /** - * BlockData: {@link Fence} - */ - JUNGLE_FENCE(14358, Fence.class), - /** - * BlockData: {@link Fence} - */ - ACACIA_FENCE(4569, Fence.class), - /** - * BlockData: {@link Fence} - */ - CHERRY_FENCE(32047, Fence.class), - /** - * BlockData: {@link Fence} - */ - DARK_OAK_FENCE(21767, Fence.class), - /** - * BlockData: {@link Fence} - */ - PALE_OAK_FENCE(10547, Fence.class), - /** - * BlockData: {@link Fence} - */ - MANGROVE_FENCE(15021, Fence.class), - /** - * BlockData: {@link Fence} - */ - BAMBOO_FENCE(17207, Fence.class), - /** - * BlockData: {@link Fence} - */ - CRIMSON_FENCE(21075, Fence.class), - /** - * BlockData: {@link Fence} - */ - WARPED_FENCE(18438, Fence.class), - PUMPKIN(19170), - /** - * BlockData: {@link Directional} - */ - CARVED_PUMPKIN(25833, Directional.class), - /** - * BlockData: {@link Directional} - */ - JACK_O_LANTERN(13758, Directional.class), - NETHERRACK(23425), - SOUL_SAND(16841), - SOUL_SOIL(31140), - /** - * BlockData: {@link Orientable} - */ - BASALT(28478, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - POLISHED_BASALT(11659, Orientable.class), - SMOOTH_BASALT(13617), - SOUL_TORCH(14292), - GLOWSTONE(32713), - INFESTED_STONE(18440), - INFESTED_COBBLESTONE(4348), - INFESTED_STONE_BRICKS(19749), - INFESTED_MOSSY_STONE_BRICKS(9850), - INFESTED_CRACKED_STONE_BRICKS(7476), - INFESTED_CHISELED_STONE_BRICKS(4728), - /** - * BlockData: {@link Orientable} - */ - INFESTED_DEEPSLATE(9472, Orientable.class), - STONE_BRICKS(6962), - MOSSY_STONE_BRICKS(16415), - CRACKED_STONE_BRICKS(27869), - CHISELED_STONE_BRICKS(9087), - PACKED_MUD(7472), - MUD_BRICKS(29168), - DEEPSLATE_BRICKS(13193), - CRACKED_DEEPSLATE_BRICKS(17105), - DEEPSLATE_TILES(11250), - CRACKED_DEEPSLATE_TILES(26249), - CHISELED_DEEPSLATE(23825), - REINFORCED_DEEPSLATE(10949), - /** - * BlockData: {@link MultipleFacing} - */ - BROWN_MUSHROOM_BLOCK(6291, MultipleFacing.class), - /** - * BlockData: {@link MultipleFacing} - */ - RED_MUSHROOM_BLOCK(20766, MultipleFacing.class), - /** - * BlockData: {@link MultipleFacing} - */ - MUSHROOM_STEM(16543, MultipleFacing.class), - /** - * BlockData: {@link Fence} - */ - IRON_BARS(9378, Fence.class), - /** - * BlockData: {@link Chain} - */ - CHAIN(28265, Chain.class), - /** - * BlockData: {@link Fence} - */ - GLASS_PANE(5709, Fence.class), - MELON(25172), - /** - * BlockData: {@link MultipleFacing} - */ - VINE(14564, MultipleFacing.class), - /** - * BlockData: {@link GlowLichen} - */ - GLOW_LICHEN(19165, GlowLichen.class), - /** - * BlockData: {@link ResinClump} - */ - RESIN_CLUMP(28662, ResinClump.class), - RESIN_BLOCK(26344), - RESIN_BRICKS(8331), - /** - * BlockData: {@link Stairs} - */ - RESIN_BRICK_STAIRS(31170, Stairs.class), - /** - * BlockData: {@link Slab} - */ - RESIN_BRICK_SLAB(25553, Slab.class), - /** - * BlockData: {@link Wall} - */ - RESIN_BRICK_WALL(8538, Wall.class), - CHISELED_RESIN_BRICKS(5529), - /** - * BlockData: {@link Stairs} - */ - BRICK_STAIRS(21534, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - STONE_BRICK_STAIRS(27032, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - MUD_BRICK_STAIRS(13620, Stairs.class), - /** - * BlockData: {@link Snowable} - */ - MYCELIUM(9913, Snowable.class), - LILY_PAD(19271), - NETHER_BRICKS(27802), - CRACKED_NETHER_BRICKS(10888), - CHISELED_NETHER_BRICKS(21613), - /** - * BlockData: {@link Fence} - */ - NETHER_BRICK_FENCE(5286, Fence.class), - /** - * BlockData: {@link Stairs} - */ - NETHER_BRICK_STAIRS(12085, Stairs.class), - SCULK(17870), - /** - * BlockData: {@link SculkVein} - */ - SCULK_VEIN(11615, SculkVein.class), - /** - * BlockData: {@link SculkCatalyst} - */ - SCULK_CATALYST(12017, SculkCatalyst.class), - /** - * BlockData: {@link SculkShrieker} - */ - SCULK_SHRIEKER(20985, SculkShrieker.class), - ENCHANTING_TABLE(16255), - /** - * BlockData: {@link EndPortalFrame} - */ - END_PORTAL_FRAME(15480, EndPortalFrame.class), - END_STONE(29686), - END_STONE_BRICKS(20314), - DRAGON_EGG(29946), - /** - * BlockData: {@link Stairs} - */ - SANDSTONE_STAIRS(18474, Stairs.class), - /** - * BlockData: {@link EnderChest} - */ - ENDER_CHEST(32349, EnderChest.class), - EMERALD_BLOCK(9914), - /** - * BlockData: {@link Stairs} - */ - OAK_STAIRS(5449, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - SPRUCE_STAIRS(11192, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - BIRCH_STAIRS(7657, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - JUNGLE_STAIRS(20636, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - ACACIA_STAIRS(17453, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - CHERRY_STAIRS(18380, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - DARK_OAK_STAIRS(22921, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - PALE_OAK_STAIRS(20755, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - MANGROVE_STAIRS(27641, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - BAMBOO_STAIRS(25674, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - BAMBOO_MOSAIC_STAIRS(20977, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - CRIMSON_STAIRS(32442, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - WARPED_STAIRS(17721, Stairs.class), - /** - * BlockData: {@link CommandBlock} - */ - COMMAND_BLOCK(4355, CommandBlock.class), - BEACON(6608), - /** - * BlockData: {@link Wall} - */ - COBBLESTONE_WALL(12616, Wall.class), - /** - * BlockData: {@link Wall} - */ - MOSSY_COBBLESTONE_WALL(11536, Wall.class), - /** - * BlockData: {@link Wall} - */ - BRICK_WALL(18995, Wall.class), - /** - * BlockData: {@link Wall} - */ - PRISMARINE_WALL(18184, Wall.class), - /** - * BlockData: {@link Wall} - */ - RED_SANDSTONE_WALL(4753, Wall.class), - /** - * BlockData: {@link Wall} - */ - MOSSY_STONE_BRICK_WALL(18259, Wall.class), - /** - * BlockData: {@link Wall} - */ - GRANITE_WALL(23279, Wall.class), - /** - * BlockData: {@link Wall} - */ - STONE_BRICK_WALL(29073, Wall.class), - /** - * BlockData: {@link Wall} - */ - MUD_BRICK_WALL(18292, Wall.class), - /** - * BlockData: {@link Wall} - */ - NETHER_BRICK_WALL(10398, Wall.class), - /** - * BlockData: {@link Wall} - */ - ANDESITE_WALL(14938, Wall.class), - /** - * BlockData: {@link Wall} - */ - RED_NETHER_BRICK_WALL(4580, Wall.class), - /** - * BlockData: {@link Wall} - */ - SANDSTONE_WALL(18470, Wall.class), - /** - * BlockData: {@link Wall} - */ - END_STONE_BRICK_WALL(27225, Wall.class), - /** - * BlockData: {@link Wall} - */ - DIORITE_WALL(17412, Wall.class), - /** - * BlockData: {@link Wall} - */ - BLACKSTONE_WALL(17327, Wall.class), - /** - * BlockData: {@link Wall} - */ - POLISHED_BLACKSTONE_WALL(15119, Wall.class), - /** - * BlockData: {@link Wall} - */ - POLISHED_BLACKSTONE_BRICK_WALL(9540, Wall.class), - /** - * BlockData: {@link Wall} - */ - COBBLED_DEEPSLATE_WALL(21893, Wall.class), - /** - * BlockData: {@link Wall} - */ - POLISHED_DEEPSLATE_WALL(6574, Wall.class), - /** - * BlockData: {@link Wall} - */ - DEEPSLATE_BRICK_WALL(13304, Wall.class), - /** - * BlockData: {@link Wall} - */ - DEEPSLATE_TILE_WALL(17077, Wall.class), - /** - * BlockData: {@link Directional} - */ - ANVIL(18718, Directional.class), - /** - * BlockData: {@link Directional} - */ - CHIPPED_ANVIL(10623, Directional.class), - /** - * BlockData: {@link Directional} - */ - DAMAGED_ANVIL(10274, Directional.class), - CHISELED_QUARTZ_BLOCK(30964), - QUARTZ_BLOCK(11987), - QUARTZ_BRICKS(23358), - /** - * BlockData: {@link Orientable} - */ - QUARTZ_PILLAR(16452, Orientable.class), - /** - * BlockData: {@link Stairs} - */ - QUARTZ_STAIRS(24079, Stairs.class), - WHITE_TERRACOTTA(20975), - ORANGE_TERRACOTTA(18684), - MAGENTA_TERRACOTTA(25900), - LIGHT_BLUE_TERRACOTTA(31779), - YELLOW_TERRACOTTA(32129), - LIME_TERRACOTTA(24013), - PINK_TERRACOTTA(23727), - GRAY_TERRACOTTA(18004), - LIGHT_GRAY_TERRACOTTA(26388), - CYAN_TERRACOTTA(25940), - PURPLE_TERRACOTTA(10387), - BLUE_TERRACOTTA(5236), - BROWN_TERRACOTTA(23664), - GREEN_TERRACOTTA(4105), - RED_TERRACOTTA(5086), - BLACK_TERRACOTTA(26691), - /** - * BlockData: {@link Waterlogged} - */ - BARRIER(26453, Waterlogged.class), - /** - * BlockData: {@link Light} - */ - LIGHT(17829, Light.class), - /** - * BlockData: {@link Orientable} - */ - HAY_BLOCK(17461, Orientable.class), - WHITE_CARPET(15117), - ORANGE_CARPET(24752), - MAGENTA_CARPET(6180), - LIGHT_BLUE_CARPET(21194), - YELLOW_CARPET(18149), - LIME_CARPET(15443), - PINK_CARPET(27381), - GRAY_CARPET(26991), - LIGHT_GRAY_CARPET(11317), - CYAN_CARPET(9742), - PURPLE_CARPET(5574), - BLUE_CARPET(13292), - BROWN_CARPET(23352), - GREEN_CARPET(7780), - RED_CARPET(5424), - BLACK_CARPET(6056), - TERRACOTTA(16544), - PACKED_ICE(28993), - DIRT_PATH(10846), - /** - * BlockData: {@link Bisected} - */ - SUNFLOWER(7408, Bisected.class), - /** - * BlockData: {@link Bisected} - */ - LILAC(22837, Bisected.class), - /** - * BlockData: {@link Bisected} - */ - ROSE_BUSH(6080, Bisected.class), - /** - * BlockData: {@link Bisected} - */ - PEONY(21155, Bisected.class), - /** - * BlockData: {@link Bisected} - */ - TALL_GRASS(21559, Bisected.class), - /** - * BlockData: {@link Bisected} - */ - LARGE_FERN(30177, Bisected.class), - WHITE_STAINED_GLASS(31190), - ORANGE_STAINED_GLASS(25142), - MAGENTA_STAINED_GLASS(26814), - LIGHT_BLUE_STAINED_GLASS(17162), - YELLOW_STAINED_GLASS(12182), - LIME_STAINED_GLASS(24266), - PINK_STAINED_GLASS(16164), - GRAY_STAINED_GLASS(29979), - LIGHT_GRAY_STAINED_GLASS(5843), - CYAN_STAINED_GLASS(30604), - PURPLE_STAINED_GLASS(21845), - BLUE_STAINED_GLASS(7107), - BROWN_STAINED_GLASS(20945), - GREEN_STAINED_GLASS(22503), - RED_STAINED_GLASS(9717), - BLACK_STAINED_GLASS(13941), - /** - * BlockData: {@link GlassPane} - */ - WHITE_STAINED_GLASS_PANE(10557, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - ORANGE_STAINED_GLASS_PANE(21089, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - MAGENTA_STAINED_GLASS_PANE(14082, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - LIGHT_BLUE_STAINED_GLASS_PANE(18721, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - YELLOW_STAINED_GLASS_PANE(20298, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - LIME_STAINED_GLASS_PANE(10610, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - PINK_STAINED_GLASS_PANE(24637, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - GRAY_STAINED_GLASS_PANE(25272, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - LIGHT_GRAY_STAINED_GLASS_PANE(19008, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - CYAN_STAINED_GLASS_PANE(11784, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - PURPLE_STAINED_GLASS_PANE(10948, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - BLUE_STAINED_GLASS_PANE(28484, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - BROWN_STAINED_GLASS_PANE(17557, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - GREEN_STAINED_GLASS_PANE(4767, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - RED_STAINED_GLASS_PANE(8630, GlassPane.class), - /** - * BlockData: {@link GlassPane} - */ - BLACK_STAINED_GLASS_PANE(13201, GlassPane.class), - PRISMARINE(7539), - PRISMARINE_BRICKS(29118), - DARK_PRISMARINE(19940), - /** - * BlockData: {@link Stairs} - */ - PRISMARINE_STAIRS(19217, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - PRISMARINE_BRICK_STAIRS(15445, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - DARK_PRISMARINE_STAIRS(26511, Stairs.class), - SEA_LANTERN(20780), - RED_SANDSTONE(9092), - CHISELED_RED_SANDSTONE(15529), - CUT_RED_SANDSTONE(29108), - /** - * BlockData: {@link Stairs} - */ - RED_SANDSTONE_STAIRS(25466, Stairs.class), - /** - * BlockData: {@link CommandBlock} - */ - REPEATING_COMMAND_BLOCK(12405, CommandBlock.class), - /** - * BlockData: {@link CommandBlock} - */ - CHAIN_COMMAND_BLOCK(26798, CommandBlock.class), - MAGMA_BLOCK(25927), - NETHER_WART_BLOCK(15486), - WARPED_WART_BLOCK(15463), - RED_NETHER_BRICKS(18056), - /** - * BlockData: {@link Orientable} - */ - BONE_BLOCK(17312, Orientable.class), - STRUCTURE_VOID(30806), - /** - * BlockData: {@link Directional} - */ - SHULKER_BOX(7776, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - WHITE_SHULKER_BOX(31750, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - ORANGE_SHULKER_BOX(21673, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - MAGENTA_SHULKER_BOX(21566, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_BLUE_SHULKER_BOX(18226, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - YELLOW_SHULKER_BOX(28700, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIME_SHULKER_BOX(28360, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - PINK_SHULKER_BOX(24968, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - GRAY_SHULKER_BOX(12754, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_GRAY_SHULKER_BOX(21345, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - CYAN_SHULKER_BOX(28123, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - PURPLE_SHULKER_BOX(10373, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLUE_SHULKER_BOX(11476, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - BROWN_SHULKER_BOX(24230, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - GREEN_SHULKER_BOX(9377, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - RED_SHULKER_BOX(32448, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLACK_SHULKER_BOX(24076, 1, Directional.class), - /** - * BlockData: {@link Directional} - */ - WHITE_GLAZED_TERRACOTTA(11326, Directional.class), - /** - * BlockData: {@link Directional} - */ - ORANGE_GLAZED_TERRACOTTA(27451, Directional.class), - /** - * BlockData: {@link Directional} - */ - MAGENTA_GLAZED_TERRACOTTA(8067, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_BLUE_GLAZED_TERRACOTTA(4336, Directional.class), - /** - * BlockData: {@link Directional} - */ - YELLOW_GLAZED_TERRACOTTA(10914, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIME_GLAZED_TERRACOTTA(13861, Directional.class), - /** - * BlockData: {@link Directional} - */ - PINK_GLAZED_TERRACOTTA(10260, Directional.class), - /** - * BlockData: {@link Directional} - */ - GRAY_GLAZED_TERRACOTTA(6256, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_GRAY_GLAZED_TERRACOTTA(10707, Directional.class), - /** - * BlockData: {@link Directional} - */ - CYAN_GLAZED_TERRACOTTA(9550, Directional.class), - /** - * BlockData: {@link Directional} - */ - PURPLE_GLAZED_TERRACOTTA(4818, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLUE_GLAZED_TERRACOTTA(23823, Directional.class), - /** - * BlockData: {@link Directional} - */ - BROWN_GLAZED_TERRACOTTA(5655, Directional.class), - /** - * BlockData: {@link Directional} - */ - GREEN_GLAZED_TERRACOTTA(6958, Directional.class), - /** - * BlockData: {@link Directional} - */ - RED_GLAZED_TERRACOTTA(24989, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLACK_GLAZED_TERRACOTTA(29678, Directional.class), - WHITE_CONCRETE(6281), - ORANGE_CONCRETE(19914), - MAGENTA_CONCRETE(20591), - LIGHT_BLUE_CONCRETE(29481), - YELLOW_CONCRETE(15722), - LIME_CONCRETE(5863), - PINK_CONCRETE(5227), - GRAY_CONCRETE(13959), - LIGHT_GRAY_CONCRETE(14453), - CYAN_CONCRETE(26522), - PURPLE_CONCRETE(20623), - BLUE_CONCRETE(18756), - BROWN_CONCRETE(19006), - GREEN_CONCRETE(17949), - RED_CONCRETE(8032), - BLACK_CONCRETE(13338), - WHITE_CONCRETE_POWDER(10363), - ORANGE_CONCRETE_POWDER(30159), - MAGENTA_CONCRETE_POWDER(8272), - LIGHT_BLUE_CONCRETE_POWDER(31206), - YELLOW_CONCRETE_POWDER(10655), - LIME_CONCRETE_POWDER(28859), - PINK_CONCRETE_POWDER(6421), - GRAY_CONCRETE_POWDER(13031), - LIGHT_GRAY_CONCRETE_POWDER(21589), - CYAN_CONCRETE_POWDER(15734), - PURPLE_CONCRETE_POWDER(26808), - BLUE_CONCRETE_POWDER(17773), - BROWN_CONCRETE_POWDER(21485), - GREEN_CONCRETE_POWDER(6904), - RED_CONCRETE_POWDER(13286), - BLACK_CONCRETE_POWDER(16150), - /** - * BlockData: {@link TurtleEgg} - */ - TURTLE_EGG(32101, TurtleEgg.class), - /** - * BlockData: {@link Hatchable} - */ - SNIFFER_EGG(12980, Hatchable.class), - DEAD_TUBE_CORAL_BLOCK(28350), - DEAD_BRAIN_CORAL_BLOCK(12979), - DEAD_BUBBLE_CORAL_BLOCK(28220), - DEAD_FIRE_CORAL_BLOCK(5307), - DEAD_HORN_CORAL_BLOCK(15103), - TUBE_CORAL_BLOCK(23723), - BRAIN_CORAL_BLOCK(30618), - BUBBLE_CORAL_BLOCK(15437), - FIRE_CORAL_BLOCK(12119), - HORN_CORAL_BLOCK(19958), - /** - * BlockData: {@link Waterlogged} - */ - TUBE_CORAL(23048, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - BRAIN_CORAL(31316, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - BUBBLE_CORAL(12464, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - FIRE_CORAL(29151, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - HORN_CORAL(19511, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_BRAIN_CORAL(9116, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_BUBBLE_CORAL(30583, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_FIRE_CORAL(8365, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_HORN_CORAL(5755, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_TUBE_CORAL(18028, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - TUBE_CORAL_FAN(19929, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - BRAIN_CORAL_FAN(13849, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - BUBBLE_CORAL_FAN(10795, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - FIRE_CORAL_FAN(11112, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - HORN_CORAL_FAN(13610, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_TUBE_CORAL_FAN(17628, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_BRAIN_CORAL_FAN(26150, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_BUBBLE_CORAL_FAN(17322, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_FIRE_CORAL_FAN(27073, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - DEAD_HORN_CORAL_FAN(11387, Waterlogged.class), - BLUE_ICE(22449), - /** - * BlockData: {@link Waterlogged} - */ - CONDUIT(5148, Waterlogged.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_GRANITE_STAIRS(29588, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - SMOOTH_RED_SANDSTONE_STAIRS(17561, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - MOSSY_STONE_BRICK_STAIRS(27578, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_DIORITE_STAIRS(4625, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - MOSSY_COBBLESTONE_STAIRS(29210, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - END_STONE_BRICK_STAIRS(28831, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - STONE_STAIRS(23784, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - SMOOTH_SANDSTONE_STAIRS(21183, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - SMOOTH_QUARTZ_STAIRS(19560, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - GRANITE_STAIRS(21840, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - ANDESITE_STAIRS(17747, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - RED_NETHER_BRICK_STAIRS(26374, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_ANDESITE_STAIRS(7573, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - DIORITE_STAIRS(13134, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - COBBLED_DEEPSLATE_STAIRS(20699, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_DEEPSLATE_STAIRS(19513, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - DEEPSLATE_BRICK_STAIRS(29624, Stairs.class), - /** - * BlockData: {@link Stairs} - */ - DEEPSLATE_TILE_STAIRS(6361, Stairs.class), - /** - * BlockData: {@link Slab} - */ - POLISHED_GRANITE_SLAB(4521, Slab.class), - /** - * BlockData: {@link Slab} - */ - SMOOTH_RED_SANDSTONE_SLAB(16304, Slab.class), - /** - * BlockData: {@link Slab} - */ - MOSSY_STONE_BRICK_SLAB(14002, Slab.class), - /** - * BlockData: {@link Slab} - */ - POLISHED_DIORITE_SLAB(18303, Slab.class), - /** - * BlockData: {@link Slab} - */ - MOSSY_COBBLESTONE_SLAB(12139, Slab.class), - /** - * BlockData: {@link Slab} - */ - END_STONE_BRICK_SLAB(23239, Slab.class), - /** - * BlockData: {@link Slab} - */ - SMOOTH_SANDSTONE_SLAB(9030, Slab.class), - /** - * BlockData: {@link Slab} - */ - SMOOTH_QUARTZ_SLAB(26543, Slab.class), - /** - * BlockData: {@link Slab} - */ - GRANITE_SLAB(10901, Slab.class), - /** - * BlockData: {@link Slab} - */ - ANDESITE_SLAB(32124, Slab.class), - /** - * BlockData: {@link Slab} - */ - RED_NETHER_BRICK_SLAB(12462, Slab.class), - /** - * BlockData: {@link Slab} - */ - POLISHED_ANDESITE_SLAB(24573, Slab.class), - /** - * BlockData: {@link Slab} - */ - DIORITE_SLAB(25526, Slab.class), - /** - * BlockData: {@link Slab} - */ - COBBLED_DEEPSLATE_SLAB(17388, Slab.class), - /** - * BlockData: {@link Slab} - */ - POLISHED_DEEPSLATE_SLAB(32201, Slab.class), - /** - * BlockData: {@link Slab} - */ - DEEPSLATE_BRICK_SLAB(23910, Slab.class), - /** - * BlockData: {@link Slab} - */ - DEEPSLATE_TILE_SLAB(13315, Slab.class), - /** - * BlockData: {@link Scaffolding} - */ - SCAFFOLDING(15757, Scaffolding.class), - REDSTONE(11233), - /** - * BlockData: {@link Lightable} - */ - REDSTONE_TORCH(22547, Lightable.class), - REDSTONE_BLOCK(19496), - /** - * BlockData: {@link Repeater} - */ - REPEATER(28823, Repeater.class), - /** - * BlockData: {@link Comparator} - */ - COMPARATOR(18911, Comparator.class), - /** - * BlockData: {@link Piston} - */ - PISTON(21130, Piston.class), - /** - * BlockData: {@link Piston} - */ - STICKY_PISTON(18127, Piston.class), - SLIME_BLOCK(31892), - HONEY_BLOCK(30615), - /** - * BlockData: {@link Observer} - */ - OBSERVER(10726, Observer.class), - /** - * BlockData: {@link Hopper} - */ - HOPPER(31974, Hopper.class), - /** - * BlockData: {@link Dispenser} - */ - DISPENSER(20871, Dispenser.class), - /** - * BlockData: {@link Dispenser} - */ - DROPPER(31273, Dispenser.class), - /** - * BlockData: {@link Lectern} - */ - LECTERN(23490, Lectern.class), - /** - * BlockData: {@link AnaloguePowerable} - */ - TARGET(22637, AnaloguePowerable.class), - /** - * BlockData: {@link Switch} - */ - LEVER(15319, Switch.class), - /** - * BlockData: {@link LightningRod} - */ - LIGHTNING_ROD(30770, LightningRod.class), - /** - * BlockData: {@link DaylightDetector} - */ - DAYLIGHT_DETECTOR(8864, DaylightDetector.class), - /** - * BlockData: {@link SculkSensor} - */ - SCULK_SENSOR(5598, SculkSensor.class), - /** - * BlockData: {@link CalibratedSculkSensor} - */ - CALIBRATED_SCULK_SENSOR(21034, CalibratedSculkSensor.class), - /** - * BlockData: {@link TripwireHook} - */ - TRIPWIRE_HOOK(8130, TripwireHook.class), - /** - * BlockData: {@link Chest} - */ - TRAPPED_CHEST(18970, Chest.class), - /** - * BlockData: {@link TNT} - */ - TNT(7896, TNT.class), - /** - * BlockData: {@link Lightable} - */ - REDSTONE_LAMP(8217, Lightable.class), - /** - * BlockData: {@link NoteBlock} - */ - NOTE_BLOCK(20979, NoteBlock.class), - /** - * BlockData: {@link Switch} - */ - STONE_BUTTON(12279, Switch.class), - /** - * BlockData: {@link Switch} - */ - POLISHED_BLACKSTONE_BUTTON(20760, Switch.class), - /** - * BlockData: {@link Switch} - */ - OAK_BUTTON(13510, Switch.class), - /** - * BlockData: {@link Switch} - */ - SPRUCE_BUTTON(23281, Switch.class), - /** - * BlockData: {@link Switch} - */ - BIRCH_BUTTON(26934, Switch.class), - /** - * BlockData: {@link Switch} - */ - JUNGLE_BUTTON(25317, Switch.class), - /** - * BlockData: {@link Switch} - */ - ACACIA_BUTTON(13993, Switch.class), - /** - * BlockData: {@link Switch} - */ - CHERRY_BUTTON(9058, Switch.class), - /** - * BlockData: {@link Switch} - */ - DARK_OAK_BUTTON(6214, Switch.class), - /** - * BlockData: {@link Switch} - */ - PALE_OAK_BUTTON(5238, Switch.class), - /** - * BlockData: {@link Switch} - */ - MANGROVE_BUTTON(9838, Switch.class), - /** - * BlockData: {@link Switch} - */ - BAMBOO_BUTTON(21810, Switch.class), - /** - * BlockData: {@link Switch} - */ - CRIMSON_BUTTON(26799, Switch.class), - /** - * BlockData: {@link Switch} - */ - WARPED_BUTTON(25264, Switch.class), - /** - * BlockData: {@link Powerable} - */ - STONE_PRESSURE_PLATE(22591, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - POLISHED_BLACKSTONE_PRESSURE_PLATE(32340, Powerable.class), - /** - * BlockData: {@link AnaloguePowerable} - */ - LIGHT_WEIGHTED_PRESSURE_PLATE(14875, AnaloguePowerable.class), - /** - * BlockData: {@link AnaloguePowerable} - */ - HEAVY_WEIGHTED_PRESSURE_PLATE(16970, AnaloguePowerable.class), - /** - * BlockData: {@link Powerable} - */ - OAK_PRESSURE_PLATE(20108, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - SPRUCE_PRESSURE_PLATE(15932, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - BIRCH_PRESSURE_PLATE(9664, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - JUNGLE_PRESSURE_PLATE(11376, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - ACACIA_PRESSURE_PLATE(17586, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - CHERRY_PRESSURE_PLATE(8651, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - DARK_OAK_PRESSURE_PLATE(31375, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - PALE_OAK_PRESSURE_PLATE(30527, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - MANGROVE_PRESSURE_PLATE(9748, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - BAMBOO_PRESSURE_PLATE(26740, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - CRIMSON_PRESSURE_PLATE(18316, Powerable.class), - /** - * BlockData: {@link Powerable} - */ - WARPED_PRESSURE_PLATE(29516, Powerable.class), - /** - * BlockData: {@link Door} - */ - IRON_DOOR(4788, Door.class), - /** - * BlockData: {@link Door} - */ - OAK_DOOR(20341, Door.class), - /** - * BlockData: {@link Door} - */ - SPRUCE_DOOR(10642, Door.class), - /** - * BlockData: {@link Door} - */ - BIRCH_DOOR(14759, Door.class), - /** - * BlockData: {@link Door} - */ - JUNGLE_DOOR(28163, Door.class), - /** - * BlockData: {@link Door} - */ - ACACIA_DOOR(23797, Door.class), - /** - * BlockData: {@link Door} - */ - CHERRY_DOOR(12684, Door.class), - /** - * BlockData: {@link Door} - */ - DARK_OAK_DOOR(10669, Door.class), - /** - * BlockData: {@link Door} - */ - PALE_OAK_DOOR(23817, Door.class), - /** - * BlockData: {@link Door} - */ - MANGROVE_DOOR(18964, Door.class), - /** - * BlockData: {@link Door} - */ - BAMBOO_DOOR(19971, Door.class), - /** - * BlockData: {@link Door} - */ - CRIMSON_DOOR(19544, Door.class), - /** - * BlockData: {@link Door} - */ - WARPED_DOOR(15062, Door.class), - /** - * BlockData: {@link Door} - */ - COPPER_DOOR(26809, Door.class), - /** - * BlockData: {@link Door} - */ - EXPOSED_COPPER_DOOR(13236, Door.class), - /** - * BlockData: {@link Door} - */ - WEATHERED_COPPER_DOOR(10208, Door.class), - /** - * BlockData: {@link Door} - */ - OXIDIZED_COPPER_DOOR(5348, Door.class), - /** - * BlockData: {@link Door} - */ - WAXED_COPPER_DOOR(9954, Door.class), - /** - * BlockData: {@link Door} - */ - WAXED_EXPOSED_COPPER_DOOR(20748, Door.class), - /** - * BlockData: {@link Door} - */ - WAXED_WEATHERED_COPPER_DOOR(25073, Door.class), - /** - * BlockData: {@link Door} - */ - WAXED_OXIDIZED_COPPER_DOOR(23888, Door.class), - /** - * BlockData: {@link TrapDoor} - */ - IRON_TRAPDOOR(17095, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - OAK_TRAPDOOR(16927, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - SPRUCE_TRAPDOOR(10289, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - BIRCH_TRAPDOOR(32585, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - JUNGLE_TRAPDOOR(8626, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - ACACIA_TRAPDOOR(18343, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - CHERRY_TRAPDOOR(6293, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - DARK_OAK_TRAPDOOR(10355, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - PALE_OAK_TRAPDOOR(20647, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - MANGROVE_TRAPDOOR(17066, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - BAMBOO_TRAPDOOR(9174, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - CRIMSON_TRAPDOOR(25056, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WARPED_TRAPDOOR(7708, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - COPPER_TRAPDOOR(12110, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - EXPOSED_COPPER_TRAPDOOR(19219, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WEATHERED_COPPER_TRAPDOOR(28254, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - OXIDIZED_COPPER_TRAPDOOR(26518, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WAXED_COPPER_TRAPDOOR(12626, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WAXED_EXPOSED_COPPER_TRAPDOOR(11010, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WAXED_WEATHERED_COPPER_TRAPDOOR(30709, TrapDoor.class), - /** - * BlockData: {@link TrapDoor} - */ - WAXED_OXIDIZED_COPPER_TRAPDOOR(21450, TrapDoor.class), - /** - * BlockData: {@link Gate} - */ - OAK_FENCE_GATE(16689, Gate.class), - /** - * BlockData: {@link Gate} - */ - SPRUCE_FENCE_GATE(26423, Gate.class), - /** - * BlockData: {@link Gate} - */ - BIRCH_FENCE_GATE(6322, Gate.class), - /** - * BlockData: {@link Gate} - */ - JUNGLE_FENCE_GATE(21360, Gate.class), - /** - * BlockData: {@link Gate} - */ - ACACIA_FENCE_GATE(14145, Gate.class), - /** - * BlockData: {@link Gate} - */ - CHERRY_FENCE_GATE(28222, Gate.class), - /** - * BlockData: {@link Gate} - */ - DARK_OAK_FENCE_GATE(10679, Gate.class), - /** - * BlockData: {@link Gate} - */ - PALE_OAK_FENCE_GATE(21221, Gate.class), - /** - * BlockData: {@link Gate} - */ - MANGROVE_FENCE_GATE(28476, Gate.class), - /** - * BlockData: {@link Gate} - */ - BAMBOO_FENCE_GATE(14290, Gate.class), - /** - * BlockData: {@link Gate} - */ - CRIMSON_FENCE_GATE(15602, Gate.class), - /** - * BlockData: {@link Gate} - */ - WARPED_FENCE_GATE(11115, Gate.class), - /** - * BlockData: {@link RedstoneRail} - */ - POWERED_RAIL(11064, RedstoneRail.class), - /** - * BlockData: {@link RedstoneRail} - */ - DETECTOR_RAIL(13475, RedstoneRail.class), - /** - * BlockData: {@link Rail} - */ - RAIL(13285, Rail.class), - /** - * BlockData: {@link RedstoneRail} - */ - ACTIVATOR_RAIL(5834, RedstoneRail.class), - SADDLE(30206, 1), - MINECART(14352, 1), - CHEST_MINECART(4497, 1), - FURNACE_MINECART(14196, 1), - TNT_MINECART(4277, 1), - HOPPER_MINECART(19024, 1), - CARROT_ON_A_STICK(27809, 1, 25), - WARPED_FUNGUS_ON_A_STICK(11706, 1, 100), - PHANTOM_MEMBRANE(18398), - ELYTRA(23829, 1, 432), - OAK_BOAT(17570, 1), - OAK_CHEST_BOAT(7765, 1), - SPRUCE_BOAT(31427, 1), - SPRUCE_CHEST_BOAT(30841, 1), - BIRCH_BOAT(28104, 1), - BIRCH_CHEST_BOAT(18546, 1), - JUNGLE_BOAT(4495, 1), - JUNGLE_CHEST_BOAT(20133, 1), - ACACIA_BOAT(27326, 1), - ACACIA_CHEST_BOAT(28455, 1), - CHERRY_BOAT(13628, 1), - CHERRY_CHEST_BOAT(7165, 1), - DARK_OAK_BOAT(28618, 1), - DARK_OAK_CHEST_BOAT(8733, 1), - PALE_OAK_BOAT(18534, 1), - PALE_OAK_CHEST_BOAT(26297, 1), - MANGROVE_BOAT(20792, 1), - MANGROVE_CHEST_BOAT(18572, 1), - BAMBOO_RAFT(25901, 1), - BAMBOO_CHEST_RAFT(20056, 1), - /** - * BlockData: {@link StructureBlock} - */ - STRUCTURE_BLOCK(26831, StructureBlock.class), - /** - * BlockData: {@link Jigsaw} - */ - JIGSAW(17398, Jigsaw.class), - TURTLE_HELMET(30120, 1, 275), - TURTLE_SCUTE(6766), - ARMADILLO_SCUTE(11497), - WOLF_ARMOR(17138, 1, 64), - FLINT_AND_STEEL(28620, 1, 64), - BOWL(32661), - APPLE(7720), - BOW(8745, 1, 384), - ARROW(31091), - COAL(29067), - CHARCOAL(5390), - DIAMOND(20865), - EMERALD(5654), - LAPIS_LAZULI(11075), - QUARTZ(23608), - AMETHYST_SHARD(7613), - RAW_IRON(5329), - IRON_INGOT(24895), - RAW_COPPER(6162), - COPPER_INGOT(12611), - RAW_GOLD(19564), - GOLD_INGOT(28927), - NETHERITE_INGOT(32457), - NETHERITE_SCRAP(29331), - WOODEN_SWORD(7175, 1, 59), - WOODEN_SHOVEL(28432, 1, 59), - WOODEN_PICKAXE(12792, 1, 59), - WOODEN_AXE(6292, 1, 59), - WOODEN_HOE(16043, 1, 59), - STONE_SWORD(25084, 1, 131), - STONE_SHOVEL(9520, 1, 131), - STONE_PICKAXE(14611, 1, 131), - STONE_AXE(6338, 1, 131), - STONE_HOE(22855, 1, 131), - GOLDEN_SWORD(10505, 1, 32), - GOLDEN_SHOVEL(15597, 1, 32), - GOLDEN_PICKAXE(25898, 1, 32), - GOLDEN_AXE(4878, 1, 32), - GOLDEN_HOE(19337, 1, 32), - IRON_SWORD(10904, 1, 250), - IRON_SHOVEL(30045, 1, 250), - IRON_PICKAXE(8842, 1, 250), - IRON_AXE(15894, 1, 250), - IRON_HOE(11339, 1, 250), - DIAMOND_SWORD(27707, 1, 1561), - DIAMOND_SHOVEL(25415, 1, 1561), - DIAMOND_PICKAXE(24291, 1, 1561), - DIAMOND_AXE(27277, 1, 1561), - DIAMOND_HOE(24050, 1, 1561), - NETHERITE_SWORD(23871, 1, 2031), - NETHERITE_SHOVEL(29728, 1, 2031), - NETHERITE_PICKAXE(9930, 1, 2031), - NETHERITE_AXE(29533, 1, 2031), - NETHERITE_HOE(27385, 1, 2031), - STICK(9773), - MUSHROOM_STEW(16336, 1), - STRING(12806), - FEATHER(30548), - GUNPOWDER(29974), - WHEAT_SEEDS(28742), - /** - * BlockData: {@link Ageable} - */ - WHEAT(27709, Ageable.class), - BREAD(32049), - LEATHER_HELMET(11624, 1, 55), - LEATHER_CHESTPLATE(29275, 1, 80), - LEATHER_LEGGINGS(28210, 1, 75), - LEATHER_BOOTS(15282, 1, 65), - CHAINMAIL_HELMET(26114, 1, 165), - CHAINMAIL_CHESTPLATE(23602, 1, 240), - CHAINMAIL_LEGGINGS(19087, 1, 225), - CHAINMAIL_BOOTS(17953, 1, 195), - IRON_HELMET(12025, 1, 165), - IRON_CHESTPLATE(28112, 1, 240), - IRON_LEGGINGS(18951, 1, 225), - IRON_BOOTS(8531, 1, 195), - DIAMOND_HELMET(10755, 1, 363), - DIAMOND_CHESTPLATE(32099, 1, 528), - DIAMOND_LEGGINGS(26500, 1, 495), - DIAMOND_BOOTS(16522, 1, 429), - GOLDEN_HELMET(7945, 1, 77), - GOLDEN_CHESTPLATE(4507, 1, 112), - GOLDEN_LEGGINGS(21002, 1, 105), - GOLDEN_BOOTS(7859, 1, 91), - NETHERITE_HELMET(15907, 1, 407), - NETHERITE_CHESTPLATE(6106, 1, 592), - NETHERITE_LEGGINGS(25605, 1, 555), - NETHERITE_BOOTS(8923, 1, 481), - FLINT(23596), - PORKCHOP(30896), - COOKED_PORKCHOP(27231), - PAINTING(23945), - GOLDEN_APPLE(27732), - ENCHANTED_GOLDEN_APPLE(8280), - /** - * BlockData: {@link Sign} - */ - OAK_SIGN(8192, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - SPRUCE_SIGN(21502, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - BIRCH_SIGN(11351, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - JUNGLE_SIGN(24717, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - ACACIA_SIGN(29808, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - CHERRY_SIGN(16520, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - DARK_OAK_SIGN(15127, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - PALE_OAK_SIGN(12116, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - MANGROVE_SIGN(21975, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - BAMBOO_SIGN(26139, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - CRIMSON_SIGN(12162, 16, Sign.class), - /** - * BlockData: {@link Sign} - */ - WARPED_SIGN(10407, 16, Sign.class), - /** - * BlockData: {@link HangingSign} - */ - OAK_HANGING_SIGN(20116, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - SPRUCE_HANGING_SIGN(24371, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - BIRCH_HANGING_SIGN(17938, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - JUNGLE_HANGING_SIGN(27671, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - ACACIA_HANGING_SIGN(30257, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - CHERRY_HANGING_SIGN(5088, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - DARK_OAK_HANGING_SIGN(23360, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - PALE_OAK_HANGING_SIGN(7097, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - MANGROVE_HANGING_SIGN(25106, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - BAMBOO_HANGING_SIGN(4726, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - CRIMSON_HANGING_SIGN(20696, 16, HangingSign.class), - /** - * BlockData: {@link HangingSign} - */ - WARPED_HANGING_SIGN(8195, 16, HangingSign.class), - BUCKET(15215, 16), - WATER_BUCKET(8802, 1), - LAVA_BUCKET(9228, 1), - POWDER_SNOW_BUCKET(31101, 1), - SNOWBALL(19487, 16), - LEATHER(16414), - MILK_BUCKET(9680, 1), - PUFFERFISH_BUCKET(8861, 1), - SALMON_BUCKET(9606, 1), - COD_BUCKET(28601, 1), - TROPICAL_FISH_BUCKET(29995, 1), - AXOLOTL_BUCKET(20669, 1), - TADPOLE_BUCKET(9731, 1), - BRICK(6820), - CLAY_BALL(24603), - DRIED_KELP_BLOCK(12966), - PAPER(9923), - BOOK(23097), - SLIME_BALL(5242), - EGG(21603, 16), - COMPASS(24139), - RECOVERY_COMPASS(12710), - BUNDLE(16835, 1), - WHITE_BUNDLE(12072, 1), - ORANGE_BUNDLE(18288, 1), - MAGENTA_BUNDLE(15328, 1), - LIGHT_BLUE_BUNDLE(18639, 1), - YELLOW_BUNDLE(27749, 1), - LIME_BUNDLE(30093, 1), - PINK_BUNDLE(21400, 1), - GRAY_BUNDLE(21262, 1), - LIGHT_GRAY_BUNDLE(26338, 1), - CYAN_BUNDLE(8942, 1), - PURPLE_BUNDLE(10319, 1), - BLUE_BUNDLE(31501, 1), - BROWN_BUNDLE(15464, 1), - GREEN_BUNDLE(4597, 1), - RED_BUNDLE(19986, 1), - BLACK_BUNDLE(22519, 1), - FISHING_ROD(4167, 1, 64), - CLOCK(14980), - SPYGLASS(27490, 1), - GLOWSTONE_DUST(6665), - COD(24691), - SALMON(18516), - TROPICAL_FISH(24879), - PUFFERFISH(8115), - COOKED_COD(9681), - COOKED_SALMON(5615), - INK_SAC(7184), - GLOW_INK_SAC(9686), - COCOA_BEANS(30186), - WHITE_DYE(10758), - ORANGE_DYE(13866), - MAGENTA_DYE(11788), - LIGHT_BLUE_DYE(28738), - YELLOW_DYE(5952), - LIME_DYE(6147), - PINK_DYE(31151), - GRAY_DYE(9184), - LIGHT_GRAY_DYE(27643), - CYAN_DYE(8043), - PURPLE_DYE(6347), - BLUE_DYE(11588), - BROWN_DYE(7648), - GREEN_DYE(23215), - RED_DYE(5728), - BLACK_DYE(6202), - BONE_MEAL(32458), - BONE(5686), - SUGAR(30638), - /** - * BlockData: {@link Cake} - */ - CAKE(27048, 1, Cake.class), - /** - * BlockData: {@link Bed} - */ - WHITE_BED(8185, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - ORANGE_BED(11194, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - MAGENTA_BED(20061, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - LIGHT_BLUE_BED(20957, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - YELLOW_BED(30410, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - LIME_BED(27860, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - PINK_BED(13795, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - GRAY_BED(15745, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - LIGHT_GRAY_BED(5090, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - CYAN_BED(16746, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - PURPLE_BED(29755, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - BLUE_BED(12714, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - BROWN_BED(26672, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - GREEN_BED(13797, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - RED_BED(30910, 1, Bed.class), - /** - * BlockData: {@link Bed} - */ - BLACK_BED(20490, 1, Bed.class), - COOKIE(27431), - /** - * BlockData: {@link Crafter} - */ - CRAFTER(25243, Crafter.class), - FILLED_MAP(23504), - SHEARS(27971, 1, 238), - MELON_SLICE(5347), - DRIED_KELP(21042), - PUMPKIN_SEEDS(28985), - MELON_SEEDS(18340), - BEEF(4803), - COOKED_BEEF(21595), - CHICKEN(17281), - COOKED_CHICKEN(16984), - ROTTEN_FLESH(21591), - ENDER_PEARL(5259, 16), - BLAZE_ROD(8289), - GHAST_TEAR(18222), - GOLD_NUGGET(28814), - /** - * BlockData: {@link Ageable} - */ - NETHER_WART(29227, Ageable.class), - GLASS_BOTTLE(6116), - POTION(24020, 1), - SPIDER_EYE(9318), - FERMENTED_SPIDER_EYE(19386), - BLAZE_POWDER(18941), - MAGMA_CREAM(25097), - /** - * BlockData: {@link BrewingStand} - */ - BREWING_STAND(14539, BrewingStand.class), - CAULDRON(26531), - ENDER_EYE(24860), - GLISTERING_MELON_SLICE(20158), - ARMADILLO_SPAWN_EGG(22098), - ALLAY_SPAWN_EGG(7909), - AXOLOTL_SPAWN_EGG(30381), - BAT_SPAWN_EGG(14607), - BEE_SPAWN_EGG(22924), - BLAZE_SPAWN_EGG(4759), - BOGGED_SPAWN_EGG(12042), - BREEZE_SPAWN_EGG(7580), - CAT_SPAWN_EGG(29583), - CAMEL_SPAWN_EGG(14760), - CAVE_SPIDER_SPAWN_EGG(23341), - CHICKEN_SPAWN_EGG(5462), - COD_SPAWN_EGG(27248), - COW_SPAWN_EGG(14761), - CREEPER_SPAWN_EGG(9653), - DOLPHIN_SPAWN_EGG(20787), - DONKEY_SPAWN_EGG(14513), - DROWNED_SPAWN_EGG(19368), - ELDER_GUARDIAN_SPAWN_EGG(11418), - ENDER_DRAGON_SPAWN_EGG(28092), - ENDERMAN_SPAWN_EGG(29488), - ENDERMITE_SPAWN_EGG(16617), - EVOKER_SPAWN_EGG(21271), - FOX_SPAWN_EGG(22376), - FROG_SPAWN_EGG(26682), - GHAST_SPAWN_EGG(9970), - GLOW_SQUID_SPAWN_EGG(31578), - GOAT_SPAWN_EGG(30639), - GUARDIAN_SPAWN_EGG(20113), - HOGLIN_SPAWN_EGG(14088), - HORSE_SPAWN_EGG(25981), - HUSK_SPAWN_EGG(20178), - IRON_GOLEM_SPAWN_EGG(12781), - LLAMA_SPAWN_EGG(23640), - MAGMA_CUBE_SPAWN_EGG(26638), - MOOSHROOM_SPAWN_EGG(22125), - MULE_SPAWN_EGG(11229), - OCELOT_SPAWN_EGG(30080), - PANDA_SPAWN_EGG(23759), - PARROT_SPAWN_EGG(23614), - PHANTOM_SPAWN_EGG(24648), - PIG_SPAWN_EGG(22584), - PIGLIN_SPAWN_EGG(16193), - PIGLIN_BRUTE_SPAWN_EGG(30230), - PILLAGER_SPAWN_EGG(28659), - POLAR_BEAR_SPAWN_EGG(17015), - PUFFERFISH_SPAWN_EGG(24570), - RABBIT_SPAWN_EGG(26496), - RAVAGER_SPAWN_EGG(8726), - SALMON_SPAWN_EGG(18739), - SHEEP_SPAWN_EGG(24488), - SHULKER_SPAWN_EGG(31848), - SILVERFISH_SPAWN_EGG(14537), - SKELETON_SPAWN_EGG(15261), - SKELETON_HORSE_SPAWN_EGG(21356), - SLIME_SPAWN_EGG(17196), - SNIFFER_SPAWN_EGG(27473), - SNOW_GOLEM_SPAWN_EGG(24732), - SPIDER_SPAWN_EGG(14984), - SQUID_SPAWN_EGG(10682), - STRAY_SPAWN_EGG(30153), - STRIDER_SPAWN_EGG(6203), - TADPOLE_SPAWN_EGG(32467), - TRADER_LLAMA_SPAWN_EGG(8439), - TROPICAL_FISH_SPAWN_EGG(19713), - TURTLE_SPAWN_EGG(17324), - VEX_SPAWN_EGG(27751), - VILLAGER_SPAWN_EGG(30348), - VINDICATOR_SPAWN_EGG(25324), - WANDERING_TRADER_SPAWN_EGG(17904), - WARDEN_SPAWN_EGG(27553), - WITCH_SPAWN_EGG(11837), - WITHER_SPAWN_EGG(8024), - WITHER_SKELETON_SPAWN_EGG(10073), - WOLF_SPAWN_EGG(21692), - ZOGLIN_SPAWN_EGG(7442), - CREAKING_SPAWN_EGG(9598), - ZOMBIE_SPAWN_EGG(5814), - ZOMBIE_HORSE_SPAWN_EGG(4275), - ZOMBIE_VILLAGER_SPAWN_EGG(10311), - ZOMBIFIED_PIGLIN_SPAWN_EGG(6626), - EXPERIENCE_BOTTLE(12858), - FIRE_CHARGE(4842), - WIND_CHARGE(23928), - WRITABLE_BOOK(13393, 1), - WRITTEN_BOOK(24164, 16), - BREEZE_ROD(14281), - MACE(4771, 1, 500), - ITEM_FRAME(27318), - GLOW_ITEM_FRAME(26473), - FLOWER_POT(30567), - CARROT(22824), - POTATO(21088), - BAKED_POTATO(14624), - POISONOUS_POTATO(32640), - MAP(21655), - GOLDEN_CARROT(5300), - /** - * BlockData: {@link Skull} - */ - SKELETON_SKULL(13270, Skull.class), - /** - * BlockData: {@link Skull} - */ - WITHER_SKELETON_SKULL(31487, Skull.class), - /** - * BlockData: {@link Skull} - */ - PLAYER_HEAD(21174, Skull.class), - /** - * BlockData: {@link Skull} - */ - ZOMBIE_HEAD(9304, Skull.class), - /** - * BlockData: {@link Skull} - */ - CREEPER_HEAD(29146, Skull.class), - /** - * BlockData: {@link Skull} - */ - DRAGON_HEAD(20084, Skull.class), - /** - * BlockData: {@link Skull} - */ - PIGLIN_HEAD(5512, Skull.class), - NETHER_STAR(12469), - PUMPKIN_PIE(28725), - FIREWORK_ROCKET(23841), - FIREWORK_STAR(12190), - ENCHANTED_BOOK(11741, 1), - NETHER_BRICK(19996), - RESIN_BRICK(19050), - PRISMARINE_SHARD(10993), - PRISMARINE_CRYSTALS(31546), - RABBIT(23068), - COOKED_RABBIT(4454), - RABBIT_STEW(25318, 1), - RABBIT_FOOT(13864), - RABBIT_HIDE(12467), - ARMOR_STAND(12852, 16), - IRON_HORSE_ARMOR(30108, 1), - GOLDEN_HORSE_ARMOR(7996, 1), - DIAMOND_HORSE_ARMOR(10321, 1), - LEATHER_HORSE_ARMOR(30667, 1), - LEAD(29539), - NAME_TAG(30731), - COMMAND_BLOCK_MINECART(7992, 1), - MUTTON(4792), - COOKED_MUTTON(31447), - /** - * BlockData: {@link Rotatable} - */ - WHITE_BANNER(17562, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - ORANGE_BANNER(4839, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - MAGENTA_BANNER(15591, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - LIGHT_BLUE_BANNER(18060, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - YELLOW_BANNER(30382, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - LIME_BANNER(18887, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - PINK_BANNER(19439, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - GRAY_BANNER(12053, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - LIGHT_GRAY_BANNER(11417, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - CYAN_BANNER(9839, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - PURPLE_BANNER(29027, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - BLUE_BANNER(18481, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - BROWN_BANNER(11481, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - GREEN_BANNER(10698, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - RED_BANNER(26961, 16, Rotatable.class), - /** - * BlockData: {@link Rotatable} - */ - BLACK_BANNER(9365, 16, Rotatable.class), - END_CRYSTAL(19090), - CHORUS_FRUIT(7652), - POPPED_CHORUS_FRUIT(27844), - TORCHFLOWER_SEEDS(18153), - PITCHER_POD(7977), - BEETROOT(23305), - BEETROOT_SEEDS(21282), - BEETROOT_SOUP(16036, 1), - DRAGON_BREATH(20154), - SPLASH_POTION(30248, 1), - SPECTRAL_ARROW(4568), - TIPPED_ARROW(25164), - LINGERING_POTION(25857, 1), - SHIELD(29943, 1, 336), - TOTEM_OF_UNDYING(10139, 1), - SHULKER_SHELL(27848), - IRON_NUGGET(13715), - KNOWLEDGE_BOOK(12646, 1), - DEBUG_STICK(24562, 1), - MUSIC_DISC_13(16359, 1), - MUSIC_DISC_CAT(16246, 1), - MUSIC_DISC_BLOCKS(26667, 1), - MUSIC_DISC_CHIRP(19436, 1), - MUSIC_DISC_CREATOR(20345, 1), - MUSIC_DISC_CREATOR_MUSIC_BOX(7202, 1), - MUSIC_DISC_FAR(31742, 1), - MUSIC_DISC_MALL(11517, 1), - MUSIC_DISC_MELLOHI(26117, 1), - MUSIC_DISC_STAL(14989, 1), - MUSIC_DISC_STRAD(16785, 1), - MUSIC_DISC_WARD(24026, 1), - MUSIC_DISC_11(27426, 1), - MUSIC_DISC_WAIT(26499, 1), - MUSIC_DISC_OTHERSIDE(12974, 1), - MUSIC_DISC_RELIC(8200, 1), - MUSIC_DISC_5(9212, 1), - MUSIC_DISC_PIGSTEP(21323, 1), - MUSIC_DISC_PRECIPICE(28677, 1), - DISC_FRAGMENT_5(29729), - TRIDENT(7534, 1, 250), - NAUTILUS_SHELL(19989), - HEART_OF_THE_SEA(11807), - CROSSBOW(4340, 1, 465), - SUSPICIOUS_STEW(8173, 1), - /** - * BlockData: {@link Directional} - */ - LOOM(14276, Directional.class), - FLOWER_BANNER_PATTERN(5762, 1), - CREEPER_BANNER_PATTERN(15774, 1), - SKULL_BANNER_PATTERN(7680, 1), - MOJANG_BANNER_PATTERN(11903, 1), - GLOBE_BANNER_PATTERN(27753, 1), - PIGLIN_BANNER_PATTERN(22028, 1), - FLOW_BANNER_PATTERN(32683, 1), - GUSTER_BANNER_PATTERN(27267, 1), - FIELD_MASONED_BANNER_PATTERN(19157, 1), - BORDURE_INDENTED_BANNER_PATTERN(25850, 1), - GOAT_HORN(28237, 1), - /** - * BlockData: {@link Levelled} - */ - COMPOSTER(31247, Levelled.class), - /** - * BlockData: {@link Barrel} - */ - BARREL(22396, Barrel.class), - /** - * BlockData: {@link Furnace} - */ - SMOKER(24781, Furnace.class), - /** - * BlockData: {@link Furnace} - */ - BLAST_FURNACE(31157, Furnace.class), - CARTOGRAPHY_TABLE(28529), - FLETCHING_TABLE(30838), - /** - * BlockData: {@link Grindstone} - */ - GRINDSTONE(26260, Grindstone.class), - SMITHING_TABLE(9082), - /** - * BlockData: {@link Directional} - */ - STONECUTTER(25170, Directional.class), - /** - * BlockData: {@link Bell} - */ - BELL(20000, Bell.class), - /** - * BlockData: {@link Lantern} - */ - LANTERN(5992, Lantern.class), - /** - * BlockData: {@link Lantern} - */ - SOUL_LANTERN(27778, Lantern.class), - SWEET_BERRIES(19747), - GLOW_BERRIES(11584), - /** - * BlockData: {@link Campfire} - */ - CAMPFIRE(8488, Campfire.class), - /** - * BlockData: {@link Campfire} - */ - SOUL_CAMPFIRE(4238, Campfire.class), - SHROOMLIGHT(20424), - HONEYCOMB(9482), - /** - * BlockData: {@link Beehive} - */ - BEE_NEST(8825, Beehive.class), - /** - * BlockData: {@link Beehive} - */ - BEEHIVE(11830, Beehive.class), - HONEY_BOTTLE(22927, 16), - HONEYCOMB_BLOCK(28780), - LODESTONE(23127), - CRYING_OBSIDIAN(31545), - BLACKSTONE(7354), - /** - * BlockData: {@link Slab} - */ - BLACKSTONE_SLAB(11948, Slab.class), - /** - * BlockData: {@link Stairs} - */ - BLACKSTONE_STAIRS(14646, Stairs.class), - GILDED_BLACKSTONE(8498), - POLISHED_BLACKSTONE(18144), - /** - * BlockData: {@link Slab} - */ - POLISHED_BLACKSTONE_SLAB(23430, Slab.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_BLACKSTONE_STAIRS(8653, Stairs.class), - CHISELED_POLISHED_BLACKSTONE(21942), - POLISHED_BLACKSTONE_BRICKS(19844), - /** - * BlockData: {@link Slab} - */ - POLISHED_BLACKSTONE_BRICK_SLAB(12219, Slab.class), - /** - * BlockData: {@link Stairs} - */ - POLISHED_BLACKSTONE_BRICK_STAIRS(17983, Stairs.class), - CRACKED_POLISHED_BLACKSTONE_BRICKS(16846), - /** - * BlockData: {@link RespawnAnchor} - */ - RESPAWN_ANCHOR(4099, RespawnAnchor.class), - /** - * BlockData: {@link Candle} - */ - CANDLE(16122, Candle.class), - /** - * BlockData: {@link Candle} - */ - WHITE_CANDLE(26410, Candle.class), - /** - * BlockData: {@link Candle} - */ - ORANGE_CANDLE(22668, Candle.class), - /** - * BlockData: {@link Candle} - */ - MAGENTA_CANDLE(25467, Candle.class), - /** - * BlockData: {@link Candle} - */ - LIGHT_BLUE_CANDLE(28681, Candle.class), - /** - * BlockData: {@link Candle} - */ - YELLOW_CANDLE(14351, Candle.class), - /** - * BlockData: {@link Candle} - */ - LIME_CANDLE(21778, Candle.class), - /** - * BlockData: {@link Candle} - */ - PINK_CANDLE(28259, Candle.class), - /** - * BlockData: {@link Candle} - */ - GRAY_CANDLE(10721, Candle.class), - /** - * BlockData: {@link Candle} - */ - LIGHT_GRAY_CANDLE(10031, Candle.class), - /** - * BlockData: {@link Candle} - */ - CYAN_CANDLE(24765, Candle.class), - /** - * BlockData: {@link Candle} - */ - PURPLE_CANDLE(19606, Candle.class), - /** - * BlockData: {@link Candle} - */ - BLUE_CANDLE(29047, Candle.class), - /** - * BlockData: {@link Candle} - */ - BROWN_CANDLE(26145, Candle.class), - /** - * BlockData: {@link Candle} - */ - GREEN_CANDLE(29756, Candle.class), - /** - * BlockData: {@link Candle} - */ - RED_CANDLE(4214, Candle.class), - /** - * BlockData: {@link Candle} - */ - BLACK_CANDLE(12617, Candle.class), - /** - * BlockData: {@link AmethystCluster} - */ - SMALL_AMETHYST_BUD(14958, AmethystCluster.class), - /** - * BlockData: {@link AmethystCluster} - */ - MEDIUM_AMETHYST_BUD(8429, AmethystCluster.class), - /** - * BlockData: {@link AmethystCluster} - */ - LARGE_AMETHYST_BUD(7279, AmethystCluster.class), - /** - * BlockData: {@link AmethystCluster} - */ - AMETHYST_CLUSTER(13142, AmethystCluster.class), - /** - * BlockData: {@link PointedDripstone} - */ - POINTED_DRIPSTONE(18755, PointedDripstone.class), - /** - * BlockData: {@link Orientable} - */ - OCHRE_FROGLIGHT(25330, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - VERDANT_FROGLIGHT(22793, Orientable.class), - /** - * BlockData: {@link Orientable} - */ - PEARLESCENT_FROGLIGHT(21441, Orientable.class), - FROGSPAWN(8350), - ECHO_SHARD(12529), - BRUSH(30569, 1, 64), - NETHERITE_UPGRADE_SMITHING_TEMPLATE(7615), - SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE(16124), - DUNE_ARMOR_TRIM_SMITHING_TEMPLATE(30925), - COAST_ARMOR_TRIM_SMITHING_TEMPLATE(25501), - WILD_ARMOR_TRIM_SMITHING_TEMPLATE(5870), - WARD_ARMOR_TRIM_SMITHING_TEMPLATE(24534), - EYE_ARMOR_TRIM_SMITHING_TEMPLATE(14663), - VEX_ARMOR_TRIM_SMITHING_TEMPLATE(25818), - TIDE_ARMOR_TRIM_SMITHING_TEMPLATE(20420), - SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE(14386), - RIB_ARMOR_TRIM_SMITHING_TEMPLATE(6010), - SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE(29143), - WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE(4957), - SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE(20537), - SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE(7070), - RAISER_ARMOR_TRIM_SMITHING_TEMPLATE(29116), - HOST_ARMOR_TRIM_SMITHING_TEMPLATE(12165), - FLOW_ARMOR_TRIM_SMITHING_TEMPLATE(29175), - BOLT_ARMOR_TRIM_SMITHING_TEMPLATE(9698), - ANGLER_POTTERY_SHERD(9952), - ARCHER_POTTERY_SHERD(21629), - ARMS_UP_POTTERY_SHERD(5484), - BLADE_POTTERY_SHERD(25079), - BREWER_POTTERY_SHERD(23429), - BURN_POTTERY_SHERD(21259), - DANGER_POTTERY_SHERD(30506), - EXPLORER_POTTERY_SHERD(5124), - FLOW_POTTERY_SHERD(4896), - FRIEND_POTTERY_SHERD(18221), - GUSTER_POTTERY_SHERD(28193), - HEART_POTTERY_SHERD(17607), - HEARTBREAK_POTTERY_SHERD(21108), - HOWL_POTTERY_SHERD(24900), - MINER_POTTERY_SHERD(30602), - MOURNER_POTTERY_SHERD(23993), - PLENTY_POTTERY_SHERD(28236), - PRIZE_POTTERY_SHERD(4341), - SCRAPE_POTTERY_SHERD(30034), - SHEAF_POTTERY_SHERD(23652), - SHELTER_POTTERY_SHERD(28390), - SKULL_POTTERY_SHERD(16980), - SNORT_POTTERY_SHERD(15921), - /** - * BlockData: {@link Waterlogged} - */ - COPPER_GRATE(16221, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - EXPOSED_COPPER_GRATE(7783, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - WEATHERED_COPPER_GRATE(24954, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - OXIDIZED_COPPER_GRATE(14122, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - WAXED_COPPER_GRATE(11230, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - WAXED_EXPOSED_COPPER_GRATE(20520, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - WAXED_WEATHERED_COPPER_GRATE(16533, Waterlogged.class), - /** - * BlockData: {@link Waterlogged} - */ - WAXED_OXIDIZED_COPPER_GRATE(32010, Waterlogged.class), - /** - * BlockData: {@link CopperBulb} - */ - COPPER_BULB(21370, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - EXPOSED_COPPER_BULB(11944, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - WEATHERED_COPPER_BULB(10800, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - OXIDIZED_COPPER_BULB(22421, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - WAXED_COPPER_BULB(23756, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - WAXED_EXPOSED_COPPER_BULB(5530, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - WAXED_WEATHERED_COPPER_BULB(13239, CopperBulb.class), - /** - * BlockData: {@link CopperBulb} - */ - WAXED_OXIDIZED_COPPER_BULB(26892, CopperBulb.class), - /** - * BlockData: {@link TrialSpawner} - */ - TRIAL_SPAWNER(19902, TrialSpawner.class), - TRIAL_KEY(12725), - OMINOUS_TRIAL_KEY(4986), - /** - * BlockData: {@link Vault} - */ - VAULT(6288, Vault.class), - OMINOUS_BOTTLE(26321), - /** - * BlockData: {@link Levelled} - */ - WATER(24998, Levelled.class), - /** - * BlockData: {@link Levelled} - */ - LAVA(8415, Levelled.class), - /** - * BlockData: {@link Bisected} - */ - TALL_SEAGRASS(27189, Bisected.class), - /** - * BlockData: {@link PistonHead} - */ - PISTON_HEAD(30226, PistonHead.class), - /** - * BlockData: {@link TechnicalPiston} - */ - MOVING_PISTON(13831, TechnicalPiston.class), - /** - * BlockData: {@link Directional} - */ - WALL_TORCH(25890, Directional.class), - /** - * BlockData: {@link Fire} - */ - FIRE(16396, Fire.class), - SOUL_FIRE(30163), - /** - * BlockData: {@link RedstoneWire} - */ - REDSTONE_WIRE(25984, RedstoneWire.class), - /** - * BlockData: {@link WallSign} - */ - OAK_WALL_SIGN(12984, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - SPRUCE_WALL_SIGN(7352, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - BIRCH_WALL_SIGN(9887, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - ACACIA_WALL_SIGN(20316, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - CHERRY_WALL_SIGN(20188, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - JUNGLE_WALL_SIGN(29629, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - DARK_OAK_WALL_SIGN(9508, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - PALE_OAK_WALL_SIGN(23103, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - MANGROVE_WALL_SIGN(27203, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - BAMBOO_WALL_SIGN(18857, 16, WallSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - OAK_WALL_HANGING_SIGN(15637, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - SPRUCE_WALL_HANGING_SIGN(18833, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - BIRCH_WALL_HANGING_SIGN(15937, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - ACACIA_WALL_HANGING_SIGN(22477, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - CHERRY_WALL_HANGING_SIGN(10953, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - JUNGLE_WALL_HANGING_SIGN(16691, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - DARK_OAK_WALL_HANGING_SIGN(14296, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - PALE_OAK_WALL_HANGING_SIGN(23484, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - MANGROVE_WALL_HANGING_SIGN(16974, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - CRIMSON_WALL_HANGING_SIGN(28982, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - WARPED_WALL_HANGING_SIGN(20605, WallHangingSign.class), - /** - * BlockData: {@link WallHangingSign} - */ - BAMBOO_WALL_HANGING_SIGN(6669, WallHangingSign.class), - /** - * BlockData: {@link RedstoneWallTorch} - */ - REDSTONE_WALL_TORCH(7595, RedstoneWallTorch.class), - /** - * BlockData: {@link Directional} - */ - SOUL_WALL_TORCH(27500, Directional.class), - /** - * BlockData: {@link Orientable} - */ - NETHER_PORTAL(19469, Orientable.class), - /** - * BlockData: {@link Directional} - */ - ATTACHED_PUMPKIN_STEM(12724, Directional.class), - /** - * BlockData: {@link Directional} - */ - ATTACHED_MELON_STEM(30882, Directional.class), - /** - * BlockData: {@link Ageable} - */ - PUMPKIN_STEM(19021, Ageable.class), - /** - * BlockData: {@link Ageable} - */ - MELON_STEM(8247, Ageable.class), - /** - * BlockData: {@link Levelled} - */ - WATER_CAULDRON(32008, Levelled.class), - LAVA_CAULDRON(4514), - /** - * BlockData: {@link Levelled} - */ - POWDER_SNOW_CAULDRON(31571, Levelled.class), - END_PORTAL(16782), - /** - * BlockData: {@link Cocoa} - */ - COCOA(29709, Cocoa.class), - /** - * BlockData: {@link Tripwire} - */ - TRIPWIRE(8810, Tripwire.class), - POTTED_TORCHFLOWER(21278), - POTTED_OAK_SAPLING(11905), - POTTED_SPRUCE_SAPLING(29498), - POTTED_BIRCH_SAPLING(32484), - POTTED_JUNGLE_SAPLING(7525), - POTTED_ACACIA_SAPLING(14096), - POTTED_CHERRY_SAPLING(30785), - POTTED_DARK_OAK_SAPLING(6486), - POTTED_PALE_OAK_SAPLING(15538), - POTTED_MANGROVE_PROPAGULE(22003), - POTTED_FERN(23315), - POTTED_DANDELION(9727), - POTTED_POPPY(7457), - POTTED_BLUE_ORCHID(6599), - POTTED_ALLIUM(13184), - POTTED_AZURE_BLUET(8754), - POTTED_RED_TULIP(28594), - POTTED_ORANGE_TULIP(28807), - POTTED_WHITE_TULIP(24330), - POTTED_PINK_TULIP(10089), - POTTED_OXEYE_DAISY(19707), - POTTED_CORNFLOWER(28917), - POTTED_LILY_OF_THE_VALLEY(9364), - POTTED_WITHER_ROSE(26876), - POTTED_RED_MUSHROOM(22881), - POTTED_BROWN_MUSHROOM(14481), - POTTED_DEAD_BUSH(13020), - POTTED_CACTUS(8777), - /** - * BlockData: {@link Ageable} - */ - CARROTS(17258, Ageable.class), - /** - * BlockData: {@link Ageable} - */ - POTATOES(10879, Ageable.class), - /** - * BlockData: {@link WallSkull} - */ - SKELETON_WALL_SKULL(31650, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - WITHER_SKELETON_WALL_SKULL(9326, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - ZOMBIE_WALL_HEAD(16296, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - PLAYER_WALL_HEAD(13164, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - CREEPER_WALL_HEAD(30123, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - DRAGON_WALL_HEAD(19818, WallSkull.class), - /** - * BlockData: {@link WallSkull} - */ - PIGLIN_WALL_HEAD(4446, WallSkull.class), - /** - * BlockData: {@link Directional} - */ - WHITE_WALL_BANNER(15967, Directional.class), - /** - * BlockData: {@link Directional} - */ - ORANGE_WALL_BANNER(9936, Directional.class), - /** - * BlockData: {@link Directional} - */ - MAGENTA_WALL_BANNER(23291, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_BLUE_WALL_BANNER(12011, Directional.class), - /** - * BlockData: {@link Directional} - */ - YELLOW_WALL_BANNER(32004, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIME_WALL_BANNER(21422, Directional.class), - /** - * BlockData: {@link Directional} - */ - PINK_WALL_BANNER(9421, Directional.class), - /** - * BlockData: {@link Directional} - */ - GRAY_WALL_BANNER(24275, Directional.class), - /** - * BlockData: {@link Directional} - */ - LIGHT_GRAY_WALL_BANNER(31088, Directional.class), - /** - * BlockData: {@link Directional} - */ - CYAN_WALL_BANNER(10889, Directional.class), - /** - * BlockData: {@link Directional} - */ - PURPLE_WALL_BANNER(14298, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLUE_WALL_BANNER(17757, Directional.class), - /** - * BlockData: {@link Directional} - */ - BROWN_WALL_BANNER(14731, Directional.class), - /** - * BlockData: {@link Directional} - */ - GREEN_WALL_BANNER(15046, Directional.class), - /** - * BlockData: {@link Directional} - */ - RED_WALL_BANNER(4378, Directional.class), - /** - * BlockData: {@link Directional} - */ - BLACK_WALL_BANNER(4919, Directional.class), - /** - * BlockData: {@link Ageable} - */ - TORCHFLOWER_CROP(28460, Ageable.class), - /** - * BlockData: {@link PitcherCrop} - */ - PITCHER_CROP(15420, PitcherCrop.class), - /** - * BlockData: {@link Ageable} - */ - BEETROOTS(22075, Ageable.class), - END_GATEWAY(26605), - /** - * BlockData: {@link Ageable} - */ - FROSTED_ICE(21814, Ageable.class), - KELP_PLANT(29697), - /** - * BlockData: {@link CoralWallFan} - */ - DEAD_TUBE_CORAL_WALL_FAN(5128, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - DEAD_BRAIN_CORAL_WALL_FAN(23718, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - DEAD_BUBBLE_CORAL_WALL_FAN(18453, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - DEAD_FIRE_CORAL_WALL_FAN(23375, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - DEAD_HORN_CORAL_WALL_FAN(27550, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - TUBE_CORAL_WALL_FAN(25282, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - BRAIN_CORAL_WALL_FAN(22685, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - BUBBLE_CORAL_WALL_FAN(20382, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - FIRE_CORAL_WALL_FAN(20100, CoralWallFan.class), - /** - * BlockData: {@link CoralWallFan} - */ - HORN_CORAL_WALL_FAN(28883, CoralWallFan.class), - BAMBOO_SAPLING(8478), - POTTED_BAMBOO(22542), - VOID_AIR(13668), - CAVE_AIR(17422), - /** - * BlockData: {@link BubbleColumn} - */ - BUBBLE_COLUMN(31612, BubbleColumn.class), - /** - * BlockData: {@link Ageable} - */ - SWEET_BERRY_BUSH(11958, Ageable.class), - WEEPING_VINES_PLANT(19437), - TWISTING_VINES_PLANT(25338), - /** - * BlockData: {@link WallSign} - */ - CRIMSON_WALL_SIGN(19242, 16, WallSign.class), - /** - * BlockData: {@link WallSign} - */ - WARPED_WALL_SIGN(13534, 16, WallSign.class), - POTTED_CRIMSON_FUNGUS(5548), - POTTED_WARPED_FUNGUS(30800), - POTTED_CRIMSON_ROOTS(13852), - POTTED_WARPED_ROOTS(6403), - /** - * BlockData: {@link Lightable} - */ - CANDLE_CAKE(25423, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - WHITE_CANDLE_CAKE(12674, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - ORANGE_CANDLE_CAKE(24982, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - MAGENTA_CANDLE_CAKE(11022, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - LIGHT_BLUE_CANDLE_CAKE(7787, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - YELLOW_CANDLE_CAKE(17157, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - LIME_CANDLE_CAKE(14309, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - PINK_CANDLE_CAKE(20405, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - GRAY_CANDLE_CAKE(6777, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - LIGHT_GRAY_CANDLE_CAKE(11318, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - CYAN_CANDLE_CAKE(21202, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - PURPLE_CANDLE_CAKE(22663, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - BLUE_CANDLE_CAKE(26425, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - BROWN_CANDLE_CAKE(26024, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - GREEN_CANDLE_CAKE(16334, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - RED_CANDLE_CAKE(24151, Lightable.class), - /** - * BlockData: {@link Lightable} - */ - BLACK_CANDLE_CAKE(15191, Lightable.class), - POWDER_SNOW(24077), - /** - * BlockData: {@link CaveVines} - */ - CAVE_VINES(7339, CaveVines.class), - /** - * BlockData: {@link CaveVinesPlant} - */ - CAVE_VINES_PLANT(30645, CaveVinesPlant.class), - /** - * BlockData: {@link Dripleaf} - */ - BIG_DRIPLEAF_STEM(13167, Dripleaf.class), - POTTED_AZALEA_BUSH(20430), - POTTED_FLOWERING_AZALEA_BUSH(10609), - POTTED_OPEN_EYEBLOSSOM(24999), - POTTED_CLOSED_EYEBLOSSOM(16694), + // Start generate - Items + // @GeneratedFrom 1.21.5 + ACACIA_BOAT(-1, 1), + ACACIA_CHEST_BOAT(-1, 1), + AIR(-1), + ALLAY_SPAWN_EGG(-1), + AMETHYST_SHARD(-1), + ANGLER_POTTERY_SHERD(-1), + APPLE(-1), + ARCHER_POTTERY_SHERD(-1), + ARMADILLO_SCUTE(-1), + ARMADILLO_SPAWN_EGG(-1), + ARMOR_STAND(-1, 16), + ARMS_UP_POTTERY_SHERD(-1), + ARROW(-1), + AXOLOTL_BUCKET(-1, 1), + AXOLOTL_SPAWN_EGG(-1), + BAKED_POTATO(-1), + BAMBOO_CHEST_RAFT(-1, 1), + BAMBOO_RAFT(-1, 1), + BAT_SPAWN_EGG(-1), + BEE_SPAWN_EGG(-1), + BEEF(-1), + BEETROOT(-1), + BEETROOT_SEEDS(-1), + BEETROOT_SOUP(-1, 1), + BIRCH_BOAT(-1, 1), + BIRCH_CHEST_BOAT(-1, 1), + BLACK_BUNDLE(-1, 1), + BLACK_DYE(-1), + BLADE_POTTERY_SHERD(-1), + BLAZE_POWDER(-1), + BLAZE_ROD(-1), + BLAZE_SPAWN_EGG(-1), + BLUE_BUNDLE(-1, 1), + BLUE_DYE(-1), + BLUE_EGG(-1, 16), + BOGGED_SPAWN_EGG(-1), + BOLT_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + BONE(-1), + BONE_MEAL(-1), + BOOK(-1), + BORDURE_INDENTED_BANNER_PATTERN(-1, 1), + BOW(-1, 1), + BOWL(-1), + BREAD(-1), + BREEZE_ROD(-1), + BREEZE_SPAWN_EGG(-1), + BREWER_POTTERY_SHERD(-1), + BRICK(-1), + BROWN_BUNDLE(-1, 1), + BROWN_DYE(-1), + BROWN_EGG(-1, 16), + BRUSH(-1, 1), + BUCKET(-1, 16), + BUNDLE(-1, 1), + BURN_POTTERY_SHERD(-1), + CAMEL_SPAWN_EGG(-1), + CARROT(-1), + CARROT_ON_A_STICK(-1, 1), + CAT_SPAWN_EGG(-1), + CAVE_SPIDER_SPAWN_EGG(-1), + CHAINMAIL_BOOTS(-1, 1), + CHAINMAIL_CHESTPLATE(-1, 1), + CHAINMAIL_HELMET(-1, 1), + CHAINMAIL_LEGGINGS(-1, 1), + CHARCOAL(-1), + CHERRY_BOAT(-1, 1), + CHERRY_CHEST_BOAT(-1, 1), + CHEST_MINECART(-1, 1), + CHICKEN(-1), + CHICKEN_SPAWN_EGG(-1), + CHORUS_FRUIT(-1), + CLAY_BALL(-1), + CLOCK(-1), + COAL(-1), + COAST_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + COCOA_BEANS(-1), + COD(-1), + COD_BUCKET(-1, 1), + COD_SPAWN_EGG(-1), + COMMAND_BLOCK_MINECART(-1, 1), + COMPASS(-1), + COOKED_BEEF(-1), + COOKED_CHICKEN(-1), + COOKED_COD(-1), + COOKED_MUTTON(-1), + COOKED_PORKCHOP(-1), + COOKED_RABBIT(-1), + COOKED_SALMON(-1), + COOKIE(-1), + COPPER_INGOT(-1), + COW_SPAWN_EGG(-1), + CREAKING_SPAWN_EGG(-1), + CREEPER_BANNER_PATTERN(-1, 1), + CREEPER_SPAWN_EGG(-1), + CROSSBOW(-1, 1), + CYAN_BUNDLE(-1, 1), + CYAN_DYE(-1), + DANGER_POTTERY_SHERD(-1), + DARK_OAK_BOAT(-1, 1), + DARK_OAK_CHEST_BOAT(-1, 1), + DEBUG_STICK(-1, 1), + DIAMOND(-1), + DIAMOND_AXE(-1, 1), + DIAMOND_BOOTS(-1, 1), + DIAMOND_CHESTPLATE(-1, 1), + DIAMOND_HELMET(-1, 1), + DIAMOND_HOE(-1, 1), + DIAMOND_HORSE_ARMOR(-1, 1), + DIAMOND_LEGGINGS(-1, 1), + DIAMOND_PICKAXE(-1, 1), + DIAMOND_SHOVEL(-1, 1), + DIAMOND_SWORD(-1, 1), + DRAGON_BREATH(-1), + END_CRYSTAL(-1), + FIELD_MASONED_BANNER_PATTERN(-1, 1), + FLOW_BANNER_PATTERN(-1, 1), + GLOBE_BANNER_PATTERN(-1, 1), + IRON_NUGGET(-1), + KNOWLEDGE_BOOK(-1, 1), + LINGERING_POTION(-1, 1), + MUSIC_DISC_5(-1, 1), + DISC_FRAGMENT_5(-1), + DOLPHIN_SPAWN_EGG(-1), + DONKEY_SPAWN_EGG(-1), + DRIED_KELP(-1), + DROWNED_SPAWN_EGG(-1), + DUNE_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + ECHO_SHARD(-1), + EGG(-1, 16), + ELDER_GUARDIAN_SPAWN_EGG(-1), + ELYTRA(-1, 1), + EMERALD(-1), + ENCHANTED_BOOK(-1, 1), + ENCHANTED_GOLDEN_APPLE(-1), + ENDER_DRAGON_SPAWN_EGG(-1), + ENDER_EYE(-1), + ENDER_PEARL(-1, 16), + ENDERMAN_SPAWN_EGG(-1), + ENDERMITE_SPAWN_EGG(-1), + EVOKER_SPAWN_EGG(-1), + EXPERIENCE_BOTTLE(-1), + EXPLORER_POTTERY_SHERD(-1), + EYE_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + FEATHER(-1), + FERMENTED_SPIDER_EYE(-1), + FILLED_MAP(-1), + FIRE_CHARGE(-1), + FIREWORK_ROCKET(-1), + FIREWORK_STAR(-1), + FISHING_ROD(-1, 1), + FLINT(-1), + FLINT_AND_STEEL(-1, 1), + FLOW_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + FLOW_POTTERY_SHERD(-1), + FLOWER_BANNER_PATTERN(-1, 1), + FOX_SPAWN_EGG(-1), + FRIEND_POTTERY_SHERD(-1), + FROG_SPAWN_EGG(-1), + FURNACE_MINECART(-1, 1), + GHAST_SPAWN_EGG(-1), + GHAST_TEAR(-1), + GLASS_BOTTLE(-1), + GLISTERING_MELON_SLICE(-1), + GLOW_BERRIES(-1), + GLOW_INK_SAC(-1), + GLOW_ITEM_FRAME(-1), + GLOW_SQUID_SPAWN_EGG(-1), + GLOWSTONE_DUST(-1), + GOAT_HORN(-1, 1), + GOAT_SPAWN_EGG(-1), + GOLD_INGOT(-1), + GOLD_NUGGET(-1), + GOLDEN_APPLE(-1), + GOLDEN_AXE(-1, 1), + GOLDEN_BOOTS(-1, 1), + GOLDEN_CARROT(-1), + GOLDEN_CHESTPLATE(-1, 1), + GOLDEN_HELMET(-1, 1), + GOLDEN_HOE(-1, 1), + GOLDEN_HORSE_ARMOR(-1, 1), + GOLDEN_LEGGINGS(-1, 1), + GOLDEN_PICKAXE(-1, 1), + GOLDEN_SHOVEL(-1, 1), + GOLDEN_SWORD(-1, 1), + GRAY_BUNDLE(-1, 1), + GRAY_DYE(-1), + GREEN_BUNDLE(-1, 1), + GREEN_DYE(-1), + GUARDIAN_SPAWN_EGG(-1), + GUNPOWDER(-1), + GUSTER_BANNER_PATTERN(-1, 1), + GUSTER_POTTERY_SHERD(-1), + HEART_OF_THE_SEA(-1), + HEART_POTTERY_SHERD(-1), + HEARTBREAK_POTTERY_SHERD(-1), + HOGLIN_SPAWN_EGG(-1), + HONEY_BOTTLE(-1, 16), + HONEYCOMB(-1), + HOPPER_MINECART(-1, 1), + HORSE_SPAWN_EGG(-1), + HOST_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + HOWL_POTTERY_SHERD(-1), + HUSK_SPAWN_EGG(-1), + INK_SAC(-1), + IRON_AXE(-1, 1), + IRON_BOOTS(-1, 1), + IRON_CHESTPLATE(-1, 1), + IRON_GOLEM_SPAWN_EGG(-1), + IRON_HELMET(-1, 1), + IRON_HOE(-1, 1), + IRON_HORSE_ARMOR(-1, 1), + IRON_INGOT(-1), + IRON_LEGGINGS(-1, 1), + IRON_PICKAXE(-1, 1), + IRON_SHOVEL(-1, 1), + IRON_SWORD(-1, 1), + ITEM_FRAME(-1), + JUNGLE_BOAT(-1, 1), + JUNGLE_CHEST_BOAT(-1, 1), + LAPIS_LAZULI(-1), + LAVA_BUCKET(-1, 1), + LEAD(-1), + LEATHER(-1), + LEATHER_BOOTS(-1, 1), + LEATHER_CHESTPLATE(-1, 1), + LEATHER_HELMET(-1, 1), + LEATHER_HORSE_ARMOR(-1, 1), + LEATHER_LEGGINGS(-1, 1), + LIGHT_BLUE_BUNDLE(-1, 1), + LIGHT_BLUE_DYE(-1), + LIGHT_GRAY_BUNDLE(-1, 1), + LIGHT_GRAY_DYE(-1), + LIME_BUNDLE(-1, 1), + LIME_DYE(-1), + LLAMA_SPAWN_EGG(-1), + MACE(-1, 1), + MAGENTA_BUNDLE(-1, 1), + MAGENTA_DYE(-1), + MAGMA_CREAM(-1), + MAGMA_CUBE_SPAWN_EGG(-1), + MANGROVE_BOAT(-1, 1), + MANGROVE_CHEST_BOAT(-1, 1), + MAP(-1), + MELON_SEEDS(-1), + MELON_SLICE(-1), + MILK_BUCKET(-1, 1), + MINECART(-1, 1), + MINER_POTTERY_SHERD(-1), + MOJANG_BANNER_PATTERN(-1, 1), + MOOSHROOM_SPAWN_EGG(-1), + MOURNER_POTTERY_SHERD(-1), + MULE_SPAWN_EGG(-1), + MUSHROOM_STEW(-1, 1), + MUSIC_DISC_11(-1, 1), + MUSIC_DISC_13(-1, 1), + MUSIC_DISC_BLOCKS(-1, 1), + MUSIC_DISC_CAT(-1, 1), + MUSIC_DISC_CHIRP(-1, 1), + MUSIC_DISC_CREATOR(-1, 1), + MUSIC_DISC_CREATOR_MUSIC_BOX(-1, 1), + MUSIC_DISC_FAR(-1, 1), + MUSIC_DISC_MALL(-1, 1), + MUSIC_DISC_MELLOHI(-1, 1), + MUSIC_DISC_OTHERSIDE(-1, 1), + MUSIC_DISC_PIGSTEP(-1, 1), + MUSIC_DISC_PRECIPICE(-1, 1), + MUSIC_DISC_RELIC(-1, 1), + MUSIC_DISC_STAL(-1, 1), + MUSIC_DISC_STRAD(-1, 1), + MUSIC_DISC_WAIT(-1, 1), + MUSIC_DISC_WARD(-1, 1), + MUTTON(-1), + NAME_TAG(-1), + NAUTILUS_SHELL(-1), + NETHER_BRICK(-1), + NETHER_STAR(-1), + NETHERITE_AXE(-1, 1), + NETHERITE_BOOTS(-1, 1), + NETHERITE_CHESTPLATE(-1, 1), + NETHERITE_HELMET(-1, 1), + NETHERITE_HOE(-1, 1), + NETHERITE_INGOT(-1), + NETHERITE_LEGGINGS(-1, 1), + NETHERITE_PICKAXE(-1, 1), + NETHERITE_SCRAP(-1), + NETHERITE_SHOVEL(-1, 1), + NETHERITE_SWORD(-1, 1), + NETHERITE_UPGRADE_SMITHING_TEMPLATE(-1), + OAK_BOAT(-1, 1), + OAK_CHEST_BOAT(-1, 1), + OCELOT_SPAWN_EGG(-1), + OMINOUS_BOTTLE(-1), + OMINOUS_TRIAL_KEY(-1), + ORANGE_BUNDLE(-1, 1), + ORANGE_DYE(-1), + PAINTING(-1), + PALE_OAK_BOAT(-1, 1), + PALE_OAK_CHEST_BOAT(-1, 1), + PANDA_SPAWN_EGG(-1), + PAPER(-1), + PARROT_SPAWN_EGG(-1), + PHANTOM_MEMBRANE(-1), + PHANTOM_SPAWN_EGG(-1), + PIG_SPAWN_EGG(-1), + PIGLIN_BANNER_PATTERN(-1, 1), + PIGLIN_BRUTE_SPAWN_EGG(-1), + PIGLIN_SPAWN_EGG(-1), + PILLAGER_SPAWN_EGG(-1), + PINK_BUNDLE(-1, 1), + PINK_DYE(-1), + PITCHER_POD(-1), + PLENTY_POTTERY_SHERD(-1), + POISONOUS_POTATO(-1), + POLAR_BEAR_SPAWN_EGG(-1), + POPPED_CHORUS_FRUIT(-1), + PORKCHOP(-1), + POTATO(-1), + POTION(-1, 1), + POWDER_SNOW_BUCKET(-1, 1), + PRISMARINE_CRYSTALS(-1), + PRISMARINE_SHARD(-1), + PRIZE_POTTERY_SHERD(-1), + PUFFERFISH(-1), + PUFFERFISH_BUCKET(-1, 1), + PUFFERFISH_SPAWN_EGG(-1), + PUMPKIN_PIE(-1), + PUMPKIN_SEEDS(-1), + PURPLE_BUNDLE(-1, 1), + PURPLE_DYE(-1), + QUARTZ(-1), + RABBIT(-1), + RABBIT_FOOT(-1), + RABBIT_HIDE(-1), + RABBIT_SPAWN_EGG(-1), + RABBIT_STEW(-1, 1), + RAISER_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + RAVAGER_SPAWN_EGG(-1), + RAW_COPPER(-1), + RAW_GOLD(-1), + RAW_IRON(-1), + RECOVERY_COMPASS(-1), + RED_BUNDLE(-1, 1), + RED_DYE(-1), + REDSTONE(-1), + RESIN_BRICK(-1), + RIB_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + ROTTEN_FLESH(-1), + SADDLE(-1, 1), + SALMON(-1), + SALMON_BUCKET(-1, 1), + SALMON_SPAWN_EGG(-1), + SCRAPE_POTTERY_SHERD(-1), + SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + SHEAF_POTTERY_SHERD(-1), + SHEARS(-1, 1), + SHEEP_SPAWN_EGG(-1), + SHELTER_POTTERY_SHERD(-1), + SHIELD(-1, 1), + SHULKER_SHELL(-1), + SHULKER_SPAWN_EGG(-1), + SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + SILVERFISH_SPAWN_EGG(-1), + SKELETON_HORSE_SPAWN_EGG(-1), + SKELETON_SPAWN_EGG(-1), + SKULL_BANNER_PATTERN(-1, 1), + SKULL_POTTERY_SHERD(-1), + SLIME_BALL(-1), + SLIME_SPAWN_EGG(-1), + SNIFFER_SPAWN_EGG(-1), + SNORT_POTTERY_SHERD(-1), + SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + SNOW_GOLEM_SPAWN_EGG(-1), + SNOWBALL(-1, 16), + SPECTRAL_ARROW(-1), + SPIDER_EYE(-1), + SPIDER_SPAWN_EGG(-1), + SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + SPLASH_POTION(-1, 1), + SPRUCE_BOAT(-1, 1), + SPRUCE_CHEST_BOAT(-1, 1), + SPYGLASS(-1, 1), + SQUID_SPAWN_EGG(-1), + STICK(-1), + STONE_AXE(-1, 1), + STONE_HOE(-1, 1), + STONE_PICKAXE(-1, 1), + STONE_SHOVEL(-1, 1), + STONE_SWORD(-1, 1), + STRAY_SPAWN_EGG(-1), + STRIDER_SPAWN_EGG(-1), + STRING(-1), + SUGAR(-1), + SUSPICIOUS_STEW(-1, 1), + SWEET_BERRIES(-1), + TADPOLE_BUCKET(-1, 1), + TADPOLE_SPAWN_EGG(-1), + TIDE_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + TIPPED_ARROW(-1), + TNT_MINECART(-1, 1), + TORCHFLOWER_SEEDS(-1), + TOTEM_OF_UNDYING(-1, 1), + TRADER_LLAMA_SPAWN_EGG(-1), + TRIAL_KEY(-1), + TRIDENT(-1, 1), + TROPICAL_FISH(-1), + TROPICAL_FISH_BUCKET(-1, 1), + TROPICAL_FISH_SPAWN_EGG(-1), + TURTLE_HELMET(-1, 1), + TURTLE_SCUTE(-1), + TURTLE_SPAWN_EGG(-1), + VEX_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + VEX_SPAWN_EGG(-1), + VILLAGER_SPAWN_EGG(-1), + VINDICATOR_SPAWN_EGG(-1), + WANDERING_TRADER_SPAWN_EGG(-1), + WARD_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + WARDEN_SPAWN_EGG(-1), + WARPED_FUNGUS_ON_A_STICK(-1, 1), + WATER_BUCKET(-1, 1), + WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + WHEAT_SEEDS(-1), + WHITE_BUNDLE(-1, 1), + WHITE_DYE(-1), + WILD_ARMOR_TRIM_SMITHING_TEMPLATE(-1), + WIND_CHARGE(-1), + WITCH_SPAWN_EGG(-1), + WITHER_SKELETON_SPAWN_EGG(-1), + WITHER_SPAWN_EGG(-1), + WOLF_ARMOR(-1, 1), + WOLF_SPAWN_EGG(-1), + WOODEN_AXE(-1, 1), + WOODEN_HOE(-1, 1), + WOODEN_PICKAXE(-1, 1), + WOODEN_SHOVEL(-1, 1), + WOODEN_SWORD(-1, 1), + WRITABLE_BOOK(-1, 1), + WRITTEN_BOOK(-1, 16), + YELLOW_BUNDLE(-1, 1), + YELLOW_DYE(-1), + ZOGLIN_SPAWN_EGG(-1), + ZOMBIE_HORSE_SPAWN_EGG(-1), + ZOMBIE_SPAWN_EGG(-1), + ZOMBIE_VILLAGER_SPAWN_EGG(-1), + ZOMBIFIED_PIGLIN_SPAWN_EGG(-1), + // End generate - Items + // Start generate - Blocks + // @GeneratedFrom 1.21.5 + ACACIA_BUTTON(-1, Switch.class), + ACACIA_DOOR(-1, Door.class), + ACACIA_FENCE(-1, Fence.class), + ACACIA_FENCE_GATE(-1, Gate.class), + ACACIA_HANGING_SIGN(-1, 16, HangingSign.class), + ACACIA_LEAVES(-1, Leaves.class), + ACACIA_LOG(-1, Orientable.class), + ACACIA_PLANKS(-1), + ACACIA_PRESSURE_PLATE(-1, Powerable.class), + ACACIA_SAPLING(-1, Sapling.class), + ACACIA_SIGN(-1, 16, Sign.class), + ACACIA_SLAB(-1, Slab.class), + ACACIA_STAIRS(-1, Stairs.class), + ACACIA_TRAPDOOR(-1, TrapDoor.class), + ACACIA_WALL_HANGING_SIGN(-1, WallHangingSign.class), + ACACIA_WALL_SIGN(-1, 16, WallSign.class), + ACACIA_WOOD(-1, Orientable.class), + ACTIVATOR_RAIL(-1, RedstoneRail.class), + ALLIUM(-1), + AMETHYST_BLOCK(-1), + AMETHYST_CLUSTER(-1, AmethystCluster.class), + ANCIENT_DEBRIS(-1), + ANDESITE(-1), + ANDESITE_SLAB(-1, Slab.class), + ANDESITE_STAIRS(-1, Stairs.class), + ANDESITE_WALL(-1, Wall.class), + ANVIL(-1, Directional.class), + ATTACHED_MELON_STEM(-1, Directional.class), + ATTACHED_PUMPKIN_STEM(-1, Directional.class), + AZALEA(-1), + AZALEA_LEAVES(-1, Leaves.class), + AZURE_BLUET(-1), + BAMBOO(-1, Bamboo.class), + BAMBOO_BLOCK(-1, Orientable.class), + BAMBOO_BUTTON(-1, Switch.class), + BAMBOO_DOOR(-1, Door.class), + BAMBOO_FENCE(-1, Fence.class), + BAMBOO_FENCE_GATE(-1, Gate.class), + BAMBOO_HANGING_SIGN(-1, 16, HangingSign.class), + BAMBOO_MOSAIC(-1), + BAMBOO_MOSAIC_SLAB(-1, Slab.class), + BAMBOO_MOSAIC_STAIRS(-1, Stairs.class), + BAMBOO_PLANKS(-1), + BAMBOO_PRESSURE_PLATE(-1, Powerable.class), + BAMBOO_SAPLING(-1), + BAMBOO_SIGN(-1, 16, Sign.class), + BAMBOO_SLAB(-1, Slab.class), + BAMBOO_STAIRS(-1, Stairs.class), + BAMBOO_TRAPDOOR(-1, TrapDoor.class), + BAMBOO_WALL_HANGING_SIGN(-1, WallHangingSign.class), + BAMBOO_WALL_SIGN(-1, 16, WallSign.class), + BARREL(-1, Barrel.class), + BARRIER(-1, Waterlogged.class), + BASALT(-1, Orientable.class), + BEACON(-1), + BEDROCK(-1), + BEE_NEST(-1, Beehive.class), + BEEHIVE(-1, Beehive.class), + BEETROOTS(-1, Ageable.class), + BELL(-1, Bell.class), + BIG_DRIPLEAF(-1, BigDripleaf.class), + BIG_DRIPLEAF_STEM(-1, Dripleaf.class), + BIRCH_BUTTON(-1, Switch.class), + BIRCH_DOOR(-1, Door.class), + BIRCH_FENCE(-1, Fence.class), + BIRCH_FENCE_GATE(-1, Gate.class), + BIRCH_HANGING_SIGN(-1, 16, HangingSign.class), + BIRCH_LEAVES(-1, Leaves.class), + BIRCH_LOG(-1, Orientable.class), + BIRCH_PLANKS(-1), + BIRCH_PRESSURE_PLATE(-1, Powerable.class), + BIRCH_SAPLING(-1, Sapling.class), + BIRCH_SIGN(-1, 16, Sign.class), + BIRCH_SLAB(-1, Slab.class), + BIRCH_STAIRS(-1, Stairs.class), + BIRCH_TRAPDOOR(-1, TrapDoor.class), + BIRCH_WALL_HANGING_SIGN(-1, WallHangingSign.class), + BIRCH_WALL_SIGN(-1, 16, WallSign.class), + BIRCH_WOOD(-1, Orientable.class), + BLACK_BANNER(-1, 16, Rotatable.class), + BLACK_BED(-1, 1, Bed.class), + BLACK_CANDLE(-1, Candle.class), + BLACK_CANDLE_CAKE(-1, Lightable.class), + BLACK_CARPET(-1), + BLACK_CONCRETE(-1), + BLACK_CONCRETE_POWDER(-1), + BLACK_GLAZED_TERRACOTTA(-1, Directional.class), + BLACK_SHULKER_BOX(-1, 1, Directional.class), + BLACK_STAINED_GLASS(-1), + BLACK_STAINED_GLASS_PANE(-1, GlassPane.class), + BLACK_TERRACOTTA(-1), + BLACK_WALL_BANNER(-1, Directional.class), + BLACK_WOOL(-1), + BLACKSTONE(-1), + BLACKSTONE_SLAB(-1, Slab.class), + BLACKSTONE_STAIRS(-1, Stairs.class), + BLACKSTONE_WALL(-1, Wall.class), + BLAST_FURNACE(-1, Furnace.class), + BLUE_BANNER(-1, 16, Rotatable.class), + BLUE_BED(-1, 1, Bed.class), + BLUE_CANDLE(-1, Candle.class), + BLUE_CANDLE_CAKE(-1, Lightable.class), + BLUE_CARPET(-1), + BLUE_CONCRETE(-1), + BLUE_CONCRETE_POWDER(-1), + BLUE_GLAZED_TERRACOTTA(-1, Directional.class), + BLUE_ICE(-1), + BLUE_ORCHID(-1), + BLUE_SHULKER_BOX(-1, 1, Directional.class), + BLUE_STAINED_GLASS(-1), + BLUE_STAINED_GLASS_PANE(-1, GlassPane.class), + BLUE_TERRACOTTA(-1), + BLUE_WALL_BANNER(-1, Directional.class), + BLUE_WOOL(-1), + BONE_BLOCK(-1, Orientable.class), + BOOKSHELF(-1), + BRAIN_CORAL(-1, Waterlogged.class), + BRAIN_CORAL_BLOCK(-1), + BRAIN_CORAL_FAN(-1, Waterlogged.class), + BRAIN_CORAL_WALL_FAN(-1, CoralWallFan.class), + BREWING_STAND(-1, BrewingStand.class), + BRICK_SLAB(-1, Slab.class), + BRICK_STAIRS(-1, Stairs.class), + BRICK_WALL(-1, Wall.class), + BRICKS(-1), + BROWN_BANNER(-1, 16, Rotatable.class), + BROWN_BED(-1, 1, Bed.class), + BROWN_CANDLE(-1, Candle.class), + BROWN_CANDLE_CAKE(-1, Lightable.class), + BROWN_CARPET(-1), + BROWN_CONCRETE(-1), + BROWN_CONCRETE_POWDER(-1), + BROWN_GLAZED_TERRACOTTA(-1, Directional.class), + BROWN_MUSHROOM(-1), + BROWN_MUSHROOM_BLOCK(-1, MultipleFacing.class), + BROWN_SHULKER_BOX(-1, 1, Directional.class), + BROWN_STAINED_GLASS(-1), + BROWN_STAINED_GLASS_PANE(-1, GlassPane.class), + BROWN_TERRACOTTA(-1), + BROWN_WALL_BANNER(-1, Directional.class), + BROWN_WOOL(-1), + BUBBLE_COLUMN(-1, BubbleColumn.class), + BUBBLE_CORAL(-1, Waterlogged.class), + BUBBLE_CORAL_BLOCK(-1), + BUBBLE_CORAL_FAN(-1, Waterlogged.class), + BUBBLE_CORAL_WALL_FAN(-1, CoralWallFan.class), + BUDDING_AMETHYST(-1), + BUSH(-1), + CACTUS(-1, Ageable.class), + CACTUS_FLOWER(-1), + CAKE(-1, 1, Cake.class), + CALCITE(-1), + CALIBRATED_SCULK_SENSOR(-1, CalibratedSculkSensor.class), + CAMPFIRE(-1, Campfire.class), + CANDLE(-1, Candle.class), + CANDLE_CAKE(-1, Lightable.class), + CARROTS(-1, Ageable.class), + CARTOGRAPHY_TABLE(-1), + CARVED_PUMPKIN(-1, Directional.class), + CAULDRON(-1), + CAVE_AIR(-1), + CAVE_VINES(-1, CaveVines.class), + CAVE_VINES_PLANT(-1, CaveVinesPlant.class), + CHAIN(-1, Chain.class), + CHAIN_COMMAND_BLOCK(-1, CommandBlock.class), + CHERRY_BUTTON(-1, Switch.class), + CHERRY_DOOR(-1, Door.class), + CHERRY_FENCE(-1, Fence.class), + CHERRY_FENCE_GATE(-1, Gate.class), + CHERRY_HANGING_SIGN(-1, 16, HangingSign.class), + CHERRY_LEAVES(-1, Leaves.class), + CHERRY_LOG(-1, Orientable.class), + CHERRY_PLANKS(-1), + CHERRY_PRESSURE_PLATE(-1, Powerable.class), + CHERRY_SAPLING(-1, Sapling.class), + CHERRY_SIGN(-1, 16, Sign.class), + CHERRY_SLAB(-1, Slab.class), + CHERRY_STAIRS(-1, Stairs.class), + CHERRY_TRAPDOOR(-1, TrapDoor.class), + CHERRY_WALL_HANGING_SIGN(-1, WallHangingSign.class), + CHERRY_WALL_SIGN(-1, 16, WallSign.class), + CHERRY_WOOD(-1, Orientable.class), + CHEST(-1, Chest.class), + CHIPPED_ANVIL(-1, Directional.class), + CHISELED_BOOKSHELF(-1, ChiseledBookshelf.class), + CHISELED_COPPER(-1), + CHISELED_DEEPSLATE(-1), + CHISELED_NETHER_BRICKS(-1), + CHISELED_POLISHED_BLACKSTONE(-1), + CHISELED_QUARTZ_BLOCK(-1), + CHISELED_RED_SANDSTONE(-1), + CHISELED_RESIN_BRICKS(-1), + CHISELED_SANDSTONE(-1), + CHISELED_STONE_BRICKS(-1), + CHISELED_TUFF(-1), + CHISELED_TUFF_BRICKS(-1), + CHORUS_FLOWER(-1, Ageable.class), + CHORUS_PLANT(-1, MultipleFacing.class), + CLAY(-1), + CLOSED_EYEBLOSSOM(-1), + COAL_BLOCK(-1), + COAL_ORE(-1), + COARSE_DIRT(-1), + COBBLED_DEEPSLATE(-1), + COBBLED_DEEPSLATE_SLAB(-1, Slab.class), + COBBLED_DEEPSLATE_STAIRS(-1, Stairs.class), + COBBLED_DEEPSLATE_WALL(-1, Wall.class), + COBBLESTONE(-1), + COBBLESTONE_SLAB(-1, Slab.class), + COBBLESTONE_STAIRS(-1, Stairs.class), + COBBLESTONE_WALL(-1, Wall.class), + COBWEB(-1), + COCOA(-1, Cocoa.class), + COMMAND_BLOCK(-1, CommandBlock.class), + COMPARATOR(-1, Comparator.class), + COMPOSTER(-1, Levelled.class), + CONDUIT(-1, Waterlogged.class), + COPPER_BLOCK(-1), + COPPER_BULB(-1, CopperBulb.class), + COPPER_DOOR(-1, Door.class), + COPPER_GRATE(-1, Waterlogged.class), + COPPER_ORE(-1), + COPPER_TRAPDOOR(-1, TrapDoor.class), + CORNFLOWER(-1), + CRACKED_DEEPSLATE_BRICKS(-1), + CRACKED_DEEPSLATE_TILES(-1), + CRACKED_NETHER_BRICKS(-1), + CRACKED_POLISHED_BLACKSTONE_BRICKS(-1), + CRACKED_STONE_BRICKS(-1), + CRAFTER(-1, Crafter.class), + CRAFTING_TABLE(-1), + CREAKING_HEART(-1, CreakingHeart.class), + CREEPER_HEAD(-1, Skull.class), + CREEPER_WALL_HEAD(-1, WallSkull.class), + CRIMSON_BUTTON(-1, Switch.class), + CRIMSON_DOOR(-1, Door.class), + CRIMSON_FENCE(-1, Fence.class), + CRIMSON_FENCE_GATE(-1, Gate.class), + CRIMSON_FUNGUS(-1), + CRIMSON_HANGING_SIGN(-1, 16, HangingSign.class), + CRIMSON_HYPHAE(-1, Orientable.class), + CRIMSON_NYLIUM(-1), + CRIMSON_PLANKS(-1), + CRIMSON_PRESSURE_PLATE(-1, Powerable.class), + CRIMSON_ROOTS(-1), + CRIMSON_SIGN(-1, 16, Sign.class), + CRIMSON_SLAB(-1, Slab.class), + CRIMSON_STAIRS(-1, Stairs.class), + CRIMSON_STEM(-1, Orientable.class), + CRIMSON_TRAPDOOR(-1, TrapDoor.class), + CRIMSON_WALL_HANGING_SIGN(-1, WallHangingSign.class), + CRIMSON_WALL_SIGN(-1, 16, WallSign.class), + CRYING_OBSIDIAN(-1), + CUT_COPPER(-1), + CUT_COPPER_SLAB(-1, Slab.class), + CUT_COPPER_STAIRS(-1, Stairs.class), + CUT_RED_SANDSTONE(-1), + CUT_RED_SANDSTONE_SLAB(-1, Slab.class), + CUT_SANDSTONE(-1), + CUT_SANDSTONE_SLAB(-1, Slab.class), + CYAN_BANNER(-1, 16, Rotatable.class), + CYAN_BED(-1, 1, Bed.class), + CYAN_CANDLE(-1, Candle.class), + CYAN_CANDLE_CAKE(-1, Lightable.class), + CYAN_CARPET(-1), + CYAN_CONCRETE(-1), + CYAN_CONCRETE_POWDER(-1), + CYAN_GLAZED_TERRACOTTA(-1, Directional.class), + CYAN_SHULKER_BOX(-1, 1, Directional.class), + CYAN_STAINED_GLASS(-1), + CYAN_STAINED_GLASS_PANE(-1, GlassPane.class), + CYAN_TERRACOTTA(-1), + CYAN_WALL_BANNER(-1, Directional.class), + CYAN_WOOL(-1), + DAMAGED_ANVIL(-1, Directional.class), + DANDELION(-1), + DARK_OAK_BUTTON(-1, Switch.class), + DARK_OAK_DOOR(-1, Door.class), + DARK_OAK_FENCE(-1, Fence.class), + DARK_OAK_FENCE_GATE(-1, Gate.class), + DARK_OAK_HANGING_SIGN(-1, 16, HangingSign.class), + DARK_OAK_LEAVES(-1, Leaves.class), + DARK_OAK_LOG(-1, Orientable.class), + DARK_OAK_PLANKS(-1), + DARK_OAK_PRESSURE_PLATE(-1, Powerable.class), + DARK_OAK_SAPLING(-1, Sapling.class), + DARK_OAK_SIGN(-1, 16, Sign.class), + DARK_OAK_SLAB(-1, Slab.class), + DARK_OAK_STAIRS(-1, Stairs.class), + DARK_OAK_TRAPDOOR(-1, TrapDoor.class), + DARK_OAK_WALL_HANGING_SIGN(-1, WallHangingSign.class), + DARK_OAK_WALL_SIGN(-1, 16, WallSign.class), + DARK_OAK_WOOD(-1, Orientable.class), + DARK_PRISMARINE(-1), + DARK_PRISMARINE_SLAB(-1, Slab.class), + DARK_PRISMARINE_STAIRS(-1, Stairs.class), + DAYLIGHT_DETECTOR(-1, DaylightDetector.class), + DEAD_BRAIN_CORAL(-1, Waterlogged.class), + DEAD_BRAIN_CORAL_BLOCK(-1), + DEAD_BRAIN_CORAL_FAN(-1, Waterlogged.class), + DEAD_BRAIN_CORAL_WALL_FAN(-1, CoralWallFan.class), + DEAD_BUBBLE_CORAL(-1, Waterlogged.class), + DEAD_BUBBLE_CORAL_BLOCK(-1), + DEAD_BUBBLE_CORAL_FAN(-1, Waterlogged.class), + DEAD_BUBBLE_CORAL_WALL_FAN(-1, CoralWallFan.class), + DEAD_BUSH(-1), + DEAD_FIRE_CORAL(-1, Waterlogged.class), + DEAD_FIRE_CORAL_BLOCK(-1), + DEAD_FIRE_CORAL_FAN(-1, Waterlogged.class), + DEAD_FIRE_CORAL_WALL_FAN(-1, CoralWallFan.class), + DEAD_HORN_CORAL(-1, Waterlogged.class), + DEAD_HORN_CORAL_BLOCK(-1), + DEAD_HORN_CORAL_FAN(-1, Waterlogged.class), + DEAD_HORN_CORAL_WALL_FAN(-1, CoralWallFan.class), + DEAD_TUBE_CORAL(-1, Waterlogged.class), + DEAD_TUBE_CORAL_BLOCK(-1), + DEAD_TUBE_CORAL_FAN(-1, Waterlogged.class), + DEAD_TUBE_CORAL_WALL_FAN(-1, CoralWallFan.class), + DECORATED_POT(-1, DecoratedPot.class), + DEEPSLATE(-1, Orientable.class), + DEEPSLATE_BRICK_SLAB(-1, Slab.class), + DEEPSLATE_BRICK_STAIRS(-1, Stairs.class), + DEEPSLATE_BRICK_WALL(-1, Wall.class), + DEEPSLATE_BRICKS(-1), + DEEPSLATE_COAL_ORE(-1), + DEEPSLATE_COPPER_ORE(-1), + DEEPSLATE_DIAMOND_ORE(-1), + DEEPSLATE_EMERALD_ORE(-1), + DEEPSLATE_GOLD_ORE(-1), + DEEPSLATE_IRON_ORE(-1), + DEEPSLATE_LAPIS_ORE(-1), + DEEPSLATE_REDSTONE_ORE(-1, Lightable.class), + DEEPSLATE_TILE_SLAB(-1, Slab.class), + DEEPSLATE_TILE_STAIRS(-1, Stairs.class), + DEEPSLATE_TILE_WALL(-1, Wall.class), + DEEPSLATE_TILES(-1), + DETECTOR_RAIL(-1, RedstoneRail.class), + DIAMOND_BLOCK(-1), + DIAMOND_ORE(-1), + DIORITE(-1), + DIORITE_SLAB(-1, Slab.class), + DIORITE_STAIRS(-1, Stairs.class), + DIORITE_WALL(-1, Wall.class), + DIRT(-1), + DIRT_PATH(-1), + DISPENSER(-1, Dispenser.class), + DRAGON_EGG(-1), + DRAGON_HEAD(-1, Skull.class), + DRAGON_WALL_HEAD(-1, WallSkull.class), + DRIED_KELP_BLOCK(-1), + DRIPSTONE_BLOCK(-1), + DROPPER(-1, Dispenser.class), + EMERALD_BLOCK(-1), + EMERALD_ORE(-1), + ENCHANTING_TABLE(-1), + END_GATEWAY(-1), + END_PORTAL(-1), + END_PORTAL_FRAME(-1, EndPortalFrame.class), + END_ROD(-1, Directional.class), + END_STONE(-1), + END_STONE_BRICK_SLAB(-1, Slab.class), + END_STONE_BRICK_STAIRS(-1, Stairs.class), + END_STONE_BRICK_WALL(-1, Wall.class), + END_STONE_BRICKS(-1), + ENDER_CHEST(-1, EnderChest.class), + EXPOSED_CHISELED_COPPER(-1), + EXPOSED_COPPER(-1), + EXPOSED_COPPER_BULB(-1, CopperBulb.class), + EXPOSED_COPPER_DOOR(-1, Door.class), + EXPOSED_COPPER_GRATE(-1, Waterlogged.class), + EXPOSED_COPPER_TRAPDOOR(-1, TrapDoor.class), + EXPOSED_CUT_COPPER(-1), + EXPOSED_CUT_COPPER_SLAB(-1, Slab.class), + EXPOSED_CUT_COPPER_STAIRS(-1, Stairs.class), + FARMLAND(-1, Farmland.class), + FERN(-1), + FIRE(-1, Fire.class), + FIRE_CORAL(-1, Waterlogged.class), + FIRE_CORAL_BLOCK(-1), + FIRE_CORAL_FAN(-1, Waterlogged.class), + FIRE_CORAL_WALL_FAN(-1, CoralWallFan.class), + FIREFLY_BUSH(-1), + FLETCHING_TABLE(-1), + FLOWER_POT(-1), + FLOWERING_AZALEA(-1), + FLOWERING_AZALEA_LEAVES(-1, Leaves.class), + FROGSPAWN(-1), + FROSTED_ICE(-1, Ageable.class), + FURNACE(-1, Furnace.class), + GILDED_BLACKSTONE(-1), + GLASS(-1), + GLASS_PANE(-1, Fence.class), + GLOW_LICHEN(-1, GlowLichen.class), + GLOWSTONE(-1), + GOLD_BLOCK(-1), + GOLD_ORE(-1), + GRANITE(-1), + GRANITE_SLAB(-1, Slab.class), + GRANITE_STAIRS(-1, Stairs.class), + GRANITE_WALL(-1, Wall.class), + GRASS_BLOCK(-1, Snowable.class), + GRAVEL(-1), + GRAY_BANNER(-1, 16, Rotatable.class), + GRAY_BED(-1, 1, Bed.class), + GRAY_CANDLE(-1, Candle.class), + GRAY_CANDLE_CAKE(-1, Lightable.class), + GRAY_CARPET(-1), + GRAY_CONCRETE(-1), + GRAY_CONCRETE_POWDER(-1), + GRAY_GLAZED_TERRACOTTA(-1, Directional.class), + GRAY_SHULKER_BOX(-1, 1, Directional.class), + GRAY_STAINED_GLASS(-1), + GRAY_STAINED_GLASS_PANE(-1, GlassPane.class), + GRAY_TERRACOTTA(-1), + GRAY_WALL_BANNER(-1, Directional.class), + GRAY_WOOL(-1), + GREEN_BANNER(-1, 16, Rotatable.class), + GREEN_BED(-1, 1, Bed.class), + GREEN_CANDLE(-1, Candle.class), + GREEN_CANDLE_CAKE(-1, Lightable.class), + GREEN_CARPET(-1), + GREEN_CONCRETE(-1), + GREEN_CONCRETE_POWDER(-1), + GREEN_GLAZED_TERRACOTTA(-1, Directional.class), + GREEN_SHULKER_BOX(-1, 1, Directional.class), + GREEN_STAINED_GLASS(-1), + GREEN_STAINED_GLASS_PANE(-1, GlassPane.class), + GREEN_TERRACOTTA(-1), + GREEN_WALL_BANNER(-1, Directional.class), + GREEN_WOOL(-1), + GRINDSTONE(-1, Grindstone.class), + HANGING_ROOTS(-1, Waterlogged.class), + HAY_BLOCK(-1, Orientable.class), + HEAVY_CORE(-1, Waterlogged.class), + HEAVY_WEIGHTED_PRESSURE_PLATE(-1, AnaloguePowerable.class), + HONEY_BLOCK(-1), + HONEYCOMB_BLOCK(-1), + HOPPER(-1, Hopper.class), + HORN_CORAL(-1, Waterlogged.class), + HORN_CORAL_BLOCK(-1), + HORN_CORAL_FAN(-1, Waterlogged.class), + HORN_CORAL_WALL_FAN(-1, CoralWallFan.class), + ICE(-1), + INFESTED_CHISELED_STONE_BRICKS(-1), + INFESTED_COBBLESTONE(-1), + INFESTED_CRACKED_STONE_BRICKS(-1), + INFESTED_DEEPSLATE(-1, Orientable.class), + INFESTED_MOSSY_STONE_BRICKS(-1), + INFESTED_STONE(-1), + INFESTED_STONE_BRICKS(-1), + IRON_BARS(-1, Fence.class), + IRON_BLOCK(-1), + IRON_DOOR(-1, Door.class), + IRON_ORE(-1), + IRON_TRAPDOOR(-1, TrapDoor.class), + JACK_O_LANTERN(-1, Directional.class), + JIGSAW(-1, Jigsaw.class), + JUKEBOX(-1, Jukebox.class), + JUNGLE_BUTTON(-1, Switch.class), + JUNGLE_DOOR(-1, Door.class), + JUNGLE_FENCE(-1, Fence.class), + JUNGLE_FENCE_GATE(-1, Gate.class), + JUNGLE_HANGING_SIGN(-1, 16, HangingSign.class), + JUNGLE_LEAVES(-1, Leaves.class), + JUNGLE_LOG(-1, Orientable.class), + JUNGLE_PLANKS(-1), + JUNGLE_PRESSURE_PLATE(-1, Powerable.class), + JUNGLE_SAPLING(-1, Sapling.class), + JUNGLE_SIGN(-1, 16, Sign.class), + JUNGLE_SLAB(-1, Slab.class), + JUNGLE_STAIRS(-1, Stairs.class), + JUNGLE_TRAPDOOR(-1, TrapDoor.class), + JUNGLE_WALL_HANGING_SIGN(-1, WallHangingSign.class), + JUNGLE_WALL_SIGN(-1, 16, WallSign.class), + JUNGLE_WOOD(-1, Orientable.class), + KELP(-1, Ageable.class), + KELP_PLANT(-1), + LADDER(-1, Ladder.class), + LANTERN(-1, Lantern.class), + LAPIS_BLOCK(-1), + LAPIS_ORE(-1), + LARGE_AMETHYST_BUD(-1, AmethystCluster.class), + LARGE_FERN(-1, Bisected.class), + LAVA(-1, Levelled.class), + LAVA_CAULDRON(-1), + LEAF_LITTER(-1, LeafLitter.class), + LECTERN(-1, Lectern.class), + LEVER(-1, Switch.class), + LIGHT(-1, Light.class), + LIGHT_BLUE_BANNER(-1, 16, Rotatable.class), + LIGHT_BLUE_BED(-1, 1, Bed.class), + LIGHT_BLUE_CANDLE(-1, Candle.class), + LIGHT_BLUE_CANDLE_CAKE(-1, Lightable.class), + LIGHT_BLUE_CARPET(-1), + LIGHT_BLUE_CONCRETE(-1), + LIGHT_BLUE_CONCRETE_POWDER(-1), + LIGHT_BLUE_GLAZED_TERRACOTTA(-1, Directional.class), + LIGHT_BLUE_SHULKER_BOX(-1, 1, Directional.class), + LIGHT_BLUE_STAINED_GLASS(-1), + LIGHT_BLUE_STAINED_GLASS_PANE(-1, GlassPane.class), + LIGHT_BLUE_TERRACOTTA(-1), + LIGHT_BLUE_WALL_BANNER(-1, Directional.class), + LIGHT_BLUE_WOOL(-1), + LIGHT_GRAY_BANNER(-1, 16, Rotatable.class), + LIGHT_GRAY_BED(-1, 1, Bed.class), + LIGHT_GRAY_CANDLE(-1, Candle.class), + LIGHT_GRAY_CANDLE_CAKE(-1, Lightable.class), + LIGHT_GRAY_CARPET(-1), + LIGHT_GRAY_CONCRETE(-1), + LIGHT_GRAY_CONCRETE_POWDER(-1), + LIGHT_GRAY_GLAZED_TERRACOTTA(-1, Directional.class), + LIGHT_GRAY_SHULKER_BOX(-1, 1, Directional.class), + LIGHT_GRAY_STAINED_GLASS(-1), + LIGHT_GRAY_STAINED_GLASS_PANE(-1, GlassPane.class), + LIGHT_GRAY_TERRACOTTA(-1), + LIGHT_GRAY_WALL_BANNER(-1, Directional.class), + LIGHT_GRAY_WOOL(-1), + LIGHT_WEIGHTED_PRESSURE_PLATE(-1, AnaloguePowerable.class), + LIGHTNING_ROD(-1, LightningRod.class), + LILAC(-1, Bisected.class), + LILY_OF_THE_VALLEY(-1), + LILY_PAD(-1), + LIME_BANNER(-1, 16, Rotatable.class), + LIME_BED(-1, 1, Bed.class), + LIME_CANDLE(-1, Candle.class), + LIME_CANDLE_CAKE(-1, Lightable.class), + LIME_CARPET(-1), + LIME_CONCRETE(-1), + LIME_CONCRETE_POWDER(-1), + LIME_GLAZED_TERRACOTTA(-1, Directional.class), + LIME_SHULKER_BOX(-1, 1, Directional.class), + LIME_STAINED_GLASS(-1), + LIME_STAINED_GLASS_PANE(-1, GlassPane.class), + LIME_TERRACOTTA(-1), + LIME_WALL_BANNER(-1, Directional.class), + LIME_WOOL(-1), + LODESTONE(-1), + LOOM(-1, Directional.class), + MAGENTA_BANNER(-1, 16, Rotatable.class), + MAGENTA_BED(-1, 1, Bed.class), + MAGENTA_CANDLE(-1, Candle.class), + MAGENTA_CANDLE_CAKE(-1, Lightable.class), + MAGENTA_CARPET(-1), + MAGENTA_CONCRETE(-1), + MAGENTA_CONCRETE_POWDER(-1), + MAGENTA_GLAZED_TERRACOTTA(-1, Directional.class), + MAGENTA_SHULKER_BOX(-1, 1, Directional.class), + MAGENTA_STAINED_GLASS(-1), + MAGENTA_STAINED_GLASS_PANE(-1, GlassPane.class), + MAGENTA_TERRACOTTA(-1), + MAGENTA_WALL_BANNER(-1, Directional.class), + MAGENTA_WOOL(-1), + MAGMA_BLOCK(-1), + MANGROVE_BUTTON(-1, Switch.class), + MANGROVE_DOOR(-1, Door.class), + MANGROVE_FENCE(-1, Fence.class), + MANGROVE_FENCE_GATE(-1, Gate.class), + MANGROVE_HANGING_SIGN(-1, 16, HangingSign.class), + MANGROVE_LEAVES(-1, Leaves.class), + MANGROVE_LOG(-1, Orientable.class), + MANGROVE_PLANKS(-1), + MANGROVE_PRESSURE_PLATE(-1, Powerable.class), + MANGROVE_PROPAGULE(-1, MangrovePropagule.class), + MANGROVE_ROOTS(-1, Waterlogged.class), + MANGROVE_SIGN(-1, 16, Sign.class), + MANGROVE_SLAB(-1, Slab.class), + MANGROVE_STAIRS(-1, Stairs.class), + MANGROVE_TRAPDOOR(-1, TrapDoor.class), + MANGROVE_WALL_HANGING_SIGN(-1, WallHangingSign.class), + MANGROVE_WALL_SIGN(-1, 16, WallSign.class), + MANGROVE_WOOD(-1, Orientable.class), + MEDIUM_AMETHYST_BUD(-1, AmethystCluster.class), + MELON(-1), + MELON_STEM(-1, Ageable.class), + MOSS_BLOCK(-1), + MOSS_CARPET(-1), + MOSSY_COBBLESTONE(-1), + MOSSY_COBBLESTONE_SLAB(-1, Slab.class), + MOSSY_COBBLESTONE_STAIRS(-1, Stairs.class), + MOSSY_COBBLESTONE_WALL(-1, Wall.class), + MOSSY_STONE_BRICK_SLAB(-1, Slab.class), + MOSSY_STONE_BRICK_STAIRS(-1, Stairs.class), + MOSSY_STONE_BRICK_WALL(-1, Wall.class), + MOSSY_STONE_BRICKS(-1), + MOVING_PISTON(-1, TechnicalPiston.class), + MUD(-1), + MUD_BRICK_SLAB(-1, Slab.class), + MUD_BRICK_STAIRS(-1, Stairs.class), + MUD_BRICK_WALL(-1, Wall.class), + MUD_BRICKS(-1), + MUDDY_MANGROVE_ROOTS(-1, Orientable.class), + MUSHROOM_STEM(-1, MultipleFacing.class), + MYCELIUM(-1, Snowable.class), + NETHER_BRICK_FENCE(-1, Fence.class), + NETHER_BRICK_SLAB(-1, Slab.class), + NETHER_BRICK_STAIRS(-1, Stairs.class), + NETHER_BRICK_WALL(-1, Wall.class), + NETHER_BRICKS(-1), + NETHER_GOLD_ORE(-1), + NETHER_PORTAL(-1, Orientable.class), + NETHER_QUARTZ_ORE(-1), + NETHER_SPROUTS(-1), + NETHER_WART(-1, Ageable.class), + NETHER_WART_BLOCK(-1), + NETHERITE_BLOCK(-1), + NETHERRACK(-1), + NOTE_BLOCK(-1, NoteBlock.class), + OAK_BUTTON(-1, Switch.class), + OAK_DOOR(-1, Door.class), + OAK_FENCE(-1, Fence.class), + OAK_FENCE_GATE(-1, Gate.class), + OAK_HANGING_SIGN(-1, 16, HangingSign.class), + OAK_LEAVES(-1, Leaves.class), + OAK_LOG(-1, Orientable.class), + OAK_PLANKS(-1), + OAK_PRESSURE_PLATE(-1, Powerable.class), + OAK_SAPLING(-1, Sapling.class), + OAK_SIGN(-1, 16, Sign.class), + OAK_SLAB(-1, Slab.class), + OAK_STAIRS(-1, Stairs.class), + OAK_TRAPDOOR(-1, TrapDoor.class), + OAK_WALL_HANGING_SIGN(-1, WallHangingSign.class), + OAK_WALL_SIGN(-1, 16, WallSign.class), + OAK_WOOD(-1, Orientable.class), + OBSERVER(-1, Observer.class), + OBSIDIAN(-1), + OCHRE_FROGLIGHT(-1, Orientable.class), + OPEN_EYEBLOSSOM(-1), + ORANGE_BANNER(-1, 16, Rotatable.class), + ORANGE_BED(-1, 1, Bed.class), + ORANGE_CANDLE(-1, Candle.class), + ORANGE_CANDLE_CAKE(-1, Lightable.class), + ORANGE_CARPET(-1), + ORANGE_CONCRETE(-1), + ORANGE_CONCRETE_POWDER(-1), + ORANGE_GLAZED_TERRACOTTA(-1, Directional.class), + ORANGE_SHULKER_BOX(-1, 1, Directional.class), + ORANGE_STAINED_GLASS(-1), + ORANGE_STAINED_GLASS_PANE(-1, GlassPane.class), + ORANGE_TERRACOTTA(-1), + ORANGE_TULIP(-1), + ORANGE_WALL_BANNER(-1, Directional.class), + ORANGE_WOOL(-1), + OXEYE_DAISY(-1), + OXIDIZED_CHISELED_COPPER(-1), + OXIDIZED_COPPER(-1), + OXIDIZED_COPPER_BULB(-1, CopperBulb.class), + OXIDIZED_COPPER_DOOR(-1, Door.class), + OXIDIZED_COPPER_GRATE(-1, Waterlogged.class), + OXIDIZED_COPPER_TRAPDOOR(-1, TrapDoor.class), + OXIDIZED_CUT_COPPER(-1), + OXIDIZED_CUT_COPPER_SLAB(-1, Slab.class), + OXIDIZED_CUT_COPPER_STAIRS(-1, Stairs.class), + PACKED_ICE(-1), + PACKED_MUD(-1), + PALE_HANGING_MOSS(-1, HangingMoss.class), + PALE_MOSS_BLOCK(-1), + PALE_MOSS_CARPET(-1, MossyCarpet.class), + PALE_OAK_BUTTON(-1, Switch.class), + PALE_OAK_DOOR(-1, Door.class), + PALE_OAK_FENCE(-1, Fence.class), + PALE_OAK_FENCE_GATE(-1, Gate.class), + PALE_OAK_HANGING_SIGN(-1, 16, HangingSign.class), + PALE_OAK_LEAVES(-1, Leaves.class), + PALE_OAK_LOG(-1, Orientable.class), + PALE_OAK_PLANKS(-1), + PALE_OAK_PRESSURE_PLATE(-1, Powerable.class), + PALE_OAK_SAPLING(-1, Sapling.class), + PALE_OAK_SIGN(-1, 16, Sign.class), + PALE_OAK_SLAB(-1, Slab.class), + PALE_OAK_STAIRS(-1, Stairs.class), + PALE_OAK_TRAPDOOR(-1, TrapDoor.class), + PALE_OAK_WALL_HANGING_SIGN(-1, WallHangingSign.class), + PALE_OAK_WALL_SIGN(-1, 16, WallSign.class), + PALE_OAK_WOOD(-1, Orientable.class), + PEARLESCENT_FROGLIGHT(-1, Orientable.class), + PEONY(-1, Bisected.class), + PETRIFIED_OAK_SLAB(-1, Slab.class), + PIGLIN_HEAD(-1, Skull.class), + PIGLIN_WALL_HEAD(-1, WallSkull.class), + PINK_BANNER(-1, 16, Rotatable.class), + PINK_BED(-1, 1, Bed.class), + PINK_CANDLE(-1, Candle.class), + PINK_CANDLE_CAKE(-1, Lightable.class), + PINK_CARPET(-1), + PINK_CONCRETE(-1), + PINK_CONCRETE_POWDER(-1), + PINK_GLAZED_TERRACOTTA(-1, Directional.class), + PINK_PETALS(-1, FlowerBed.class), + PINK_SHULKER_BOX(-1, 1, Directional.class), + PINK_STAINED_GLASS(-1), + PINK_STAINED_GLASS_PANE(-1, GlassPane.class), + PINK_TERRACOTTA(-1), + PINK_TULIP(-1), + PINK_WALL_BANNER(-1, Directional.class), + PINK_WOOL(-1), + PISTON(-1, Piston.class), + PISTON_HEAD(-1, PistonHead.class), + PITCHER_CROP(-1, PitcherCrop.class), + PITCHER_PLANT(-1, Bisected.class), + PLAYER_HEAD(-1, Skull.class), + PLAYER_WALL_HEAD(-1, WallSkull.class), + PODZOL(-1, Snowable.class), + POINTED_DRIPSTONE(-1, PointedDripstone.class), + POLISHED_ANDESITE(-1), + POLISHED_ANDESITE_SLAB(-1, Slab.class), + POLISHED_ANDESITE_STAIRS(-1, Stairs.class), + POLISHED_BASALT(-1, Orientable.class), + POLISHED_BLACKSTONE(-1), + POLISHED_BLACKSTONE_BRICK_SLAB(-1, Slab.class), + POLISHED_BLACKSTONE_BRICK_STAIRS(-1, Stairs.class), + POLISHED_BLACKSTONE_BRICK_WALL(-1, Wall.class), + POLISHED_BLACKSTONE_BRICKS(-1), + POLISHED_BLACKSTONE_BUTTON(-1, Switch.class), + POLISHED_BLACKSTONE_PRESSURE_PLATE(-1, Powerable.class), + POLISHED_BLACKSTONE_SLAB(-1, Slab.class), + POLISHED_BLACKSTONE_STAIRS(-1, Stairs.class), + POLISHED_BLACKSTONE_WALL(-1, Wall.class), + POLISHED_DEEPSLATE(-1), + POLISHED_DEEPSLATE_SLAB(-1, Slab.class), + POLISHED_DEEPSLATE_STAIRS(-1, Stairs.class), + POLISHED_DEEPSLATE_WALL(-1, Wall.class), + POLISHED_DIORITE(-1), + POLISHED_DIORITE_SLAB(-1, Slab.class), + POLISHED_DIORITE_STAIRS(-1, Stairs.class), + POLISHED_GRANITE(-1), + POLISHED_GRANITE_SLAB(-1, Slab.class), + POLISHED_GRANITE_STAIRS(-1, Stairs.class), + POLISHED_TUFF(-1), + POLISHED_TUFF_SLAB(-1, Slab.class), + POLISHED_TUFF_STAIRS(-1, Stairs.class), + POLISHED_TUFF_WALL(-1, Wall.class), + POPPY(-1), + POTATOES(-1, Ageable.class), + POTTED_ACACIA_SAPLING(-1), + POTTED_ALLIUM(-1), + POTTED_AZALEA_BUSH(-1), + POTTED_AZURE_BLUET(-1), + POTTED_BAMBOO(-1), + POTTED_BIRCH_SAPLING(-1), + POTTED_BLUE_ORCHID(-1), + POTTED_BROWN_MUSHROOM(-1), + POTTED_CACTUS(-1), + POTTED_CHERRY_SAPLING(-1), + POTTED_CLOSED_EYEBLOSSOM(-1), + POTTED_CORNFLOWER(-1), + POTTED_CRIMSON_FUNGUS(-1), + POTTED_CRIMSON_ROOTS(-1), + POTTED_DANDELION(-1), + POTTED_DARK_OAK_SAPLING(-1), + POTTED_DEAD_BUSH(-1), + POTTED_FERN(-1), + POTTED_FLOWERING_AZALEA_BUSH(-1), + POTTED_JUNGLE_SAPLING(-1), + POTTED_LILY_OF_THE_VALLEY(-1), + POTTED_MANGROVE_PROPAGULE(-1), + POTTED_OAK_SAPLING(-1), + POTTED_OPEN_EYEBLOSSOM(-1), + POTTED_ORANGE_TULIP(-1), + POTTED_OXEYE_DAISY(-1), + POTTED_PALE_OAK_SAPLING(-1), + POTTED_PINK_TULIP(-1), + POTTED_POPPY(-1), + POTTED_RED_MUSHROOM(-1), + POTTED_RED_TULIP(-1), + POTTED_SPRUCE_SAPLING(-1), + POTTED_TORCHFLOWER(-1), + POTTED_WARPED_FUNGUS(-1), + POTTED_WARPED_ROOTS(-1), + POTTED_WHITE_TULIP(-1), + POTTED_WITHER_ROSE(-1), + POWDER_SNOW(-1), + POWDER_SNOW_CAULDRON(-1, Levelled.class), + POWERED_RAIL(-1, RedstoneRail.class), + PRISMARINE(-1), + PRISMARINE_BRICK_SLAB(-1, Slab.class), + PRISMARINE_BRICK_STAIRS(-1, Stairs.class), + PRISMARINE_BRICKS(-1), + PRISMARINE_SLAB(-1, Slab.class), + PRISMARINE_STAIRS(-1, Stairs.class), + PRISMARINE_WALL(-1, Wall.class), + PUMPKIN(-1), + PUMPKIN_STEM(-1, Ageable.class), + PURPLE_BANNER(-1, 16, Rotatable.class), + PURPLE_BED(-1, 1, Bed.class), + PURPLE_CANDLE(-1, Candle.class), + PURPLE_CANDLE_CAKE(-1, Lightable.class), + PURPLE_CARPET(-1), + PURPLE_CONCRETE(-1), + PURPLE_CONCRETE_POWDER(-1), + PURPLE_GLAZED_TERRACOTTA(-1, Directional.class), + PURPLE_SHULKER_BOX(-1, 1, Directional.class), + PURPLE_STAINED_GLASS(-1), + PURPLE_STAINED_GLASS_PANE(-1, GlassPane.class), + PURPLE_TERRACOTTA(-1), + PURPLE_WALL_BANNER(-1, Directional.class), + PURPLE_WOOL(-1), + PURPUR_BLOCK(-1), + PURPUR_PILLAR(-1, Orientable.class), + PURPUR_SLAB(-1, Slab.class), + PURPUR_STAIRS(-1, Stairs.class), + QUARTZ_BLOCK(-1), + QUARTZ_BRICKS(-1), + QUARTZ_PILLAR(-1, Orientable.class), + QUARTZ_SLAB(-1, Slab.class), + QUARTZ_STAIRS(-1, Stairs.class), + RAIL(-1, Rail.class), + RAW_COPPER_BLOCK(-1), + RAW_GOLD_BLOCK(-1), + RAW_IRON_BLOCK(-1), + RED_BANNER(-1, 16, Rotatable.class), + RED_BED(-1, 1, Bed.class), + RED_CANDLE(-1, Candle.class), + RED_CANDLE_CAKE(-1, Lightable.class), + RED_CARPET(-1), + RED_CONCRETE(-1), + RED_CONCRETE_POWDER(-1), + RED_GLAZED_TERRACOTTA(-1, Directional.class), + RED_MUSHROOM(-1), + RED_MUSHROOM_BLOCK(-1, MultipleFacing.class), + RED_NETHER_BRICK_SLAB(-1, Slab.class), + RED_NETHER_BRICK_STAIRS(-1, Stairs.class), + RED_NETHER_BRICK_WALL(-1, Wall.class), + RED_NETHER_BRICKS(-1), + RED_SAND(-1), + RED_SANDSTONE(-1), + RED_SANDSTONE_SLAB(-1, Slab.class), + RED_SANDSTONE_STAIRS(-1, Stairs.class), + RED_SANDSTONE_WALL(-1, Wall.class), + RED_SHULKER_BOX(-1, 1, Directional.class), + RED_STAINED_GLASS(-1), + RED_STAINED_GLASS_PANE(-1, GlassPane.class), + RED_TERRACOTTA(-1), + RED_TULIP(-1), + RED_WALL_BANNER(-1, Directional.class), + RED_WOOL(-1), + REDSTONE_BLOCK(-1), + REDSTONE_LAMP(-1, Lightable.class), + REDSTONE_ORE(-1, Lightable.class), + REDSTONE_TORCH(-1, Lightable.class), + REDSTONE_WALL_TORCH(-1, RedstoneWallTorch.class), + REDSTONE_WIRE(-1, RedstoneWire.class), + REINFORCED_DEEPSLATE(-1), + REPEATER(-1, Repeater.class), + REPEATING_COMMAND_BLOCK(-1, CommandBlock.class), + RESIN_BLOCK(-1), + RESIN_BRICK_SLAB(-1, Slab.class), + RESIN_BRICK_STAIRS(-1, Stairs.class), + RESIN_BRICK_WALL(-1, Wall.class), + RESIN_BRICKS(-1), + RESIN_CLUMP(-1, ResinClump.class), + RESPAWN_ANCHOR(-1, RespawnAnchor.class), + ROOTED_DIRT(-1), + ROSE_BUSH(-1, Bisected.class), + SAND(-1), + SANDSTONE(-1), + SANDSTONE_SLAB(-1, Slab.class), + SANDSTONE_STAIRS(-1, Stairs.class), + SANDSTONE_WALL(-1, Wall.class), + SCAFFOLDING(-1, Scaffolding.class), + SCULK(-1), + SCULK_CATALYST(-1, SculkCatalyst.class), + SCULK_SENSOR(-1, SculkSensor.class), + SCULK_SHRIEKER(-1, SculkShrieker.class), + SCULK_VEIN(-1, SculkVein.class), + SEA_LANTERN(-1), + SEA_PICKLE(-1, SeaPickle.class), + SEAGRASS(-1), + SHORT_DRY_GRASS(-1), + SHORT_GRASS(-1), + SHROOMLIGHT(-1), + SHULKER_BOX(-1, 1, Directional.class), + SKELETON_SKULL(-1, Skull.class), + SKELETON_WALL_SKULL(-1, WallSkull.class), + SLIME_BLOCK(-1), + SMALL_AMETHYST_BUD(-1, AmethystCluster.class), + SMALL_DRIPLEAF(-1, SmallDripleaf.class), + SMITHING_TABLE(-1), + SMOKER(-1, Furnace.class), + SMOOTH_BASALT(-1), + SMOOTH_QUARTZ(-1), + SMOOTH_QUARTZ_SLAB(-1, Slab.class), + SMOOTH_QUARTZ_STAIRS(-1, Stairs.class), + SMOOTH_RED_SANDSTONE(-1), + SMOOTH_RED_SANDSTONE_SLAB(-1, Slab.class), + SMOOTH_RED_SANDSTONE_STAIRS(-1, Stairs.class), + SMOOTH_SANDSTONE(-1), + SMOOTH_SANDSTONE_SLAB(-1, Slab.class), + SMOOTH_SANDSTONE_STAIRS(-1, Stairs.class), + SMOOTH_STONE(-1), + SMOOTH_STONE_SLAB(-1, Slab.class), + SNIFFER_EGG(-1, Hatchable.class), + SNOW(-1, Snow.class), + SNOW_BLOCK(-1), + SOUL_CAMPFIRE(-1, Campfire.class), + SOUL_FIRE(-1), + SOUL_LANTERN(-1, Lantern.class), + SOUL_SAND(-1), + SOUL_SOIL(-1), + SOUL_TORCH(-1), + SOUL_WALL_TORCH(-1, Directional.class), + SPAWNER(-1), + SPONGE(-1), + SPORE_BLOSSOM(-1), + SPRUCE_BUTTON(-1, Switch.class), + SPRUCE_DOOR(-1, Door.class), + SPRUCE_FENCE(-1, Fence.class), + SPRUCE_FENCE_GATE(-1, Gate.class), + SPRUCE_HANGING_SIGN(-1, 16, HangingSign.class), + SPRUCE_LEAVES(-1, Leaves.class), + SPRUCE_LOG(-1, Orientable.class), + SPRUCE_PLANKS(-1), + SPRUCE_PRESSURE_PLATE(-1, Powerable.class), + SPRUCE_SAPLING(-1, Sapling.class), + SPRUCE_SIGN(-1, 16, Sign.class), + SPRUCE_SLAB(-1, Slab.class), + SPRUCE_STAIRS(-1, Stairs.class), + SPRUCE_TRAPDOOR(-1, TrapDoor.class), + SPRUCE_WALL_HANGING_SIGN(-1, WallHangingSign.class), + SPRUCE_WALL_SIGN(-1, 16, WallSign.class), + SPRUCE_WOOD(-1, Orientable.class), + STICKY_PISTON(-1, Piston.class), + STONE(-1), + STONE_BRICK_SLAB(-1, Slab.class), + STONE_BRICK_STAIRS(-1, Stairs.class), + STONE_BRICK_WALL(-1, Wall.class), + STONE_BRICKS(-1), + STONE_BUTTON(-1, Switch.class), + STONE_PRESSURE_PLATE(-1, Powerable.class), + STONE_SLAB(-1, Slab.class), + STONE_STAIRS(-1, Stairs.class), + STONECUTTER(-1, Directional.class), + STRIPPED_ACACIA_LOG(-1, Orientable.class), + STRIPPED_ACACIA_WOOD(-1, Orientable.class), + STRIPPED_BAMBOO_BLOCK(-1, Orientable.class), + STRIPPED_BIRCH_LOG(-1, Orientable.class), + STRIPPED_BIRCH_WOOD(-1, Orientable.class), + STRIPPED_CHERRY_LOG(-1, Orientable.class), + STRIPPED_CHERRY_WOOD(-1, Orientable.class), + STRIPPED_CRIMSON_HYPHAE(-1, Orientable.class), + STRIPPED_CRIMSON_STEM(-1, Orientable.class), + STRIPPED_DARK_OAK_LOG(-1, Orientable.class), + STRIPPED_DARK_OAK_WOOD(-1, Orientable.class), + STRIPPED_JUNGLE_LOG(-1, Orientable.class), + STRIPPED_JUNGLE_WOOD(-1, Orientable.class), + STRIPPED_MANGROVE_LOG(-1, Orientable.class), + STRIPPED_MANGROVE_WOOD(-1, Orientable.class), + STRIPPED_OAK_LOG(-1, Orientable.class), + STRIPPED_OAK_WOOD(-1, Orientable.class), + STRIPPED_PALE_OAK_LOG(-1, Orientable.class), + STRIPPED_PALE_OAK_WOOD(-1, Orientable.class), + STRIPPED_SPRUCE_LOG(-1, Orientable.class), + STRIPPED_SPRUCE_WOOD(-1, Orientable.class), + STRIPPED_WARPED_HYPHAE(-1, Orientable.class), + STRIPPED_WARPED_STEM(-1, Orientable.class), + STRUCTURE_BLOCK(-1, StructureBlock.class), + STRUCTURE_VOID(-1), + SUGAR_CANE(-1, Ageable.class), + SUNFLOWER(-1, Bisected.class), + SUSPICIOUS_GRAVEL(-1, Brushable.class), + SUSPICIOUS_SAND(-1, Brushable.class), + SWEET_BERRY_BUSH(-1, Ageable.class), + TALL_DRY_GRASS(-1), + TALL_GRASS(-1, Bisected.class), + TALL_SEAGRASS(-1, Bisected.class), + TARGET(-1, AnaloguePowerable.class), + TERRACOTTA(-1), + TEST_BLOCK(-1, TestBlock.class), + TEST_INSTANCE_BLOCK(-1), + TINTED_GLASS(-1), + TNT(-1, TNT.class), + TORCH(-1), + TORCHFLOWER(-1), + TORCHFLOWER_CROP(-1, Ageable.class), + TRAPPED_CHEST(-1, Chest.class), + TRIAL_SPAWNER(-1, TrialSpawner.class), + TRIPWIRE(-1, Tripwire.class), + TRIPWIRE_HOOK(-1, TripwireHook.class), + TUBE_CORAL(-1, Waterlogged.class), + TUBE_CORAL_BLOCK(-1), + TUBE_CORAL_FAN(-1, Waterlogged.class), + TUBE_CORAL_WALL_FAN(-1, CoralWallFan.class), + TUFF(-1), + TUFF_BRICK_SLAB(-1, Slab.class), + TUFF_BRICK_STAIRS(-1, Stairs.class), + TUFF_BRICK_WALL(-1, Wall.class), + TUFF_BRICKS(-1), + TUFF_SLAB(-1, Slab.class), + TUFF_STAIRS(-1, Stairs.class), + TUFF_WALL(-1, Wall.class), + TURTLE_EGG(-1, TurtleEgg.class), + TWISTING_VINES(-1, Ageable.class), + TWISTING_VINES_PLANT(-1), + VAULT(-1, Vault.class), + VERDANT_FROGLIGHT(-1, Orientable.class), + VINE(-1, MultipleFacing.class), + VOID_AIR(-1), + WALL_TORCH(-1, Directional.class), + WARPED_BUTTON(-1, Switch.class), + WARPED_DOOR(-1, Door.class), + WARPED_FENCE(-1, Fence.class), + WARPED_FENCE_GATE(-1, Gate.class), + WARPED_FUNGUS(-1), + WARPED_HANGING_SIGN(-1, 16, HangingSign.class), + WARPED_HYPHAE(-1, Orientable.class), + WARPED_NYLIUM(-1), + WARPED_PLANKS(-1), + WARPED_PRESSURE_PLATE(-1, Powerable.class), + WARPED_ROOTS(-1), + WARPED_SIGN(-1, 16, Sign.class), + WARPED_SLAB(-1, Slab.class), + WARPED_STAIRS(-1, Stairs.class), + WARPED_STEM(-1, Orientable.class), + WARPED_TRAPDOOR(-1, TrapDoor.class), + WARPED_WALL_HANGING_SIGN(-1, WallHangingSign.class), + WARPED_WALL_SIGN(-1, 16, WallSign.class), + WARPED_WART_BLOCK(-1), + WATER(-1, Levelled.class), + WATER_CAULDRON(-1, Levelled.class), + WAXED_CHISELED_COPPER(-1), + WAXED_COPPER_BLOCK(-1), + WAXED_COPPER_BULB(-1, CopperBulb.class), + WAXED_COPPER_DOOR(-1, Door.class), + WAXED_COPPER_GRATE(-1, Waterlogged.class), + WAXED_COPPER_TRAPDOOR(-1, TrapDoor.class), + WAXED_CUT_COPPER(-1), + WAXED_CUT_COPPER_SLAB(-1, Slab.class), + WAXED_CUT_COPPER_STAIRS(-1, Stairs.class), + WAXED_EXPOSED_CHISELED_COPPER(-1), + WAXED_EXPOSED_COPPER(-1), + WAXED_EXPOSED_COPPER_BULB(-1, CopperBulb.class), + WAXED_EXPOSED_COPPER_DOOR(-1, Door.class), + WAXED_EXPOSED_COPPER_GRATE(-1, Waterlogged.class), + WAXED_EXPOSED_COPPER_TRAPDOOR(-1, TrapDoor.class), + WAXED_EXPOSED_CUT_COPPER(-1), + WAXED_EXPOSED_CUT_COPPER_SLAB(-1, Slab.class), + WAXED_EXPOSED_CUT_COPPER_STAIRS(-1, Stairs.class), + WAXED_OXIDIZED_CHISELED_COPPER(-1), + WAXED_OXIDIZED_COPPER(-1), + WAXED_OXIDIZED_COPPER_BULB(-1, CopperBulb.class), + WAXED_OXIDIZED_COPPER_DOOR(-1, Door.class), + WAXED_OXIDIZED_COPPER_GRATE(-1, Waterlogged.class), + WAXED_OXIDIZED_COPPER_TRAPDOOR(-1, TrapDoor.class), + WAXED_OXIDIZED_CUT_COPPER(-1), + WAXED_OXIDIZED_CUT_COPPER_SLAB(-1, Slab.class), + WAXED_OXIDIZED_CUT_COPPER_STAIRS(-1, Stairs.class), + WAXED_WEATHERED_CHISELED_COPPER(-1), + WAXED_WEATHERED_COPPER(-1), + WAXED_WEATHERED_COPPER_BULB(-1, CopperBulb.class), + WAXED_WEATHERED_COPPER_DOOR(-1, Door.class), + WAXED_WEATHERED_COPPER_GRATE(-1, Waterlogged.class), + WAXED_WEATHERED_COPPER_TRAPDOOR(-1, TrapDoor.class), + WAXED_WEATHERED_CUT_COPPER(-1), + WAXED_WEATHERED_CUT_COPPER_SLAB(-1, Slab.class), + WAXED_WEATHERED_CUT_COPPER_STAIRS(-1, Stairs.class), + WEATHERED_CHISELED_COPPER(-1), + WEATHERED_COPPER(-1), + WEATHERED_COPPER_BULB(-1, CopperBulb.class), + WEATHERED_COPPER_DOOR(-1, Door.class), + WEATHERED_COPPER_GRATE(-1, Waterlogged.class), + WEATHERED_COPPER_TRAPDOOR(-1, TrapDoor.class), + WEATHERED_CUT_COPPER(-1), + WEATHERED_CUT_COPPER_SLAB(-1, Slab.class), + WEATHERED_CUT_COPPER_STAIRS(-1, Stairs.class), + WEEPING_VINES(-1, Ageable.class), + WEEPING_VINES_PLANT(-1), + WET_SPONGE(-1), + WHEAT(-1, Ageable.class), + WHITE_BANNER(-1, 16, Rotatable.class), + WHITE_BED(-1, 1, Bed.class), + WHITE_CANDLE(-1, Candle.class), + WHITE_CANDLE_CAKE(-1, Lightable.class), + WHITE_CARPET(-1), + WHITE_CONCRETE(-1), + WHITE_CONCRETE_POWDER(-1), + WHITE_GLAZED_TERRACOTTA(-1, Directional.class), + WHITE_SHULKER_BOX(-1, 1, Directional.class), + WHITE_STAINED_GLASS(-1), + WHITE_STAINED_GLASS_PANE(-1, GlassPane.class), + WHITE_TERRACOTTA(-1), + WHITE_TULIP(-1), + WHITE_WALL_BANNER(-1, Directional.class), + WHITE_WOOL(-1), + WILDFLOWERS(-1, FlowerBed.class), + WITHER_ROSE(-1), + WITHER_SKELETON_SKULL(-1, Skull.class), + WITHER_SKELETON_WALL_SKULL(-1, WallSkull.class), + YELLOW_BANNER(-1, 16, Rotatable.class), + YELLOW_BED(-1, 1, Bed.class), + YELLOW_CANDLE(-1, Candle.class), + YELLOW_CANDLE_CAKE(-1, Lightable.class), + YELLOW_CARPET(-1), + YELLOW_CONCRETE(-1), + YELLOW_CONCRETE_POWDER(-1), + YELLOW_GLAZED_TERRACOTTA(-1, Directional.class), + YELLOW_SHULKER_BOX(-1, 1, Directional.class), + YELLOW_STAINED_GLASS(-1), + YELLOW_STAINED_GLASS_PANE(-1, GlassPane.class), + YELLOW_TERRACOTTA(-1), + YELLOW_WALL_BANNER(-1, Directional.class), + YELLOW_WOOL(-1), + ZOMBIE_HEAD(-1, Skull.class), + ZOMBIE_WALL_HEAD(-1, WallSkull.class), + // End generate - Blocks // ----- Legacy Separator ----- @Deprecated(since = "1.13", forRemoval = true) LEGACY_AIR(0, 0), @@ -4325,17 +2208,17 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla LEGACY_STRUCTURE_BLOCK(255), // ----- Item Separator ----- @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_SPADE(256, 1, 250), + LEGACY_IRON_SPADE(256, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_PICKAXE(257, 1, 250), + LEGACY_IRON_PICKAXE(257, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_AXE(258, 1, 250), + LEGACY_IRON_AXE(258, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_FLINT_AND_STEEL(259, 1, 64), + LEGACY_FLINT_AND_STEEL(259, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_APPLE(260), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_BOW(261, 1, 384), + LEGACY_BOW(261, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_ARROW(262), @Deprecated(since = "1.13", forRemoval = true) @@ -4347,31 +2230,31 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_GOLD_INGOT(266), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_SWORD(267, 1, 250), + LEGACY_IRON_SWORD(267, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_WOOD_SWORD(268, 1, 59), + LEGACY_WOOD_SWORD(268, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_WOOD_SPADE(269, 1, 59), + LEGACY_WOOD_SPADE(269, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_WOOD_PICKAXE(270, 1, 59), + LEGACY_WOOD_PICKAXE(270, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_WOOD_AXE(271, 1, 59), + LEGACY_WOOD_AXE(271, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_STONE_SWORD(272, 1, 131), + LEGACY_STONE_SWORD(272, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_STONE_SPADE(273, 1, 131), + LEGACY_STONE_SPADE(273, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_STONE_PICKAXE(274, 1, 131), + LEGACY_STONE_PICKAXE(274, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_STONE_AXE(275, 1, 131), + LEGACY_STONE_AXE(275, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_SWORD(276, 1, 1561), + LEGACY_DIAMOND_SWORD(276, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_SPADE(277, 1, 1561), + LEGACY_DIAMOND_SPADE(277, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_PICKAXE(278, 1, 1561), + LEGACY_DIAMOND_PICKAXE(278, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_AXE(279, 1, 1561), + LEGACY_DIAMOND_AXE(279, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_STICK(280), @Deprecated(since = "1.13", forRemoval = true) @@ -4379,13 +2262,13 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_MUSHROOM_SOUP(282, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_SWORD(283, 1, 32), + LEGACY_GOLD_SWORD(283, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_SPADE(284, 1, 32), + LEGACY_GOLD_SPADE(284, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_PICKAXE(285, 1, 32), + LEGACY_GOLD_PICKAXE(285, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_AXE(286, 1, 32), + LEGACY_GOLD_AXE(286, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_STRING(287), @Deprecated(since = "1.13", forRemoval = true) @@ -4393,15 +2276,15 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_SULPHUR(289), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_WOOD_HOE(290, 1, 59), + LEGACY_WOOD_HOE(290, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_STONE_HOE(291, 1, 131), + LEGACY_STONE_HOE(291, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_HOE(292, 1, 250), + LEGACY_IRON_HOE(292, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_HOE(293, 1, 1561), + LEGACY_DIAMOND_HOE(293, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_HOE(294, 1, 32), + LEGACY_GOLD_HOE(294, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_SEEDS(295), @Deprecated(since = "1.13", forRemoval = true) @@ -4409,45 +2292,45 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_BREAD(297), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_LEATHER_HELMET(298, 1, 55), + LEGACY_LEATHER_HELMET(298, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_LEATHER_CHESTPLATE(299, 1, 80), + LEGACY_LEATHER_CHESTPLATE(299, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_LEATHER_LEGGINGS(300, 1, 75), + LEGACY_LEATHER_LEGGINGS(300, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_LEATHER_BOOTS(301, 1, 65), + LEGACY_LEATHER_BOOTS(301, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_CHAINMAIL_HELMET(302, 1, 165), + LEGACY_CHAINMAIL_HELMET(302, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_CHAINMAIL_CHESTPLATE(303, 1, 240), + LEGACY_CHAINMAIL_CHESTPLATE(303, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_CHAINMAIL_LEGGINGS(304, 1, 225), + LEGACY_CHAINMAIL_LEGGINGS(304, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_CHAINMAIL_BOOTS(305, 1, 195), + LEGACY_CHAINMAIL_BOOTS(305, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_HELMET(306, 1, 165), + LEGACY_IRON_HELMET(306, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_CHESTPLATE(307, 1, 240), + LEGACY_IRON_CHESTPLATE(307, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_LEGGINGS(308, 1, 225), + LEGACY_IRON_LEGGINGS(308, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_IRON_BOOTS(309, 1, 195), + LEGACY_IRON_BOOTS(309, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_HELMET(310, 1, 363), + LEGACY_DIAMOND_HELMET(310, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_CHESTPLATE(311, 1, 528), + LEGACY_DIAMOND_CHESTPLATE(311, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_LEGGINGS(312, 1, 495), + LEGACY_DIAMOND_LEGGINGS(312, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_DIAMOND_BOOTS(313, 1, 429), + LEGACY_DIAMOND_BOOTS(313, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_HELMET(314, 1, 77), + LEGACY_GOLD_HELMET(314, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_CHESTPLATE(315, 1, 112), + LEGACY_GOLD_CHESTPLATE(315, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_LEGGINGS(316, 1, 105), + LEGACY_GOLD_LEGGINGS(316, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_GOLD_BOOTS(317, 1, 91), + LEGACY_GOLD_BOOTS(317, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_FLINT(318), @Deprecated(since = "1.13", forRemoval = true) @@ -4505,7 +2388,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_COMPASS(345), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_FISHING_ROD(346, 1, 64), + LEGACY_FISHING_ROD(346, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_WATCH(347), @Deprecated(since = "1.13", forRemoval = true) @@ -4534,7 +2417,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_MAP(358, org.bukkit.material.MaterialData.class), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_SHEARS(359, 1, 238), + LEGACY_SHEARS(359, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_MELON(360), @Deprecated(since = "1.13", forRemoval = true) @@ -4612,7 +2495,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_SKULL_ITEM(397), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_CARROT_STICK(398, 1, 25), + LEGACY_CARROT_STICK(398, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_NETHER_STAR(399), @Deprecated(since = "1.13", forRemoval = true) @@ -4700,9 +2583,9 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla @Deprecated(since = "1.13", forRemoval = true) LEGACY_LINGERING_POTION(441, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_SHIELD(442, 1, 336), + LEGACY_SHIELD(442, 1), @Deprecated(since = "1.13", forRemoval = true) - LEGACY_ELYTRA(443, 1, 431), + LEGACY_ELYTRA(443, 1), @Deprecated(since = "1.13", forRemoval = true) LEGACY_BOAT_SPRUCE(444, 1), @Deprecated(since = "1.13", forRemoval = true) @@ -4755,7 +2638,6 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla private final Constructor ctor; private static final Map BY_NAME = Maps.newHashMap(); private final int maxStack; - private final short durability; public final Class data; private final boolean legacy; private final NamespacedKey key; @@ -4770,21 +2652,12 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla this(id, stack, MaterialData.class); } - private Material(final int id, final int stack, final int durability) { - this(id, stack, durability, MaterialData.class); - } - - private Material(final int id, /*@NotNull*/ final Class data) { + private Material(final int id, final Class data) { this(id, 64, data); } - private Material(final int id, final int stack, /*@NotNull*/ final Class data) { - this(id, stack, 0, data); - } - - private Material(final int id, final int stack, final int durability, /*@NotNull*/ final Class data) { + private Material(final int id, final int stack, final Class data) { this.id = id; - this.durability = (short) durability; this.maxStack = stack; this.data = data; this.legacy = this.name().startsWith(LEGACY_PREFIX); @@ -4818,22 +2691,6 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla }); } - // Paper start - - /** - * @return If the type is either AIR, CAVE_AIR or VOID_AIR - */ - public boolean isEmpty() { - switch (this) { - case AIR: - case CAVE_AIR: - case VOID_AIR: - return true; - } - return false; - } - // Paper end - // Paper start - add Translatable @Override public @NotNull String translationKey() { @@ -4941,7 +2798,8 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla * @return Maximum durability for this material */ public short getMaxDurability() { - return durability; + ItemType type = asItemType(); + return type == null ? 0 : type.getMaxDurability(); } /** @@ -5160,6 +3018,15 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla return type != null && type.isAir(); } + /** + * @return If the type is either AIR, CAVE_AIR or VOID_AIR + * @deprecated use {@link #isAir()} + */ + @Deprecated(since = "1.21.5") + public boolean isEmpty() { + return this.isAir(); + } + /** * Check if the material is a block and does not block any light * @@ -5174,6 +3041,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla } switch (this) { // + // Start generate - Material#isTransparent case ACACIA_BUTTON: case ACACIA_SAPLING: case ACTIVATOR_RAIL: @@ -5301,6 +3169,7 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla case YELLOW_CARPET: case ZOMBIE_HEAD: case ZOMBIE_WALL_HEAD: + // End generate - Material#isTransparent // ----- Legacy Separator ----- case LEGACY_AIR: case LEGACY_SAPLING: @@ -5528,75 +3397,10 @@ public enum Material implements Keyed, Translatable, net.kyori.adventure.transla */ @NotNull public EquipmentSlot getEquipmentSlot() { - Preconditions.checkArgument(isItem(), "The Material is not an item!"); - switch (this) { - // - case CARVED_PUMPKIN: - case CHAINMAIL_HELMET: - case CREEPER_HEAD: - case DIAMOND_HELMET: - case DRAGON_HEAD: - case GOLDEN_HELMET: - case IRON_HELMET: - case LEATHER_HELMET: - case NETHERITE_HELMET: - case PLAYER_HEAD: - case PIGLIN_HEAD: - case SKELETON_SKULL: - case TURTLE_HELMET: - case WITHER_SKELETON_SKULL: - case ZOMBIE_HEAD: - return EquipmentSlot.HEAD; - case CHAINMAIL_CHESTPLATE: - case DIAMOND_CHESTPLATE: - case ELYTRA: - case GOLDEN_CHESTPLATE: - case IRON_CHESTPLATE: - case LEATHER_CHESTPLATE: - case NETHERITE_CHESTPLATE: - return EquipmentSlot.CHEST; - case CHAINMAIL_LEGGINGS: - case DIAMOND_LEGGINGS: - case GOLDEN_LEGGINGS: - case IRON_LEGGINGS: - case LEATHER_LEGGINGS: - case NETHERITE_LEGGINGS: - return EquipmentSlot.LEGS; - case CHAINMAIL_BOOTS: - case DIAMOND_BOOTS: - case GOLDEN_BOOTS: - case IRON_BOOTS: - case LEATHER_BOOTS: - case NETHERITE_BOOTS: - return EquipmentSlot.FEET; - case SHIELD: - return EquipmentSlot.OFF_HAND; - case BLACK_CARPET: - case BLUE_CARPET: - case BROWN_CARPET: - case CYAN_CARPET: - case DIAMOND_HORSE_ARMOR: - case GOLDEN_HORSE_ARMOR: - case GRAY_CARPET: - case GREEN_CARPET: - case IRON_HORSE_ARMOR: - case LEATHER_HORSE_ARMOR: - case LIGHT_BLUE_CARPET: - case LIGHT_GRAY_CARPET: - case LIME_CARPET: - case MAGENTA_CARPET: - case ORANGE_CARPET: - case PINK_CARPET: - case PURPLE_CARPET: - case RED_CARPET: - case WHITE_CARPET: - case WOLF_ARMOR: - case YELLOW_CARPET: - return EquipmentSlot.BODY; - default: - return EquipmentSlot.HAND; - // - } + ItemType type = asItemType(); + Preconditions.checkArgument(type != null, "The Material is not an item!"); + Equippable equippable = type.getDefaultData(DataComponentTypes.EQUIPPABLE); + return equippable == null ? EquipmentSlot.HAND : equippable.slot(); } // Paper start - improve default item attribute API diff --git a/paper-api/src/main/java/org/bukkit/MusicInstrument.java b/paper-api/src/main/java/org/bukkit/MusicInstrument.java index bfe64b367..0b987a12e 100644 --- a/paper-api/src/main/java/org/bukkit/MusicInstrument.java +++ b/paper-api/src/main/java/org/bukkit/MusicInstrument.java @@ -10,15 +10,25 @@ import org.jetbrains.annotations.Nullable; public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys - public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn"); - public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn"); - public static final MusicInstrument SEEK_GOAT_HORN = getInstrument("seek_goat_horn"); - public static final MusicInstrument FEEL_GOAT_HORN = getInstrument("feel_goat_horn"); + // Start generate - MusicInstrument + // @GeneratedFrom 1.21.5 public static final MusicInstrument ADMIRE_GOAT_HORN = getInstrument("admire_goat_horn"); + public static final MusicInstrument CALL_GOAT_HORN = getInstrument("call_goat_horn"); - public static final MusicInstrument YEARN_GOAT_HORN = getInstrument("yearn_goat_horn"); + public static final MusicInstrument DREAM_GOAT_HORN = getInstrument("dream_goat_horn"); + public static final MusicInstrument FEEL_GOAT_HORN = getInstrument("feel_goat_horn"); + + public static final MusicInstrument PONDER_GOAT_HORN = getInstrument("ponder_goat_horn"); + + public static final MusicInstrument SEEK_GOAT_HORN = getInstrument("seek_goat_horn"); + + public static final MusicInstrument SING_GOAT_HORN = getInstrument("sing_goat_horn"); + + public static final MusicInstrument YEARN_GOAT_HORN = getInstrument("yearn_goat_horn"); + // End generate - MusicInstrument + /** * Returns a {@link MusicInstrument} by a {@link NamespacedKey}. * diff --git a/paper-api/src/main/java/org/bukkit/Nameable.java b/paper-api/src/main/java/org/bukkit/Nameable.java index 45d996878..6b536a6fd 100644 --- a/paper-api/src/main/java/org/bukkit/Nameable.java +++ b/paper-api/src/main/java/org/bukkit/Nameable.java @@ -7,7 +7,6 @@ import org.jetbrains.annotations.Nullable; */ public interface Nameable { - // Paper start /** * Gets the custom name. * @@ -29,7 +28,6 @@ public interface Nameable { * @param customName the custom name to set */ void customName(final net.kyori.adventure.text.@Nullable Component customName); - // Paper end /** * Gets the custom name on a mob or block. If there is no name this method diff --git a/paper-api/src/main/java/org/bukkit/NamespacedKey.java b/paper-api/src/main/java/org/bukkit/NamespacedKey.java index cb5782340..36d8d113d 100644 --- a/paper-api/src/main/java/org/bukkit/NamespacedKey.java +++ b/paper-api/src/main/java/org/bukkit/NamespacedKey.java @@ -30,7 +30,7 @@ public final class NamespacedKey implements net.kyori.adventure.key.Key, com.des * compatibility measures. */ public static final String BUKKIT = "bukkit"; - // + private final String namespace; private final String key; diff --git a/paper-api/src/main/java/org/bukkit/OfflinePlayer.java b/paper-api/src/main/java/org/bukkit/OfflinePlayer.java index ed8e11001..c749a898e 100644 --- a/paper-api/src/main/java/org/bukkit/OfflinePlayer.java +++ b/paper-api/src/main/java/org/bukkit/OfflinePlayer.java @@ -257,7 +257,10 @@ public interface OfflinePlayer extends ServerOperator, AnimalTamer, Configuratio */ @Nullable @Deprecated(since = "1.20.4") - public Location getBedSpawnLocation(); + default Location getBedSpawnLocation() { + return this.getRespawnLocation(); + } + // Paper start /** * Gets the last date and time that this player logged into the server. diff --git a/paper-api/src/main/java/org/bukkit/Particle.java b/paper-api/src/main/java/org/bukkit/Particle.java index 31c368934..4f515490f 100644 --- a/paper-api/src/main/java/org/bukkit/Particle.java +++ b/paper-api/src/main/java/org/bukkit/Particle.java @@ -3,7 +3,6 @@ package org.bukkit; import com.google.common.base.Preconditions; import org.bukkit.block.data.BlockData; import org.bukkit.inventory.ItemStack; -import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; public enum Particle implements Keyed { @@ -22,7 +21,7 @@ public enum Particle implements Keyed { EFFECT("effect"), INSTANT_EFFECT("instant_effect"), /** - * Uses {@link Color} as DataType + * Uses {@link Color} as DataType (with alpha support) */ ENTITY_EFFECT("entity_effect", Color.class), WITCH("witch"), @@ -117,16 +116,20 @@ public enum Particle implements Keyed { SONIC_BOOM("sonic_boom"), SCULK_SOUL("sculk_soul"), /** - * Use {@link Float} as DataType + * Uses {@link Float} as DataType */ SCULK_CHARGE("sculk_charge", Float.class), SCULK_CHARGE_POP("sculk_charge_pop"), /** - * Use {@link Integer} as DataType + * Uses {@link Integer} as DataType */ SHRIEK("shriek", Integer.class), CHERRY_LEAVES("cherry_leaves"), PALE_OAK_LEAVES("pale_oak_leaves"), + /** + * Uses {@link Color} as DataType (with alpha support) + */ + TINTED_LEAVES("tinted_leaves", Color.class), EGG_CRACK("egg_crack"), DUST_PLUME("dust_plume"), WHITE_SMOKE("white_smoke"), @@ -147,6 +150,7 @@ public enum Particle implements Keyed { * Uses {@link BlockData} as DataType */ BLOCK_CRUMBLE("block_crumble", BlockData.class), + FIREFLY("firefly"), /** * Uses {@link Trail} as DataType */ diff --git a/paper-api/src/main/java/org/bukkit/Raid.java b/paper-api/src/main/java/org/bukkit/Raid.java index fa98599e3..939ab072e 100644 --- a/paper-api/src/main/java/org/bukkit/Raid.java +++ b/paper-api/src/main/java/org/bukkit/Raid.java @@ -137,7 +137,10 @@ public interface Raid extends org.bukkit.persistence.PersistentDataHolder { // P * Gets the id of this raid. * * @return the raid id + * @deprecated Raid identifiers are magic internal values and may or may not be present. + * -1 is returned for raids without an assigned id. */ + @Deprecated(forRemoval = true, since = "1.21.5") int getId(); /** diff --git a/paper-api/src/main/java/org/bukkit/Registry.java b/paper-api/src/main/java/org/bukkit/Registry.java index 75e236ae2..e1dc02621 100644 --- a/paper-api/src/main/java/org/bukkit/Registry.java +++ b/paper-api/src/main/java/org/bukkit/Registry.java @@ -148,8 +148,10 @@ public interface Registry extends Iterable { * Server cat types. * * @see Cat.Type + * @deprecated use {@link RegistryAccess#getRegistry(RegistryKey)} with {@link RegistryKey#CAT_VARIANT} */ - Registry CAT_VARIANT = registryFor(RegistryKey.CAT_VARIANT); + @Deprecated(since = "1.21.5") + Registry CAT_VARIANT = legacyRegistryFor(Cat.Type.class); /** * Server enchantments. * @@ -291,10 +293,10 @@ public interface Registry extends Iterable { * * @see MemoryKey */ - Registry MEMORY_MODULE_TYPE = new NotARegistry<>() { + Registry> MEMORY_MODULE_TYPE = new NotARegistry<>() { @Override - public Iterator iterator() { + public Iterator> iterator() { return MemoryKey.values().iterator(); } @@ -304,7 +306,7 @@ public interface Registry extends Iterable { } @Override - public @Nullable MemoryKey get(final NamespacedKey key) { + public @Nullable MemoryKey get(final NamespacedKey key) { return MemoryKey.getByKey(key); } }; @@ -318,8 +320,10 @@ public interface Registry extends Iterable { * Frog variants. * * @see Frog.Variant + * @deprecated use {@link RegistryAccess#getRegistry(RegistryKey)} with {@link RegistryKey#FROG_VARIANT} */ - Registry FROG_VARIANT = registryFor(RegistryKey.FROG_VARIANT); + @Deprecated(since = "1.21.5") + Registry FROG_VARIANT = legacyRegistryFor(Frog.Variant.class); /** * Wolf variants. * diff --git a/paper-api/src/main/java/org/bukkit/Server.java b/paper-api/src/main/java/org/bukkit/Server.java index 0c1f3053e..7dbfff8e0 100644 --- a/paper-api/src/main/java/org/bukkit/Server.java +++ b/paper-api/src/main/java/org/bukkit/Server.java @@ -151,8 +151,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * uses. Normal and immediate iterator use without consequences that * affect the collection are fully supported. The effects following * (non-exhaustive) {@link Entity#teleport(Location) teleportation}, - * {@link Player#setHealth(double) death}, and {@link Player#kickPlayer( - * String) kicking} are undefined. Any use of this collection from + * {@link Player#setHealth(double) death}, and {@link Player#kick( + * Component) kicking} are undefined. Any use of this collection from * asynchronous threads is unsafe. *

* For safe consequential iteration or mimicking the old array behavior, @@ -387,7 +387,9 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @deprecated use {@link #broadcast(net.kyori.adventure.text.Component)} */ @Deprecated // Paper - public int broadcastMessage(@NotNull String message); + default int broadcastMessage(@NotNull String message) { + return this.broadcast(message, BROADCAST_CHANNEL_USERS); + } // Paper start /** @@ -1296,7 +1298,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @deprecated in favour of {@link #broadcast(net.kyori.adventure.text.Component, String)} */ @Deprecated // Paper - public int broadcast(@NotNull String message, @NotNull String permission); + default int broadcast(@NotNull String message, @NotNull String permission) { + return this.broadcast(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message), permission); + } + // Paper start /** * Broadcast a message to all players. @@ -1307,7 +1312,9 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi * @param message the message * @return the number of players */ - int broadcast(net.kyori.adventure.text.@NotNull Component message); + default int broadcast(net.kyori.adventure.text.@NotNull Component message) { + return this.broadcast(message, BROADCAST_CHANNEL_USERS); + } /** * Broadcasts the specified message to every user with the given diff --git a/paper-api/src/main/java/org/bukkit/Sound.java b/paper-api/src/main/java/org/bukkit/Sound.java index e2fb7cfba..8d5fc91fa 100644 --- a/paper-api/src/main/java/org/bukkit/Sound.java +++ b/paper-api/src/main/java/org/bukkit/Sound.java @@ -23,1657 +23,3412 @@ import org.jetbrains.annotations.NotNull; */ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type + // Start generate - Sound + // @GeneratedFrom 1.21.5 Sound AMBIENT_BASALT_DELTAS_ADDITIONS = getSound("ambient.basalt_deltas.additions"); + Sound AMBIENT_BASALT_DELTAS_LOOP = getSound("ambient.basalt_deltas.loop"); + Sound AMBIENT_BASALT_DELTAS_MOOD = getSound("ambient.basalt_deltas.mood"); + Sound AMBIENT_CAVE = getSound("ambient.cave"); + Sound AMBIENT_CRIMSON_FOREST_ADDITIONS = getSound("ambient.crimson_forest.additions"); + Sound AMBIENT_CRIMSON_FOREST_LOOP = getSound("ambient.crimson_forest.loop"); + Sound AMBIENT_CRIMSON_FOREST_MOOD = getSound("ambient.crimson_forest.mood"); + Sound AMBIENT_NETHER_WASTES_ADDITIONS = getSound("ambient.nether_wastes.additions"); + Sound AMBIENT_NETHER_WASTES_LOOP = getSound("ambient.nether_wastes.loop"); + Sound AMBIENT_NETHER_WASTES_MOOD = getSound("ambient.nether_wastes.mood"); + Sound AMBIENT_SOUL_SAND_VALLEY_ADDITIONS = getSound("ambient.soul_sand_valley.additions"); + Sound AMBIENT_SOUL_SAND_VALLEY_LOOP = getSound("ambient.soul_sand_valley.loop"); + Sound AMBIENT_SOUL_SAND_VALLEY_MOOD = getSound("ambient.soul_sand_valley.mood"); + Sound AMBIENT_UNDERWATER_ENTER = getSound("ambient.underwater.enter"); + Sound AMBIENT_UNDERWATER_EXIT = getSound("ambient.underwater.exit"); + Sound AMBIENT_UNDERWATER_LOOP = getSound("ambient.underwater.loop"); + Sound AMBIENT_UNDERWATER_LOOP_ADDITIONS = getSound("ambient.underwater.loop.additions"); + Sound AMBIENT_UNDERWATER_LOOP_ADDITIONS_RARE = getSound("ambient.underwater.loop.additions.rare"); + Sound AMBIENT_UNDERWATER_LOOP_ADDITIONS_ULTRA_RARE = getSound("ambient.underwater.loop.additions.ultra_rare"); + Sound AMBIENT_WARPED_FOREST_ADDITIONS = getSound("ambient.warped_forest.additions"); + Sound AMBIENT_WARPED_FOREST_LOOP = getSound("ambient.warped_forest.loop"); + Sound AMBIENT_WARPED_FOREST_MOOD = getSound("ambient.warped_forest.mood"); + Sound BLOCK_AMETHYST_BLOCK_BREAK = getSound("block.amethyst_block.break"); + Sound BLOCK_AMETHYST_BLOCK_CHIME = getSound("block.amethyst_block.chime"); + Sound BLOCK_AMETHYST_BLOCK_FALL = getSound("block.amethyst_block.fall"); + Sound BLOCK_AMETHYST_BLOCK_HIT = getSound("block.amethyst_block.hit"); + Sound BLOCK_AMETHYST_BLOCK_PLACE = getSound("block.amethyst_block.place"); + Sound BLOCK_AMETHYST_BLOCK_RESONATE = getSound("block.amethyst_block.resonate"); + Sound BLOCK_AMETHYST_BLOCK_STEP = getSound("block.amethyst_block.step"); + Sound BLOCK_AMETHYST_CLUSTER_BREAK = getSound("block.amethyst_cluster.break"); + Sound BLOCK_AMETHYST_CLUSTER_FALL = getSound("block.amethyst_cluster.fall"); + Sound BLOCK_AMETHYST_CLUSTER_HIT = getSound("block.amethyst_cluster.hit"); + Sound BLOCK_AMETHYST_CLUSTER_PLACE = getSound("block.amethyst_cluster.place"); + Sound BLOCK_AMETHYST_CLUSTER_STEP = getSound("block.amethyst_cluster.step"); + Sound BLOCK_ANCIENT_DEBRIS_BREAK = getSound("block.ancient_debris.break"); + Sound BLOCK_ANCIENT_DEBRIS_FALL = getSound("block.ancient_debris.fall"); + Sound BLOCK_ANCIENT_DEBRIS_HIT = getSound("block.ancient_debris.hit"); + Sound BLOCK_ANCIENT_DEBRIS_PLACE = getSound("block.ancient_debris.place"); + Sound BLOCK_ANCIENT_DEBRIS_STEP = getSound("block.ancient_debris.step"); + Sound BLOCK_ANVIL_BREAK = getSound("block.anvil.break"); + Sound BLOCK_ANVIL_DESTROY = getSound("block.anvil.destroy"); + Sound BLOCK_ANVIL_FALL = getSound("block.anvil.fall"); + Sound BLOCK_ANVIL_HIT = getSound("block.anvil.hit"); + Sound BLOCK_ANVIL_LAND = getSound("block.anvil.land"); + Sound BLOCK_ANVIL_PLACE = getSound("block.anvil.place"); + Sound BLOCK_ANVIL_STEP = getSound("block.anvil.step"); + Sound BLOCK_ANVIL_USE = getSound("block.anvil.use"); + Sound BLOCK_AZALEA_BREAK = getSound("block.azalea.break"); + Sound BLOCK_AZALEA_FALL = getSound("block.azalea.fall"); + Sound BLOCK_AZALEA_HIT = getSound("block.azalea.hit"); - Sound BLOCK_AZALEA_LEAVES_BREAK = getSound("block.azalea_leaves.break"); - Sound BLOCK_AZALEA_LEAVES_FALL = getSound("block.azalea_leaves.fall"); - Sound BLOCK_AZALEA_LEAVES_HIT = getSound("block.azalea_leaves.hit"); - Sound BLOCK_AZALEA_LEAVES_PLACE = getSound("block.azalea_leaves.place"); - Sound BLOCK_AZALEA_LEAVES_STEP = getSound("block.azalea_leaves.step"); + Sound BLOCK_AZALEA_PLACE = getSound("block.azalea.place"); + Sound BLOCK_AZALEA_STEP = getSound("block.azalea.step"); + + Sound BLOCK_AZALEA_LEAVES_BREAK = getSound("block.azalea_leaves.break"); + + Sound BLOCK_AZALEA_LEAVES_FALL = getSound("block.azalea_leaves.fall"); + + Sound BLOCK_AZALEA_LEAVES_HIT = getSound("block.azalea_leaves.hit"); + + Sound BLOCK_AZALEA_LEAVES_PLACE = getSound("block.azalea_leaves.place"); + + Sound BLOCK_AZALEA_LEAVES_STEP = getSound("block.azalea_leaves.step"); + Sound BLOCK_BAMBOO_BREAK = getSound("block.bamboo.break"); + Sound BLOCK_BAMBOO_FALL = getSound("block.bamboo.fall"); + Sound BLOCK_BAMBOO_HIT = getSound("block.bamboo.hit"); + Sound BLOCK_BAMBOO_PLACE = getSound("block.bamboo.place"); - Sound BLOCK_BAMBOO_SAPLING_BREAK = getSound("block.bamboo_sapling.break"); - Sound BLOCK_BAMBOO_SAPLING_HIT = getSound("block.bamboo_sapling.hit"); - Sound BLOCK_BAMBOO_SAPLING_PLACE = getSound("block.bamboo_sapling.place"); + Sound BLOCK_BAMBOO_STEP = getSound("block.bamboo.step"); + + Sound BLOCK_BAMBOO_SAPLING_BREAK = getSound("block.bamboo_sapling.break"); + + Sound BLOCK_BAMBOO_SAPLING_HIT = getSound("block.bamboo_sapling.hit"); + + Sound BLOCK_BAMBOO_SAPLING_PLACE = getSound("block.bamboo_sapling.place"); + Sound BLOCK_BAMBOO_WOOD_BREAK = getSound("block.bamboo_wood.break"); - Sound BLOCK_BAMBOO_WOOD_BUTTON_CLICK_OFF = getSound("block.bamboo_wood_button.click_off"); - Sound BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON = getSound("block.bamboo_wood_button.click_on"); - Sound BLOCK_BAMBOO_WOOD_DOOR_CLOSE = getSound("block.bamboo_wood_door.close"); - Sound BLOCK_BAMBOO_WOOD_DOOR_OPEN = getSound("block.bamboo_wood_door.open"); + Sound BLOCK_BAMBOO_WOOD_FALL = getSound("block.bamboo_wood.fall"); - Sound BLOCK_BAMBOO_WOOD_FENCE_GATE_CLOSE = getSound("block.bamboo_wood_fence_gate.close"); - Sound BLOCK_BAMBOO_WOOD_FENCE_GATE_OPEN = getSound("block.bamboo_wood_fence_gate.open"); - Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_BREAK = getSound("block.bamboo_wood_hanging_sign.break"); - Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_FALL = getSound("block.bamboo_wood_hanging_sign.fall"); - Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_HIT = getSound("block.bamboo_wood_hanging_sign.hit"); - Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_PLACE = getSound("block.bamboo_wood_hanging_sign.place"); - Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_STEP = getSound("block.bamboo_wood_hanging_sign.step"); + Sound BLOCK_BAMBOO_WOOD_HIT = getSound("block.bamboo_wood.hit"); + Sound BLOCK_BAMBOO_WOOD_PLACE = getSound("block.bamboo_wood.place"); - Sound BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.bamboo_wood_pressure_plate.click_off"); - Sound BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.bamboo_wood_pressure_plate.click_on"); + Sound BLOCK_BAMBOO_WOOD_STEP = getSound("block.bamboo_wood.step"); + + Sound BLOCK_BAMBOO_WOOD_BUTTON_CLICK_OFF = getSound("block.bamboo_wood_button.click_off"); + + Sound BLOCK_BAMBOO_WOOD_BUTTON_CLICK_ON = getSound("block.bamboo_wood_button.click_on"); + + Sound BLOCK_BAMBOO_WOOD_DOOR_CLOSE = getSound("block.bamboo_wood_door.close"); + + Sound BLOCK_BAMBOO_WOOD_DOOR_OPEN = getSound("block.bamboo_wood_door.open"); + + Sound BLOCK_BAMBOO_WOOD_FENCE_GATE_CLOSE = getSound("block.bamboo_wood_fence_gate.close"); + + Sound BLOCK_BAMBOO_WOOD_FENCE_GATE_OPEN = getSound("block.bamboo_wood_fence_gate.open"); + + Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_BREAK = getSound("block.bamboo_wood_hanging_sign.break"); + + Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_FALL = getSound("block.bamboo_wood_hanging_sign.fall"); + + Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_HIT = getSound("block.bamboo_wood_hanging_sign.hit"); + + Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_PLACE = getSound("block.bamboo_wood_hanging_sign.place"); + + Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_STEP = getSound("block.bamboo_wood_hanging_sign.step"); + + Sound BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.bamboo_wood_pressure_plate.click_off"); + + Sound BLOCK_BAMBOO_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.bamboo_wood_pressure_plate.click_on"); + Sound BLOCK_BAMBOO_WOOD_TRAPDOOR_CLOSE = getSound("block.bamboo_wood_trapdoor.close"); + Sound BLOCK_BAMBOO_WOOD_TRAPDOOR_OPEN = getSound("block.bamboo_wood_trapdoor.open"); + Sound BLOCK_BARREL_CLOSE = getSound("block.barrel.close"); + Sound BLOCK_BARREL_OPEN = getSound("block.barrel.open"); + Sound BLOCK_BASALT_BREAK = getSound("block.basalt.break"); + Sound BLOCK_BASALT_FALL = getSound("block.basalt.fall"); + Sound BLOCK_BASALT_HIT = getSound("block.basalt.hit"); + Sound BLOCK_BASALT_PLACE = getSound("block.basalt.place"); + Sound BLOCK_BASALT_STEP = getSound("block.basalt.step"); + Sound BLOCK_BEACON_ACTIVATE = getSound("block.beacon.activate"); + Sound BLOCK_BEACON_AMBIENT = getSound("block.beacon.ambient"); + Sound BLOCK_BEACON_DEACTIVATE = getSound("block.beacon.deactivate"); + Sound BLOCK_BEACON_POWER_SELECT = getSound("block.beacon.power_select"); + Sound BLOCK_BEEHIVE_DRIP = getSound("block.beehive.drip"); + Sound BLOCK_BEEHIVE_ENTER = getSound("block.beehive.enter"); + Sound BLOCK_BEEHIVE_EXIT = getSound("block.beehive.exit"); + Sound BLOCK_BEEHIVE_SHEAR = getSound("block.beehive.shear"); + Sound BLOCK_BEEHIVE_WORK = getSound("block.beehive.work"); + Sound BLOCK_BELL_RESONATE = getSound("block.bell.resonate"); + Sound BLOCK_BELL_USE = getSound("block.bell.use"); + Sound BLOCK_BIG_DRIPLEAF_BREAK = getSound("block.big_dripleaf.break"); + Sound BLOCK_BIG_DRIPLEAF_FALL = getSound("block.big_dripleaf.fall"); + Sound BLOCK_BIG_DRIPLEAF_HIT = getSound("block.big_dripleaf.hit"); + Sound BLOCK_BIG_DRIPLEAF_PLACE = getSound("block.big_dripleaf.place"); + Sound BLOCK_BIG_DRIPLEAF_STEP = getSound("block.big_dripleaf.step"); + Sound BLOCK_BIG_DRIPLEAF_TILT_DOWN = getSound("block.big_dripleaf.tilt_down"); + Sound BLOCK_BIG_DRIPLEAF_TILT_UP = getSound("block.big_dripleaf.tilt_up"); + Sound BLOCK_BLASTFURNACE_FIRE_CRACKLE = getSound("block.blastfurnace.fire_crackle"); + Sound BLOCK_BONE_BLOCK_BREAK = getSound("block.bone_block.break"); + Sound BLOCK_BONE_BLOCK_FALL = getSound("block.bone_block.fall"); + Sound BLOCK_BONE_BLOCK_HIT = getSound("block.bone_block.hit"); + Sound BLOCK_BONE_BLOCK_PLACE = getSound("block.bone_block.place"); + Sound BLOCK_BONE_BLOCK_STEP = getSound("block.bone_block.step"); + Sound BLOCK_BREWING_STAND_BREW = getSound("block.brewing_stand.brew"); + Sound BLOCK_BUBBLE_COLUMN_BUBBLE_POP = getSound("block.bubble_column.bubble_pop"); + Sound BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT = getSound("block.bubble_column.upwards_ambient"); + Sound BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE = getSound("block.bubble_column.upwards_inside"); + Sound BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT = getSound("block.bubble_column.whirlpool_ambient"); + Sound BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE = getSound("block.bubble_column.whirlpool_inside"); + + Sound BLOCK_CACTUS_FLOWER_BREAK = getSound("block.cactus_flower.break"); + + Sound BLOCK_CACTUS_FLOWER_PLACE = getSound("block.cactus_flower.place"); + Sound BLOCK_CAKE_ADD_CANDLE = getSound("block.cake.add_candle"); + Sound BLOCK_CALCITE_BREAK = getSound("block.calcite.break"); + Sound BLOCK_CALCITE_FALL = getSound("block.calcite.fall"); + Sound BLOCK_CALCITE_HIT = getSound("block.calcite.hit"); + Sound BLOCK_CALCITE_PLACE = getSound("block.calcite.place"); + Sound BLOCK_CALCITE_STEP = getSound("block.calcite.step"); + Sound BLOCK_CAMPFIRE_CRACKLE = getSound("block.campfire.crackle"); + Sound BLOCK_CANDLE_AMBIENT = getSound("block.candle.ambient"); + Sound BLOCK_CANDLE_BREAK = getSound("block.candle.break"); + Sound BLOCK_CANDLE_EXTINGUISH = getSound("block.candle.extinguish"); + Sound BLOCK_CANDLE_FALL = getSound("block.candle.fall"); + Sound BLOCK_CANDLE_HIT = getSound("block.candle.hit"); + Sound BLOCK_CANDLE_PLACE = getSound("block.candle.place"); + Sound BLOCK_CANDLE_STEP = getSound("block.candle.step"); + Sound BLOCK_CAVE_VINES_BREAK = getSound("block.cave_vines.break"); + Sound BLOCK_CAVE_VINES_FALL = getSound("block.cave_vines.fall"); + Sound BLOCK_CAVE_VINES_HIT = getSound("block.cave_vines.hit"); + Sound BLOCK_CAVE_VINES_PICK_BERRIES = getSound("block.cave_vines.pick_berries"); + Sound BLOCK_CAVE_VINES_PLACE = getSound("block.cave_vines.place"); + Sound BLOCK_CAVE_VINES_STEP = getSound("block.cave_vines.step"); + Sound BLOCK_CHAIN_BREAK = getSound("block.chain.break"); + Sound BLOCK_CHAIN_FALL = getSound("block.chain.fall"); + Sound BLOCK_CHAIN_HIT = getSound("block.chain.hit"); + Sound BLOCK_CHAIN_PLACE = getSound("block.chain.place"); + Sound BLOCK_CHAIN_STEP = getSound("block.chain.step"); + Sound BLOCK_CHERRY_LEAVES_BREAK = getSound("block.cherry_leaves.break"); + Sound BLOCK_CHERRY_LEAVES_FALL = getSound("block.cherry_leaves.fall"); + Sound BLOCK_CHERRY_LEAVES_HIT = getSound("block.cherry_leaves.hit"); + Sound BLOCK_CHERRY_LEAVES_PLACE = getSound("block.cherry_leaves.place"); + Sound BLOCK_CHERRY_LEAVES_STEP = getSound("block.cherry_leaves.step"); + Sound BLOCK_CHERRY_SAPLING_BREAK = getSound("block.cherry_sapling.break"); + Sound BLOCK_CHERRY_SAPLING_FALL = getSound("block.cherry_sapling.fall"); + Sound BLOCK_CHERRY_SAPLING_HIT = getSound("block.cherry_sapling.hit"); + Sound BLOCK_CHERRY_SAPLING_PLACE = getSound("block.cherry_sapling.place"); + Sound BLOCK_CHERRY_SAPLING_STEP = getSound("block.cherry_sapling.step"); + Sound BLOCK_CHERRY_WOOD_BREAK = getSound("block.cherry_wood.break"); - Sound BLOCK_CHERRY_WOOD_BUTTON_CLICK_OFF = getSound("block.cherry_wood_button.click_off"); - Sound BLOCK_CHERRY_WOOD_BUTTON_CLICK_ON = getSound("block.cherry_wood_button.click_on"); - Sound BLOCK_CHERRY_WOOD_DOOR_CLOSE = getSound("block.cherry_wood_door.close"); - Sound BLOCK_CHERRY_WOOD_DOOR_OPEN = getSound("block.cherry_wood_door.open"); + Sound BLOCK_CHERRY_WOOD_FALL = getSound("block.cherry_wood.fall"); - Sound BLOCK_CHERRY_WOOD_FENCE_GATE_CLOSE = getSound("block.cherry_wood_fence_gate.close"); - Sound BLOCK_CHERRY_WOOD_FENCE_GATE_OPEN = getSound("block.cherry_wood_fence_gate.open"); - Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_BREAK = getSound("block.cherry_wood_hanging_sign.break"); - Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_FALL = getSound("block.cherry_wood_hanging_sign.fall"); - Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_HIT = getSound("block.cherry_wood_hanging_sign.hit"); - Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_PLACE = getSound("block.cherry_wood_hanging_sign.place"); - Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_STEP = getSound("block.cherry_wood_hanging_sign.step"); + Sound BLOCK_CHERRY_WOOD_HIT = getSound("block.cherry_wood.hit"); + Sound BLOCK_CHERRY_WOOD_PLACE = getSound("block.cherry_wood.place"); - Sound BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.cherry_wood_pressure_plate.click_off"); - Sound BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.cherry_wood_pressure_plate.click_on"); + Sound BLOCK_CHERRY_WOOD_STEP = getSound("block.cherry_wood.step"); + + Sound BLOCK_CHERRY_WOOD_BUTTON_CLICK_OFF = getSound("block.cherry_wood_button.click_off"); + + Sound BLOCK_CHERRY_WOOD_BUTTON_CLICK_ON = getSound("block.cherry_wood_button.click_on"); + + Sound BLOCK_CHERRY_WOOD_DOOR_CLOSE = getSound("block.cherry_wood_door.close"); + + Sound BLOCK_CHERRY_WOOD_DOOR_OPEN = getSound("block.cherry_wood_door.open"); + + Sound BLOCK_CHERRY_WOOD_FENCE_GATE_CLOSE = getSound("block.cherry_wood_fence_gate.close"); + + Sound BLOCK_CHERRY_WOOD_FENCE_GATE_OPEN = getSound("block.cherry_wood_fence_gate.open"); + + Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_BREAK = getSound("block.cherry_wood_hanging_sign.break"); + + Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_FALL = getSound("block.cherry_wood_hanging_sign.fall"); + + Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_HIT = getSound("block.cherry_wood_hanging_sign.hit"); + + Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_PLACE = getSound("block.cherry_wood_hanging_sign.place"); + + Sound BLOCK_CHERRY_WOOD_HANGING_SIGN_STEP = getSound("block.cherry_wood_hanging_sign.step"); + + Sound BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.cherry_wood_pressure_plate.click_off"); + + Sound BLOCK_CHERRY_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.cherry_wood_pressure_plate.click_on"); + Sound BLOCK_CHERRY_WOOD_TRAPDOOR_CLOSE = getSound("block.cherry_wood_trapdoor.close"); + Sound BLOCK_CHERRY_WOOD_TRAPDOOR_OPEN = getSound("block.cherry_wood_trapdoor.open"); + Sound BLOCK_CHEST_CLOSE = getSound("block.chest.close"); + Sound BLOCK_CHEST_LOCKED = getSound("block.chest.locked"); + Sound BLOCK_CHEST_OPEN = getSound("block.chest.open"); + Sound BLOCK_CHISELED_BOOKSHELF_BREAK = getSound("block.chiseled_bookshelf.break"); + Sound BLOCK_CHISELED_BOOKSHELF_FALL = getSound("block.chiseled_bookshelf.fall"); + Sound BLOCK_CHISELED_BOOKSHELF_HIT = getSound("block.chiseled_bookshelf.hit"); + Sound BLOCK_CHISELED_BOOKSHELF_INSERT = getSound("block.chiseled_bookshelf.insert"); + Sound BLOCK_CHISELED_BOOKSHELF_INSERT_ENCHANTED = getSound("block.chiseled_bookshelf.insert.enchanted"); + Sound BLOCK_CHISELED_BOOKSHELF_PICKUP = getSound("block.chiseled_bookshelf.pickup"); + Sound BLOCK_CHISELED_BOOKSHELF_PICKUP_ENCHANTED = getSound("block.chiseled_bookshelf.pickup.enchanted"); + Sound BLOCK_CHISELED_BOOKSHELF_PLACE = getSound("block.chiseled_bookshelf.place"); + Sound BLOCK_CHISELED_BOOKSHELF_STEP = getSound("block.chiseled_bookshelf.step"); + Sound BLOCK_CHORUS_FLOWER_DEATH = getSound("block.chorus_flower.death"); + Sound BLOCK_CHORUS_FLOWER_GROW = getSound("block.chorus_flower.grow"); + Sound BLOCK_COBWEB_BREAK = getSound("block.cobweb.break"); + Sound BLOCK_COBWEB_FALL = getSound("block.cobweb.fall"); + Sound BLOCK_COBWEB_HIT = getSound("block.cobweb.hit"); + Sound BLOCK_COBWEB_PLACE = getSound("block.cobweb.place"); + Sound BLOCK_COBWEB_STEP = getSound("block.cobweb.step"); + Sound BLOCK_COMPARATOR_CLICK = getSound("block.comparator.click"); + Sound BLOCK_COMPOSTER_EMPTY = getSound("block.composter.empty"); + Sound BLOCK_COMPOSTER_FILL = getSound("block.composter.fill"); + Sound BLOCK_COMPOSTER_FILL_SUCCESS = getSound("block.composter.fill_success"); + Sound BLOCK_COMPOSTER_READY = getSound("block.composter.ready"); + Sound BLOCK_CONDUIT_ACTIVATE = getSound("block.conduit.activate"); + Sound BLOCK_CONDUIT_AMBIENT = getSound("block.conduit.ambient"); + Sound BLOCK_CONDUIT_AMBIENT_SHORT = getSound("block.conduit.ambient.short"); + Sound BLOCK_CONDUIT_ATTACK_TARGET = getSound("block.conduit.attack.target"); + Sound BLOCK_CONDUIT_DEACTIVATE = getSound("block.conduit.deactivate"); + Sound BLOCK_COPPER_BREAK = getSound("block.copper.break"); - Sound BLOCK_COPPER_BULB_BREAK = getSound("block.copper_bulb.break"); - Sound BLOCK_COPPER_BULB_FALL = getSound("block.copper_bulb.fall"); - Sound BLOCK_COPPER_BULB_HIT = getSound("block.copper_bulb.hit"); - Sound BLOCK_COPPER_BULB_PLACE = getSound("block.copper_bulb.place"); - Sound BLOCK_COPPER_BULB_STEP = getSound("block.copper_bulb.step"); - Sound BLOCK_COPPER_BULB_TURN_OFF = getSound("block.copper_bulb.turn_off"); - Sound BLOCK_COPPER_BULB_TURN_ON = getSound("block.copper_bulb.turn_on"); - Sound BLOCK_COPPER_DOOR_CLOSE = getSound("block.copper_door.close"); - Sound BLOCK_COPPER_DOOR_OPEN = getSound("block.copper_door.open"); + Sound BLOCK_COPPER_FALL = getSound("block.copper.fall"); - Sound BLOCK_COPPER_GRATE_BREAK = getSound("block.copper_grate.break"); - Sound BLOCK_COPPER_GRATE_FALL = getSound("block.copper_grate.fall"); - Sound BLOCK_COPPER_GRATE_HIT = getSound("block.copper_grate.hit"); - Sound BLOCK_COPPER_GRATE_PLACE = getSound("block.copper_grate.place"); - Sound BLOCK_COPPER_GRATE_STEP = getSound("block.copper_grate.step"); + Sound BLOCK_COPPER_HIT = getSound("block.copper.hit"); + Sound BLOCK_COPPER_PLACE = getSound("block.copper.place"); + Sound BLOCK_COPPER_STEP = getSound("block.copper.step"); + + Sound BLOCK_COPPER_BULB_BREAK = getSound("block.copper_bulb.break"); + + Sound BLOCK_COPPER_BULB_FALL = getSound("block.copper_bulb.fall"); + + Sound BLOCK_COPPER_BULB_HIT = getSound("block.copper_bulb.hit"); + + Sound BLOCK_COPPER_BULB_PLACE = getSound("block.copper_bulb.place"); + + Sound BLOCK_COPPER_BULB_STEP = getSound("block.copper_bulb.step"); + + Sound BLOCK_COPPER_BULB_TURN_OFF = getSound("block.copper_bulb.turn_off"); + + Sound BLOCK_COPPER_BULB_TURN_ON = getSound("block.copper_bulb.turn_on"); + + Sound BLOCK_COPPER_DOOR_CLOSE = getSound("block.copper_door.close"); + + Sound BLOCK_COPPER_DOOR_OPEN = getSound("block.copper_door.open"); + + Sound BLOCK_COPPER_GRATE_BREAK = getSound("block.copper_grate.break"); + + Sound BLOCK_COPPER_GRATE_FALL = getSound("block.copper_grate.fall"); + + Sound BLOCK_COPPER_GRATE_HIT = getSound("block.copper_grate.hit"); + + Sound BLOCK_COPPER_GRATE_PLACE = getSound("block.copper_grate.place"); + + Sound BLOCK_COPPER_GRATE_STEP = getSound("block.copper_grate.step"); + Sound BLOCK_COPPER_TRAPDOOR_CLOSE = getSound("block.copper_trapdoor.close"); + Sound BLOCK_COPPER_TRAPDOOR_OPEN = getSound("block.copper_trapdoor.open"); + Sound BLOCK_CORAL_BLOCK_BREAK = getSound("block.coral_block.break"); + Sound BLOCK_CORAL_BLOCK_FALL = getSound("block.coral_block.fall"); + Sound BLOCK_CORAL_BLOCK_HIT = getSound("block.coral_block.hit"); + Sound BLOCK_CORAL_BLOCK_PLACE = getSound("block.coral_block.place"); + Sound BLOCK_CORAL_BLOCK_STEP = getSound("block.coral_block.step"); + Sound BLOCK_CRAFTER_CRAFT = getSound("block.crafter.craft"); + Sound BLOCK_CRAFTER_FAIL = getSound("block.crafter.fail"); + Sound BLOCK_CREAKING_HEART_BREAK = getSound("block.creaking_heart.break"); + Sound BLOCK_CREAKING_HEART_FALL = getSound("block.creaking_heart.fall"); + Sound BLOCK_CREAKING_HEART_HIT = getSound("block.creaking_heart.hit"); + Sound BLOCK_CREAKING_HEART_HURT = getSound("block.creaking_heart.hurt"); + Sound BLOCK_CREAKING_HEART_IDLE = getSound("block.creaking_heart.idle"); + Sound BLOCK_CREAKING_HEART_PLACE = getSound("block.creaking_heart.place"); + Sound BLOCK_CREAKING_HEART_SPAWN = getSound("block.creaking_heart.spawn"); + Sound BLOCK_CREAKING_HEART_STEP = getSound("block.creaking_heart.step"); + Sound BLOCK_CROP_BREAK = getSound("block.crop.break"); + + Sound BLOCK_DEADBUSH_IDLE = getSound("block.deadbush.idle"); + Sound BLOCK_DECORATED_POT_BREAK = getSound("block.decorated_pot.break"); + Sound BLOCK_DECORATED_POT_FALL = getSound("block.decorated_pot.fall"); + Sound BLOCK_DECORATED_POT_HIT = getSound("block.decorated_pot.hit"); + Sound BLOCK_DECORATED_POT_INSERT = getSound("block.decorated_pot.insert"); + Sound BLOCK_DECORATED_POT_INSERT_FAIL = getSound("block.decorated_pot.insert_fail"); + Sound BLOCK_DECORATED_POT_PLACE = getSound("block.decorated_pot.place"); + Sound BLOCK_DECORATED_POT_SHATTER = getSound("block.decorated_pot.shatter"); + Sound BLOCK_DECORATED_POT_STEP = getSound("block.decorated_pot.step"); + Sound BLOCK_DEEPSLATE_BREAK = getSound("block.deepslate.break"); - Sound BLOCK_DEEPSLATE_BRICKS_BREAK = getSound("block.deepslate_bricks.break"); - Sound BLOCK_DEEPSLATE_BRICKS_FALL = getSound("block.deepslate_bricks.fall"); - Sound BLOCK_DEEPSLATE_BRICKS_HIT = getSound("block.deepslate_bricks.hit"); - Sound BLOCK_DEEPSLATE_BRICKS_PLACE = getSound("block.deepslate_bricks.place"); - Sound BLOCK_DEEPSLATE_BRICKS_STEP = getSound("block.deepslate_bricks.step"); + Sound BLOCK_DEEPSLATE_FALL = getSound("block.deepslate.fall"); + Sound BLOCK_DEEPSLATE_HIT = getSound("block.deepslate.hit"); + Sound BLOCK_DEEPSLATE_PLACE = getSound("block.deepslate.place"); + Sound BLOCK_DEEPSLATE_STEP = getSound("block.deepslate.step"); + + Sound BLOCK_DEEPSLATE_BRICKS_BREAK = getSound("block.deepslate_bricks.break"); + + Sound BLOCK_DEEPSLATE_BRICKS_FALL = getSound("block.deepslate_bricks.fall"); + + Sound BLOCK_DEEPSLATE_BRICKS_HIT = getSound("block.deepslate_bricks.hit"); + + Sound BLOCK_DEEPSLATE_BRICKS_PLACE = getSound("block.deepslate_bricks.place"); + + Sound BLOCK_DEEPSLATE_BRICKS_STEP = getSound("block.deepslate_bricks.step"); + Sound BLOCK_DEEPSLATE_TILES_BREAK = getSound("block.deepslate_tiles.break"); + Sound BLOCK_DEEPSLATE_TILES_FALL = getSound("block.deepslate_tiles.fall"); + Sound BLOCK_DEEPSLATE_TILES_HIT = getSound("block.deepslate_tiles.hit"); + Sound BLOCK_DEEPSLATE_TILES_PLACE = getSound("block.deepslate_tiles.place"); + Sound BLOCK_DEEPSLATE_TILES_STEP = getSound("block.deepslate_tiles.step"); + Sound BLOCK_DISPENSER_DISPENSE = getSound("block.dispenser.dispense"); + Sound BLOCK_DISPENSER_FAIL = getSound("block.dispenser.fail"); + Sound BLOCK_DISPENSER_LAUNCH = getSound("block.dispenser.launch"); + Sound BLOCK_DRIPSTONE_BLOCK_BREAK = getSound("block.dripstone_block.break"); + Sound BLOCK_DRIPSTONE_BLOCK_FALL = getSound("block.dripstone_block.fall"); + Sound BLOCK_DRIPSTONE_BLOCK_HIT = getSound("block.dripstone_block.hit"); + Sound BLOCK_DRIPSTONE_BLOCK_PLACE = getSound("block.dripstone_block.place"); + Sound BLOCK_DRIPSTONE_BLOCK_STEP = getSound("block.dripstone_block.step"); + Sound BLOCK_ENCHANTMENT_TABLE_USE = getSound("block.enchantment_table.use"); - Sound BLOCK_ENDER_CHEST_CLOSE = getSound("block.ender_chest.close"); - Sound BLOCK_ENDER_CHEST_OPEN = getSound("block.ender_chest.open"); + Sound BLOCK_END_GATEWAY_SPAWN = getSound("block.end_gateway.spawn"); - Sound BLOCK_END_PORTAL_FRAME_FILL = getSound("block.end_portal_frame.fill"); + Sound BLOCK_END_PORTAL_SPAWN = getSound("block.end_portal.spawn"); + + Sound BLOCK_END_PORTAL_FRAME_FILL = getSound("block.end_portal_frame.fill"); + + Sound BLOCK_ENDER_CHEST_CLOSE = getSound("block.ender_chest.close"); + + Sound BLOCK_ENDER_CHEST_OPEN = getSound("block.ender_chest.open"); + Sound BLOCK_EYEBLOSSOM_CLOSE = getSound("block.eyeblossom.close"); + Sound BLOCK_EYEBLOSSOM_CLOSE_LONG = getSound("block.eyeblossom.close_long"); + Sound BLOCK_EYEBLOSSOM_IDLE = getSound("block.eyeblossom.idle"); + Sound BLOCK_EYEBLOSSOM_OPEN = getSound("block.eyeblossom.open"); + Sound BLOCK_EYEBLOSSOM_OPEN_LONG = getSound("block.eyeblossom.open_long"); + Sound BLOCK_FENCE_GATE_CLOSE = getSound("block.fence_gate.close"); + Sound BLOCK_FENCE_GATE_OPEN = getSound("block.fence_gate.open"); + Sound BLOCK_FIRE_AMBIENT = getSound("block.fire.ambient"); + Sound BLOCK_FIRE_EXTINGUISH = getSound("block.fire.extinguish"); + + Sound BLOCK_FIREFLY_BUSH_IDLE = getSound("block.firefly_bush.idle"); + Sound BLOCK_FLOWERING_AZALEA_BREAK = getSound("block.flowering_azalea.break"); + Sound BLOCK_FLOWERING_AZALEA_FALL = getSound("block.flowering_azalea.fall"); + Sound BLOCK_FLOWERING_AZALEA_HIT = getSound("block.flowering_azalea.hit"); + Sound BLOCK_FLOWERING_AZALEA_PLACE = getSound("block.flowering_azalea.place"); + Sound BLOCK_FLOWERING_AZALEA_STEP = getSound("block.flowering_azalea.step"); + Sound BLOCK_FROGLIGHT_BREAK = getSound("block.froglight.break"); + Sound BLOCK_FROGLIGHT_FALL = getSound("block.froglight.fall"); + Sound BLOCK_FROGLIGHT_HIT = getSound("block.froglight.hit"); + Sound BLOCK_FROGLIGHT_PLACE = getSound("block.froglight.place"); + Sound BLOCK_FROGLIGHT_STEP = getSound("block.froglight.step"); + Sound BLOCK_FROGSPAWN_BREAK = getSound("block.frogspawn.break"); + Sound BLOCK_FROGSPAWN_FALL = getSound("block.frogspawn.fall"); + Sound BLOCK_FROGSPAWN_HATCH = getSound("block.frogspawn.hatch"); + Sound BLOCK_FROGSPAWN_HIT = getSound("block.frogspawn.hit"); + Sound BLOCK_FROGSPAWN_PLACE = getSound("block.frogspawn.place"); + Sound BLOCK_FROGSPAWN_STEP = getSound("block.frogspawn.step"); + Sound BLOCK_FUNGUS_BREAK = getSound("block.fungus.break"); + Sound BLOCK_FUNGUS_FALL = getSound("block.fungus.fall"); + Sound BLOCK_FUNGUS_HIT = getSound("block.fungus.hit"); + Sound BLOCK_FUNGUS_PLACE = getSound("block.fungus.place"); + Sound BLOCK_FUNGUS_STEP = getSound("block.fungus.step"); + Sound BLOCK_FURNACE_FIRE_CRACKLE = getSound("block.furnace.fire_crackle"); + Sound BLOCK_GILDED_BLACKSTONE_BREAK = getSound("block.gilded_blackstone.break"); + Sound BLOCK_GILDED_BLACKSTONE_FALL = getSound("block.gilded_blackstone.fall"); + Sound BLOCK_GILDED_BLACKSTONE_HIT = getSound("block.gilded_blackstone.hit"); + Sound BLOCK_GILDED_BLACKSTONE_PLACE = getSound("block.gilded_blackstone.place"); + Sound BLOCK_GILDED_BLACKSTONE_STEP = getSound("block.gilded_blackstone.step"); + Sound BLOCK_GLASS_BREAK = getSound("block.glass.break"); + Sound BLOCK_GLASS_FALL = getSound("block.glass.fall"); + Sound BLOCK_GLASS_HIT = getSound("block.glass.hit"); + Sound BLOCK_GLASS_PLACE = getSound("block.glass.place"); + Sound BLOCK_GLASS_STEP = getSound("block.glass.step"); + Sound BLOCK_GRASS_BREAK = getSound("block.grass.break"); + Sound BLOCK_GRASS_FALL = getSound("block.grass.fall"); + Sound BLOCK_GRASS_HIT = getSound("block.grass.hit"); + Sound BLOCK_GRASS_PLACE = getSound("block.grass.place"); + Sound BLOCK_GRASS_STEP = getSound("block.grass.step"); + Sound BLOCK_GRAVEL_BREAK = getSound("block.gravel.break"); + Sound BLOCK_GRAVEL_FALL = getSound("block.gravel.fall"); + Sound BLOCK_GRAVEL_HIT = getSound("block.gravel.hit"); + Sound BLOCK_GRAVEL_PLACE = getSound("block.gravel.place"); + Sound BLOCK_GRAVEL_STEP = getSound("block.gravel.step"); + Sound BLOCK_GRINDSTONE_USE = getSound("block.grindstone.use"); + Sound BLOCK_GROWING_PLANT_CROP = getSound("block.growing_plant.crop"); + Sound BLOCK_HANGING_ROOTS_BREAK = getSound("block.hanging_roots.break"); + Sound BLOCK_HANGING_ROOTS_FALL = getSound("block.hanging_roots.fall"); + Sound BLOCK_HANGING_ROOTS_HIT = getSound("block.hanging_roots.hit"); + Sound BLOCK_HANGING_ROOTS_PLACE = getSound("block.hanging_roots.place"); + Sound BLOCK_HANGING_ROOTS_STEP = getSound("block.hanging_roots.step"); + Sound BLOCK_HANGING_SIGN_BREAK = getSound("block.hanging_sign.break"); + Sound BLOCK_HANGING_SIGN_FALL = getSound("block.hanging_sign.fall"); + Sound BLOCK_HANGING_SIGN_HIT = getSound("block.hanging_sign.hit"); + Sound BLOCK_HANGING_SIGN_PLACE = getSound("block.hanging_sign.place"); + Sound BLOCK_HANGING_SIGN_STEP = getSound("block.hanging_sign.step"); + Sound BLOCK_HANGING_SIGN_WAXED_INTERACT_FAIL = getSound("block.hanging_sign.waxed_interact_fail"); + Sound BLOCK_HEAVY_CORE_BREAK = getSound("block.heavy_core.break"); + Sound BLOCK_HEAVY_CORE_FALL = getSound("block.heavy_core.fall"); + Sound BLOCK_HEAVY_CORE_HIT = getSound("block.heavy_core.hit"); + Sound BLOCK_HEAVY_CORE_PLACE = getSound("block.heavy_core.place"); + Sound BLOCK_HEAVY_CORE_STEP = getSound("block.heavy_core.step"); + Sound BLOCK_HONEY_BLOCK_BREAK = getSound("block.honey_block.break"); + Sound BLOCK_HONEY_BLOCK_FALL = getSound("block.honey_block.fall"); + Sound BLOCK_HONEY_BLOCK_HIT = getSound("block.honey_block.hit"); + Sound BLOCK_HONEY_BLOCK_PLACE = getSound("block.honey_block.place"); + Sound BLOCK_HONEY_BLOCK_SLIDE = getSound("block.honey_block.slide"); + Sound BLOCK_HONEY_BLOCK_STEP = getSound("block.honey_block.step"); + + Sound BLOCK_IRON_BREAK = getSound("block.iron.break"); + + Sound BLOCK_IRON_FALL = getSound("block.iron.fall"); + + Sound BLOCK_IRON_HIT = getSound("block.iron.hit"); + + Sound BLOCK_IRON_PLACE = getSound("block.iron.place"); + + Sound BLOCK_IRON_STEP = getSound("block.iron.step"); + Sound BLOCK_IRON_DOOR_CLOSE = getSound("block.iron_door.close"); + Sound BLOCK_IRON_DOOR_OPEN = getSound("block.iron_door.open"); + Sound BLOCK_IRON_TRAPDOOR_CLOSE = getSound("block.iron_trapdoor.close"); + Sound BLOCK_IRON_TRAPDOOR_OPEN = getSound("block.iron_trapdoor.open"); + Sound BLOCK_LADDER_BREAK = getSound("block.ladder.break"); + Sound BLOCK_LADDER_FALL = getSound("block.ladder.fall"); + Sound BLOCK_LADDER_HIT = getSound("block.ladder.hit"); + Sound BLOCK_LADDER_PLACE = getSound("block.ladder.place"); + Sound BLOCK_LADDER_STEP = getSound("block.ladder.step"); + Sound BLOCK_LANTERN_BREAK = getSound("block.lantern.break"); + Sound BLOCK_LANTERN_FALL = getSound("block.lantern.fall"); + Sound BLOCK_LANTERN_HIT = getSound("block.lantern.hit"); + Sound BLOCK_LANTERN_PLACE = getSound("block.lantern.place"); + Sound BLOCK_LANTERN_STEP = getSound("block.lantern.step"); + Sound BLOCK_LARGE_AMETHYST_BUD_BREAK = getSound("block.large_amethyst_bud.break"); + Sound BLOCK_LARGE_AMETHYST_BUD_PLACE = getSound("block.large_amethyst_bud.place"); + Sound BLOCK_LAVA_AMBIENT = getSound("block.lava.ambient"); + Sound BLOCK_LAVA_EXTINGUISH = getSound("block.lava.extinguish"); + Sound BLOCK_LAVA_POP = getSound("block.lava.pop"); + + Sound BLOCK_LEAF_LITTER_BREAK = getSound("block.leaf_litter.break"); + + Sound BLOCK_LEAF_LITTER_FALL = getSound("block.leaf_litter.fall"); + + Sound BLOCK_LEAF_LITTER_HIT = getSound("block.leaf_litter.hit"); + + Sound BLOCK_LEAF_LITTER_PLACE = getSound("block.leaf_litter.place"); + + Sound BLOCK_LEAF_LITTER_STEP = getSound("block.leaf_litter.step"); + Sound BLOCK_LEVER_CLICK = getSound("block.lever.click"); + Sound BLOCK_LILY_PAD_PLACE = getSound("block.lily_pad.place"); + Sound BLOCK_LODESTONE_BREAK = getSound("block.lodestone.break"); + Sound BLOCK_LODESTONE_FALL = getSound("block.lodestone.fall"); + Sound BLOCK_LODESTONE_HIT = getSound("block.lodestone.hit"); + Sound BLOCK_LODESTONE_PLACE = getSound("block.lodestone.place"); + Sound BLOCK_LODESTONE_STEP = getSound("block.lodestone.step"); + Sound BLOCK_MANGROVE_ROOTS_BREAK = getSound("block.mangrove_roots.break"); + Sound BLOCK_MANGROVE_ROOTS_FALL = getSound("block.mangrove_roots.fall"); + Sound BLOCK_MANGROVE_ROOTS_HIT = getSound("block.mangrove_roots.hit"); + Sound BLOCK_MANGROVE_ROOTS_PLACE = getSound("block.mangrove_roots.place"); + Sound BLOCK_MANGROVE_ROOTS_STEP = getSound("block.mangrove_roots.step"); + Sound BLOCK_MEDIUM_AMETHYST_BUD_BREAK = getSound("block.medium_amethyst_bud.break"); + Sound BLOCK_MEDIUM_AMETHYST_BUD_PLACE = getSound("block.medium_amethyst_bud.place"); + Sound BLOCK_METAL_BREAK = getSound("block.metal.break"); + Sound BLOCK_METAL_FALL = getSound("block.metal.fall"); + Sound BLOCK_METAL_HIT = getSound("block.metal.hit"); + Sound BLOCK_METAL_PLACE = getSound("block.metal.place"); - Sound BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF = getSound("block.metal_pressure_plate.click_off"); - Sound BLOCK_METAL_PRESSURE_PLATE_CLICK_ON = getSound("block.metal_pressure_plate.click_on"); + Sound BLOCK_METAL_STEP = getSound("block.metal.step"); + + Sound BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF = getSound("block.metal_pressure_plate.click_off"); + + Sound BLOCK_METAL_PRESSURE_PLATE_CLICK_ON = getSound("block.metal_pressure_plate.click_on"); + Sound BLOCK_MOSS_BREAK = getSound("block.moss.break"); - Sound BLOCK_MOSS_CARPET_BREAK = getSound("block.moss_carpet.break"); - Sound BLOCK_MOSS_CARPET_FALL = getSound("block.moss_carpet.fall"); - Sound BLOCK_MOSS_CARPET_HIT = getSound("block.moss_carpet.hit"); - Sound BLOCK_MOSS_CARPET_PLACE = getSound("block.moss_carpet.place"); - Sound BLOCK_MOSS_CARPET_STEP = getSound("block.moss_carpet.step"); + Sound BLOCK_MOSS_FALL = getSound("block.moss.fall"); + Sound BLOCK_MOSS_HIT = getSound("block.moss.hit"); + Sound BLOCK_MOSS_PLACE = getSound("block.moss.place"); + Sound BLOCK_MOSS_STEP = getSound("block.moss.step"); - Sound BLOCK_MUDDY_MANGROVE_ROOTS_BREAK = getSound("block.muddy_mangrove_roots.break"); - Sound BLOCK_MUDDY_MANGROVE_ROOTS_FALL = getSound("block.muddy_mangrove_roots.fall"); - Sound BLOCK_MUDDY_MANGROVE_ROOTS_HIT = getSound("block.muddy_mangrove_roots.hit"); - Sound BLOCK_MUDDY_MANGROVE_ROOTS_PLACE = getSound("block.muddy_mangrove_roots.place"); - Sound BLOCK_MUDDY_MANGROVE_ROOTS_STEP = getSound("block.muddy_mangrove_roots.step"); + + Sound BLOCK_MOSS_CARPET_BREAK = getSound("block.moss_carpet.break"); + + Sound BLOCK_MOSS_CARPET_FALL = getSound("block.moss_carpet.fall"); + + Sound BLOCK_MOSS_CARPET_HIT = getSound("block.moss_carpet.hit"); + + Sound BLOCK_MOSS_CARPET_PLACE = getSound("block.moss_carpet.place"); + + Sound BLOCK_MOSS_CARPET_STEP = getSound("block.moss_carpet.step"); + Sound BLOCK_MUD_BREAK = getSound("block.mud.break"); - Sound BLOCK_MUD_BRICKS_BREAK = getSound("block.mud_bricks.break"); - Sound BLOCK_MUD_BRICKS_FALL = getSound("block.mud_bricks.fall"); - Sound BLOCK_MUD_BRICKS_HIT = getSound("block.mud_bricks.hit"); - Sound BLOCK_MUD_BRICKS_PLACE = getSound("block.mud_bricks.place"); - Sound BLOCK_MUD_BRICKS_STEP = getSound("block.mud_bricks.step"); + Sound BLOCK_MUD_FALL = getSound("block.mud.fall"); + Sound BLOCK_MUD_HIT = getSound("block.mud.hit"); + Sound BLOCK_MUD_PLACE = getSound("block.mud.place"); + Sound BLOCK_MUD_STEP = getSound("block.mud.step"); - Sound BLOCK_NETHERITE_BLOCK_BREAK = getSound("block.netherite_block.break"); - Sound BLOCK_NETHERITE_BLOCK_FALL = getSound("block.netherite_block.fall"); - Sound BLOCK_NETHERITE_BLOCK_HIT = getSound("block.netherite_block.hit"); - Sound BLOCK_NETHERITE_BLOCK_PLACE = getSound("block.netherite_block.place"); - Sound BLOCK_NETHERITE_BLOCK_STEP = getSound("block.netherite_block.step"); - Sound BLOCK_NETHERRACK_BREAK = getSound("block.netherrack.break"); - Sound BLOCK_NETHERRACK_FALL = getSound("block.netherrack.fall"); - Sound BLOCK_NETHERRACK_HIT = getSound("block.netherrack.hit"); - Sound BLOCK_NETHERRACK_PLACE = getSound("block.netherrack.place"); - Sound BLOCK_NETHERRACK_STEP = getSound("block.netherrack.step"); + + Sound BLOCK_MUD_BRICKS_BREAK = getSound("block.mud_bricks.break"); + + Sound BLOCK_MUD_BRICKS_FALL = getSound("block.mud_bricks.fall"); + + Sound BLOCK_MUD_BRICKS_HIT = getSound("block.mud_bricks.hit"); + + Sound BLOCK_MUD_BRICKS_PLACE = getSound("block.mud_bricks.place"); + + Sound BLOCK_MUD_BRICKS_STEP = getSound("block.mud_bricks.step"); + + Sound BLOCK_MUDDY_MANGROVE_ROOTS_BREAK = getSound("block.muddy_mangrove_roots.break"); + + Sound BLOCK_MUDDY_MANGROVE_ROOTS_FALL = getSound("block.muddy_mangrove_roots.fall"); + + Sound BLOCK_MUDDY_MANGROVE_ROOTS_HIT = getSound("block.muddy_mangrove_roots.hit"); + + Sound BLOCK_MUDDY_MANGROVE_ROOTS_PLACE = getSound("block.muddy_mangrove_roots.place"); + + Sound BLOCK_MUDDY_MANGROVE_ROOTS_STEP = getSound("block.muddy_mangrove_roots.step"); + Sound BLOCK_NETHER_BRICKS_BREAK = getSound("block.nether_bricks.break"); + Sound BLOCK_NETHER_BRICKS_FALL = getSound("block.nether_bricks.fall"); + Sound BLOCK_NETHER_BRICKS_HIT = getSound("block.nether_bricks.hit"); + Sound BLOCK_NETHER_BRICKS_PLACE = getSound("block.nether_bricks.place"); + Sound BLOCK_NETHER_BRICKS_STEP = getSound("block.nether_bricks.step"); + Sound BLOCK_NETHER_GOLD_ORE_BREAK = getSound("block.nether_gold_ore.break"); + Sound BLOCK_NETHER_GOLD_ORE_FALL = getSound("block.nether_gold_ore.fall"); + Sound BLOCK_NETHER_GOLD_ORE_HIT = getSound("block.nether_gold_ore.hit"); + Sound BLOCK_NETHER_GOLD_ORE_PLACE = getSound("block.nether_gold_ore.place"); + Sound BLOCK_NETHER_GOLD_ORE_STEP = getSound("block.nether_gold_ore.step"); + Sound BLOCK_NETHER_ORE_BREAK = getSound("block.nether_ore.break"); + Sound BLOCK_NETHER_ORE_FALL = getSound("block.nether_ore.fall"); + Sound BLOCK_NETHER_ORE_HIT = getSound("block.nether_ore.hit"); + Sound BLOCK_NETHER_ORE_PLACE = getSound("block.nether_ore.place"); + Sound BLOCK_NETHER_ORE_STEP = getSound("block.nether_ore.step"); + Sound BLOCK_NETHER_SPROUTS_BREAK = getSound("block.nether_sprouts.break"); + Sound BLOCK_NETHER_SPROUTS_FALL = getSound("block.nether_sprouts.fall"); + Sound BLOCK_NETHER_SPROUTS_HIT = getSound("block.nether_sprouts.hit"); + Sound BLOCK_NETHER_SPROUTS_PLACE = getSound("block.nether_sprouts.place"); + Sound BLOCK_NETHER_SPROUTS_STEP = getSound("block.nether_sprouts.step"); + Sound BLOCK_NETHER_WART_BREAK = getSound("block.nether_wart.break"); + Sound BLOCK_NETHER_WOOD_BREAK = getSound("block.nether_wood.break"); - Sound BLOCK_NETHER_WOOD_BUTTON_CLICK_OFF = getSound("block.nether_wood_button.click_off"); - Sound BLOCK_NETHER_WOOD_BUTTON_CLICK_ON = getSound("block.nether_wood_button.click_on"); - Sound BLOCK_NETHER_WOOD_DOOR_CLOSE = getSound("block.nether_wood_door.close"); - Sound BLOCK_NETHER_WOOD_DOOR_OPEN = getSound("block.nether_wood_door.open"); + Sound BLOCK_NETHER_WOOD_FALL = getSound("block.nether_wood.fall"); - Sound BLOCK_NETHER_WOOD_FENCE_GATE_CLOSE = getSound("block.nether_wood_fence_gate.close"); - Sound BLOCK_NETHER_WOOD_FENCE_GATE_OPEN = getSound("block.nether_wood_fence_gate.open"); - Sound BLOCK_NETHER_WOOD_HANGING_SIGN_BREAK = getSound("block.nether_wood_hanging_sign.break"); - Sound BLOCK_NETHER_WOOD_HANGING_SIGN_FALL = getSound("block.nether_wood_hanging_sign.fall"); - Sound BLOCK_NETHER_WOOD_HANGING_SIGN_HIT = getSound("block.nether_wood_hanging_sign.hit"); - Sound BLOCK_NETHER_WOOD_HANGING_SIGN_PLACE = getSound("block.nether_wood_hanging_sign.place"); - Sound BLOCK_NETHER_WOOD_HANGING_SIGN_STEP = getSound("block.nether_wood_hanging_sign.step"); + Sound BLOCK_NETHER_WOOD_HIT = getSound("block.nether_wood.hit"); + Sound BLOCK_NETHER_WOOD_PLACE = getSound("block.nether_wood.place"); - Sound BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.nether_wood_pressure_plate.click_off"); - Sound BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.nether_wood_pressure_plate.click_on"); + Sound BLOCK_NETHER_WOOD_STEP = getSound("block.nether_wood.step"); + + Sound BLOCK_NETHER_WOOD_BUTTON_CLICK_OFF = getSound("block.nether_wood_button.click_off"); + + Sound BLOCK_NETHER_WOOD_BUTTON_CLICK_ON = getSound("block.nether_wood_button.click_on"); + + Sound BLOCK_NETHER_WOOD_DOOR_CLOSE = getSound("block.nether_wood_door.close"); + + Sound BLOCK_NETHER_WOOD_DOOR_OPEN = getSound("block.nether_wood_door.open"); + + Sound BLOCK_NETHER_WOOD_FENCE_GATE_CLOSE = getSound("block.nether_wood_fence_gate.close"); + + Sound BLOCK_NETHER_WOOD_FENCE_GATE_OPEN = getSound("block.nether_wood_fence_gate.open"); + + Sound BLOCK_NETHER_WOOD_HANGING_SIGN_BREAK = getSound("block.nether_wood_hanging_sign.break"); + + Sound BLOCK_NETHER_WOOD_HANGING_SIGN_FALL = getSound("block.nether_wood_hanging_sign.fall"); + + Sound BLOCK_NETHER_WOOD_HANGING_SIGN_HIT = getSound("block.nether_wood_hanging_sign.hit"); + + Sound BLOCK_NETHER_WOOD_HANGING_SIGN_PLACE = getSound("block.nether_wood_hanging_sign.place"); + + Sound BLOCK_NETHER_WOOD_HANGING_SIGN_STEP = getSound("block.nether_wood_hanging_sign.step"); + + Sound BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_OFF = getSound("block.nether_wood_pressure_plate.click_off"); + + Sound BLOCK_NETHER_WOOD_PRESSURE_PLATE_CLICK_ON = getSound("block.nether_wood_pressure_plate.click_on"); + Sound BLOCK_NETHER_WOOD_TRAPDOOR_CLOSE = getSound("block.nether_wood_trapdoor.close"); + Sound BLOCK_NETHER_WOOD_TRAPDOOR_OPEN = getSound("block.nether_wood_trapdoor.open"); + + Sound BLOCK_NETHERITE_BLOCK_BREAK = getSound("block.netherite_block.break"); + + Sound BLOCK_NETHERITE_BLOCK_FALL = getSound("block.netherite_block.fall"); + + Sound BLOCK_NETHERITE_BLOCK_HIT = getSound("block.netherite_block.hit"); + + Sound BLOCK_NETHERITE_BLOCK_PLACE = getSound("block.netherite_block.place"); + + Sound BLOCK_NETHERITE_BLOCK_STEP = getSound("block.netherite_block.step"); + + Sound BLOCK_NETHERRACK_BREAK = getSound("block.netherrack.break"); + + Sound BLOCK_NETHERRACK_FALL = getSound("block.netherrack.fall"); + + Sound BLOCK_NETHERRACK_HIT = getSound("block.netherrack.hit"); + + Sound BLOCK_NETHERRACK_PLACE = getSound("block.netherrack.place"); + + Sound BLOCK_NETHERRACK_STEP = getSound("block.netherrack.step"); + Sound BLOCK_NOTE_BLOCK_BANJO = getSound("block.note_block.banjo"); + Sound BLOCK_NOTE_BLOCK_BASEDRUM = getSound("block.note_block.basedrum"); + Sound BLOCK_NOTE_BLOCK_BASS = getSound("block.note_block.bass"); + Sound BLOCK_NOTE_BLOCK_BELL = getSound("block.note_block.bell"); + Sound BLOCK_NOTE_BLOCK_BIT = getSound("block.note_block.bit"); + Sound BLOCK_NOTE_BLOCK_CHIME = getSound("block.note_block.chime"); + Sound BLOCK_NOTE_BLOCK_COW_BELL = getSound("block.note_block.cow_bell"); + Sound BLOCK_NOTE_BLOCK_DIDGERIDOO = getSound("block.note_block.didgeridoo"); + Sound BLOCK_NOTE_BLOCK_FLUTE = getSound("block.note_block.flute"); + Sound BLOCK_NOTE_BLOCK_GUITAR = getSound("block.note_block.guitar"); + Sound BLOCK_NOTE_BLOCK_HARP = getSound("block.note_block.harp"); + Sound BLOCK_NOTE_BLOCK_HAT = getSound("block.note_block.hat"); + Sound BLOCK_NOTE_BLOCK_IMITATE_CREEPER = getSound("block.note_block.imitate.creeper"); + Sound BLOCK_NOTE_BLOCK_IMITATE_ENDER_DRAGON = getSound("block.note_block.imitate.ender_dragon"); + Sound BLOCK_NOTE_BLOCK_IMITATE_PIGLIN = getSound("block.note_block.imitate.piglin"); + Sound BLOCK_NOTE_BLOCK_IMITATE_SKELETON = getSound("block.note_block.imitate.skeleton"); + Sound BLOCK_NOTE_BLOCK_IMITATE_WITHER_SKELETON = getSound("block.note_block.imitate.wither_skeleton"); + Sound BLOCK_NOTE_BLOCK_IMITATE_ZOMBIE = getSound("block.note_block.imitate.zombie"); + Sound BLOCK_NOTE_BLOCK_IRON_XYLOPHONE = getSound("block.note_block.iron_xylophone"); + Sound BLOCK_NOTE_BLOCK_PLING = getSound("block.note_block.pling"); + Sound BLOCK_NOTE_BLOCK_SNARE = getSound("block.note_block.snare"); + Sound BLOCK_NOTE_BLOCK_XYLOPHONE = getSound("block.note_block.xylophone"); + Sound BLOCK_NYLIUM_BREAK = getSound("block.nylium.break"); + Sound BLOCK_NYLIUM_FALL = getSound("block.nylium.fall"); + Sound BLOCK_NYLIUM_HIT = getSound("block.nylium.hit"); + Sound BLOCK_NYLIUM_PLACE = getSound("block.nylium.place"); + Sound BLOCK_NYLIUM_STEP = getSound("block.nylium.step"); + Sound BLOCK_PACKED_MUD_BREAK = getSound("block.packed_mud.break"); + Sound BLOCK_PACKED_MUD_FALL = getSound("block.packed_mud.fall"); + Sound BLOCK_PACKED_MUD_HIT = getSound("block.packed_mud.hit"); + Sound BLOCK_PACKED_MUD_PLACE = getSound("block.packed_mud.place"); + Sound BLOCK_PACKED_MUD_STEP = getSound("block.packed_mud.step"); + Sound BLOCK_PALE_HANGING_MOSS_IDLE = getSound("block.pale_hanging_moss.idle"); + Sound BLOCK_PINK_PETALS_BREAK = getSound("block.pink_petals.break"); + Sound BLOCK_PINK_PETALS_FALL = getSound("block.pink_petals.fall"); + Sound BLOCK_PINK_PETALS_HIT = getSound("block.pink_petals.hit"); + Sound BLOCK_PINK_PETALS_PLACE = getSound("block.pink_petals.place"); + Sound BLOCK_PINK_PETALS_STEP = getSound("block.pink_petals.step"); + Sound BLOCK_PISTON_CONTRACT = getSound("block.piston.contract"); + Sound BLOCK_PISTON_EXTEND = getSound("block.piston.extend"); + Sound BLOCK_POINTED_DRIPSTONE_BREAK = getSound("block.pointed_dripstone.break"); + Sound BLOCK_POINTED_DRIPSTONE_DRIP_LAVA = getSound("block.pointed_dripstone.drip_lava"); + Sound BLOCK_POINTED_DRIPSTONE_DRIP_LAVA_INTO_CAULDRON = getSound("block.pointed_dripstone.drip_lava_into_cauldron"); + Sound BLOCK_POINTED_DRIPSTONE_DRIP_WATER = getSound("block.pointed_dripstone.drip_water"); + Sound BLOCK_POINTED_DRIPSTONE_DRIP_WATER_INTO_CAULDRON = getSound("block.pointed_dripstone.drip_water_into_cauldron"); + Sound BLOCK_POINTED_DRIPSTONE_FALL = getSound("block.pointed_dripstone.fall"); + Sound BLOCK_POINTED_DRIPSTONE_HIT = getSound("block.pointed_dripstone.hit"); + Sound BLOCK_POINTED_DRIPSTONE_LAND = getSound("block.pointed_dripstone.land"); + Sound BLOCK_POINTED_DRIPSTONE_PLACE = getSound("block.pointed_dripstone.place"); + Sound BLOCK_POINTED_DRIPSTONE_STEP = getSound("block.pointed_dripstone.step"); + Sound BLOCK_POLISHED_DEEPSLATE_BREAK = getSound("block.polished_deepslate.break"); + Sound BLOCK_POLISHED_DEEPSLATE_FALL = getSound("block.polished_deepslate.fall"); + Sound BLOCK_POLISHED_DEEPSLATE_HIT = getSound("block.polished_deepslate.hit"); + Sound BLOCK_POLISHED_DEEPSLATE_PLACE = getSound("block.polished_deepslate.place"); + Sound BLOCK_POLISHED_DEEPSLATE_STEP = getSound("block.polished_deepslate.step"); + Sound BLOCK_POLISHED_TUFF_BREAK = getSound("block.polished_tuff.break"); + Sound BLOCK_POLISHED_TUFF_FALL = getSound("block.polished_tuff.fall"); + Sound BLOCK_POLISHED_TUFF_HIT = getSound("block.polished_tuff.hit"); + Sound BLOCK_POLISHED_TUFF_PLACE = getSound("block.polished_tuff.place"); + Sound BLOCK_POLISHED_TUFF_STEP = getSound("block.polished_tuff.step"); + Sound BLOCK_PORTAL_AMBIENT = getSound("block.portal.ambient"); + Sound BLOCK_PORTAL_TRAVEL = getSound("block.portal.travel"); + Sound BLOCK_PORTAL_TRIGGER = getSound("block.portal.trigger"); + Sound BLOCK_POWDER_SNOW_BREAK = getSound("block.powder_snow.break"); + Sound BLOCK_POWDER_SNOW_FALL = getSound("block.powder_snow.fall"); + Sound BLOCK_POWDER_SNOW_HIT = getSound("block.powder_snow.hit"); + Sound BLOCK_POWDER_SNOW_PLACE = getSound("block.powder_snow.place"); + Sound BLOCK_POWDER_SNOW_STEP = getSound("block.powder_snow.step"); + Sound BLOCK_PUMPKIN_CARVE = getSound("block.pumpkin.carve"); + Sound BLOCK_REDSTONE_TORCH_BURNOUT = getSound("block.redstone_torch.burnout"); + Sound BLOCK_RESIN_BREAK = getSound("block.resin.break"); - Sound BLOCK_RESIN_BRICKS_BREAK = getSound("block.resin_bricks.break"); - Sound BLOCK_RESIN_BRICKS_FALL = getSound("block.resin_bricks.fall"); - Sound BLOCK_RESIN_BRICKS_HIT = getSound("block.resin_bricks.hit"); - Sound BLOCK_RESIN_BRICKS_PLACE = getSound("block.resin_bricks.place"); - Sound BLOCK_RESIN_BRICKS_STEP = getSound("block.resin_bricks.step"); + Sound BLOCK_RESIN_FALL = getSound("block.resin.fall"); + Sound BLOCK_RESIN_PLACE = getSound("block.resin.place"); + Sound BLOCK_RESIN_STEP = getSound("block.resin.step"); + + Sound BLOCK_RESIN_BRICKS_BREAK = getSound("block.resin_bricks.break"); + + Sound BLOCK_RESIN_BRICKS_FALL = getSound("block.resin_bricks.fall"); + + Sound BLOCK_RESIN_BRICKS_HIT = getSound("block.resin_bricks.hit"); + + Sound BLOCK_RESIN_BRICKS_PLACE = getSound("block.resin_bricks.place"); + + Sound BLOCK_RESIN_BRICKS_STEP = getSound("block.resin_bricks.step"); + Sound BLOCK_RESPAWN_ANCHOR_AMBIENT = getSound("block.respawn_anchor.ambient"); + Sound BLOCK_RESPAWN_ANCHOR_CHARGE = getSound("block.respawn_anchor.charge"); + Sound BLOCK_RESPAWN_ANCHOR_DEPLETE = getSound("block.respawn_anchor.deplete"); + Sound BLOCK_RESPAWN_ANCHOR_SET_SPAWN = getSound("block.respawn_anchor.set_spawn"); + Sound BLOCK_ROOTED_DIRT_BREAK = getSound("block.rooted_dirt.break"); + Sound BLOCK_ROOTED_DIRT_FALL = getSound("block.rooted_dirt.fall"); + Sound BLOCK_ROOTED_DIRT_HIT = getSound("block.rooted_dirt.hit"); + Sound BLOCK_ROOTED_DIRT_PLACE = getSound("block.rooted_dirt.place"); + Sound BLOCK_ROOTED_DIRT_STEP = getSound("block.rooted_dirt.step"); + Sound BLOCK_ROOTS_BREAK = getSound("block.roots.break"); + Sound BLOCK_ROOTS_FALL = getSound("block.roots.fall"); + Sound BLOCK_ROOTS_HIT = getSound("block.roots.hit"); + Sound BLOCK_ROOTS_PLACE = getSound("block.roots.place"); + Sound BLOCK_ROOTS_STEP = getSound("block.roots.step"); + Sound BLOCK_SAND_BREAK = getSound("block.sand.break"); + Sound BLOCK_SAND_FALL = getSound("block.sand.fall"); + Sound BLOCK_SAND_HIT = getSound("block.sand.hit"); + + Sound BLOCK_SAND_IDLE = getSound("block.sand.idle"); + Sound BLOCK_SAND_PLACE = getSound("block.sand.place"); + Sound BLOCK_SAND_STEP = getSound("block.sand.step"); + + Sound BLOCK_SAND_WIND = getSound("block.sand.wind"); + Sound BLOCK_SCAFFOLDING_BREAK = getSound("block.scaffolding.break"); + Sound BLOCK_SCAFFOLDING_FALL = getSound("block.scaffolding.fall"); + Sound BLOCK_SCAFFOLDING_HIT = getSound("block.scaffolding.hit"); + Sound BLOCK_SCAFFOLDING_PLACE = getSound("block.scaffolding.place"); + Sound BLOCK_SCAFFOLDING_STEP = getSound("block.scaffolding.step"); + Sound BLOCK_SCULK_BREAK = getSound("block.sculk.break"); - Sound BLOCK_SCULK_CATALYST_BLOOM = getSound("block.sculk_catalyst.bloom"); - Sound BLOCK_SCULK_CATALYST_BREAK = getSound("block.sculk_catalyst.break"); - Sound BLOCK_SCULK_CATALYST_FALL = getSound("block.sculk_catalyst.fall"); - Sound BLOCK_SCULK_CATALYST_HIT = getSound("block.sculk_catalyst.hit"); - Sound BLOCK_SCULK_CATALYST_PLACE = getSound("block.sculk_catalyst.place"); - Sound BLOCK_SCULK_CATALYST_STEP = getSound("block.sculk_catalyst.step"); + Sound BLOCK_SCULK_CHARGE = getSound("block.sculk.charge"); + Sound BLOCK_SCULK_FALL = getSound("block.sculk.fall"); + Sound BLOCK_SCULK_HIT = getSound("block.sculk.hit"); + Sound BLOCK_SCULK_PLACE = getSound("block.sculk.place"); - Sound BLOCK_SCULK_SENSOR_BREAK = getSound("block.sculk_sensor.break"); - Sound BLOCK_SCULK_SENSOR_CLICKING = getSound("block.sculk_sensor.clicking"); - Sound BLOCK_SCULK_SENSOR_CLICKING_STOP = getSound("block.sculk_sensor.clicking_stop"); - Sound BLOCK_SCULK_SENSOR_FALL = getSound("block.sculk_sensor.fall"); - Sound BLOCK_SCULK_SENSOR_HIT = getSound("block.sculk_sensor.hit"); - Sound BLOCK_SCULK_SENSOR_PLACE = getSound("block.sculk_sensor.place"); - Sound BLOCK_SCULK_SENSOR_STEP = getSound("block.sculk_sensor.step"); - Sound BLOCK_SCULK_SHRIEKER_BREAK = getSound("block.sculk_shrieker.break"); - Sound BLOCK_SCULK_SHRIEKER_FALL = getSound("block.sculk_shrieker.fall"); - Sound BLOCK_SCULK_SHRIEKER_HIT = getSound("block.sculk_shrieker.hit"); - Sound BLOCK_SCULK_SHRIEKER_PLACE = getSound("block.sculk_shrieker.place"); - Sound BLOCK_SCULK_SHRIEKER_SHRIEK = getSound("block.sculk_shrieker.shriek"); - Sound BLOCK_SCULK_SHRIEKER_STEP = getSound("block.sculk_shrieker.step"); + Sound BLOCK_SCULK_SPREAD = getSound("block.sculk.spread"); + Sound BLOCK_SCULK_STEP = getSound("block.sculk.step"); + + Sound BLOCK_SCULK_CATALYST_BLOOM = getSound("block.sculk_catalyst.bloom"); + + Sound BLOCK_SCULK_CATALYST_BREAK = getSound("block.sculk_catalyst.break"); + + Sound BLOCK_SCULK_CATALYST_FALL = getSound("block.sculk_catalyst.fall"); + + Sound BLOCK_SCULK_CATALYST_HIT = getSound("block.sculk_catalyst.hit"); + + Sound BLOCK_SCULK_CATALYST_PLACE = getSound("block.sculk_catalyst.place"); + + Sound BLOCK_SCULK_CATALYST_STEP = getSound("block.sculk_catalyst.step"); + + Sound BLOCK_SCULK_SENSOR_BREAK = getSound("block.sculk_sensor.break"); + + Sound BLOCK_SCULK_SENSOR_CLICKING = getSound("block.sculk_sensor.clicking"); + + Sound BLOCK_SCULK_SENSOR_CLICKING_STOP = getSound("block.sculk_sensor.clicking_stop"); + + Sound BLOCK_SCULK_SENSOR_FALL = getSound("block.sculk_sensor.fall"); + + Sound BLOCK_SCULK_SENSOR_HIT = getSound("block.sculk_sensor.hit"); + + Sound BLOCK_SCULK_SENSOR_PLACE = getSound("block.sculk_sensor.place"); + + Sound BLOCK_SCULK_SENSOR_STEP = getSound("block.sculk_sensor.step"); + + Sound BLOCK_SCULK_SHRIEKER_BREAK = getSound("block.sculk_shrieker.break"); + + Sound BLOCK_SCULK_SHRIEKER_FALL = getSound("block.sculk_shrieker.fall"); + + Sound BLOCK_SCULK_SHRIEKER_HIT = getSound("block.sculk_shrieker.hit"); + + Sound BLOCK_SCULK_SHRIEKER_PLACE = getSound("block.sculk_shrieker.place"); + + Sound BLOCK_SCULK_SHRIEKER_SHRIEK = getSound("block.sculk_shrieker.shriek"); + + Sound BLOCK_SCULK_SHRIEKER_STEP = getSound("block.sculk_shrieker.step"); + Sound BLOCK_SCULK_VEIN_BREAK = getSound("block.sculk_vein.break"); + Sound BLOCK_SCULK_VEIN_FALL = getSound("block.sculk_vein.fall"); + Sound BLOCK_SCULK_VEIN_HIT = getSound("block.sculk_vein.hit"); + Sound BLOCK_SCULK_VEIN_PLACE = getSound("block.sculk_vein.place"); + Sound BLOCK_SCULK_VEIN_STEP = getSound("block.sculk_vein.step"); + Sound BLOCK_SHROOMLIGHT_BREAK = getSound("block.shroomlight.break"); + Sound BLOCK_SHROOMLIGHT_FALL = getSound("block.shroomlight.fall"); + Sound BLOCK_SHROOMLIGHT_HIT = getSound("block.shroomlight.hit"); + Sound BLOCK_SHROOMLIGHT_PLACE = getSound("block.shroomlight.place"); + Sound BLOCK_SHROOMLIGHT_STEP = getSound("block.shroomlight.step"); + Sound BLOCK_SHULKER_BOX_CLOSE = getSound("block.shulker_box.close"); + Sound BLOCK_SHULKER_BOX_OPEN = getSound("block.shulker_box.open"); + Sound BLOCK_SIGN_WAXED_INTERACT_FAIL = getSound("block.sign.waxed_interact_fail"); + Sound BLOCK_SLIME_BLOCK_BREAK = getSound("block.slime_block.break"); + Sound BLOCK_SLIME_BLOCK_FALL = getSound("block.slime_block.fall"); + Sound BLOCK_SLIME_BLOCK_HIT = getSound("block.slime_block.hit"); + Sound BLOCK_SLIME_BLOCK_PLACE = getSound("block.slime_block.place"); + Sound BLOCK_SLIME_BLOCK_STEP = getSound("block.slime_block.step"); + Sound BLOCK_SMALL_AMETHYST_BUD_BREAK = getSound("block.small_amethyst_bud.break"); + Sound BLOCK_SMALL_AMETHYST_BUD_PLACE = getSound("block.small_amethyst_bud.place"); + Sound BLOCK_SMALL_DRIPLEAF_BREAK = getSound("block.small_dripleaf.break"); + Sound BLOCK_SMALL_DRIPLEAF_FALL = getSound("block.small_dripleaf.fall"); + Sound BLOCK_SMALL_DRIPLEAF_HIT = getSound("block.small_dripleaf.hit"); + Sound BLOCK_SMALL_DRIPLEAF_PLACE = getSound("block.small_dripleaf.place"); + Sound BLOCK_SMALL_DRIPLEAF_STEP = getSound("block.small_dripleaf.step"); + Sound BLOCK_SMITHING_TABLE_USE = getSound("block.smithing_table.use"); + Sound BLOCK_SMOKER_SMOKE = getSound("block.smoker.smoke"); + Sound BLOCK_SNIFFER_EGG_CRACK = getSound("block.sniffer_egg.crack"); + Sound BLOCK_SNIFFER_EGG_HATCH = getSound("block.sniffer_egg.hatch"); + Sound BLOCK_SNIFFER_EGG_PLOP = getSound("block.sniffer_egg.plop"); + Sound BLOCK_SNOW_BREAK = getSound("block.snow.break"); + Sound BLOCK_SNOW_FALL = getSound("block.snow.fall"); + Sound BLOCK_SNOW_HIT = getSound("block.snow.hit"); + Sound BLOCK_SNOW_PLACE = getSound("block.snow.place"); + Sound BLOCK_SNOW_STEP = getSound("block.snow.step"); + Sound BLOCK_SOUL_SAND_BREAK = getSound("block.soul_sand.break"); + Sound BLOCK_SOUL_SAND_FALL = getSound("block.soul_sand.fall"); + Sound BLOCK_SOUL_SAND_HIT = getSound("block.soul_sand.hit"); + Sound BLOCK_SOUL_SAND_PLACE = getSound("block.soul_sand.place"); + Sound BLOCK_SOUL_SAND_STEP = getSound("block.soul_sand.step"); + Sound BLOCK_SOUL_SOIL_BREAK = getSound("block.soul_soil.break"); + Sound BLOCK_SOUL_SOIL_FALL = getSound("block.soul_soil.fall"); + Sound BLOCK_SOUL_SOIL_HIT = getSound("block.soul_soil.hit"); + Sound BLOCK_SOUL_SOIL_PLACE = getSound("block.soul_soil.place"); + Sound BLOCK_SOUL_SOIL_STEP = getSound("block.soul_soil.step"); + Sound BLOCK_SPAWNER_BREAK = getSound("block.spawner.break"); + Sound BLOCK_SPAWNER_FALL = getSound("block.spawner.fall"); + Sound BLOCK_SPAWNER_HIT = getSound("block.spawner.hit"); + Sound BLOCK_SPAWNER_PLACE = getSound("block.spawner.place"); + Sound BLOCK_SPAWNER_STEP = getSound("block.spawner.step"); + Sound BLOCK_SPONGE_ABSORB = getSound("block.sponge.absorb"); + Sound BLOCK_SPONGE_BREAK = getSound("block.sponge.break"); + Sound BLOCK_SPONGE_FALL = getSound("block.sponge.fall"); + Sound BLOCK_SPONGE_HIT = getSound("block.sponge.hit"); + Sound BLOCK_SPONGE_PLACE = getSound("block.sponge.place"); + Sound BLOCK_SPONGE_STEP = getSound("block.sponge.step"); + Sound BLOCK_SPORE_BLOSSOM_BREAK = getSound("block.spore_blossom.break"); + Sound BLOCK_SPORE_BLOSSOM_FALL = getSound("block.spore_blossom.fall"); + Sound BLOCK_SPORE_BLOSSOM_HIT = getSound("block.spore_blossom.hit"); + Sound BLOCK_SPORE_BLOSSOM_PLACE = getSound("block.spore_blossom.place"); + Sound BLOCK_SPORE_BLOSSOM_STEP = getSound("block.spore_blossom.step"); + Sound BLOCK_STEM_BREAK = getSound("block.stem.break"); + Sound BLOCK_STEM_FALL = getSound("block.stem.fall"); + Sound BLOCK_STEM_HIT = getSound("block.stem.hit"); + Sound BLOCK_STEM_PLACE = getSound("block.stem.place"); + Sound BLOCK_STEM_STEP = getSound("block.stem.step"); + Sound BLOCK_STONE_BREAK = getSound("block.stone.break"); - Sound BLOCK_STONE_BUTTON_CLICK_OFF = getSound("block.stone_button.click_off"); - Sound BLOCK_STONE_BUTTON_CLICK_ON = getSound("block.stone_button.click_on"); + Sound BLOCK_STONE_FALL = getSound("block.stone.fall"); + Sound BLOCK_STONE_HIT = getSound("block.stone.hit"); + Sound BLOCK_STONE_PLACE = getSound("block.stone.place"); - Sound BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF = getSound("block.stone_pressure_plate.click_off"); - Sound BLOCK_STONE_PRESSURE_PLATE_CLICK_ON = getSound("block.stone_pressure_plate.click_on"); + Sound BLOCK_STONE_STEP = getSound("block.stone.step"); + + Sound BLOCK_STONE_BUTTON_CLICK_OFF = getSound("block.stone_button.click_off"); + + Sound BLOCK_STONE_BUTTON_CLICK_ON = getSound("block.stone_button.click_on"); + + Sound BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF = getSound("block.stone_pressure_plate.click_off"); + + Sound BLOCK_STONE_PRESSURE_PLATE_CLICK_ON = getSound("block.stone_pressure_plate.click_on"); + Sound BLOCK_SUSPICIOUS_GRAVEL_BREAK = getSound("block.suspicious_gravel.break"); + Sound BLOCK_SUSPICIOUS_GRAVEL_FALL = getSound("block.suspicious_gravel.fall"); + Sound BLOCK_SUSPICIOUS_GRAVEL_HIT = getSound("block.suspicious_gravel.hit"); + Sound BLOCK_SUSPICIOUS_GRAVEL_PLACE = getSound("block.suspicious_gravel.place"); + Sound BLOCK_SUSPICIOUS_GRAVEL_STEP = getSound("block.suspicious_gravel.step"); + Sound BLOCK_SUSPICIOUS_SAND_BREAK = getSound("block.suspicious_sand.break"); + Sound BLOCK_SUSPICIOUS_SAND_FALL = getSound("block.suspicious_sand.fall"); + Sound BLOCK_SUSPICIOUS_SAND_HIT = getSound("block.suspicious_sand.hit"); + Sound BLOCK_SUSPICIOUS_SAND_PLACE = getSound("block.suspicious_sand.place"); + Sound BLOCK_SUSPICIOUS_SAND_STEP = getSound("block.suspicious_sand.step"); + Sound BLOCK_SWEET_BERRY_BUSH_BREAK = getSound("block.sweet_berry_bush.break"); + Sound BLOCK_SWEET_BERRY_BUSH_PICK_BERRIES = getSound("block.sweet_berry_bush.pick_berries"); + Sound BLOCK_SWEET_BERRY_BUSH_PLACE = getSound("block.sweet_berry_bush.place"); + Sound BLOCK_TRIAL_SPAWNER_ABOUT_TO_SPAWN_ITEM = getSound("block.trial_spawner.about_to_spawn_item"); + Sound BLOCK_TRIAL_SPAWNER_AMBIENT = getSound("block.trial_spawner.ambient"); + Sound BLOCK_TRIAL_SPAWNER_AMBIENT_OMINOUS = getSound("block.trial_spawner.ambient_ominous"); + Sound BLOCK_TRIAL_SPAWNER_BREAK = getSound("block.trial_spawner.break"); + Sound BLOCK_TRIAL_SPAWNER_CLOSE_SHUTTER = getSound("block.trial_spawner.close_shutter"); + Sound BLOCK_TRIAL_SPAWNER_DETECT_PLAYER = getSound("block.trial_spawner.detect_player"); + Sound BLOCK_TRIAL_SPAWNER_EJECT_ITEM = getSound("block.trial_spawner.eject_item"); + Sound BLOCK_TRIAL_SPAWNER_FALL = getSound("block.trial_spawner.fall"); + Sound BLOCK_TRIAL_SPAWNER_HIT = getSound("block.trial_spawner.hit"); + Sound BLOCK_TRIAL_SPAWNER_OMINOUS_ACTIVATE = getSound("block.trial_spawner.ominous_activate"); + Sound BLOCK_TRIAL_SPAWNER_OPEN_SHUTTER = getSound("block.trial_spawner.open_shutter"); + Sound BLOCK_TRIAL_SPAWNER_PLACE = getSound("block.trial_spawner.place"); + Sound BLOCK_TRIAL_SPAWNER_SPAWN_ITEM = getSound("block.trial_spawner.spawn_item"); + Sound BLOCK_TRIAL_SPAWNER_SPAWN_ITEM_BEGIN = getSound("block.trial_spawner.spawn_item_begin"); + Sound BLOCK_TRIAL_SPAWNER_SPAWN_MOB = getSound("block.trial_spawner.spawn_mob"); + Sound BLOCK_TRIAL_SPAWNER_STEP = getSound("block.trial_spawner.step"); + Sound BLOCK_TRIPWIRE_ATTACH = getSound("block.tripwire.attach"); + Sound BLOCK_TRIPWIRE_CLICK_OFF = getSound("block.tripwire.click_off"); + Sound BLOCK_TRIPWIRE_CLICK_ON = getSound("block.tripwire.click_on"); + Sound BLOCK_TRIPWIRE_DETACH = getSound("block.tripwire.detach"); + Sound BLOCK_TUFF_BREAK = getSound("block.tuff.break"); - Sound BLOCK_TUFF_BRICKS_BREAK = getSound("block.tuff_bricks.break"); - Sound BLOCK_TUFF_BRICKS_FALL = getSound("block.tuff_bricks.fall"); - Sound BLOCK_TUFF_BRICKS_HIT = getSound("block.tuff_bricks.hit"); - Sound BLOCK_TUFF_BRICKS_PLACE = getSound("block.tuff_bricks.place"); - Sound BLOCK_TUFF_BRICKS_STEP = getSound("block.tuff_bricks.step"); + Sound BLOCK_TUFF_FALL = getSound("block.tuff.fall"); + Sound BLOCK_TUFF_HIT = getSound("block.tuff.hit"); + Sound BLOCK_TUFF_PLACE = getSound("block.tuff.place"); + Sound BLOCK_TUFF_STEP = getSound("block.tuff.step"); + + Sound BLOCK_TUFF_BRICKS_BREAK = getSound("block.tuff_bricks.break"); + + Sound BLOCK_TUFF_BRICKS_FALL = getSound("block.tuff_bricks.fall"); + + Sound BLOCK_TUFF_BRICKS_HIT = getSound("block.tuff_bricks.hit"); + + Sound BLOCK_TUFF_BRICKS_PLACE = getSound("block.tuff_bricks.place"); + + Sound BLOCK_TUFF_BRICKS_STEP = getSound("block.tuff_bricks.step"); + Sound BLOCK_VAULT_ACTIVATE = getSound("block.vault.activate"); + Sound BLOCK_VAULT_AMBIENT = getSound("block.vault.ambient"); + Sound BLOCK_VAULT_BREAK = getSound("block.vault.break"); + Sound BLOCK_VAULT_CLOSE_SHUTTER = getSound("block.vault.close_shutter"); + Sound BLOCK_VAULT_DEACTIVATE = getSound("block.vault.deactivate"); + Sound BLOCK_VAULT_EJECT_ITEM = getSound("block.vault.eject_item"); + Sound BLOCK_VAULT_FALL = getSound("block.vault.fall"); + Sound BLOCK_VAULT_HIT = getSound("block.vault.hit"); + Sound BLOCK_VAULT_INSERT_ITEM = getSound("block.vault.insert_item"); + Sound BLOCK_VAULT_INSERT_ITEM_FAIL = getSound("block.vault.insert_item_fail"); + Sound BLOCK_VAULT_OPEN_SHUTTER = getSound("block.vault.open_shutter"); + Sound BLOCK_VAULT_PLACE = getSound("block.vault.place"); + Sound BLOCK_VAULT_REJECT_REWARDED_PLAYER = getSound("block.vault.reject_rewarded_player"); + Sound BLOCK_VAULT_STEP = getSound("block.vault.step"); + Sound BLOCK_VINE_BREAK = getSound("block.vine.break"); + Sound BLOCK_VINE_FALL = getSound("block.vine.fall"); + Sound BLOCK_VINE_HIT = getSound("block.vine.hit"); + Sound BLOCK_VINE_PLACE = getSound("block.vine.place"); + Sound BLOCK_VINE_STEP = getSound("block.vine.step"); + Sound BLOCK_WART_BLOCK_BREAK = getSound("block.wart_block.break"); + Sound BLOCK_WART_BLOCK_FALL = getSound("block.wart_block.fall"); + Sound BLOCK_WART_BLOCK_HIT = getSound("block.wart_block.hit"); + Sound BLOCK_WART_BLOCK_PLACE = getSound("block.wart_block.place"); + Sound BLOCK_WART_BLOCK_STEP = getSound("block.wart_block.step"); + Sound BLOCK_WATER_AMBIENT = getSound("block.water.ambient"); + Sound BLOCK_WEEPING_VINES_BREAK = getSound("block.weeping_vines.break"); + Sound BLOCK_WEEPING_VINES_FALL = getSound("block.weeping_vines.fall"); + Sound BLOCK_WEEPING_VINES_HIT = getSound("block.weeping_vines.hit"); + Sound BLOCK_WEEPING_VINES_PLACE = getSound("block.weeping_vines.place"); + Sound BLOCK_WEEPING_VINES_STEP = getSound("block.weeping_vines.step"); + Sound BLOCK_WET_GRASS_BREAK = getSound("block.wet_grass.break"); + Sound BLOCK_WET_GRASS_FALL = getSound("block.wet_grass.fall"); + Sound BLOCK_WET_GRASS_HIT = getSound("block.wet_grass.hit"); + Sound BLOCK_WET_GRASS_PLACE = getSound("block.wet_grass.place"); + Sound BLOCK_WET_GRASS_STEP = getSound("block.wet_grass.step"); + Sound BLOCK_WET_SPONGE_BREAK = getSound("block.wet_sponge.break"); + Sound BLOCK_WET_SPONGE_DRIES = getSound("block.wet_sponge.dries"); + Sound BLOCK_WET_SPONGE_FALL = getSound("block.wet_sponge.fall"); + Sound BLOCK_WET_SPONGE_HIT = getSound("block.wet_sponge.hit"); + Sound BLOCK_WET_SPONGE_PLACE = getSound("block.wet_sponge.place"); + Sound BLOCK_WET_SPONGE_STEP = getSound("block.wet_sponge.step"); - Sound BLOCK_WOODEN_BUTTON_CLICK_OFF = getSound("block.wooden_button.click_off"); - Sound BLOCK_WOODEN_BUTTON_CLICK_ON = getSound("block.wooden_button.click_on"); - Sound BLOCK_WOODEN_DOOR_CLOSE = getSound("block.wooden_door.close"); - Sound BLOCK_WOODEN_DOOR_OPEN = getSound("block.wooden_door.open"); - Sound BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF = getSound("block.wooden_pressure_plate.click_off"); - Sound BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON = getSound("block.wooden_pressure_plate.click_on"); - Sound BLOCK_WOODEN_TRAPDOOR_CLOSE = getSound("block.wooden_trapdoor.close"); - Sound BLOCK_WOODEN_TRAPDOOR_OPEN = getSound("block.wooden_trapdoor.open"); + Sound BLOCK_WOOD_BREAK = getSound("block.wood.break"); + Sound BLOCK_WOOD_FALL = getSound("block.wood.fall"); + Sound BLOCK_WOOD_HIT = getSound("block.wood.hit"); + Sound BLOCK_WOOD_PLACE = getSound("block.wood.place"); + Sound BLOCK_WOOD_STEP = getSound("block.wood.step"); + + Sound BLOCK_WOODEN_BUTTON_CLICK_OFF = getSound("block.wooden_button.click_off"); + + Sound BLOCK_WOODEN_BUTTON_CLICK_ON = getSound("block.wooden_button.click_on"); + + Sound BLOCK_WOODEN_DOOR_CLOSE = getSound("block.wooden_door.close"); + + Sound BLOCK_WOODEN_DOOR_OPEN = getSound("block.wooden_door.open"); + + Sound BLOCK_WOODEN_PRESSURE_PLATE_CLICK_OFF = getSound("block.wooden_pressure_plate.click_off"); + + Sound BLOCK_WOODEN_PRESSURE_PLATE_CLICK_ON = getSound("block.wooden_pressure_plate.click_on"); + + Sound BLOCK_WOODEN_TRAPDOOR_CLOSE = getSound("block.wooden_trapdoor.close"); + + Sound BLOCK_WOODEN_TRAPDOOR_OPEN = getSound("block.wooden_trapdoor.open"); + Sound BLOCK_WOOL_BREAK = getSound("block.wool.break"); + Sound BLOCK_WOOL_FALL = getSound("block.wool.fall"); + Sound BLOCK_WOOL_HIT = getSound("block.wool.hit"); + Sound BLOCK_WOOL_PLACE = getSound("block.wool.place"); + Sound BLOCK_WOOL_STEP = getSound("block.wool.step"); + Sound ENCHANT_THORNS_HIT = getSound("enchant.thorns.hit"); - Sound ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM = getSound("entity.allay.ambient_without_item"); + Sound ENTITY_ALLAY_AMBIENT_WITH_ITEM = getSound("entity.allay.ambient_with_item"); + + Sound ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM = getSound("entity.allay.ambient_without_item"); + Sound ENTITY_ALLAY_DEATH = getSound("entity.allay.death"); + Sound ENTITY_ALLAY_HURT = getSound("entity.allay.hurt"); + Sound ENTITY_ALLAY_ITEM_GIVEN = getSound("entity.allay.item_given"); + Sound ENTITY_ALLAY_ITEM_TAKEN = getSound("entity.allay.item_taken"); + Sound ENTITY_ALLAY_ITEM_THROWN = getSound("entity.allay.item_thrown"); + Sound ENTITY_ARMADILLO_AMBIENT = getSound("entity.armadillo.ambient"); + Sound ENTITY_ARMADILLO_BRUSH = getSound("entity.armadillo.brush"); + Sound ENTITY_ARMADILLO_DEATH = getSound("entity.armadillo.death"); + Sound ENTITY_ARMADILLO_EAT = getSound("entity.armadillo.eat"); + Sound ENTITY_ARMADILLO_HURT = getSound("entity.armadillo.hurt"); + Sound ENTITY_ARMADILLO_HURT_REDUCED = getSound("entity.armadillo.hurt_reduced"); + Sound ENTITY_ARMADILLO_LAND = getSound("entity.armadillo.land"); + Sound ENTITY_ARMADILLO_PEEK = getSound("entity.armadillo.peek"); + Sound ENTITY_ARMADILLO_ROLL = getSound("entity.armadillo.roll"); + Sound ENTITY_ARMADILLO_SCUTE_DROP = getSound("entity.armadillo.scute_drop"); + Sound ENTITY_ARMADILLO_STEP = getSound("entity.armadillo.step"); + Sound ENTITY_ARMADILLO_UNROLL_FINISH = getSound("entity.armadillo.unroll_finish"); + Sound ENTITY_ARMADILLO_UNROLL_START = getSound("entity.armadillo.unroll_start"); + Sound ENTITY_ARMOR_STAND_BREAK = getSound("entity.armor_stand.break"); + Sound ENTITY_ARMOR_STAND_FALL = getSound("entity.armor_stand.fall"); + Sound ENTITY_ARMOR_STAND_HIT = getSound("entity.armor_stand.hit"); + Sound ENTITY_ARMOR_STAND_PLACE = getSound("entity.armor_stand.place"); + Sound ENTITY_ARROW_HIT = getSound("entity.arrow.hit"); + Sound ENTITY_ARROW_HIT_PLAYER = getSound("entity.arrow.hit_player"); + Sound ENTITY_ARROW_SHOOT = getSound("entity.arrow.shoot"); + Sound ENTITY_AXOLOTL_ATTACK = getSound("entity.axolotl.attack"); + Sound ENTITY_AXOLOTL_DEATH = getSound("entity.axolotl.death"); + Sound ENTITY_AXOLOTL_HURT = getSound("entity.axolotl.hurt"); + Sound ENTITY_AXOLOTL_IDLE_AIR = getSound("entity.axolotl.idle_air"); + Sound ENTITY_AXOLOTL_IDLE_WATER = getSound("entity.axolotl.idle_water"); + Sound ENTITY_AXOLOTL_SPLASH = getSound("entity.axolotl.splash"); + Sound ENTITY_AXOLOTL_SWIM = getSound("entity.axolotl.swim"); + Sound ENTITY_BAT_AMBIENT = getSound("entity.bat.ambient"); + Sound ENTITY_BAT_DEATH = getSound("entity.bat.death"); + Sound ENTITY_BAT_HURT = getSound("entity.bat.hurt"); + Sound ENTITY_BAT_LOOP = getSound("entity.bat.loop"); + Sound ENTITY_BAT_TAKEOFF = getSound("entity.bat.takeoff"); + Sound ENTITY_BEE_DEATH = getSound("entity.bee.death"); + Sound ENTITY_BEE_HURT = getSound("entity.bee.hurt"); + Sound ENTITY_BEE_LOOP = getSound("entity.bee.loop"); + Sound ENTITY_BEE_LOOP_AGGRESSIVE = getSound("entity.bee.loop_aggressive"); + Sound ENTITY_BEE_POLLINATE = getSound("entity.bee.pollinate"); + Sound ENTITY_BEE_STING = getSound("entity.bee.sting"); + Sound ENTITY_BLAZE_AMBIENT = getSound("entity.blaze.ambient"); + Sound ENTITY_BLAZE_BURN = getSound("entity.blaze.burn"); + Sound ENTITY_BLAZE_DEATH = getSound("entity.blaze.death"); + Sound ENTITY_BLAZE_HURT = getSound("entity.blaze.hurt"); + Sound ENTITY_BLAZE_SHOOT = getSound("entity.blaze.shoot"); + Sound ENTITY_BOAT_PADDLE_LAND = getSound("entity.boat.paddle_land"); + Sound ENTITY_BOAT_PADDLE_WATER = getSound("entity.boat.paddle_water"); + Sound ENTITY_BOGGED_AMBIENT = getSound("entity.bogged.ambient"); + Sound ENTITY_BOGGED_DEATH = getSound("entity.bogged.death"); + Sound ENTITY_BOGGED_HURT = getSound("entity.bogged.hurt"); + Sound ENTITY_BOGGED_SHEAR = getSound("entity.bogged.shear"); + Sound ENTITY_BOGGED_STEP = getSound("entity.bogged.step"); + Sound ENTITY_BREEZE_CHARGE = getSound("entity.breeze.charge"); + Sound ENTITY_BREEZE_DEATH = getSound("entity.breeze.death"); + Sound ENTITY_BREEZE_DEFLECT = getSound("entity.breeze.deflect"); + Sound ENTITY_BREEZE_HURT = getSound("entity.breeze.hurt"); + Sound ENTITY_BREEZE_IDLE_AIR = getSound("entity.breeze.idle_air"); + Sound ENTITY_BREEZE_IDLE_GROUND = getSound("entity.breeze.idle_ground"); + Sound ENTITY_BREEZE_INHALE = getSound("entity.breeze.inhale"); + Sound ENTITY_BREEZE_JUMP = getSound("entity.breeze.jump"); + Sound ENTITY_BREEZE_LAND = getSound("entity.breeze.land"); + Sound ENTITY_BREEZE_SHOOT = getSound("entity.breeze.shoot"); + Sound ENTITY_BREEZE_SLIDE = getSound("entity.breeze.slide"); + Sound ENTITY_BREEZE_WHIRL = getSound("entity.breeze.whirl"); + Sound ENTITY_BREEZE_WIND_BURST = getSound("entity.breeze.wind_burst"); + Sound ENTITY_CAMEL_AMBIENT = getSound("entity.camel.ambient"); + Sound ENTITY_CAMEL_DASH = getSound("entity.camel.dash"); + Sound ENTITY_CAMEL_DASH_READY = getSound("entity.camel.dash_ready"); + Sound ENTITY_CAMEL_DEATH = getSound("entity.camel.death"); + Sound ENTITY_CAMEL_EAT = getSound("entity.camel.eat"); + Sound ENTITY_CAMEL_HURT = getSound("entity.camel.hurt"); + Sound ENTITY_CAMEL_SADDLE = getSound("entity.camel.saddle"); + Sound ENTITY_CAMEL_SIT = getSound("entity.camel.sit"); + Sound ENTITY_CAMEL_STAND = getSound("entity.camel.stand"); + Sound ENTITY_CAMEL_STEP = getSound("entity.camel.step"); + Sound ENTITY_CAMEL_STEP_SAND = getSound("entity.camel.step_sand"); + Sound ENTITY_CAT_AMBIENT = getSound("entity.cat.ambient"); + Sound ENTITY_CAT_BEG_FOR_FOOD = getSound("entity.cat.beg_for_food"); + Sound ENTITY_CAT_DEATH = getSound("entity.cat.death"); + Sound ENTITY_CAT_EAT = getSound("entity.cat.eat"); + Sound ENTITY_CAT_HISS = getSound("entity.cat.hiss"); + Sound ENTITY_CAT_HURT = getSound("entity.cat.hurt"); + Sound ENTITY_CAT_PURR = getSound("entity.cat.purr"); + Sound ENTITY_CAT_PURREOW = getSound("entity.cat.purreow"); + Sound ENTITY_CAT_STRAY_AMBIENT = getSound("entity.cat.stray_ambient"); + Sound ENTITY_CHICKEN_AMBIENT = getSound("entity.chicken.ambient"); + Sound ENTITY_CHICKEN_DEATH = getSound("entity.chicken.death"); + Sound ENTITY_CHICKEN_EGG = getSound("entity.chicken.egg"); + Sound ENTITY_CHICKEN_HURT = getSound("entity.chicken.hurt"); + Sound ENTITY_CHICKEN_STEP = getSound("entity.chicken.step"); + Sound ENTITY_COD_AMBIENT = getSound("entity.cod.ambient"); + Sound ENTITY_COD_DEATH = getSound("entity.cod.death"); + Sound ENTITY_COD_FLOP = getSound("entity.cod.flop"); + Sound ENTITY_COD_HURT = getSound("entity.cod.hurt"); + Sound ENTITY_COW_AMBIENT = getSound("entity.cow.ambient"); + Sound ENTITY_COW_DEATH = getSound("entity.cow.death"); + Sound ENTITY_COW_HURT = getSound("entity.cow.hurt"); + Sound ENTITY_COW_MILK = getSound("entity.cow.milk"); + Sound ENTITY_COW_STEP = getSound("entity.cow.step"); + Sound ENTITY_CREAKING_ACTIVATE = getSound("entity.creaking.activate"); + Sound ENTITY_CREAKING_AMBIENT = getSound("entity.creaking.ambient"); + Sound ENTITY_CREAKING_ATTACK = getSound("entity.creaking.attack"); + Sound ENTITY_CREAKING_DEACTIVATE = getSound("entity.creaking.deactivate"); + Sound ENTITY_CREAKING_DEATH = getSound("entity.creaking.death"); + Sound ENTITY_CREAKING_FREEZE = getSound("entity.creaking.freeze"); + Sound ENTITY_CREAKING_SPAWN = getSound("entity.creaking.spawn"); + Sound ENTITY_CREAKING_STEP = getSound("entity.creaking.step"); + Sound ENTITY_CREAKING_SWAY = getSound("entity.creaking.sway"); + Sound ENTITY_CREAKING_TWITCH = getSound("entity.creaking.twitch"); + Sound ENTITY_CREAKING_UNFREEZE = getSound("entity.creaking.unfreeze"); + Sound ENTITY_CREEPER_DEATH = getSound("entity.creeper.death"); + Sound ENTITY_CREEPER_HURT = getSound("entity.creeper.hurt"); + Sound ENTITY_CREEPER_PRIMED = getSound("entity.creeper.primed"); + Sound ENTITY_DOLPHIN_AMBIENT = getSound("entity.dolphin.ambient"); + Sound ENTITY_DOLPHIN_AMBIENT_WATER = getSound("entity.dolphin.ambient_water"); + Sound ENTITY_DOLPHIN_ATTACK = getSound("entity.dolphin.attack"); + Sound ENTITY_DOLPHIN_DEATH = getSound("entity.dolphin.death"); + Sound ENTITY_DOLPHIN_EAT = getSound("entity.dolphin.eat"); + Sound ENTITY_DOLPHIN_HURT = getSound("entity.dolphin.hurt"); + Sound ENTITY_DOLPHIN_JUMP = getSound("entity.dolphin.jump"); + Sound ENTITY_DOLPHIN_PLAY = getSound("entity.dolphin.play"); + Sound ENTITY_DOLPHIN_SPLASH = getSound("entity.dolphin.splash"); + Sound ENTITY_DOLPHIN_SWIM = getSound("entity.dolphin.swim"); + Sound ENTITY_DONKEY_AMBIENT = getSound("entity.donkey.ambient"); + Sound ENTITY_DONKEY_ANGRY = getSound("entity.donkey.angry"); + Sound ENTITY_DONKEY_CHEST = getSound("entity.donkey.chest"); + Sound ENTITY_DONKEY_DEATH = getSound("entity.donkey.death"); + Sound ENTITY_DONKEY_EAT = getSound("entity.donkey.eat"); + Sound ENTITY_DONKEY_HURT = getSound("entity.donkey.hurt"); + Sound ENTITY_DONKEY_JUMP = getSound("entity.donkey.jump"); + Sound ENTITY_DRAGON_FIREBALL_EXPLODE = getSound("entity.dragon_fireball.explode"); + Sound ENTITY_DROWNED_AMBIENT = getSound("entity.drowned.ambient"); + Sound ENTITY_DROWNED_AMBIENT_WATER = getSound("entity.drowned.ambient_water"); + Sound ENTITY_DROWNED_DEATH = getSound("entity.drowned.death"); + Sound ENTITY_DROWNED_DEATH_WATER = getSound("entity.drowned.death_water"); + Sound ENTITY_DROWNED_HURT = getSound("entity.drowned.hurt"); + Sound ENTITY_DROWNED_HURT_WATER = getSound("entity.drowned.hurt_water"); + Sound ENTITY_DROWNED_SHOOT = getSound("entity.drowned.shoot"); + Sound ENTITY_DROWNED_STEP = getSound("entity.drowned.step"); + Sound ENTITY_DROWNED_SWIM = getSound("entity.drowned.swim"); + Sound ENTITY_EGG_THROW = getSound("entity.egg.throw"); + Sound ENTITY_ELDER_GUARDIAN_AMBIENT = getSound("entity.elder_guardian.ambient"); + Sound ENTITY_ELDER_GUARDIAN_AMBIENT_LAND = getSound("entity.elder_guardian.ambient_land"); + Sound ENTITY_ELDER_GUARDIAN_CURSE = getSound("entity.elder_guardian.curse"); + Sound ENTITY_ELDER_GUARDIAN_DEATH = getSound("entity.elder_guardian.death"); + Sound ENTITY_ELDER_GUARDIAN_DEATH_LAND = getSound("entity.elder_guardian.death_land"); + Sound ENTITY_ELDER_GUARDIAN_FLOP = getSound("entity.elder_guardian.flop"); + Sound ENTITY_ELDER_GUARDIAN_HURT = getSound("entity.elder_guardian.hurt"); + Sound ENTITY_ELDER_GUARDIAN_HURT_LAND = getSound("entity.elder_guardian.hurt_land"); - Sound ENTITY_ENDERMAN_AMBIENT = getSound("entity.enderman.ambient"); - Sound ENTITY_ENDERMAN_DEATH = getSound("entity.enderman.death"); - Sound ENTITY_ENDERMAN_HURT = getSound("entity.enderman.hurt"); - Sound ENTITY_ENDERMAN_SCREAM = getSound("entity.enderman.scream"); - Sound ENTITY_ENDERMAN_STARE = getSound("entity.enderman.stare"); - Sound ENTITY_ENDERMAN_TELEPORT = getSound("entity.enderman.teleport"); - Sound ENTITY_ENDERMITE_AMBIENT = getSound("entity.endermite.ambient"); - Sound ENTITY_ENDERMITE_DEATH = getSound("entity.endermite.death"); - Sound ENTITY_ENDERMITE_HURT = getSound("entity.endermite.hurt"); - Sound ENTITY_ENDERMITE_STEP = getSound("entity.endermite.step"); + Sound ENTITY_ENDER_DRAGON_AMBIENT = getSound("entity.ender_dragon.ambient"); + Sound ENTITY_ENDER_DRAGON_DEATH = getSound("entity.ender_dragon.death"); + Sound ENTITY_ENDER_DRAGON_FLAP = getSound("entity.ender_dragon.flap"); + Sound ENTITY_ENDER_DRAGON_GROWL = getSound("entity.ender_dragon.growl"); + Sound ENTITY_ENDER_DRAGON_HURT = getSound("entity.ender_dragon.hurt"); + Sound ENTITY_ENDER_DRAGON_SHOOT = getSound("entity.ender_dragon.shoot"); + Sound ENTITY_ENDER_EYE_DEATH = getSound("entity.ender_eye.death"); + Sound ENTITY_ENDER_EYE_LAUNCH = getSound("entity.ender_eye.launch"); + Sound ENTITY_ENDER_PEARL_THROW = getSound("entity.ender_pearl.throw"); + + Sound ENTITY_ENDERMAN_AMBIENT = getSound("entity.enderman.ambient"); + + Sound ENTITY_ENDERMAN_DEATH = getSound("entity.enderman.death"); + + Sound ENTITY_ENDERMAN_HURT = getSound("entity.enderman.hurt"); + + Sound ENTITY_ENDERMAN_SCREAM = getSound("entity.enderman.scream"); + + Sound ENTITY_ENDERMAN_STARE = getSound("entity.enderman.stare"); + + Sound ENTITY_ENDERMAN_TELEPORT = getSound("entity.enderman.teleport"); + + Sound ENTITY_ENDERMITE_AMBIENT = getSound("entity.endermite.ambient"); + + Sound ENTITY_ENDERMITE_DEATH = getSound("entity.endermite.death"); + + Sound ENTITY_ENDERMITE_HURT = getSound("entity.endermite.hurt"); + + Sound ENTITY_ENDERMITE_STEP = getSound("entity.endermite.step"); + Sound ENTITY_EVOKER_AMBIENT = getSound("entity.evoker.ambient"); + Sound ENTITY_EVOKER_CAST_SPELL = getSound("entity.evoker.cast_spell"); + Sound ENTITY_EVOKER_CELEBRATE = getSound("entity.evoker.celebrate"); + Sound ENTITY_EVOKER_DEATH = getSound("entity.evoker.death"); - Sound ENTITY_EVOKER_FANGS_ATTACK = getSound("entity.evoker_fangs.attack"); + Sound ENTITY_EVOKER_HURT = getSound("entity.evoker.hurt"); + Sound ENTITY_EVOKER_PREPARE_ATTACK = getSound("entity.evoker.prepare_attack"); + Sound ENTITY_EVOKER_PREPARE_SUMMON = getSound("entity.evoker.prepare_summon"); + Sound ENTITY_EVOKER_PREPARE_WOLOLO = getSound("entity.evoker.prepare_wololo"); + + Sound ENTITY_EVOKER_FANGS_ATTACK = getSound("entity.evoker_fangs.attack"); + Sound ENTITY_EXPERIENCE_BOTTLE_THROW = getSound("entity.experience_bottle.throw"); + Sound ENTITY_EXPERIENCE_ORB_PICKUP = getSound("entity.experience_orb.pickup"); + Sound ENTITY_FIREWORK_ROCKET_BLAST = getSound("entity.firework_rocket.blast"); + Sound ENTITY_FIREWORK_ROCKET_BLAST_FAR = getSound("entity.firework_rocket.blast_far"); + Sound ENTITY_FIREWORK_ROCKET_LARGE_BLAST = getSound("entity.firework_rocket.large_blast"); + Sound ENTITY_FIREWORK_ROCKET_LARGE_BLAST_FAR = getSound("entity.firework_rocket.large_blast_far"); + Sound ENTITY_FIREWORK_ROCKET_LAUNCH = getSound("entity.firework_rocket.launch"); + Sound ENTITY_FIREWORK_ROCKET_SHOOT = getSound("entity.firework_rocket.shoot"); + Sound ENTITY_FIREWORK_ROCKET_TWINKLE = getSound("entity.firework_rocket.twinkle"); + Sound ENTITY_FIREWORK_ROCKET_TWINKLE_FAR = getSound("entity.firework_rocket.twinkle_far"); - Sound ENTITY_FISHING_BOBBER_RETRIEVE = getSound("entity.fishing_bobber.retrieve"); - Sound ENTITY_FISHING_BOBBER_SPLASH = getSound("entity.fishing_bobber.splash"); - Sound ENTITY_FISHING_BOBBER_THROW = getSound("entity.fishing_bobber.throw"); + Sound ENTITY_FISH_SWIM = getSound("entity.fish.swim"); + + Sound ENTITY_FISHING_BOBBER_RETRIEVE = getSound("entity.fishing_bobber.retrieve"); + + Sound ENTITY_FISHING_BOBBER_SPLASH = getSound("entity.fishing_bobber.splash"); + + Sound ENTITY_FISHING_BOBBER_THROW = getSound("entity.fishing_bobber.throw"); + Sound ENTITY_FOX_AGGRO = getSound("entity.fox.aggro"); + Sound ENTITY_FOX_AMBIENT = getSound("entity.fox.ambient"); + Sound ENTITY_FOX_BITE = getSound("entity.fox.bite"); + Sound ENTITY_FOX_DEATH = getSound("entity.fox.death"); + Sound ENTITY_FOX_EAT = getSound("entity.fox.eat"); + Sound ENTITY_FOX_HURT = getSound("entity.fox.hurt"); + Sound ENTITY_FOX_SCREECH = getSound("entity.fox.screech"); + Sound ENTITY_FOX_SLEEP = getSound("entity.fox.sleep"); + Sound ENTITY_FOX_SNIFF = getSound("entity.fox.sniff"); + Sound ENTITY_FOX_SPIT = getSound("entity.fox.spit"); + Sound ENTITY_FOX_TELEPORT = getSound("entity.fox.teleport"); + Sound ENTITY_FROG_AMBIENT = getSound("entity.frog.ambient"); + Sound ENTITY_FROG_DEATH = getSound("entity.frog.death"); + Sound ENTITY_FROG_EAT = getSound("entity.frog.eat"); + Sound ENTITY_FROG_HURT = getSound("entity.frog.hurt"); + Sound ENTITY_FROG_LAY_SPAWN = getSound("entity.frog.lay_spawn"); + Sound ENTITY_FROG_LONG_JUMP = getSound("entity.frog.long_jump"); + Sound ENTITY_FROG_STEP = getSound("entity.frog.step"); + Sound ENTITY_FROG_TONGUE = getSound("entity.frog.tongue"); + Sound ENTITY_GENERIC_BIG_FALL = getSound("entity.generic.big_fall"); + Sound ENTITY_GENERIC_BURN = getSound("entity.generic.burn"); + Sound ENTITY_GENERIC_DEATH = getSound("entity.generic.death"); + Sound ENTITY_GENERIC_DRINK = getSound("entity.generic.drink"); + Sound ENTITY_GENERIC_EAT = getSound("entity.generic.eat"); + Sound ENTITY_GENERIC_EXPLODE = getSound("entity.generic.explode"); + Sound ENTITY_GENERIC_EXTINGUISH_FIRE = getSound("entity.generic.extinguish_fire"); + Sound ENTITY_GENERIC_HURT = getSound("entity.generic.hurt"); + Sound ENTITY_GENERIC_SMALL_FALL = getSound("entity.generic.small_fall"); + Sound ENTITY_GENERIC_SPLASH = getSound("entity.generic.splash"); + Sound ENTITY_GENERIC_SWIM = getSound("entity.generic.swim"); + Sound ENTITY_GHAST_AMBIENT = getSound("entity.ghast.ambient"); + Sound ENTITY_GHAST_DEATH = getSound("entity.ghast.death"); + Sound ENTITY_GHAST_HURT = getSound("entity.ghast.hurt"); + Sound ENTITY_GHAST_SCREAM = getSound("entity.ghast.scream"); + Sound ENTITY_GHAST_SHOOT = getSound("entity.ghast.shoot"); + Sound ENTITY_GHAST_WARN = getSound("entity.ghast.warn"); + Sound ENTITY_GLOW_ITEM_FRAME_ADD_ITEM = getSound("entity.glow_item_frame.add_item"); + Sound ENTITY_GLOW_ITEM_FRAME_BREAK = getSound("entity.glow_item_frame.break"); + Sound ENTITY_GLOW_ITEM_FRAME_PLACE = getSound("entity.glow_item_frame.place"); + Sound ENTITY_GLOW_ITEM_FRAME_REMOVE_ITEM = getSound("entity.glow_item_frame.remove_item"); + Sound ENTITY_GLOW_ITEM_FRAME_ROTATE_ITEM = getSound("entity.glow_item_frame.rotate_item"); + Sound ENTITY_GLOW_SQUID_AMBIENT = getSound("entity.glow_squid.ambient"); + Sound ENTITY_GLOW_SQUID_DEATH = getSound("entity.glow_squid.death"); + Sound ENTITY_GLOW_SQUID_HURT = getSound("entity.glow_squid.hurt"); + Sound ENTITY_GLOW_SQUID_SQUIRT = getSound("entity.glow_squid.squirt"); + Sound ENTITY_GOAT_AMBIENT = getSound("entity.goat.ambient"); + Sound ENTITY_GOAT_DEATH = getSound("entity.goat.death"); + Sound ENTITY_GOAT_EAT = getSound("entity.goat.eat"); + Sound ENTITY_GOAT_HORN_BREAK = getSound("entity.goat.horn_break"); + Sound ENTITY_GOAT_HURT = getSound("entity.goat.hurt"); + Sound ENTITY_GOAT_LONG_JUMP = getSound("entity.goat.long_jump"); + Sound ENTITY_GOAT_MILK = getSound("entity.goat.milk"); + Sound ENTITY_GOAT_PREPARE_RAM = getSound("entity.goat.prepare_ram"); + Sound ENTITY_GOAT_RAM_IMPACT = getSound("entity.goat.ram_impact"); + Sound ENTITY_GOAT_SCREAMING_AMBIENT = getSound("entity.goat.screaming.ambient"); + Sound ENTITY_GOAT_SCREAMING_DEATH = getSound("entity.goat.screaming.death"); + Sound ENTITY_GOAT_SCREAMING_EAT = getSound("entity.goat.screaming.eat"); + Sound ENTITY_GOAT_SCREAMING_HURT = getSound("entity.goat.screaming.hurt"); + Sound ENTITY_GOAT_SCREAMING_LONG_JUMP = getSound("entity.goat.screaming.long_jump"); + Sound ENTITY_GOAT_SCREAMING_MILK = getSound("entity.goat.screaming.milk"); + Sound ENTITY_GOAT_SCREAMING_PREPARE_RAM = getSound("entity.goat.screaming.prepare_ram"); + Sound ENTITY_GOAT_SCREAMING_RAM_IMPACT = getSound("entity.goat.screaming.ram_impact"); + Sound ENTITY_GOAT_STEP = getSound("entity.goat.step"); + Sound ENTITY_GUARDIAN_AMBIENT = getSound("entity.guardian.ambient"); + Sound ENTITY_GUARDIAN_AMBIENT_LAND = getSound("entity.guardian.ambient_land"); + Sound ENTITY_GUARDIAN_ATTACK = getSound("entity.guardian.attack"); + Sound ENTITY_GUARDIAN_DEATH = getSound("entity.guardian.death"); + Sound ENTITY_GUARDIAN_DEATH_LAND = getSound("entity.guardian.death_land"); + Sound ENTITY_GUARDIAN_FLOP = getSound("entity.guardian.flop"); + Sound ENTITY_GUARDIAN_HURT = getSound("entity.guardian.hurt"); + Sound ENTITY_GUARDIAN_HURT_LAND = getSound("entity.guardian.hurt_land"); + Sound ENTITY_HOGLIN_AMBIENT = getSound("entity.hoglin.ambient"); + Sound ENTITY_HOGLIN_ANGRY = getSound("entity.hoglin.angry"); + Sound ENTITY_HOGLIN_ATTACK = getSound("entity.hoglin.attack"); + Sound ENTITY_HOGLIN_CONVERTED_TO_ZOMBIFIED = getSound("entity.hoglin.converted_to_zombified"); + Sound ENTITY_HOGLIN_DEATH = getSound("entity.hoglin.death"); + Sound ENTITY_HOGLIN_HURT = getSound("entity.hoglin.hurt"); + Sound ENTITY_HOGLIN_RETREAT = getSound("entity.hoglin.retreat"); + Sound ENTITY_HOGLIN_STEP = getSound("entity.hoglin.step"); + Sound ENTITY_HORSE_AMBIENT = getSound("entity.horse.ambient"); + Sound ENTITY_HORSE_ANGRY = getSound("entity.horse.angry"); + Sound ENTITY_HORSE_ARMOR = getSound("entity.horse.armor"); + Sound ENTITY_HORSE_BREATHE = getSound("entity.horse.breathe"); + Sound ENTITY_HORSE_DEATH = getSound("entity.horse.death"); + Sound ENTITY_HORSE_EAT = getSound("entity.horse.eat"); + Sound ENTITY_HORSE_GALLOP = getSound("entity.horse.gallop"); + Sound ENTITY_HORSE_HURT = getSound("entity.horse.hurt"); + Sound ENTITY_HORSE_JUMP = getSound("entity.horse.jump"); + Sound ENTITY_HORSE_LAND = getSound("entity.horse.land"); + Sound ENTITY_HORSE_SADDLE = getSound("entity.horse.saddle"); + Sound ENTITY_HORSE_STEP = getSound("entity.horse.step"); + Sound ENTITY_HORSE_STEP_WOOD = getSound("entity.horse.step_wood"); + Sound ENTITY_HOSTILE_BIG_FALL = getSound("entity.hostile.big_fall"); + Sound ENTITY_HOSTILE_DEATH = getSound("entity.hostile.death"); + Sound ENTITY_HOSTILE_HURT = getSound("entity.hostile.hurt"); + Sound ENTITY_HOSTILE_SMALL_FALL = getSound("entity.hostile.small_fall"); + Sound ENTITY_HOSTILE_SPLASH = getSound("entity.hostile.splash"); + Sound ENTITY_HOSTILE_SWIM = getSound("entity.hostile.swim"); + Sound ENTITY_HUSK_AMBIENT = getSound("entity.husk.ambient"); + Sound ENTITY_HUSK_CONVERTED_TO_ZOMBIE = getSound("entity.husk.converted_to_zombie"); + Sound ENTITY_HUSK_DEATH = getSound("entity.husk.death"); + Sound ENTITY_HUSK_HURT = getSound("entity.husk.hurt"); + Sound ENTITY_HUSK_STEP = getSound("entity.husk.step"); + Sound ENTITY_ILLUSIONER_AMBIENT = getSound("entity.illusioner.ambient"); + Sound ENTITY_ILLUSIONER_CAST_SPELL = getSound("entity.illusioner.cast_spell"); + Sound ENTITY_ILLUSIONER_DEATH = getSound("entity.illusioner.death"); + Sound ENTITY_ILLUSIONER_HURT = getSound("entity.illusioner.hurt"); + Sound ENTITY_ILLUSIONER_MIRROR_MOVE = getSound("entity.illusioner.mirror_move"); + Sound ENTITY_ILLUSIONER_PREPARE_BLINDNESS = getSound("entity.illusioner.prepare_blindness"); + Sound ENTITY_ILLUSIONER_PREPARE_MIRROR = getSound("entity.illusioner.prepare_mirror"); + Sound ENTITY_IRON_GOLEM_ATTACK = getSound("entity.iron_golem.attack"); + Sound ENTITY_IRON_GOLEM_DAMAGE = getSound("entity.iron_golem.damage"); + Sound ENTITY_IRON_GOLEM_DEATH = getSound("entity.iron_golem.death"); + Sound ENTITY_IRON_GOLEM_HURT = getSound("entity.iron_golem.hurt"); + Sound ENTITY_IRON_GOLEM_REPAIR = getSound("entity.iron_golem.repair"); + Sound ENTITY_IRON_GOLEM_STEP = getSound("entity.iron_golem.step"); + Sound ENTITY_ITEM_BREAK = getSound("entity.item.break"); - Sound ENTITY_ITEM_FRAME_ADD_ITEM = getSound("entity.item_frame.add_item"); - Sound ENTITY_ITEM_FRAME_BREAK = getSound("entity.item_frame.break"); - Sound ENTITY_ITEM_FRAME_PLACE = getSound("entity.item_frame.place"); - Sound ENTITY_ITEM_FRAME_REMOVE_ITEM = getSound("entity.item_frame.remove_item"); - Sound ENTITY_ITEM_FRAME_ROTATE_ITEM = getSound("entity.item_frame.rotate_item"); + Sound ENTITY_ITEM_PICKUP = getSound("entity.item.pickup"); + + Sound ENTITY_ITEM_FRAME_ADD_ITEM = getSound("entity.item_frame.add_item"); + + Sound ENTITY_ITEM_FRAME_BREAK = getSound("entity.item_frame.break"); + + Sound ENTITY_ITEM_FRAME_PLACE = getSound("entity.item_frame.place"); + + Sound ENTITY_ITEM_FRAME_REMOVE_ITEM = getSound("entity.item_frame.remove_item"); + + Sound ENTITY_ITEM_FRAME_ROTATE_ITEM = getSound("entity.item_frame.rotate_item"); + Sound ENTITY_LEASH_KNOT_BREAK = getSound("entity.leash_knot.break"); + Sound ENTITY_LEASH_KNOT_PLACE = getSound("entity.leash_knot.place"); + Sound ENTITY_LIGHTNING_BOLT_IMPACT = getSound("entity.lightning_bolt.impact"); + Sound ENTITY_LIGHTNING_BOLT_THUNDER = getSound("entity.lightning_bolt.thunder"); + Sound ENTITY_LINGERING_POTION_THROW = getSound("entity.lingering_potion.throw"); + Sound ENTITY_LLAMA_AMBIENT = getSound("entity.llama.ambient"); + Sound ENTITY_LLAMA_ANGRY = getSound("entity.llama.angry"); + Sound ENTITY_LLAMA_CHEST = getSound("entity.llama.chest"); + Sound ENTITY_LLAMA_DEATH = getSound("entity.llama.death"); + Sound ENTITY_LLAMA_EAT = getSound("entity.llama.eat"); + Sound ENTITY_LLAMA_HURT = getSound("entity.llama.hurt"); + Sound ENTITY_LLAMA_SPIT = getSound("entity.llama.spit"); + Sound ENTITY_LLAMA_STEP = getSound("entity.llama.step"); + Sound ENTITY_LLAMA_SWAG = getSound("entity.llama.swag"); + Sound ENTITY_MAGMA_CUBE_DEATH = getSound("entity.magma_cube.death"); + Sound ENTITY_MAGMA_CUBE_DEATH_SMALL = getSound("entity.magma_cube.death_small"); + Sound ENTITY_MAGMA_CUBE_HURT = getSound("entity.magma_cube.hurt"); + Sound ENTITY_MAGMA_CUBE_HURT_SMALL = getSound("entity.magma_cube.hurt_small"); + Sound ENTITY_MAGMA_CUBE_JUMP = getSound("entity.magma_cube.jump"); + Sound ENTITY_MAGMA_CUBE_SQUISH = getSound("entity.magma_cube.squish"); + Sound ENTITY_MAGMA_CUBE_SQUISH_SMALL = getSound("entity.magma_cube.squish_small"); + Sound ENTITY_MINECART_INSIDE = getSound("entity.minecart.inside"); + Sound ENTITY_MINECART_INSIDE_UNDERWATER = getSound("entity.minecart.inside.underwater"); + Sound ENTITY_MINECART_RIDING = getSound("entity.minecart.riding"); + Sound ENTITY_MOOSHROOM_CONVERT = getSound("entity.mooshroom.convert"); + Sound ENTITY_MOOSHROOM_EAT = getSound("entity.mooshroom.eat"); + Sound ENTITY_MOOSHROOM_MILK = getSound("entity.mooshroom.milk"); + Sound ENTITY_MOOSHROOM_SHEAR = getSound("entity.mooshroom.shear"); + Sound ENTITY_MOOSHROOM_SUSPICIOUS_MILK = getSound("entity.mooshroom.suspicious_milk"); + Sound ENTITY_MULE_AMBIENT = getSound("entity.mule.ambient"); + Sound ENTITY_MULE_ANGRY = getSound("entity.mule.angry"); + Sound ENTITY_MULE_CHEST = getSound("entity.mule.chest"); + Sound ENTITY_MULE_DEATH = getSound("entity.mule.death"); + Sound ENTITY_MULE_EAT = getSound("entity.mule.eat"); + Sound ENTITY_MULE_HURT = getSound("entity.mule.hurt"); + Sound ENTITY_MULE_JUMP = getSound("entity.mule.jump"); + Sound ENTITY_OCELOT_AMBIENT = getSound("entity.ocelot.ambient"); + Sound ENTITY_OCELOT_DEATH = getSound("entity.ocelot.death"); + Sound ENTITY_OCELOT_HURT = getSound("entity.ocelot.hurt"); + Sound ENTITY_PAINTING_BREAK = getSound("entity.painting.break"); + Sound ENTITY_PAINTING_PLACE = getSound("entity.painting.place"); + Sound ENTITY_PANDA_AGGRESSIVE_AMBIENT = getSound("entity.panda.aggressive_ambient"); + Sound ENTITY_PANDA_AMBIENT = getSound("entity.panda.ambient"); + Sound ENTITY_PANDA_BITE = getSound("entity.panda.bite"); + Sound ENTITY_PANDA_CANT_BREED = getSound("entity.panda.cant_breed"); + Sound ENTITY_PANDA_DEATH = getSound("entity.panda.death"); + Sound ENTITY_PANDA_EAT = getSound("entity.panda.eat"); + Sound ENTITY_PANDA_HURT = getSound("entity.panda.hurt"); + Sound ENTITY_PANDA_PRE_SNEEZE = getSound("entity.panda.pre_sneeze"); + Sound ENTITY_PANDA_SNEEZE = getSound("entity.panda.sneeze"); + Sound ENTITY_PANDA_STEP = getSound("entity.panda.step"); + Sound ENTITY_PANDA_WORRIED_AMBIENT = getSound("entity.panda.worried_ambient"); + Sound ENTITY_PARROT_AMBIENT = getSound("entity.parrot.ambient"); + Sound ENTITY_PARROT_DEATH = getSound("entity.parrot.death"); + Sound ENTITY_PARROT_EAT = getSound("entity.parrot.eat"); + Sound ENTITY_PARROT_FLY = getSound("entity.parrot.fly"); + Sound ENTITY_PARROT_HURT = getSound("entity.parrot.hurt"); + Sound ENTITY_PARROT_IMITATE_BLAZE = getSound("entity.parrot.imitate.blaze"); + Sound ENTITY_PARROT_IMITATE_BOGGED = getSound("entity.parrot.imitate.bogged"); + Sound ENTITY_PARROT_IMITATE_BREEZE = getSound("entity.parrot.imitate.breeze"); + Sound ENTITY_PARROT_IMITATE_CREAKING = getSound("entity.parrot.imitate.creaking"); + Sound ENTITY_PARROT_IMITATE_CREEPER = getSound("entity.parrot.imitate.creeper"); + Sound ENTITY_PARROT_IMITATE_DROWNED = getSound("entity.parrot.imitate.drowned"); + Sound ENTITY_PARROT_IMITATE_ELDER_GUARDIAN = getSound("entity.parrot.imitate.elder_guardian"); - Sound ENTITY_PARROT_IMITATE_ENDERMITE = getSound("entity.parrot.imitate.endermite"); + Sound ENTITY_PARROT_IMITATE_ENDER_DRAGON = getSound("entity.parrot.imitate.ender_dragon"); + + Sound ENTITY_PARROT_IMITATE_ENDERMITE = getSound("entity.parrot.imitate.endermite"); + Sound ENTITY_PARROT_IMITATE_EVOKER = getSound("entity.parrot.imitate.evoker"); + Sound ENTITY_PARROT_IMITATE_GHAST = getSound("entity.parrot.imitate.ghast"); + Sound ENTITY_PARROT_IMITATE_GUARDIAN = getSound("entity.parrot.imitate.guardian"); + Sound ENTITY_PARROT_IMITATE_HOGLIN = getSound("entity.parrot.imitate.hoglin"); + Sound ENTITY_PARROT_IMITATE_HUSK = getSound("entity.parrot.imitate.husk"); + Sound ENTITY_PARROT_IMITATE_ILLUSIONER = getSound("entity.parrot.imitate.illusioner"); + Sound ENTITY_PARROT_IMITATE_MAGMA_CUBE = getSound("entity.parrot.imitate.magma_cube"); + Sound ENTITY_PARROT_IMITATE_PHANTOM = getSound("entity.parrot.imitate.phantom"); + Sound ENTITY_PARROT_IMITATE_PIGLIN = getSound("entity.parrot.imitate.piglin"); + Sound ENTITY_PARROT_IMITATE_PIGLIN_BRUTE = getSound("entity.parrot.imitate.piglin_brute"); + Sound ENTITY_PARROT_IMITATE_PILLAGER = getSound("entity.parrot.imitate.pillager"); + Sound ENTITY_PARROT_IMITATE_RAVAGER = getSound("entity.parrot.imitate.ravager"); + Sound ENTITY_PARROT_IMITATE_SHULKER = getSound("entity.parrot.imitate.shulker"); + Sound ENTITY_PARROT_IMITATE_SILVERFISH = getSound("entity.parrot.imitate.silverfish"); + Sound ENTITY_PARROT_IMITATE_SKELETON = getSound("entity.parrot.imitate.skeleton"); + Sound ENTITY_PARROT_IMITATE_SLIME = getSound("entity.parrot.imitate.slime"); + Sound ENTITY_PARROT_IMITATE_SPIDER = getSound("entity.parrot.imitate.spider"); + Sound ENTITY_PARROT_IMITATE_STRAY = getSound("entity.parrot.imitate.stray"); + Sound ENTITY_PARROT_IMITATE_VEX = getSound("entity.parrot.imitate.vex"); + Sound ENTITY_PARROT_IMITATE_VINDICATOR = getSound("entity.parrot.imitate.vindicator"); + Sound ENTITY_PARROT_IMITATE_WARDEN = getSound("entity.parrot.imitate.warden"); + Sound ENTITY_PARROT_IMITATE_WITCH = getSound("entity.parrot.imitate.witch"); + Sound ENTITY_PARROT_IMITATE_WITHER = getSound("entity.parrot.imitate.wither"); + Sound ENTITY_PARROT_IMITATE_WITHER_SKELETON = getSound("entity.parrot.imitate.wither_skeleton"); + Sound ENTITY_PARROT_IMITATE_ZOGLIN = getSound("entity.parrot.imitate.zoglin"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE = getSound("entity.parrot.imitate.zombie"); + Sound ENTITY_PARROT_IMITATE_ZOMBIE_VILLAGER = getSound("entity.parrot.imitate.zombie_villager"); + Sound ENTITY_PARROT_STEP = getSound("entity.parrot.step"); + Sound ENTITY_PHANTOM_AMBIENT = getSound("entity.phantom.ambient"); + Sound ENTITY_PHANTOM_BITE = getSound("entity.phantom.bite"); + Sound ENTITY_PHANTOM_DEATH = getSound("entity.phantom.death"); + Sound ENTITY_PHANTOM_FLAP = getSound("entity.phantom.flap"); + Sound ENTITY_PHANTOM_HURT = getSound("entity.phantom.hurt"); + Sound ENTITY_PHANTOM_SWOOP = getSound("entity.phantom.swoop"); - Sound ENTITY_PIGLIN_ADMIRING_ITEM = getSound("entity.piglin.admiring_item"); - Sound ENTITY_PIGLIN_AMBIENT = getSound("entity.piglin.ambient"); - Sound ENTITY_PIGLIN_ANGRY = getSound("entity.piglin.angry"); - Sound ENTITY_PIGLIN_BRUTE_AMBIENT = getSound("entity.piglin_brute.ambient"); - Sound ENTITY_PIGLIN_BRUTE_ANGRY = getSound("entity.piglin_brute.angry"); - Sound ENTITY_PIGLIN_BRUTE_CONVERTED_TO_ZOMBIFIED = getSound("entity.piglin_brute.converted_to_zombified"); - Sound ENTITY_PIGLIN_BRUTE_DEATH = getSound("entity.piglin_brute.death"); - Sound ENTITY_PIGLIN_BRUTE_HURT = getSound("entity.piglin_brute.hurt"); - Sound ENTITY_PIGLIN_BRUTE_STEP = getSound("entity.piglin_brute.step"); - Sound ENTITY_PIGLIN_CELEBRATE = getSound("entity.piglin.celebrate"); - Sound ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED = getSound("entity.piglin.converted_to_zombified"); - Sound ENTITY_PIGLIN_DEATH = getSound("entity.piglin.death"); - Sound ENTITY_PIGLIN_HURT = getSound("entity.piglin.hurt"); - Sound ENTITY_PIGLIN_JEALOUS = getSound("entity.piglin.jealous"); - Sound ENTITY_PIGLIN_RETREAT = getSound("entity.piglin.retreat"); - Sound ENTITY_PIGLIN_STEP = getSound("entity.piglin.step"); + Sound ENTITY_PIG_AMBIENT = getSound("entity.pig.ambient"); + Sound ENTITY_PIG_DEATH = getSound("entity.pig.death"); + Sound ENTITY_PIG_HURT = getSound("entity.pig.hurt"); + Sound ENTITY_PIG_SADDLE = getSound("entity.pig.saddle"); + Sound ENTITY_PIG_STEP = getSound("entity.pig.step"); + + Sound ENTITY_PIGLIN_ADMIRING_ITEM = getSound("entity.piglin.admiring_item"); + + Sound ENTITY_PIGLIN_AMBIENT = getSound("entity.piglin.ambient"); + + Sound ENTITY_PIGLIN_ANGRY = getSound("entity.piglin.angry"); + + Sound ENTITY_PIGLIN_CELEBRATE = getSound("entity.piglin.celebrate"); + + Sound ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED = getSound("entity.piglin.converted_to_zombified"); + + Sound ENTITY_PIGLIN_DEATH = getSound("entity.piglin.death"); + + Sound ENTITY_PIGLIN_HURT = getSound("entity.piglin.hurt"); + + Sound ENTITY_PIGLIN_JEALOUS = getSound("entity.piglin.jealous"); + + Sound ENTITY_PIGLIN_RETREAT = getSound("entity.piglin.retreat"); + + Sound ENTITY_PIGLIN_STEP = getSound("entity.piglin.step"); + + Sound ENTITY_PIGLIN_BRUTE_AMBIENT = getSound("entity.piglin_brute.ambient"); + + Sound ENTITY_PIGLIN_BRUTE_ANGRY = getSound("entity.piglin_brute.angry"); + + Sound ENTITY_PIGLIN_BRUTE_CONVERTED_TO_ZOMBIFIED = getSound("entity.piglin_brute.converted_to_zombified"); + + Sound ENTITY_PIGLIN_BRUTE_DEATH = getSound("entity.piglin_brute.death"); + + Sound ENTITY_PIGLIN_BRUTE_HURT = getSound("entity.piglin_brute.hurt"); + + Sound ENTITY_PIGLIN_BRUTE_STEP = getSound("entity.piglin_brute.step"); + Sound ENTITY_PILLAGER_AMBIENT = getSound("entity.pillager.ambient"); + Sound ENTITY_PILLAGER_CELEBRATE = getSound("entity.pillager.celebrate"); + Sound ENTITY_PILLAGER_DEATH = getSound("entity.pillager.death"); + Sound ENTITY_PILLAGER_HURT = getSound("entity.pillager.hurt"); + Sound ENTITY_PLAYER_ATTACK_CRIT = getSound("entity.player.attack.crit"); + Sound ENTITY_PLAYER_ATTACK_KNOCKBACK = getSound("entity.player.attack.knockback"); + Sound ENTITY_PLAYER_ATTACK_NODAMAGE = getSound("entity.player.attack.nodamage"); + Sound ENTITY_PLAYER_ATTACK_STRONG = getSound("entity.player.attack.strong"); + Sound ENTITY_PLAYER_ATTACK_SWEEP = getSound("entity.player.attack.sweep"); + Sound ENTITY_PLAYER_ATTACK_WEAK = getSound("entity.player.attack.weak"); + Sound ENTITY_PLAYER_BIG_FALL = getSound("entity.player.big_fall"); + Sound ENTITY_PLAYER_BREATH = getSound("entity.player.breath"); + Sound ENTITY_PLAYER_BURP = getSound("entity.player.burp"); + Sound ENTITY_PLAYER_DEATH = getSound("entity.player.death"); + Sound ENTITY_PLAYER_HURT = getSound("entity.player.hurt"); + Sound ENTITY_PLAYER_HURT_DROWN = getSound("entity.player.hurt_drown"); + Sound ENTITY_PLAYER_HURT_FREEZE = getSound("entity.player.hurt_freeze"); + Sound ENTITY_PLAYER_HURT_ON_FIRE = getSound("entity.player.hurt_on_fire"); + Sound ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH = getSound("entity.player.hurt_sweet_berry_bush"); + Sound ENTITY_PLAYER_LEVELUP = getSound("entity.player.levelup"); + Sound ENTITY_PLAYER_SMALL_FALL = getSound("entity.player.small_fall"); + Sound ENTITY_PLAYER_SPLASH = getSound("entity.player.splash"); + Sound ENTITY_PLAYER_SPLASH_HIGH_SPEED = getSound("entity.player.splash.high_speed"); + Sound ENTITY_PLAYER_SWIM = getSound("entity.player.swim"); + Sound ENTITY_PLAYER_TELEPORT = getSound("entity.player.teleport"); + Sound ENTITY_POLAR_BEAR_AMBIENT = getSound("entity.polar_bear.ambient"); + Sound ENTITY_POLAR_BEAR_AMBIENT_BABY = getSound("entity.polar_bear.ambient_baby"); + Sound ENTITY_POLAR_BEAR_DEATH = getSound("entity.polar_bear.death"); + Sound ENTITY_POLAR_BEAR_HURT = getSound("entity.polar_bear.hurt"); + Sound ENTITY_POLAR_BEAR_STEP = getSound("entity.polar_bear.step"); + Sound ENTITY_POLAR_BEAR_WARNING = getSound("entity.polar_bear.warning"); + Sound ENTITY_PUFFER_FISH_AMBIENT = getSound("entity.puffer_fish.ambient"); + Sound ENTITY_PUFFER_FISH_BLOW_OUT = getSound("entity.puffer_fish.blow_out"); + Sound ENTITY_PUFFER_FISH_BLOW_UP = getSound("entity.puffer_fish.blow_up"); + Sound ENTITY_PUFFER_FISH_DEATH = getSound("entity.puffer_fish.death"); + Sound ENTITY_PUFFER_FISH_FLOP = getSound("entity.puffer_fish.flop"); + Sound ENTITY_PUFFER_FISH_HURT = getSound("entity.puffer_fish.hurt"); + Sound ENTITY_PUFFER_FISH_STING = getSound("entity.puffer_fish.sting"); + Sound ENTITY_RABBIT_AMBIENT = getSound("entity.rabbit.ambient"); + Sound ENTITY_RABBIT_ATTACK = getSound("entity.rabbit.attack"); + Sound ENTITY_RABBIT_DEATH = getSound("entity.rabbit.death"); + Sound ENTITY_RABBIT_HURT = getSound("entity.rabbit.hurt"); + Sound ENTITY_RABBIT_JUMP = getSound("entity.rabbit.jump"); + Sound ENTITY_RAVAGER_AMBIENT = getSound("entity.ravager.ambient"); + Sound ENTITY_RAVAGER_ATTACK = getSound("entity.ravager.attack"); + Sound ENTITY_RAVAGER_CELEBRATE = getSound("entity.ravager.celebrate"); + Sound ENTITY_RAVAGER_DEATH = getSound("entity.ravager.death"); + Sound ENTITY_RAVAGER_HURT = getSound("entity.ravager.hurt"); + Sound ENTITY_RAVAGER_ROAR = getSound("entity.ravager.roar"); + Sound ENTITY_RAVAGER_STEP = getSound("entity.ravager.step"); + Sound ENTITY_RAVAGER_STUNNED = getSound("entity.ravager.stunned"); + Sound ENTITY_SALMON_AMBIENT = getSound("entity.salmon.ambient"); + Sound ENTITY_SALMON_DEATH = getSound("entity.salmon.death"); + Sound ENTITY_SALMON_FLOP = getSound("entity.salmon.flop"); + Sound ENTITY_SALMON_HURT = getSound("entity.salmon.hurt"); + Sound ENTITY_SHEEP_AMBIENT = getSound("entity.sheep.ambient"); + Sound ENTITY_SHEEP_DEATH = getSound("entity.sheep.death"); + Sound ENTITY_SHEEP_HURT = getSound("entity.sheep.hurt"); + Sound ENTITY_SHEEP_SHEAR = getSound("entity.sheep.shear"); + Sound ENTITY_SHEEP_STEP = getSound("entity.sheep.step"); + Sound ENTITY_SHULKER_AMBIENT = getSound("entity.shulker.ambient"); - Sound ENTITY_SHULKER_BULLET_HIT = getSound("entity.shulker_bullet.hit"); - Sound ENTITY_SHULKER_BULLET_HURT = getSound("entity.shulker_bullet.hurt"); + Sound ENTITY_SHULKER_CLOSE = getSound("entity.shulker.close"); + Sound ENTITY_SHULKER_DEATH = getSound("entity.shulker.death"); + Sound ENTITY_SHULKER_HURT = getSound("entity.shulker.hurt"); + Sound ENTITY_SHULKER_HURT_CLOSED = getSound("entity.shulker.hurt_closed"); + Sound ENTITY_SHULKER_OPEN = getSound("entity.shulker.open"); + Sound ENTITY_SHULKER_SHOOT = getSound("entity.shulker.shoot"); + Sound ENTITY_SHULKER_TELEPORT = getSound("entity.shulker.teleport"); + + Sound ENTITY_SHULKER_BULLET_HIT = getSound("entity.shulker_bullet.hit"); + + Sound ENTITY_SHULKER_BULLET_HURT = getSound("entity.shulker_bullet.hurt"); + Sound ENTITY_SILVERFISH_AMBIENT = getSound("entity.silverfish.ambient"); + Sound ENTITY_SILVERFISH_DEATH = getSound("entity.silverfish.death"); + Sound ENTITY_SILVERFISH_HURT = getSound("entity.silverfish.hurt"); + Sound ENTITY_SILVERFISH_STEP = getSound("entity.silverfish.step"); + Sound ENTITY_SKELETON_AMBIENT = getSound("entity.skeleton.ambient"); + Sound ENTITY_SKELETON_CONVERTED_TO_STRAY = getSound("entity.skeleton.converted_to_stray"); + Sound ENTITY_SKELETON_DEATH = getSound("entity.skeleton.death"); - Sound ENTITY_SKELETON_HORSE_AMBIENT = getSound("entity.skeleton_horse.ambient"); - Sound ENTITY_SKELETON_HORSE_AMBIENT_WATER = getSound("entity.skeleton_horse.ambient_water"); - Sound ENTITY_SKELETON_HORSE_DEATH = getSound("entity.skeleton_horse.death"); - Sound ENTITY_SKELETON_HORSE_GALLOP_WATER = getSound("entity.skeleton_horse.gallop_water"); - Sound ENTITY_SKELETON_HORSE_HURT = getSound("entity.skeleton_horse.hurt"); - Sound ENTITY_SKELETON_HORSE_JUMP_WATER = getSound("entity.skeleton_horse.jump_water"); - Sound ENTITY_SKELETON_HORSE_STEP_WATER = getSound("entity.skeleton_horse.step_water"); - Sound ENTITY_SKELETON_HORSE_SWIM = getSound("entity.skeleton_horse.swim"); + Sound ENTITY_SKELETON_HURT = getSound("entity.skeleton.hurt"); + Sound ENTITY_SKELETON_SHOOT = getSound("entity.skeleton.shoot"); + Sound ENTITY_SKELETON_STEP = getSound("entity.skeleton.step"); + + Sound ENTITY_SKELETON_HORSE_AMBIENT = getSound("entity.skeleton_horse.ambient"); + + Sound ENTITY_SKELETON_HORSE_AMBIENT_WATER = getSound("entity.skeleton_horse.ambient_water"); + + Sound ENTITY_SKELETON_HORSE_DEATH = getSound("entity.skeleton_horse.death"); + + Sound ENTITY_SKELETON_HORSE_GALLOP_WATER = getSound("entity.skeleton_horse.gallop_water"); + + Sound ENTITY_SKELETON_HORSE_HURT = getSound("entity.skeleton_horse.hurt"); + + Sound ENTITY_SKELETON_HORSE_JUMP_WATER = getSound("entity.skeleton_horse.jump_water"); + + Sound ENTITY_SKELETON_HORSE_STEP_WATER = getSound("entity.skeleton_horse.step_water"); + + Sound ENTITY_SKELETON_HORSE_SWIM = getSound("entity.skeleton_horse.swim"); + Sound ENTITY_SLIME_ATTACK = getSound("entity.slime.attack"); + Sound ENTITY_SLIME_DEATH = getSound("entity.slime.death"); + Sound ENTITY_SLIME_DEATH_SMALL = getSound("entity.slime.death_small"); + Sound ENTITY_SLIME_HURT = getSound("entity.slime.hurt"); + Sound ENTITY_SLIME_HURT_SMALL = getSound("entity.slime.hurt_small"); + Sound ENTITY_SLIME_JUMP = getSound("entity.slime.jump"); + Sound ENTITY_SLIME_JUMP_SMALL = getSound("entity.slime.jump_small"); + Sound ENTITY_SLIME_SQUISH = getSound("entity.slime.squish"); + Sound ENTITY_SLIME_SQUISH_SMALL = getSound("entity.slime.squish_small"); + Sound ENTITY_SNIFFER_DEATH = getSound("entity.sniffer.death"); + Sound ENTITY_SNIFFER_DIGGING = getSound("entity.sniffer.digging"); + Sound ENTITY_SNIFFER_DIGGING_STOP = getSound("entity.sniffer.digging_stop"); + Sound ENTITY_SNIFFER_DROP_SEED = getSound("entity.sniffer.drop_seed"); + Sound ENTITY_SNIFFER_EAT = getSound("entity.sniffer.eat"); + Sound ENTITY_SNIFFER_HAPPY = getSound("entity.sniffer.happy"); + Sound ENTITY_SNIFFER_HURT = getSound("entity.sniffer.hurt"); + Sound ENTITY_SNIFFER_IDLE = getSound("entity.sniffer.idle"); + Sound ENTITY_SNIFFER_SCENTING = getSound("entity.sniffer.scenting"); + Sound ENTITY_SNIFFER_SEARCHING = getSound("entity.sniffer.searching"); + Sound ENTITY_SNIFFER_SNIFFING = getSound("entity.sniffer.sniffing"); + Sound ENTITY_SNIFFER_STEP = getSound("entity.sniffer.step"); - Sound ENTITY_SNOWBALL_THROW = getSound("entity.snowball.throw"); + Sound ENTITY_SNOW_GOLEM_AMBIENT = getSound("entity.snow_golem.ambient"); + Sound ENTITY_SNOW_GOLEM_DEATH = getSound("entity.snow_golem.death"); + Sound ENTITY_SNOW_GOLEM_HURT = getSound("entity.snow_golem.hurt"); + Sound ENTITY_SNOW_GOLEM_SHEAR = getSound("entity.snow_golem.shear"); + Sound ENTITY_SNOW_GOLEM_SHOOT = getSound("entity.snow_golem.shoot"); + + Sound ENTITY_SNOWBALL_THROW = getSound("entity.snowball.throw"); + Sound ENTITY_SPIDER_AMBIENT = getSound("entity.spider.ambient"); + Sound ENTITY_SPIDER_DEATH = getSound("entity.spider.death"); + Sound ENTITY_SPIDER_HURT = getSound("entity.spider.hurt"); + Sound ENTITY_SPIDER_STEP = getSound("entity.spider.step"); + Sound ENTITY_SPLASH_POTION_BREAK = getSound("entity.splash_potion.break"); + Sound ENTITY_SPLASH_POTION_THROW = getSound("entity.splash_potion.throw"); + Sound ENTITY_SQUID_AMBIENT = getSound("entity.squid.ambient"); + Sound ENTITY_SQUID_DEATH = getSound("entity.squid.death"); + Sound ENTITY_SQUID_HURT = getSound("entity.squid.hurt"); + Sound ENTITY_SQUID_SQUIRT = getSound("entity.squid.squirt"); + Sound ENTITY_STRAY_AMBIENT = getSound("entity.stray.ambient"); + Sound ENTITY_STRAY_DEATH = getSound("entity.stray.death"); + Sound ENTITY_STRAY_HURT = getSound("entity.stray.hurt"); + Sound ENTITY_STRAY_STEP = getSound("entity.stray.step"); + Sound ENTITY_STRIDER_AMBIENT = getSound("entity.strider.ambient"); + Sound ENTITY_STRIDER_DEATH = getSound("entity.strider.death"); + Sound ENTITY_STRIDER_EAT = getSound("entity.strider.eat"); + Sound ENTITY_STRIDER_HAPPY = getSound("entity.strider.happy"); + Sound ENTITY_STRIDER_HURT = getSound("entity.strider.hurt"); + Sound ENTITY_STRIDER_RETREAT = getSound("entity.strider.retreat"); + Sound ENTITY_STRIDER_SADDLE = getSound("entity.strider.saddle"); + Sound ENTITY_STRIDER_STEP = getSound("entity.strider.step"); + Sound ENTITY_STRIDER_STEP_LAVA = getSound("entity.strider.step_lava"); + Sound ENTITY_TADPOLE_DEATH = getSound("entity.tadpole.death"); + Sound ENTITY_TADPOLE_FLOP = getSound("entity.tadpole.flop"); + Sound ENTITY_TADPOLE_GROW_UP = getSound("entity.tadpole.grow_up"); + Sound ENTITY_TADPOLE_HURT = getSound("entity.tadpole.hurt"); + Sound ENTITY_TNT_PRIMED = getSound("entity.tnt.primed"); + Sound ENTITY_TROPICAL_FISH_AMBIENT = getSound("entity.tropical_fish.ambient"); + Sound ENTITY_TROPICAL_FISH_DEATH = getSound("entity.tropical_fish.death"); + Sound ENTITY_TROPICAL_FISH_FLOP = getSound("entity.tropical_fish.flop"); + Sound ENTITY_TROPICAL_FISH_HURT = getSound("entity.tropical_fish.hurt"); + Sound ENTITY_TURTLE_AMBIENT_LAND = getSound("entity.turtle.ambient_land"); + Sound ENTITY_TURTLE_DEATH = getSound("entity.turtle.death"); + Sound ENTITY_TURTLE_DEATH_BABY = getSound("entity.turtle.death_baby"); + Sound ENTITY_TURTLE_EGG_BREAK = getSound("entity.turtle.egg_break"); + Sound ENTITY_TURTLE_EGG_CRACK = getSound("entity.turtle.egg_crack"); + Sound ENTITY_TURTLE_EGG_HATCH = getSound("entity.turtle.egg_hatch"); + Sound ENTITY_TURTLE_HURT = getSound("entity.turtle.hurt"); + Sound ENTITY_TURTLE_HURT_BABY = getSound("entity.turtle.hurt_baby"); + Sound ENTITY_TURTLE_LAY_EGG = getSound("entity.turtle.lay_egg"); + Sound ENTITY_TURTLE_SHAMBLE = getSound("entity.turtle.shamble"); + Sound ENTITY_TURTLE_SHAMBLE_BABY = getSound("entity.turtle.shamble_baby"); + Sound ENTITY_TURTLE_SWIM = getSound("entity.turtle.swim"); + Sound ENTITY_VEX_AMBIENT = getSound("entity.vex.ambient"); + Sound ENTITY_VEX_CHARGE = getSound("entity.vex.charge"); + Sound ENTITY_VEX_DEATH = getSound("entity.vex.death"); + Sound ENTITY_VEX_HURT = getSound("entity.vex.hurt"); + Sound ENTITY_VILLAGER_AMBIENT = getSound("entity.villager.ambient"); + Sound ENTITY_VILLAGER_CELEBRATE = getSound("entity.villager.celebrate"); + Sound ENTITY_VILLAGER_DEATH = getSound("entity.villager.death"); + Sound ENTITY_VILLAGER_HURT = getSound("entity.villager.hurt"); + Sound ENTITY_VILLAGER_NO = getSound("entity.villager.no"); + Sound ENTITY_VILLAGER_TRADE = getSound("entity.villager.trade"); + Sound ENTITY_VILLAGER_WORK_ARMORER = getSound("entity.villager.work_armorer"); + Sound ENTITY_VILLAGER_WORK_BUTCHER = getSound("entity.villager.work_butcher"); + Sound ENTITY_VILLAGER_WORK_CARTOGRAPHER = getSound("entity.villager.work_cartographer"); + Sound ENTITY_VILLAGER_WORK_CLERIC = getSound("entity.villager.work_cleric"); + Sound ENTITY_VILLAGER_WORK_FARMER = getSound("entity.villager.work_farmer"); + Sound ENTITY_VILLAGER_WORK_FISHERMAN = getSound("entity.villager.work_fisherman"); + Sound ENTITY_VILLAGER_WORK_FLETCHER = getSound("entity.villager.work_fletcher"); + Sound ENTITY_VILLAGER_WORK_LEATHERWORKER = getSound("entity.villager.work_leatherworker"); + Sound ENTITY_VILLAGER_WORK_LIBRARIAN = getSound("entity.villager.work_librarian"); + Sound ENTITY_VILLAGER_WORK_MASON = getSound("entity.villager.work_mason"); + Sound ENTITY_VILLAGER_WORK_SHEPHERD = getSound("entity.villager.work_shepherd"); + Sound ENTITY_VILLAGER_WORK_TOOLSMITH = getSound("entity.villager.work_toolsmith"); + Sound ENTITY_VILLAGER_WORK_WEAPONSMITH = getSound("entity.villager.work_weaponsmith"); + Sound ENTITY_VILLAGER_YES = getSound("entity.villager.yes"); + Sound ENTITY_VINDICATOR_AMBIENT = getSound("entity.vindicator.ambient"); + Sound ENTITY_VINDICATOR_CELEBRATE = getSound("entity.vindicator.celebrate"); + Sound ENTITY_VINDICATOR_DEATH = getSound("entity.vindicator.death"); + Sound ENTITY_VINDICATOR_HURT = getSound("entity.vindicator.hurt"); + Sound ENTITY_WANDERING_TRADER_AMBIENT = getSound("entity.wandering_trader.ambient"); + Sound ENTITY_WANDERING_TRADER_DEATH = getSound("entity.wandering_trader.death"); + Sound ENTITY_WANDERING_TRADER_DISAPPEARED = getSound("entity.wandering_trader.disappeared"); + Sound ENTITY_WANDERING_TRADER_DRINK_MILK = getSound("entity.wandering_trader.drink_milk"); + Sound ENTITY_WANDERING_TRADER_DRINK_POTION = getSound("entity.wandering_trader.drink_potion"); + Sound ENTITY_WANDERING_TRADER_HURT = getSound("entity.wandering_trader.hurt"); + Sound ENTITY_WANDERING_TRADER_NO = getSound("entity.wandering_trader.no"); + Sound ENTITY_WANDERING_TRADER_REAPPEARED = getSound("entity.wandering_trader.reappeared"); + Sound ENTITY_WANDERING_TRADER_TRADE = getSound("entity.wandering_trader.trade"); + Sound ENTITY_WANDERING_TRADER_YES = getSound("entity.wandering_trader.yes"); + Sound ENTITY_WARDEN_AGITATED = getSound("entity.warden.agitated"); + Sound ENTITY_WARDEN_AMBIENT = getSound("entity.warden.ambient"); + Sound ENTITY_WARDEN_ANGRY = getSound("entity.warden.angry"); + Sound ENTITY_WARDEN_ATTACK_IMPACT = getSound("entity.warden.attack_impact"); + Sound ENTITY_WARDEN_DEATH = getSound("entity.warden.death"); + Sound ENTITY_WARDEN_DIG = getSound("entity.warden.dig"); + Sound ENTITY_WARDEN_EMERGE = getSound("entity.warden.emerge"); + Sound ENTITY_WARDEN_HEARTBEAT = getSound("entity.warden.heartbeat"); + Sound ENTITY_WARDEN_HURT = getSound("entity.warden.hurt"); + Sound ENTITY_WARDEN_LISTENING = getSound("entity.warden.listening"); + Sound ENTITY_WARDEN_LISTENING_ANGRY = getSound("entity.warden.listening_angry"); + Sound ENTITY_WARDEN_NEARBY_CLOSE = getSound("entity.warden.nearby_close"); + Sound ENTITY_WARDEN_NEARBY_CLOSER = getSound("entity.warden.nearby_closer"); + Sound ENTITY_WARDEN_NEARBY_CLOSEST = getSound("entity.warden.nearby_closest"); + Sound ENTITY_WARDEN_ROAR = getSound("entity.warden.roar"); + Sound ENTITY_WARDEN_SNIFF = getSound("entity.warden.sniff"); + Sound ENTITY_WARDEN_SONIC_BOOM = getSound("entity.warden.sonic_boom"); + Sound ENTITY_WARDEN_SONIC_CHARGE = getSound("entity.warden.sonic_charge"); + Sound ENTITY_WARDEN_STEP = getSound("entity.warden.step"); + Sound ENTITY_WARDEN_TENDRIL_CLICKS = getSound("entity.warden.tendril_clicks"); + Sound ENTITY_WIND_CHARGE_THROW = getSound("entity.wind_charge.throw"); + Sound ENTITY_WIND_CHARGE_WIND_BURST = getSound("entity.wind_charge.wind_burst"); + Sound ENTITY_WITCH_AMBIENT = getSound("entity.witch.ambient"); + Sound ENTITY_WITCH_CELEBRATE = getSound("entity.witch.celebrate"); + Sound ENTITY_WITCH_DEATH = getSound("entity.witch.death"); + Sound ENTITY_WITCH_DRINK = getSound("entity.witch.drink"); + Sound ENTITY_WITCH_HURT = getSound("entity.witch.hurt"); + Sound ENTITY_WITCH_THROW = getSound("entity.witch.throw"); + Sound ENTITY_WITHER_AMBIENT = getSound("entity.wither.ambient"); + Sound ENTITY_WITHER_BREAK_BLOCK = getSound("entity.wither.break_block"); + Sound ENTITY_WITHER_DEATH = getSound("entity.wither.death"); + Sound ENTITY_WITHER_HURT = getSound("entity.wither.hurt"); + Sound ENTITY_WITHER_SHOOT = getSound("entity.wither.shoot"); - Sound ENTITY_WITHER_SKELETON_AMBIENT = getSound("entity.wither_skeleton.ambient"); - Sound ENTITY_WITHER_SKELETON_DEATH = getSound("entity.wither_skeleton.death"); - Sound ENTITY_WITHER_SKELETON_HURT = getSound("entity.wither_skeleton.hurt"); - Sound ENTITY_WITHER_SKELETON_STEP = getSound("entity.wither_skeleton.step"); + Sound ENTITY_WITHER_SPAWN = getSound("entity.wither.spawn"); + + Sound ENTITY_WITHER_SKELETON_AMBIENT = getSound("entity.wither_skeleton.ambient"); + + Sound ENTITY_WITHER_SKELETON_DEATH = getSound("entity.wither_skeleton.death"); + + Sound ENTITY_WITHER_SKELETON_HURT = getSound("entity.wither_skeleton.hurt"); + + Sound ENTITY_WITHER_SKELETON_STEP = getSound("entity.wither_skeleton.step"); + Sound ENTITY_WOLF_AMBIENT = getSound("entity.wolf.ambient"); + Sound ENTITY_WOLF_DEATH = getSound("entity.wolf.death"); + Sound ENTITY_WOLF_GROWL = getSound("entity.wolf.growl"); - Sound ENTITY_WOLF_HOWL = getSound("entity.wolf.howl"); + Sound ENTITY_WOLF_HURT = getSound("entity.wolf.hurt"); + Sound ENTITY_WOLF_PANT = getSound("entity.wolf.pant"); + Sound ENTITY_WOLF_SHAKE = getSound("entity.wolf.shake"); + Sound ENTITY_WOLF_STEP = getSound("entity.wolf.step"); + Sound ENTITY_WOLF_WHINE = getSound("entity.wolf.whine"); + + Sound ENTITY_WOLF_ANGRY_AMBIENT = getSound("entity.wolf_angry.ambient"); + + Sound ENTITY_WOLF_ANGRY_DEATH = getSound("entity.wolf_angry.death"); + + Sound ENTITY_WOLF_ANGRY_GROWL = getSound("entity.wolf_angry.growl"); + + Sound ENTITY_WOLF_ANGRY_HURT = getSound("entity.wolf_angry.hurt"); + + Sound ENTITY_WOLF_ANGRY_PANT = getSound("entity.wolf_angry.pant"); + + Sound ENTITY_WOLF_ANGRY_WHINE = getSound("entity.wolf_angry.whine"); + + Sound ENTITY_WOLF_BIG_AMBIENT = getSound("entity.wolf_big.ambient"); + + Sound ENTITY_WOLF_BIG_DEATH = getSound("entity.wolf_big.death"); + + Sound ENTITY_WOLF_BIG_GROWL = getSound("entity.wolf_big.growl"); + + Sound ENTITY_WOLF_BIG_HURT = getSound("entity.wolf_big.hurt"); + + Sound ENTITY_WOLF_BIG_PANT = getSound("entity.wolf_big.pant"); + + Sound ENTITY_WOLF_BIG_WHINE = getSound("entity.wolf_big.whine"); + + Sound ENTITY_WOLF_CUTE_AMBIENT = getSound("entity.wolf_cute.ambient"); + + Sound ENTITY_WOLF_CUTE_DEATH = getSound("entity.wolf_cute.death"); + + Sound ENTITY_WOLF_CUTE_GROWL = getSound("entity.wolf_cute.growl"); + + Sound ENTITY_WOLF_CUTE_HURT = getSound("entity.wolf_cute.hurt"); + + Sound ENTITY_WOLF_CUTE_PANT = getSound("entity.wolf_cute.pant"); + + Sound ENTITY_WOLF_CUTE_WHINE = getSound("entity.wolf_cute.whine"); + + Sound ENTITY_WOLF_GRUMPY_AMBIENT = getSound("entity.wolf_grumpy.ambient"); + + Sound ENTITY_WOLF_GRUMPY_DEATH = getSound("entity.wolf_grumpy.death"); + + Sound ENTITY_WOLF_GRUMPY_GROWL = getSound("entity.wolf_grumpy.growl"); + + Sound ENTITY_WOLF_GRUMPY_HURT = getSound("entity.wolf_grumpy.hurt"); + + Sound ENTITY_WOLF_GRUMPY_PANT = getSound("entity.wolf_grumpy.pant"); + + Sound ENTITY_WOLF_GRUMPY_WHINE = getSound("entity.wolf_grumpy.whine"); + + Sound ENTITY_WOLF_PUGLIN_AMBIENT = getSound("entity.wolf_puglin.ambient"); + + Sound ENTITY_WOLF_PUGLIN_DEATH = getSound("entity.wolf_puglin.death"); + + Sound ENTITY_WOLF_PUGLIN_GROWL = getSound("entity.wolf_puglin.growl"); + + Sound ENTITY_WOLF_PUGLIN_HURT = getSound("entity.wolf_puglin.hurt"); + + Sound ENTITY_WOLF_PUGLIN_PANT = getSound("entity.wolf_puglin.pant"); + + Sound ENTITY_WOLF_PUGLIN_WHINE = getSound("entity.wolf_puglin.whine"); + + Sound ENTITY_WOLF_SAD_AMBIENT = getSound("entity.wolf_sad.ambient"); + + Sound ENTITY_WOLF_SAD_DEATH = getSound("entity.wolf_sad.death"); + + Sound ENTITY_WOLF_SAD_GROWL = getSound("entity.wolf_sad.growl"); + + Sound ENTITY_WOLF_SAD_HURT = getSound("entity.wolf_sad.hurt"); + + Sound ENTITY_WOLF_SAD_PANT = getSound("entity.wolf_sad.pant"); + + Sound ENTITY_WOLF_SAD_WHINE = getSound("entity.wolf_sad.whine"); + Sound ENTITY_ZOGLIN_AMBIENT = getSound("entity.zoglin.ambient"); + Sound ENTITY_ZOGLIN_ANGRY = getSound("entity.zoglin.angry"); + Sound ENTITY_ZOGLIN_ATTACK = getSound("entity.zoglin.attack"); + Sound ENTITY_ZOGLIN_DEATH = getSound("entity.zoglin.death"); + Sound ENTITY_ZOGLIN_HURT = getSound("entity.zoglin.hurt"); + Sound ENTITY_ZOGLIN_STEP = getSound("entity.zoglin.step"); + Sound ENTITY_ZOMBIE_AMBIENT = getSound("entity.zombie.ambient"); + Sound ENTITY_ZOMBIE_ATTACK_IRON_DOOR = getSound("entity.zombie.attack_iron_door"); + Sound ENTITY_ZOMBIE_ATTACK_WOODEN_DOOR = getSound("entity.zombie.attack_wooden_door"); + Sound ENTITY_ZOMBIE_BREAK_WOODEN_DOOR = getSound("entity.zombie.break_wooden_door"); + Sound ENTITY_ZOMBIE_CONVERTED_TO_DROWNED = getSound("entity.zombie.converted_to_drowned"); + Sound ENTITY_ZOMBIE_DEATH = getSound("entity.zombie.death"); + Sound ENTITY_ZOMBIE_DESTROY_EGG = getSound("entity.zombie.destroy_egg"); - Sound ENTITY_ZOMBIE_HORSE_AMBIENT = getSound("entity.zombie_horse.ambient"); - Sound ENTITY_ZOMBIE_HORSE_DEATH = getSound("entity.zombie_horse.death"); - Sound ENTITY_ZOMBIE_HORSE_HURT = getSound("entity.zombie_horse.hurt"); + Sound ENTITY_ZOMBIE_HURT = getSound("entity.zombie.hurt"); + Sound ENTITY_ZOMBIE_INFECT = getSound("entity.zombie.infect"); + Sound ENTITY_ZOMBIE_STEP = getSound("entity.zombie.step"); + + Sound ENTITY_ZOMBIE_HORSE_AMBIENT = getSound("entity.zombie_horse.ambient"); + + Sound ENTITY_ZOMBIE_HORSE_DEATH = getSound("entity.zombie_horse.death"); + + Sound ENTITY_ZOMBIE_HORSE_HURT = getSound("entity.zombie_horse.hurt"); + Sound ENTITY_ZOMBIE_VILLAGER_AMBIENT = getSound("entity.zombie_villager.ambient"); + Sound ENTITY_ZOMBIE_VILLAGER_CONVERTED = getSound("entity.zombie_villager.converted"); + Sound ENTITY_ZOMBIE_VILLAGER_CURE = getSound("entity.zombie_villager.cure"); + Sound ENTITY_ZOMBIE_VILLAGER_DEATH = getSound("entity.zombie_villager.death"); + Sound ENTITY_ZOMBIE_VILLAGER_HURT = getSound("entity.zombie_villager.hurt"); + Sound ENTITY_ZOMBIE_VILLAGER_STEP = getSound("entity.zombie_villager.step"); + Sound ENTITY_ZOMBIFIED_PIGLIN_AMBIENT = getSound("entity.zombified_piglin.ambient"); + Sound ENTITY_ZOMBIFIED_PIGLIN_ANGRY = getSound("entity.zombified_piglin.angry"); + Sound ENTITY_ZOMBIFIED_PIGLIN_DEATH = getSound("entity.zombified_piglin.death"); + Sound ENTITY_ZOMBIFIED_PIGLIN_HURT = getSound("entity.zombified_piglin.hurt"); + Sound EVENT_MOB_EFFECT_BAD_OMEN = getSound("event.mob_effect.bad_omen"); + Sound EVENT_MOB_EFFECT_RAID_OMEN = getSound("event.mob_effect.raid_omen"); + Sound EVENT_MOB_EFFECT_TRIAL_OMEN = getSound("event.mob_effect.trial_omen"); + Sound EVENT_RAID_HORN = getSound("event.raid.horn"); + Sound INTENTIONALLY_EMPTY = getSound("intentionally_empty"); + Sound ITEM_ARMOR_EQUIP_CHAIN = getSound("item.armor.equip_chain"); + Sound ITEM_ARMOR_EQUIP_DIAMOND = getSound("item.armor.equip_diamond"); + Sound ITEM_ARMOR_EQUIP_ELYTRA = getSound("item.armor.equip_elytra"); + Sound ITEM_ARMOR_EQUIP_GENERIC = getSound("item.armor.equip_generic"); + Sound ITEM_ARMOR_EQUIP_GOLD = getSound("item.armor.equip_gold"); + Sound ITEM_ARMOR_EQUIP_IRON = getSound("item.armor.equip_iron"); + Sound ITEM_ARMOR_EQUIP_LEATHER = getSound("item.armor.equip_leather"); + Sound ITEM_ARMOR_EQUIP_NETHERITE = getSound("item.armor.equip_netherite"); + Sound ITEM_ARMOR_EQUIP_TURTLE = getSound("item.armor.equip_turtle"); + Sound ITEM_ARMOR_EQUIP_WOLF = getSound("item.armor.equip_wolf"); + Sound ITEM_ARMOR_UNEQUIP_WOLF = getSound("item.armor.unequip_wolf"); + Sound ITEM_AXE_SCRAPE = getSound("item.axe.scrape"); + Sound ITEM_AXE_STRIP = getSound("item.axe.strip"); + Sound ITEM_AXE_WAX_OFF = getSound("item.axe.wax_off"); + Sound ITEM_BONE_MEAL_USE = getSound("item.bone_meal.use"); + Sound ITEM_BOOK_PAGE_TURN = getSound("item.book.page_turn"); + Sound ITEM_BOOK_PUT = getSound("item.book.put"); + Sound ITEM_BOTTLE_EMPTY = getSound("item.bottle.empty"); + Sound ITEM_BOTTLE_FILL = getSound("item.bottle.fill"); + Sound ITEM_BOTTLE_FILL_DRAGONBREATH = getSound("item.bottle.fill_dragonbreath"); + Sound ITEM_BRUSH_BRUSHING_GENERIC = getSound("item.brush.brushing.generic"); + Sound ITEM_BRUSH_BRUSHING_GRAVEL = getSound("item.brush.brushing.gravel"); + Sound ITEM_BRUSH_BRUSHING_GRAVEL_COMPLETE = getSound("item.brush.brushing.gravel.complete"); + Sound ITEM_BRUSH_BRUSHING_SAND = getSound("item.brush.brushing.sand"); + Sound ITEM_BRUSH_BRUSHING_SAND_COMPLETE = getSound("item.brush.brushing.sand.complete"); + Sound ITEM_BUCKET_EMPTY = getSound("item.bucket.empty"); + Sound ITEM_BUCKET_EMPTY_AXOLOTL = getSound("item.bucket.empty_axolotl"); + Sound ITEM_BUCKET_EMPTY_FISH = getSound("item.bucket.empty_fish"); + Sound ITEM_BUCKET_EMPTY_LAVA = getSound("item.bucket.empty_lava"); + Sound ITEM_BUCKET_EMPTY_POWDER_SNOW = getSound("item.bucket.empty_powder_snow"); + Sound ITEM_BUCKET_EMPTY_TADPOLE = getSound("item.bucket.empty_tadpole"); + Sound ITEM_BUCKET_FILL = getSound("item.bucket.fill"); + Sound ITEM_BUCKET_FILL_AXOLOTL = getSound("item.bucket.fill_axolotl"); + Sound ITEM_BUCKET_FILL_FISH = getSound("item.bucket.fill_fish"); + Sound ITEM_BUCKET_FILL_LAVA = getSound("item.bucket.fill_lava"); + Sound ITEM_BUCKET_FILL_POWDER_SNOW = getSound("item.bucket.fill_powder_snow"); + Sound ITEM_BUCKET_FILL_TADPOLE = getSound("item.bucket.fill_tadpole"); + Sound ITEM_BUNDLE_DROP_CONTENTS = getSound("item.bundle.drop_contents"); + Sound ITEM_BUNDLE_INSERT = getSound("item.bundle.insert"); + Sound ITEM_BUNDLE_INSERT_FAIL = getSound("item.bundle.insert_fail"); + Sound ITEM_BUNDLE_REMOVE_ONE = getSound("item.bundle.remove_one"); + Sound ITEM_CHORUS_FRUIT_TELEPORT = getSound("item.chorus_fruit.teleport"); + Sound ITEM_CROP_PLANT = getSound("item.crop.plant"); + Sound ITEM_CROSSBOW_HIT = getSound("item.crossbow.hit"); + Sound ITEM_CROSSBOW_LOADING_END = getSound("item.crossbow.loading_end"); + Sound ITEM_CROSSBOW_LOADING_MIDDLE = getSound("item.crossbow.loading_middle"); + Sound ITEM_CROSSBOW_LOADING_START = getSound("item.crossbow.loading_start"); + Sound ITEM_CROSSBOW_QUICK_CHARGE_1 = getSound("item.crossbow.quick_charge_1"); + Sound ITEM_CROSSBOW_QUICK_CHARGE_2 = getSound("item.crossbow.quick_charge_2"); + Sound ITEM_CROSSBOW_QUICK_CHARGE_3 = getSound("item.crossbow.quick_charge_3"); + Sound ITEM_CROSSBOW_SHOOT = getSound("item.crossbow.shoot"); + Sound ITEM_DYE_USE = getSound("item.dye.use"); + Sound ITEM_ELYTRA_FLYING = getSound("item.elytra.flying"); + Sound ITEM_FIRECHARGE_USE = getSound("item.firecharge.use"); + Sound ITEM_FLINTANDSTEEL_USE = getSound("item.flintandsteel.use"); + Sound ITEM_GLOW_INK_SAC_USE = getSound("item.glow_ink_sac.use"); + Sound ITEM_GOAT_HORN_SOUND_0 = getSound("item.goat_horn.sound.0"); + Sound ITEM_GOAT_HORN_SOUND_1 = getSound("item.goat_horn.sound.1"); + Sound ITEM_GOAT_HORN_SOUND_2 = getSound("item.goat_horn.sound.2"); + Sound ITEM_GOAT_HORN_SOUND_3 = getSound("item.goat_horn.sound.3"); + Sound ITEM_GOAT_HORN_SOUND_4 = getSound("item.goat_horn.sound.4"); + Sound ITEM_GOAT_HORN_SOUND_5 = getSound("item.goat_horn.sound.5"); + Sound ITEM_GOAT_HORN_SOUND_6 = getSound("item.goat_horn.sound.6"); + Sound ITEM_GOAT_HORN_SOUND_7 = getSound("item.goat_horn.sound.7"); + Sound ITEM_HOE_TILL = getSound("item.hoe.till"); - Sound ITEM_HONEYCOMB_WAX_ON = getSound("item.honeycomb.wax_on"); + Sound ITEM_HONEY_BOTTLE_DRINK = getSound("item.honey_bottle.drink"); + + Sound ITEM_HONEYCOMB_WAX_ON = getSound("item.honeycomb.wax_on"); + Sound ITEM_INK_SAC_USE = getSound("item.ink_sac.use"); + Sound ITEM_LODESTONE_COMPASS_LOCK = getSound("item.lodestone_compass.lock"); + Sound ITEM_MACE_SMASH_AIR = getSound("item.mace.smash_air"); + Sound ITEM_MACE_SMASH_GROUND = getSound("item.mace.smash_ground"); + Sound ITEM_MACE_SMASH_GROUND_HEAVY = getSound("item.mace.smash_ground_heavy"); + Sound ITEM_NETHER_WART_PLANT = getSound("item.nether_wart.plant"); + Sound ITEM_OMINOUS_BOTTLE_DISPOSE = getSound("item.ominous_bottle.dispose"); + Sound ITEM_SHIELD_BLOCK = getSound("item.shield.block"); + Sound ITEM_SHIELD_BREAK = getSound("item.shield.break"); + Sound ITEM_SHOVEL_FLATTEN = getSound("item.shovel.flatten"); + Sound ITEM_SPYGLASS_STOP_USING = getSound("item.spyglass.stop_using"); + Sound ITEM_SPYGLASS_USE = getSound("item.spyglass.use"); + Sound ITEM_TOTEM_USE = getSound("item.totem.use"); + Sound ITEM_TRIDENT_HIT = getSound("item.trident.hit"); + Sound ITEM_TRIDENT_HIT_GROUND = getSound("item.trident.hit_ground"); + Sound ITEM_TRIDENT_RETURN = getSound("item.trident.return"); + Sound ITEM_TRIDENT_RIPTIDE_1 = getSound("item.trident.riptide_1"); + Sound ITEM_TRIDENT_RIPTIDE_2 = getSound("item.trident.riptide_2"); + Sound ITEM_TRIDENT_RIPTIDE_3 = getSound("item.trident.riptide_3"); + Sound ITEM_TRIDENT_THROW = getSound("item.trident.throw"); + Sound ITEM_TRIDENT_THUNDER = getSound("item.trident.thunder"); + Sound ITEM_WOLF_ARMOR_BREAK = getSound("item.wolf_armor.break"); + Sound ITEM_WOLF_ARMOR_CRACK = getSound("item.wolf_armor.crack"); + Sound ITEM_WOLF_ARMOR_DAMAGE = getSound("item.wolf_armor.damage"); + Sound ITEM_WOLF_ARMOR_REPAIR = getSound("item.wolf_armor.repair"); + Sound MUSIC_CREATIVE = getSound("music.creative"); + Sound MUSIC_CREDITS = getSound("music.credits"); - Sound MUSIC_DISC_11 = getSound("music_disc.11"); - Sound MUSIC_DISC_13 = getSound("music_disc.13"); - Sound MUSIC_DISC_5 = getSound("music_disc.5"); - Sound MUSIC_DISC_BLOCKS = getSound("music_disc.blocks"); - Sound MUSIC_DISC_CAT = getSound("music_disc.cat"); - Sound MUSIC_DISC_CHIRP = getSound("music_disc.chirp"); - Sound MUSIC_DISC_CREATOR = getSound("music_disc.creator"); - Sound MUSIC_DISC_CREATOR_MUSIC_BOX = getSound("music_disc.creator_music_box"); - Sound MUSIC_DISC_FAR = getSound("music_disc.far"); - Sound MUSIC_DISC_MALL = getSound("music_disc.mall"); - Sound MUSIC_DISC_MELLOHI = getSound("music_disc.mellohi"); - Sound MUSIC_DISC_OTHERSIDE = getSound("music_disc.otherside"); - Sound MUSIC_DISC_PIGSTEP = getSound("music_disc.pigstep"); - Sound MUSIC_DISC_PRECIPICE = getSound("music_disc.precipice"); - Sound MUSIC_DISC_RELIC = getSound("music_disc.relic"); - Sound MUSIC_DISC_STAL = getSound("music_disc.stal"); - Sound MUSIC_DISC_STRAD = getSound("music_disc.strad"); - Sound MUSIC_DISC_WAIT = getSound("music_disc.wait"); - Sound MUSIC_DISC_WARD = getSound("music_disc.ward"); + Sound MUSIC_DRAGON = getSound("music.dragon"); + Sound MUSIC_END = getSound("music.end"); + Sound MUSIC_GAME = getSound("music.game"); + Sound MUSIC_MENU = getSound("music.menu"); + Sound MUSIC_NETHER_BASALT_DELTAS = getSound("music.nether.basalt_deltas"); + Sound MUSIC_NETHER_CRIMSON_FOREST = getSound("music.nether.crimson_forest"); + Sound MUSIC_NETHER_NETHER_WASTES = getSound("music.nether.nether_wastes"); + Sound MUSIC_NETHER_SOUL_SAND_VALLEY = getSound("music.nether.soul_sand_valley"); + Sound MUSIC_NETHER_WARPED_FOREST = getSound("music.nether.warped_forest"); + Sound MUSIC_OVERWORLD_BADLANDS = getSound("music.overworld.badlands"); + Sound MUSIC_OVERWORLD_BAMBOO_JUNGLE = getSound("music.overworld.bamboo_jungle"); + Sound MUSIC_OVERWORLD_CHERRY_GROVE = getSound("music.overworld.cherry_grove"); + Sound MUSIC_OVERWORLD_DEEP_DARK = getSound("music.overworld.deep_dark"); + Sound MUSIC_OVERWORLD_DESERT = getSound("music.overworld.desert"); + Sound MUSIC_OVERWORLD_DRIPSTONE_CAVES = getSound("music.overworld.dripstone_caves"); + Sound MUSIC_OVERWORLD_FLOWER_FOREST = getSound("music.overworld.flower_forest"); + Sound MUSIC_OVERWORLD_FOREST = getSound("music.overworld.forest"); + Sound MUSIC_OVERWORLD_FROZEN_PEAKS = getSound("music.overworld.frozen_peaks"); + Sound MUSIC_OVERWORLD_GROVE = getSound("music.overworld.grove"); + Sound MUSIC_OVERWORLD_JAGGED_PEAKS = getSound("music.overworld.jagged_peaks"); + Sound MUSIC_OVERWORLD_JUNGLE = getSound("music.overworld.jungle"); + Sound MUSIC_OVERWORLD_LUSH_CAVES = getSound("music.overworld.lush_caves"); + Sound MUSIC_OVERWORLD_MEADOW = getSound("music.overworld.meadow"); + Sound MUSIC_OVERWORLD_OLD_GROWTH_TAIGA = getSound("music.overworld.old_growth_taiga"); + Sound MUSIC_OVERWORLD_SNOWY_SLOPES = getSound("music.overworld.snowy_slopes"); + Sound MUSIC_OVERWORLD_SPARSE_JUNGLE = getSound("music.overworld.sparse_jungle"); + Sound MUSIC_OVERWORLD_STONY_PEAKS = getSound("music.overworld.stony_peaks"); + Sound MUSIC_OVERWORLD_SWAMP = getSound("music.overworld.swamp"); + Sound MUSIC_UNDER_WATER = getSound("music.under_water"); + + Sound MUSIC_DISC_11 = getSound("music_disc.11"); + + Sound MUSIC_DISC_13 = getSound("music_disc.13"); + + Sound MUSIC_DISC_5 = getSound("music_disc.5"); + + Sound MUSIC_DISC_BLOCKS = getSound("music_disc.blocks"); + + Sound MUSIC_DISC_CAT = getSound("music_disc.cat"); + + Sound MUSIC_DISC_CHIRP = getSound("music_disc.chirp"); + + Sound MUSIC_DISC_CREATOR = getSound("music_disc.creator"); + + Sound MUSIC_DISC_CREATOR_MUSIC_BOX = getSound("music_disc.creator_music_box"); + + Sound MUSIC_DISC_FAR = getSound("music_disc.far"); + + Sound MUSIC_DISC_MALL = getSound("music_disc.mall"); + + Sound MUSIC_DISC_MELLOHI = getSound("music_disc.mellohi"); + + Sound MUSIC_DISC_OTHERSIDE = getSound("music_disc.otherside"); + + Sound MUSIC_DISC_PIGSTEP = getSound("music_disc.pigstep"); + + Sound MUSIC_DISC_PRECIPICE = getSound("music_disc.precipice"); + + Sound MUSIC_DISC_RELIC = getSound("music_disc.relic"); + + Sound MUSIC_DISC_STAL = getSound("music_disc.stal"); + + Sound MUSIC_DISC_STRAD = getSound("music_disc.strad"); + + Sound MUSIC_DISC_WAIT = getSound("music_disc.wait"); + + Sound MUSIC_DISC_WARD = getSound("music_disc.ward"); + Sound PARTICLE_SOUL_ESCAPE = getSound("particle.soul_escape"); + Sound UI_BUTTON_CLICK = getSound("ui.button.click"); + Sound UI_CARTOGRAPHY_TABLE_TAKE_RESULT = getSound("ui.cartography_table.take_result"); + Sound UI_HUD_BUBBLE_POP = getSound("ui.hud.bubble_pop"); + Sound UI_LOOM_SELECT_PATTERN = getSound("ui.loom.select_pattern"); + Sound UI_LOOM_TAKE_RESULT = getSound("ui.loom.take_result"); + Sound UI_STONECUTTER_SELECT_RECIPE = getSound("ui.stonecutter.select_recipe"); + Sound UI_STONECUTTER_TAKE_RESULT = getSound("ui.stonecutter.take_result"); + Sound UI_TOAST_CHALLENGE_COMPLETE = getSound("ui.toast.challenge_complete"); + Sound UI_TOAST_IN = getSound("ui.toast.in"); + Sound UI_TOAST_OUT = getSound("ui.toast.out"); + Sound WEATHER_RAIN = getSound("weather.rain"); + Sound WEATHER_RAIN_ABOVE = getSound("weather.rain.above"); + // End generate - Sound @NotNull private static Sound getSound(@NotNull String key) { @@ -1686,7 +3441,7 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead. */ @NotNull - @Deprecated(since = "1.21.3") + @Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Sound valueOf(@NotNull String name) { Sound sound = Bukkit.getUnsafe().get(RegistryKey.SOUND_EVENT, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); if (sound != null) { @@ -1720,7 +3475,7 @@ public interface Sound extends OldEnum, Keyed, net.kyori.adventure.sound. * @deprecated use {@link Registry#iterator()}. */ @NotNull - @Deprecated(since = "1.21.3") + @Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Sound[] values() { return Lists.newArrayList(Registry.SOUNDS).toArray(new Sound[0]); } diff --git a/paper-api/src/main/java/org/bukkit/Statistic.java b/paper-api/src/main/java/org/bukkit/Statistic.java index 4ce888688..b07521166 100644 --- a/paper-api/src/main/java/org/bukkit/Statistic.java +++ b/paper-api/src/main/java/org/bukkit/Statistic.java @@ -7,92 +7,95 @@ import org.jetbrains.annotations.NotNull; * Represents a countable statistic, which is tracked by the server. */ public enum Statistic implements Keyed { - DAMAGE_DEALT, - DAMAGE_TAKEN, - DEATHS, - MOB_KILLS, - PLAYER_KILLS, - FISH_CAUGHT, + // Start generate - StatisticCustom + // @GeneratedFrom 1.21.5 ANIMALS_BRED, - LEAVE_GAME, - JUMP, - DROP_COUNT, - DROP(Type.ITEM), - PICKUP(Type.ITEM), - /** - * Name is misleading, actually records ticks played. - */ - PLAY_ONE_MINUTE, - TOTAL_WORLD_TIME, - WALK_ONE_CM, - WALK_ON_WATER_ONE_CM, - FALL_ONE_CM, - SNEAK_TIME, - CLIMB_ONE_CM, - FLY_ONE_CM, - WALK_UNDER_WATER_ONE_CM, - MINECART_ONE_CM, - BOAT_ONE_CM, - PIG_ONE_CM, - HORSE_ONE_CM, - SPRINT_ONE_CM, - CROUCH_ONE_CM, AVIATE_ONE_CM, - MINE_BLOCK(Type.BLOCK), - USE_ITEM(Type.ITEM), - BREAK_ITEM(Type.ITEM), - CRAFT_ITEM(Type.ITEM), - KILL_ENTITY(Type.ENTITY), - ENTITY_KILLED_BY(Type.ENTITY), - TIME_SINCE_DEATH, - TALKED_TO_VILLAGER, - TRADED_WITH_VILLAGER, - CAKE_SLICES_EATEN, - CAULDRON_FILLED, - CAULDRON_USED, + BELL_RING, + BOAT_ONE_CM, ARMOR_CLEANED, BANNER_CLEANED, - BREWINGSTAND_INTERACTION, - BEACON_INTERACTION, - DROPPER_INSPECTED, - HOPPER_INSPECTED, - DISPENSER_INSPECTED, - NOTEBLOCK_PLAYED, - NOTEBLOCK_TUNED, - FLOWER_POTTED, - TRAPPED_CHEST_TRIGGERED, - ENDERCHEST_OPENED, - ITEM_ENCHANTED, - RECORD_PLAYED, - FURNACE_INTERACTION, - CRAFTING_TABLE_INTERACTION, - CHEST_OPENED, - SLEEP_IN_BED, - SHULKER_BOX_OPENED, - TIME_SINCE_REST, - SWIM_ONE_CM, + CLEAN_SHULKER_BOX, + CLIMB_ONE_CM, + CROUCH_ONE_CM, + DAMAGE_ABSORBED, + DAMAGE_BLOCKED_BY_SHIELD, + DAMAGE_DEALT, DAMAGE_DEALT_ABSORBED, DAMAGE_DEALT_RESISTED, - DAMAGE_BLOCKED_BY_SHIELD, - DAMAGE_ABSORBED, DAMAGE_RESISTED, - CLEAN_SHULKER_BOX, - OPEN_BARREL, + DAMAGE_TAKEN, + DEATHS, + DROP_COUNT, + CAKE_SLICES_EATEN, + ITEM_ENCHANTED, + FALL_ONE_CM, + CAULDRON_FILLED, + FISH_CAUGHT, + FLY_ONE_CM, + HORSE_ONE_CM, + DISPENSER_INSPECTED, + DROPPER_INSPECTED, + HOPPER_INSPECTED, + INTERACT_WITH_ANVIL, + BEACON_INTERACTION, INTERACT_WITH_BLAST_FURNACE, - INTERACT_WITH_SMOKER, - INTERACT_WITH_LECTERN, + BREWINGSTAND_INTERACTION, INTERACT_WITH_CAMPFIRE, INTERACT_WITH_CARTOGRAPHY_TABLE, + CRAFTING_TABLE_INTERACTION, + FURNACE_INTERACTION, + INTERACT_WITH_GRINDSTONE, + INTERACT_WITH_LECTERN, INTERACT_WITH_LOOM, + INTERACT_WITH_SMITHING_TABLE, + INTERACT_WITH_SMOKER, INTERACT_WITH_STONECUTTER, - BELL_RING, + JUMP, + LEAVE_GAME, + MINECART_ONE_CM, + MOB_KILLS, + OPEN_BARREL, + CHEST_OPENED, + ENDERCHEST_OPENED, + SHULKER_BOX_OPENED, + PIG_ONE_CM, + NOTEBLOCK_PLAYED, + RECORD_PLAYED, + PLAY_ONE_MINUTE, + PLAYER_KILLS, + FLOWER_POTTED, RAID_TRIGGER, RAID_WIN, - INTERACT_WITH_ANVIL, - INTERACT_WITH_GRINDSTONE, + SLEEP_IN_BED, + SNEAK_TIME, + SPRINT_ONE_CM, + STRIDER_ONE_CM, + SWIM_ONE_CM, + TALKED_TO_VILLAGER, TARGET_HIT, - INTERACT_WITH_SMITHING_TABLE, - STRIDER_ONE_CM; + TIME_SINCE_DEATH, + TIME_SINCE_REST, + TOTAL_WORLD_TIME, + TRADED_WITH_VILLAGER, + TRAPPED_CHEST_TRIGGERED, + NOTEBLOCK_TUNED, + CAULDRON_USED, + WALK_ON_WATER_ONE_CM, + WALK_ONE_CM, + WALK_UNDER_WATER_ONE_CM, + // End generate - StatisticCustom + // Start generate - StatisticType + // @GeneratedFrom 1.21.5 + BREAK_ITEM(Type.ITEM), + CRAFT_ITEM(Type.ITEM), + DROP(Type.ITEM), + KILL_ENTITY(Type.ENTITY), + ENTITY_KILLED_BY(Type.ENTITY), + MINE_BLOCK(Type.BLOCK), + PICKUP(Type.ITEM), + USE_ITEM(Type.ITEM); + // End generate - StatisticType private final Type type; private final NamespacedKey key; diff --git a/paper-api/src/main/java/org/bukkit/Tag.java b/paper-api/src/main/java/org/bukkit/Tag.java index 193858a28..1b2e40088 100644 --- a/paper-api/src/main/java/org/bukkit/Tag.java +++ b/paper-api/src/main/java/org/bukkit/Tag.java @@ -19,814 +19,860 @@ import org.jetbrains.annotations.NotNull; */ public interface Tag extends Keyed { - /** - * Key for the built in block registry. - */ + // Start generate - Tag + // @GeneratedFrom 1.21.5 String REGISTRY_BLOCKS = "blocks"; - /** - * Vanilla block tag representing all colors of wool. - */ - Tag WOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool"), Material.class); - /** - * Vanilla block tag representing all plank variants. - */ - Tag PLANKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("planks"), Material.class); - /** - * Vanilla block tag representing all regular/mossy/cracked/chiseled stone - * bricks. - */ - Tag STONE_BRICKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_bricks"), Material.class); - /** - * Vanilla block tag representing all wooden buttons. - */ - Tag WOODEN_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_buttons"), Material.class); - /** - * Vanilla block tag representing all stone buttons. - */ - Tag STONE_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_buttons"), Material.class); - /** - * Vanilla block tag representing all buttons (inherits from - * {@link #WOODEN_BUTTONS}. - */ + + Tag ACACIA_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("acacia_logs"), Material.class); + + Tag AIR = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("air"), Material.class); + + Tag ALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_hanging_signs"), Material.class); + + Tag ALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_signs"), Material.class); + + Tag ANCIENT_CITY_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ancient_city_replaceable"), Material.class); + + Tag ANIMALS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("animals_spawnable_on"), Material.class); + + Tag ANVIL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("anvil"), Material.class); + + Tag ARMADILLO_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("armadillo_spawnable_on"), Material.class); + + Tag AXOLOTLS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("axolotls_spawnable_on"), Material.class); + + Tag AZALEA_GROWS_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_grows_on"), Material.class); + + Tag AZALEA_ROOT_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_root_replaceable"), Material.class); + + Tag BADLANDS_TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("badlands_terracotta"), Material.class); + + Tag BAMBOO_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_blocks"), Material.class); + + Tag BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class); + + Tag BANNERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("banners"), Material.class); + + Tag BASE_STONE_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_nether"), Material.class); + + Tag BASE_STONE_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_overworld"), Material.class); + + Tag BATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bats_spawnable_on"), Material.class); + + Tag BEACON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beacon_base_blocks"), Material.class); + + Tag BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class); + + Tag BEE_ATTRACTIVE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bee_attractive"), Material.class); + + Tag BEE_GROWABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bee_growables"), Material.class); + + Tag BEEHIVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beehives"), Material.class); + + Tag BIG_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("big_dripleaf_placeable"), Material.class); + + Tag BIRCH_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("birch_logs"), Material.class); + + Tag BLOCKS_WIND_CHARGE_EXPLOSIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("blocks_wind_charge_explosions"), Material.class); + Tag BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("buttons"), Material.class); - /** - * Vanilla block tag representing all colors of carpet. - */ + + Tag CAMEL_SAND_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("camel_sand_step_sound_blocks"), Material.class); + + Tag CAMELS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("camels_spawnable_on"), Material.class); + + Tag CAMPFIRES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("campfires"), Material.class); + + Tag CANDLE_CAKES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candle_cakes"), Material.class); + + Tag CANDLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candles"), Material.class); + + Tag CAULDRONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cauldrons"), Material.class); + + Tag CAVE_VINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cave_vines"), Material.class); + + Tag CEILING_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ceiling_hanging_signs"), Material.class); + + Tag CHERRY_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cherry_logs"), Material.class); + + Tag CLIMBABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("climbable"), Material.class); + + Tag COAL_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coal_ores"), Material.class); + + Tag COMBINATION_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("combination_step_sound_blocks"), Material.class); + + Tag COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class); + + Tag CONCRETE_POWDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete_powder"), Material.class); + + Tag CONVERTABLE_TO_MUD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("convertable_to_mud"), Material.class); + + Tag COPPER_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("copper_ores"), Material.class); + + Tag CORAL_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_blocks"), Material.class); + + Tag CORAL_PLANTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_plants"), Material.class); + + Tag CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class); + + Tag CRIMSON_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crimson_stems"), Material.class); + + Tag CROPS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crops"), Material.class); + + Tag CRYSTAL_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crystal_sound_blocks"), Material.class); + + Tag DAMPENS_VIBRATIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dampens_vibrations"), Material.class); + + Tag DARK_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dark_oak_logs"), Material.class); + + Tag DEEPSLATE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("deepslate_ore_replaceables"), Material.class); + + Tag DIAMOND_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("diamond_ores"), Material.class); + + Tag DIRT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt"), Material.class); + + Tag DOES_NOT_BLOCK_HOPPERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("does_not_block_hoppers"), Material.class); + + Tag DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("doors"), Material.class); + + Tag DRAGON_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_immune"), Material.class); + + Tag DRAGON_TRANSPARENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_transparent"), Material.class); + + Tag DRIPSTONE_REPLACEABLE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dripstone_replaceable_blocks"), Material.class); + + Tag DRY_VEGETATION_MAY_PLACE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dry_vegetation_may_place_on"), Material.class); + + Tag EDIBLE_FOR_SHEEP = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("edible_for_sheep"), Material.class); + + Tag EMERALD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("emerald_ores"), Material.class); + + Tag ENCHANTMENT_POWER_PROVIDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_provider"), Material.class); + + Tag ENCHANTMENT_POWER_TRANSMITTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_transmitter"), Material.class); + + Tag ENDERMAN_HOLDABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enderman_holdable"), Material.class); + + Tag FALL_DAMAGE_RESETTING = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fall_damage_resetting"), Material.class); + + Tag FEATURES_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("features_cannot_replace"), Material.class); + + Tag FENCE_GATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fence_gates"), Material.class); + + Tag FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class); + + Tag FIRE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fire"), Material.class); + + Tag FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class); + + Tag FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flowers"), Material.class); + + Tag FOXES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("foxes_spawnable_on"), Material.class); + + Tag FROG_PREFER_JUMP_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frog_prefer_jump_to"), Material.class); + + Tag FROGS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frogs_spawnable_on"), Material.class); + + Tag GEODE_INVALID_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("geode_invalid_blocks"), Material.class); + + Tag GOATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("goats_spawnable_on"), Material.class); + + Tag GOLD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("gold_ores"), Material.class); + + Tag GUARDED_BY_PIGLINS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("guarded_by_piglins"), Material.class); + + Tag HOGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("hoglin_repellents"), Material.class); + + Tag ICE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ice"), Material.class); + + Tag IMPERMEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("impermeable"), Material.class); + + Tag INCORRECT_FOR_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_diamond_tool"), Material.class); + + Tag INCORRECT_FOR_GOLD_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_gold_tool"), Material.class); + + Tag INCORRECT_FOR_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_iron_tool"), Material.class); + + Tag INCORRECT_FOR_NETHERITE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_netherite_tool"), Material.class); + + Tag INCORRECT_FOR_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_stone_tool"), Material.class); + + Tag INCORRECT_FOR_WOODEN_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_wooden_tool"), Material.class); + + Tag INFINIBURN_END = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_end"), Material.class); + + Tag INFINIBURN_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_nether"), Material.class); + + Tag INFINIBURN_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_overworld"), Material.class); + + Tag INSIDE_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("inside_step_sound_blocks"), Material.class); + + Tag INVALID_SPAWN_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("invalid_spawn_inside"), Material.class); + + Tag IRON_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("iron_ores"), Material.class); + + Tag JUNGLE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("jungle_logs"), Material.class); + + Tag LAPIS_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lapis_ores"), Material.class); + + Tag LAVA_POOL_STONE_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lava_pool_stone_cannot_replace"), Material.class); + + Tag LEAVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("leaves"), Material.class); + + Tag LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs"), Material.class); + + Tag LOGS_THAT_BURN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs_that_burn"), Material.class); + + Tag LUSH_GROUND_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lush_ground_replaceable"), Material.class); + + Tag MAINTAINS_FARMLAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("maintains_farmland"), Material.class); + + Tag MANGROVE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs"), Material.class); + + Tag MANGROVE_LOGS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs_can_grow_through"), Material.class); + + Tag MANGROVE_ROOTS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_roots_can_grow_through"), Material.class); + + Tag MINEABLE_AXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/axe"), Material.class); + + Tag MINEABLE_HOE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/hoe"), Material.class); + + Tag MINEABLE_PICKAXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/pickaxe"), Material.class); + + Tag MINEABLE_SHOVEL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/shovel"), Material.class); + + Tag MOB_INTERACTABLE_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mob_interactable_doors"), Material.class); + + Tag MOOSHROOMS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mooshrooms_spawnable_on"), Material.class); + + Tag MOSS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("moss_replaceable"), Material.class); + + Tag MUSHROOM_GROW_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mushroom_grow_block"), Material.class); + + Tag NEEDS_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_diamond_tool"), Material.class); + + Tag NEEDS_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_iron_tool"), Material.class); + + Tag NEEDS_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_stone_tool"), Material.class); + + Tag NETHER_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nether_carver_replaceables"), Material.class); + + Tag NYLIUM = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nylium"), Material.class); + + Tag OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("oak_logs"), Material.class); + + Tag OCCLUDES_VIBRATION_SIGNALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("occludes_vibration_signals"), Material.class); + + Tag OVERWORLD_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("overworld_carver_replaceables"), Material.class); + + Tag OVERWORLD_NATURAL_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("overworld_natural_logs"), Material.class); + + Tag PALE_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pale_oak_logs"), Material.class); + + Tag PARROTS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("parrots_spawnable_on"), Material.class); + + Tag PIGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("piglin_repellents"), Material.class); + + Tag PLANKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("planks"), Material.class); + + Tag PLAYS_AMBIENT_DESERT_BLOCK_SOUNDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("plays_ambient_desert_block_sounds"), Material.class); + + Tag POLAR_BEARS_SPAWNABLE_ON_ALTERNATE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bears_spawnable_on_alternate"), Material.class); + + Tag PORTALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("portals"), Material.class); + + Tag PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pressure_plates"), Material.class); + + Tag PREVENT_MOB_SPAWNING_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("prevent_mob_spawning_inside"), Material.class); + + Tag RABBITS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rabbits_spawnable_on"), Material.class); + + Tag RAILS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rails"), Material.class); + + Tag REDSTONE_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("redstone_ores"), Material.class); + + Tag REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable"), Material.class); + + Tag REPLACEABLE_BY_MUSHROOMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable_by_mushrooms"), Material.class); + + Tag REPLACEABLE_BY_TREES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable_by_trees"), Material.class); + + Tag SAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sand"), Material.class); + + Tag SAPLINGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("saplings"), Material.class); + + Tag SCULK_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable"), Material.class); + + Tag SCULK_REPLACEABLE_WORLD_GEN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable_world_gen"), Material.class); + + Tag SHULKER_BOXES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shulker_boxes"), Material.class); + + Tag SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class); + + Tag SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class); + + Tag SMALL_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_dripleaf_placeable"), Material.class); + + Tag SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class); + + Tag SMELTS_TO_GLASS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("smelts_to_glass"), Material.class); + + Tag SNAPS_GOAT_HORN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snaps_goat_horn"), Material.class); + + Tag SNIFFER_DIGGABLE_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_diggable_block"), Material.class); + + Tag SNIFFER_EGG_HATCH_BOOST = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_egg_hatch_boost"), Material.class); + + Tag SNOW = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow"), Material.class); + + Tag SNOW_LAYER_CAN_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_can_survive_on"), Material.class); + + Tag SNOW_LAYER_CANNOT_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_cannot_survive_on"), Material.class); + + Tag SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); + + Tag SOUL_SPEED_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_speed_blocks"), Material.class); + + Tag SPRUCE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("spruce_logs"), Material.class); + + Tag STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stairs"), Material.class); + + Tag STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class); + + Tag STONE_BRICKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_bricks"), Material.class); + + Tag STONE_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_buttons"), Material.class); + + Tag STONE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_ore_replaceables"), Material.class); + + Tag STONE_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_pressure_plates"), Material.class); + + Tag STRIDER_WARM_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("strider_warm_blocks"), Material.class); + + Tag SWORD_EFFICIENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_efficient"), Material.class); + + Tag SWORD_INSTANTLY_MINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_instantly_mines"), Material.class); + + Tag TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("terracotta"), Material.class); + + Tag TRAIL_RUINS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trail_ruins_replaceable"), Material.class); + + Tag TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trapdoors"), Material.class); + + Tag UNDERWATER_BONEMEALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("underwater_bonemeals"), Material.class); + + Tag UNSTABLE_BOTTOM_CENTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("unstable_bottom_center"), Material.class); + + Tag VALID_SPAWN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("valid_spawn"), Material.class); + + Tag VIBRATION_RESONATORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("vibration_resonators"), Material.class); + + Tag WALL_CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_corals"), Material.class); + + Tag WALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_hanging_signs"), Material.class); + + Tag WALL_POST_OVERRIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_post_override"), Material.class); + + Tag WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class); + + Tag WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class); + + Tag WARPED_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("warped_stems"), Material.class); + + Tag WART_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wart_blocks"), Material.class); + + Tag WITHER_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_immune"), Material.class); + + Tag WITHER_SUMMON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_summon_base_blocks"), Material.class); + + Tag WOLVES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wolves_spawnable_on"), Material.class); + + Tag WOODEN_BUTTONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_buttons"), Material.class); + + Tag WOODEN_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_doors"), Material.class); + + Tag WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class); + + Tag WOODEN_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_pressure_plates"), Material.class); + + Tag WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class); + + Tag WOODEN_STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_stairs"), Material.class); + + Tag WOODEN_TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_trapdoors"), Material.class); + + Tag WOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool"), Material.class); + Tag WOOL_CARPETS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wool_carpets"), Material.class); + + String REGISTRY_ITEMS = "items"; + + Tag ITEMS_ACACIA_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("acacia_logs"), Material.class); + + Tag ITEMS_ANVIL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("anvil"), Material.class); + + Tag ITEMS_ARMADILLO_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("armadillo_food"), Material.class); + + Tag ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class); + + Tag ITEMS_AXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axes"), Material.class); + + Tag ITEMS_AXOLOTL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axolotl_food"), Material.class); + + Tag ITEMS_BAMBOO_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bamboo_blocks"), Material.class); + + Tag ITEMS_BANNERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("banners"), Material.class); + + Tag ITEMS_BEACON_PAYMENT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("beacon_payment_items"), Material.class); + + Tag ITEMS_BEDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("beds"), Material.class); + + Tag ITEMS_BEE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bee_food"), Material.class); + + Tag ITEMS_BIRCH_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("birch_logs"), Material.class); + + Tag ITEMS_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("boats"), Material.class); + + Tag ITEMS_BOOK_CLONING_TARGET = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("book_cloning_target"), Material.class); + + Tag ITEMS_BOOKSHELF_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bookshelf_books"), Material.class); + + Tag ITEMS_BREAKS_DECORATED_POTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("breaks_decorated_pots"), Material.class); + + Tag ITEMS_BREWING_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("brewing_fuel"), Material.class); + + Tag ITEMS_BUNDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bundles"), Material.class); + + Tag ITEMS_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("buttons"), Material.class); + + Tag ITEMS_CAMEL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_food"), Material.class); + + Tag ITEMS_CANDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("candles"), Material.class); + + Tag ITEMS_CAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cat_food"), Material.class); + + Tag ITEMS_CHERRY_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cherry_logs"), Material.class); + + Tag ITEMS_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_armor"), Material.class); + + Tag ITEMS_CHEST_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_boats"), Material.class); + + Tag ITEMS_CHICKEN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chicken_food"), Material.class); + + Tag ITEMS_CLUSTER_MAX_HARVESTABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cluster_max_harvestables"), Material.class); + + Tag ITEMS_COAL_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coal_ores"), Material.class); + + Tag ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class); + + Tag ITEMS_COMPASSES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("compasses"), Material.class); + + Tag ITEMS_COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class); + + Tag ITEMS_COPPER_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("copper_ores"), Material.class); + + Tag ITEMS_COW_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cow_food"), Material.class); + + Tag ITEMS_CREEPER_DROP_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_drop_music_discs"), Material.class); + + Tag ITEMS_CREEPER_IGNITERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_igniters"), Material.class); + + Tag ITEMS_CRIMSON_STEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("crimson_stems"), Material.class); + + Tag ITEMS_DAMPENS_VIBRATIONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dampens_vibrations"), Material.class); + + Tag ITEMS_DARK_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dark_oak_logs"), Material.class); + + Tag ITEMS_DECORATED_POT_INGREDIENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_ingredients"), Material.class); + + Tag ITEMS_DECORATED_POT_SHERDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_sherds"), Material.class); + + Tag ITEMS_DIAMOND_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("diamond_ores"), Material.class); + + Tag ITEMS_DIAMOND_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("diamond_tool_materials"), Material.class); + + Tag ITEMS_DIRT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dirt"), Material.class); + + Tag ITEMS_DOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("doors"), Material.class); + + Tag ITEMS_DROWNED_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("drowned_preferred_weapons"), Material.class); + + Tag ITEMS_DUPLICATES_ALLAYS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("duplicates_allays"), Material.class); + + Tag ITEMS_DYEABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dyeable"), Material.class); + + Tag ITEMS_EGGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("eggs"), Material.class); + + Tag ITEMS_EMERALD_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("emerald_ores"), Material.class); + + Tag ITEMS_ENCHANTABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/armor"), Material.class); + + Tag ITEMS_ENCHANTABLE_BOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/bow"), Material.class); + + Tag ITEMS_ENCHANTABLE_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/chest_armor"), Material.class); + + Tag ITEMS_ENCHANTABLE_CROSSBOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/crossbow"), Material.class); + + Tag ITEMS_ENCHANTABLE_DURABILITY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/durability"), Material.class); + + Tag ITEMS_ENCHANTABLE_EQUIPPABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/equippable"), Material.class); + + Tag ITEMS_ENCHANTABLE_FIRE_ASPECT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fire_aspect"), Material.class); + + Tag ITEMS_ENCHANTABLE_FISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fishing"), Material.class); + + Tag ITEMS_ENCHANTABLE_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/foot_armor"), Material.class); + + Tag ITEMS_ENCHANTABLE_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/head_armor"), Material.class); + + Tag ITEMS_ENCHANTABLE_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/leg_armor"), Material.class); + + Tag ITEMS_ENCHANTABLE_MACE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mace"), Material.class); + + Tag ITEMS_ENCHANTABLE_MINING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining"), Material.class); + + Tag ITEMS_ENCHANTABLE_MINING_LOOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining_loot"), Material.class); + + Tag ITEMS_ENCHANTABLE_SHARP_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sharp_weapon"), Material.class); + + Tag ITEMS_ENCHANTABLE_SWORD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sword"), Material.class); + + Tag ITEMS_ENCHANTABLE_TRIDENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/trident"), Material.class); + + Tag ITEMS_ENCHANTABLE_VANISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/vanishing"), Material.class); + + Tag ITEMS_ENCHANTABLE_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/weapon"), Material.class); + + Tag ITEMS_FENCE_GATES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fence_gates"), Material.class); + + Tag ITEMS_FENCES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fences"), Material.class); + + Tag ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class); + + Tag ITEMS_FLOWERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("flowers"), Material.class); + + Tag ITEMS_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("foot_armor"), Material.class); + + Tag ITEMS_FOX_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fox_food"), Material.class); + + Tag ITEMS_FREEZE_IMMUNE_WEARABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("freeze_immune_wearables"), Material.class); + + Tag ITEMS_FROG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("frog_food"), Material.class); + + Tag ITEMS_FURNACE_MINECART_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("furnace_minecart_fuel"), Material.class); + + Tag ITEMS_GAZE_DISGUISE_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gaze_disguise_equipment"), Material.class); + + Tag ITEMS_GOAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("goat_food"), Material.class); + + Tag ITEMS_GOLD_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_ores"), Material.class); + + Tag ITEMS_GOLD_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_tool_materials"), Material.class); + + Tag ITEMS_HANGING_SIGNS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hanging_signs"), Material.class); + + Tag ITEMS_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("head_armor"), Material.class); + + Tag ITEMS_HOES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoes"), Material.class); + + Tag ITEMS_HOGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoglin_food"), Material.class); + + Tag ITEMS_HORSE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_food"), Material.class); + + Tag ITEMS_HORSE_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_tempt_items"), Material.class); + + Tag ITEMS_IGNORED_BY_PIGLIN_BABIES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ignored_by_piglin_babies"), Material.class); + + Tag ITEMS_IRON_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("iron_ores"), Material.class); + + Tag ITEMS_IRON_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("iron_tool_materials"), Material.class); + + Tag ITEMS_JUNGLE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("jungle_logs"), Material.class); + + Tag ITEMS_LAPIS_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("lapis_ores"), Material.class); + + Tag ITEMS_LEAVES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("leaves"), Material.class); + + Tag ITEMS_LECTERN_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("lectern_books"), Material.class); + + Tag ITEMS_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("leg_armor"), Material.class); + + Tag ITEMS_LLAMA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_food"), Material.class); + + Tag ITEMS_LLAMA_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_tempt_items"), Material.class); + + Tag ITEMS_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("logs"), Material.class); + + Tag ITEMS_LOGS_THAT_BURN = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("logs_that_burn"), Material.class); + + Tag ITEMS_MANGROVE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("mangrove_logs"), Material.class); + + Tag ITEMS_MAP_INVISIBILITY_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("map_invisibility_equipment"), Material.class); + + Tag ITEMS_MEAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("meat"), Material.class); + + Tag ITEMS_NETHERITE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("netherite_tool_materials"), Material.class); + + Tag ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class); + + Tag ITEMS_NOTEBLOCK_TOP_INSTRUMENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("noteblock_top_instruments"), Material.class); + + Tag ITEMS_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("oak_logs"), Material.class); + + Tag ITEMS_OCELOT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ocelot_food"), Material.class); + + Tag ITEMS_PALE_OAK_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pale_oak_logs"), Material.class); + + Tag ITEMS_PANDA_EATS_FROM_GROUND = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_eats_from_ground"), Material.class); + + Tag ITEMS_PANDA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_food"), Material.class); + + Tag ITEMS_PARROT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_food"), Material.class); + + Tag ITEMS_PARROT_POISONOUS_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_poisonous_food"), Material.class); + + Tag ITEMS_PICKAXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pickaxes"), Material.class); + + Tag ITEMS_PIG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pig_food"), Material.class); + + Tag ITEMS_PIGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_food"), Material.class); + + Tag ITEMS_PIGLIN_LOVED = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_loved"), Material.class); + + Tag ITEMS_PIGLIN_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_preferred_weapons"), Material.class); + + Tag ITEMS_PIGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_repellents"), Material.class); + + Tag ITEMS_PIGLIN_SAFE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_safe_armor"), Material.class); + + Tag ITEMS_PILLAGER_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pillager_preferred_weapons"), Material.class); + + Tag ITEMS_PLANKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("planks"), Material.class); + + Tag ITEMS_RABBIT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("rabbit_food"), Material.class); + + Tag ITEMS_RAILS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("rails"), Material.class); + + Tag ITEMS_REDSTONE_ORES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("redstone_ores"), Material.class); + + Tag ITEMS_REPAIRS_CHAIN_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_chain_armor"), Material.class); + + Tag ITEMS_REPAIRS_DIAMOND_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_diamond_armor"), Material.class); + + Tag ITEMS_REPAIRS_GOLD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_gold_armor"), Material.class); + + Tag ITEMS_REPAIRS_IRON_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_iron_armor"), Material.class); + + Tag ITEMS_REPAIRS_LEATHER_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_leather_armor"), Material.class); + + Tag ITEMS_REPAIRS_NETHERITE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_netherite_armor"), Material.class); + + Tag ITEMS_REPAIRS_TURTLE_HELMET = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_turtle_helmet"), Material.class); + + Tag ITEMS_REPAIRS_WOLF_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_wolf_armor"), Material.class); + + Tag ITEMS_SAND = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sand"), Material.class); + + Tag ITEMS_SAPLINGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("saplings"), Material.class); + + Tag ITEMS_SHEEP_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sheep_food"), Material.class); + + Tag ITEMS_SHOVELS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("shovels"), Material.class); + + Tag ITEMS_SHULKER_BOXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("shulker_boxes"), Material.class); + + Tag ITEMS_SIGNS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("signs"), Material.class); + + Tag ITEMS_SKELETON_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("skeleton_preferred_weapons"), Material.class); + + Tag ITEMS_SKULLS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("skulls"), Material.class); + + Tag ITEMS_SLABS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("slabs"), Material.class); + + Tag ITEMS_SMALL_FLOWERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("small_flowers"), Material.class); + + Tag ITEMS_SMELTS_TO_GLASS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("smelts_to_glass"), Material.class); + + Tag ITEMS_SNIFFER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sniffer_food"), Material.class); + + Tag ITEMS_SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); + + Tag ITEMS_SPRUCE_LOGS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("spruce_logs"), Material.class); + + Tag ITEMS_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stairs"), Material.class); + + Tag ITEMS_STONE_BRICKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_bricks"), Material.class); + + Tag ITEMS_STONE_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_buttons"), Material.class); + + Tag ITEMS_STONE_CRAFTING_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_crafting_materials"), Material.class); + + Tag ITEMS_STONE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_tool_materials"), Material.class); + + Tag ITEMS_STRIDER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_food"), Material.class); + + Tag ITEMS_STRIDER_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_tempt_items"), Material.class); + + Tag ITEMS_SWORDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("swords"), Material.class); + + Tag ITEMS_TERRACOTTA = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("terracotta"), Material.class); + + Tag ITEMS_TRAPDOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trapdoors"), Material.class); + + Tag ITEMS_TRIM_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trim_materials"), Material.class); + + Tag ITEMS_TRIMMABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trimmable_armor"), Material.class); + + Tag ITEMS_TURTLE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("turtle_food"), Material.class); + + Tag ITEMS_VILLAGER_PICKS_UP = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_picks_up"), Material.class); + + Tag ITEMS_VILLAGER_PLANTABLE_SEEDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_plantable_seeds"), Material.class); + + Tag ITEMS_WALLS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("walls"), Material.class); + + Tag ITEMS_WARPED_STEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("warped_stems"), Material.class); + + Tag ITEMS_WART_BLOCKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wart_blocks"), Material.class); + + Tag ITEMS_WITHER_SKELETON_DISLIKED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wither_skeleton_disliked_weapons"), Material.class); + + Tag ITEMS_WOLF_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wolf_food"), Material.class); + + Tag ITEMS_WOODEN_BUTTONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_buttons"), Material.class); + + Tag ITEMS_WOODEN_DOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_doors"), Material.class); + + Tag ITEMS_WOODEN_FENCES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_fences"), Material.class); + + Tag ITEMS_WOODEN_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_pressure_plates"), Material.class); + + Tag ITEMS_WOODEN_SLABS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_slabs"), Material.class); + + Tag ITEMS_WOODEN_STAIRS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_stairs"), Material.class); + + Tag ITEMS_WOODEN_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_tool_materials"), Material.class); + + Tag ITEMS_WOODEN_TRAPDOORS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_trapdoors"), Material.class); + + Tag ITEMS_WOOL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool"), Material.class); + + Tag ITEMS_WOOL_CARPETS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wool_carpets"), Material.class); + + String REGISTRY_FLUIDS = "fluids"; + + Tag FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class); + + Tag FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class); + + String REGISTRY_ENTITY_TYPES = "entity_types"; + + Tag ENTITY_TYPES_AQUATIC = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("aquatic"), EntityType.class); + + Tag ENTITY_TYPES_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arrows"), EntityType.class); + + Tag ENTITY_TYPES_ARTHROPOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arthropod"), EntityType.class); + + Tag ENTITY_TYPES_AXOLOTL_ALWAYS_HOSTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_always_hostiles"), EntityType.class); + + Tag ENTITY_TYPES_AXOLOTL_HUNT_TARGETS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_hunt_targets"), EntityType.class); + + Tag ENTITY_TYPES_BEEHIVE_INHABITORS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("beehive_inhabitors"), EntityType.class); + + Tag ENTITY_TYPES_BOAT = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("boat"), EntityType.class); + + Tag ENTITY_TYPES_CAN_BREATHE_UNDER_WATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_breathe_under_water"), EntityType.class); + + Tag ENTITY_TYPES_CAN_EQUIP_SADDLE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_equip_saddle"), EntityType.class); + + Tag ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); + + Tag ENTITY_TYPES_CAN_WEAR_HORSE_ARMOR = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_wear_horse_armor"), EntityType.class); + + Tag ENTITY_TYPES_DEFLECTS_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_projectiles"), EntityType.class); + + Tag ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class); + + Tag ENTITY_TYPES_FALL_DAMAGE_IMMUNE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("fall_damage_immune"), EntityType.class); + + Tag ENTITY_TYPES_FREEZE_HURTS_EXTRA_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_hurts_extra_types"), EntityType.class); + + Tag ENTITY_TYPES_FREEZE_IMMUNE_ENTITY_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_immune_entity_types"), EntityType.class); + + Tag ENTITY_TYPES_FROG_FOOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("frog_food"), EntityType.class); + + Tag ENTITY_TYPES_IGNORES_POISON_AND_REGEN = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("ignores_poison_and_regen"), EntityType.class); + + Tag ENTITY_TYPES_ILLAGER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager"), EntityType.class); + + Tag ENTITY_TYPES_ILLAGER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager_friends"), EntityType.class); + + Tag ENTITY_TYPES_IMMUNE_TO_INFESTED = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_infested"), EntityType.class); + + Tag ENTITY_TYPES_IMMUNE_TO_OOZING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_oozing"), EntityType.class); + + Tag ENTITY_TYPES_IMPACT_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("impact_projectiles"), EntityType.class); + + Tag ENTITY_TYPES_INVERTED_HEALING_AND_HARM = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("inverted_healing_and_harm"), EntityType.class); + + Tag ENTITY_TYPES_NO_ANGER_FROM_WIND_CHARGE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("no_anger_from_wind_charge"), EntityType.class); + + Tag ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); + + Tag ENTITY_TYPES_NOT_SCARY_FOR_PUFFERFISH = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("not_scary_for_pufferfish"), EntityType.class); + + Tag ENTITY_TYPES_POWDER_SNOW_WALKABLE_MOBS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("powder_snow_walkable_mobs"), EntityType.class); + + Tag ENTITY_TYPES_RAIDERS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("raiders"), EntityType.class); + + Tag ENTITY_TYPES_REDIRECTABLE_PROJECTILE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("redirectable_projectile"), EntityType.class); + + Tag ENTITY_TYPES_SENSITIVE_TO_BANE_OF_ARTHROPODS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_bane_of_arthropods"), EntityType.class); + + Tag ENTITY_TYPES_SENSITIVE_TO_IMPALING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_impaling"), EntityType.class); + + Tag ENTITY_TYPES_SENSITIVE_TO_SMITE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_smite"), EntityType.class); + + Tag ENTITY_TYPES_SKELETONS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("skeletons"), EntityType.class); + + Tag ENTITY_TYPES_UNDEAD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("undead"), EntityType.class); + + Tag ENTITY_TYPES_WITHER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("wither_friends"), EntityType.class); + + Tag ENTITY_TYPES_ZOMBIES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("zombies"), EntityType.class); + + String REGISTRY_GAME_EVENTS = "game_events"; + + Tag GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class); + + Tag GAME_EVENT_IGNORE_VIBRATIONS_SNEAKING = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("ignore_vibrations_sneaking"), GameEvent.class); + + Tag GAME_EVENT_SHRIEKER_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("shrieker_can_listen"), GameEvent.class); + + Tag GAME_EVENT_VIBRATIONS = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("vibrations"), GameEvent.class); + + Tag GAME_EVENT_WARDEN_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("warden_can_listen"), GameEvent.class); + // End generate - Tag /** * @deprecated {@link #WOOL_CARPETS}. */ @Deprecated(since = "1.19") Tag CARPETS = WOOL_CARPETS; /** - * Vanilla block tag representing all wooden doors. + * Vanilla block tag representing all blocks which dead bushes may be placed on. + * + * @deprecated partially replaced by {@link #DRY_VEGETATION_MAY_PLACE_ON} */ - Tag WOODEN_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_doors"), Material.class); - /** - * Vanilla block tag representing all doors which can be opened by mobs. - */ - Tag MOB_INTERACTABLE_DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mob_interactable_doors"), Material.class); - /** - * Vanilla block tag representing all wooden stairs. - */ - Tag WOODEN_STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_stairs"), Material.class); - /** - * Vanilla block tag representing all wooden slabs. - */ - Tag WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class); - /** - * Vanilla block tag representing all wooden fences. - */ - Tag WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class); - /** - * Vanilla block tag representing all pressure plates. - */ - Tag PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pressure_plates"), Material.class); - /** - * Vanilla block tag representing all wooden pressure plates. - */ - Tag WOODEN_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_pressure_plates"), Material.class); - /** - * Vanilla block tag representing all stone pressure plates. - */ - Tag STONE_PRESSURE_PLATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_pressure_plates"), Material.class); - /** - * Vanilla block tag representing all wooden trapdoors. - */ - Tag WOODEN_TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_trapdoors"), Material.class); - /** - * Vanilla block tag representing all doors (inherits from - * {@link #WOODEN_DOORS}. - */ - Tag DOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("doors"), Material.class); - /** - * Vanilla block tag representing all sapling variants. - */ - Tag SAPLINGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("saplings"), Material.class); - /** - * Vanilla block tag representing all log and bark variants that burn. - */ - Tag LOGS_THAT_BURN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs_that_burn"), Material.class); - /** - * Vanilla block tag representing all log and bark variants. - */ - Tag LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("logs"), Material.class); - /** - * Vanilla block tag representing all dark oak log and bark variants. - */ - Tag DARK_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dark_oak_logs"), Material.class); - /** - * Vanilla block tag representing all pale oak log and bark variants. - */ - Tag PALE_OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("pale_oak_logs"), Material.class); - /** - * Vanilla block tag representing all oak log and bark variants. - */ - Tag OAK_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("oak_logs"), Material.class); - /** - * Vanilla block tag representing all birch log and bark variants. - */ - Tag BIRCH_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("birch_logs"), Material.class); - /** - * Vanilla block tag representing all acacia log and bark variants. - */ - Tag ACACIA_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("acacia_logs"), Material.class); - /** - * Vanilla block tag representing all cherry log and bark variants. - */ - Tag CHERRY_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cherry_logs"), Material.class); - /** - * Vanilla block tag representing all jungle log and bark variants. - */ - Tag JUNGLE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("jungle_logs"), Material.class); - /** - * Vanilla block tag representing all spruce log and bark variants. - */ - Tag SPRUCE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("spruce_logs"), Material.class); - /** - * Vanilla block tag representing all mangrove log and bark variants. - */ - Tag MANGROVE_LOGS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs"), Material.class); - /** - * Vanilla block tag representing all crimson stems. - */ - Tag CRIMSON_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crimson_stems"), Material.class); - /** - * Vanilla block tag representing all warped stems. - */ - Tag WARPED_STEMS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("warped_stems"), Material.class); - /** - * Vanilla block tag representing all bamboo blocks. - */ - Tag BAMBOO_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_blocks"), Material.class); - /** - * Vanilla block tag representing all banner blocks. - */ - Tag BANNERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("banners"), Material.class); - /** - * Vanilla block tag representing all sand blocks. - */ - Tag SAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sand"), Material.class); - /** - * Vanilla block tag representing all blocks which smelt to glass in a furnace. - */ - Tag SMELTS_TO_GLASS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("smelts_to_glass"), Material.class); - /** - * Vanilla block tag representing all stairs. - */ - Tag STAIRS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stairs"), Material.class); - /** - * Vanilla block tag representing all slabs. - */ - Tag SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class); - /** - * Vanilla block tag representing all walls. - */ - Tag WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class); - /** - * Vanilla block tag representing all damaged and undamaged anvils. - */ - Tag ANVIL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("anvil"), Material.class); - /** - * Vanilla block tag representing all Minecart rails. - */ - Tag RAILS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rails"), Material.class); - /** - * Vanilla block tag representing all leaves fans. - */ - Tag LEAVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("leaves"), Material.class); - /** - * Vanilla block tag representing all trapdoors (inherits from - * {@link #WOODEN_TRAPDOORS}. - */ - Tag TRAPDOORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trapdoors"), Material.class); - /** - * Vanilla block tag representing all empty and filled flower pots. - */ - Tag FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class); - /** - * Vanilla block tag representing all small flowers. - */ - Tag SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class); - /** - * Vanilla block tag representing all beds. - */ - Tag BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class); - /** - * Vanilla block tag representing all fences. - */ - Tag FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class); - /** - * Vanilla block tag representing all flowers. - */ - Tag FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flowers"), Material.class); - /** - * Vanilla block tag representing all blocks which attract bees. - */ - Tag BEE_ATTRACTIVE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bee_attractive"), Material.class); - /** - * Vanilla block tag representing all piglin repellents. - */ - Tag PIGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("piglin_repellents"), Material.class); - /** - * Vanilla block tag representing all gold ores. - */ - Tag GOLD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("gold_ores"), Material.class); - /** - * Vanilla block tag representing all iron ores. - */ - Tag IRON_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("iron_ores"), Material.class); - /** - * Vanilla block tag representing all diamond ores. - */ - Tag DIAMOND_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("diamond_ores"), Material.class); - /** - * Vanilla block tag representing all redstone ores. - */ - Tag REDSTONE_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("redstone_ores"), Material.class); - /** - * Vanilla block tag representing all lapis ores. - */ - Tag LAPIS_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lapis_ores"), Material.class); - /** - * Vanilla block tag representing all coal ores. - */ - Tag COAL_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coal_ores"), Material.class); - /** - * Vanilla block tag representing all emerald ores. - */ - Tag EMERALD_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("emerald_ores"), Material.class); - /** - * Vanilla block tag representing all copper ores. - */ - Tag COPPER_ORES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("copper_ores"), Material.class); - /** - * Vanilla block tag representing all candles. - */ - Tag CANDLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candles"), Material.class); - /** - * Vanilla block tag representing all dirt. - */ - Tag DIRT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt"), Material.class); - /** - * Vanilla block tag representing all terracotta. - */ - Tag TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("terracotta"), Material.class); - /** - * Vanilla block tag representing all badlands terracotta. - */ - Tag BADLANDS_TERRACOTTA = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("badlands_terracotta"), Material.class); - /** - * Vanilla block tag representing all concrete powder. - */ - Tag CONCRETE_POWDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("concrete_powder"), Material.class); - /** - * Vanilla block tag representing all blocks which complete the find tree - * tutorial. - */ - Tag COMPLETES_FIND_TREE_TUTORIAL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("completes_find_tree_tutorial"), Material.class); - /** - * Vanilla block tag denoting blocks that enderman may pick up and hold. - */ - Tag ENDERMAN_HOLDABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enderman_holdable"), Material.class); - /** - * Vanilla block tag denoting ice blocks. - */ - Tag ICE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ice"), Material.class); - /** - * Vanilla block tag denoting all valid mob spawn positions. - */ - Tag VALID_SPAWN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("valid_spawn"), Material.class); - /** - * Vanilla block tag denoting impermeable blocks which do not drip fluids. - */ - Tag IMPERMEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("impermeable"), Material.class); - /** - * Vanilla block tag denoting all underwater blocks which may be bonemealed. - */ - Tag UNDERWATER_BONEMEALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("underwater_bonemeals"), Material.class); - /** - * Vanilla block tag representing all coral blocks. - */ - Tag CORAL_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_blocks"), Material.class); - /** - * Vanilla block tag representing all wall corals. - */ - Tag WALL_CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_corals"), Material.class); - /** - * Vanilla block tag representing all coral plants. - */ - Tag CORAL_PLANTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("coral_plants"), Material.class); - /** - * Vanilla block tag representing all coral. - */ - Tag CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class); - /** - * Vanilla block tag denoting all blocks bamboo may be planted on. - */ - Tag BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class); - /** - * Vanilla block tag representing all standing signs. - */ - Tag STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class); - /** - * Vanilla block tag representing all wall signs. - */ - Tag WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class); - /** - * Vanilla block tag representing all regular signs. - */ - Tag SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class); - /** - * Vanilla block tag representing all ceiling signs. - */ - Tag CEILING_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ceiling_hanging_signs"), Material.class); - /** - * Vanilla block tag representing all wall hanging signs. - */ - Tag WALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_hanging_signs"), Material.class); - /** - * Vanilla block tag representing all hanging signs. - */ - Tag ALL_HANGING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_hanging_signs"), Material.class); - /** - * Vanilla block tag representing all signs, regardless of type. - */ - Tag ALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("all_signs"), Material.class); - /** - * Vanilla block tag representing all blocks immune to dragons. - */ - Tag DRAGON_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_immune"), Material.class); - /** - * Vanilla block tag representing all blocks transparent to the ender - * dragon. - */ - Tag DRAGON_TRANSPARENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dragon_transparent"), Material.class); - /** - * Vanilla block tag representing all blocks immune to withers. - */ - Tag WITHER_IMMUNE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_immune"), Material.class); - /** - * Vanilla block tag representing all base blocks used for wither summoning. - */ - Tag WITHER_SUMMON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wither_summon_base_blocks"), Material.class); - /** - * Vanilla block tag representing all beehives. - */ - Tag BEEHIVES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beehives"), Material.class); - /** - * Vanilla block tag representing all crops. - */ - Tag CROPS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crops"), Material.class); - /** - * Vanilla block tag representing all bee growables. - */ - Tag BEE_GROWABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bee_growables"), Material.class); - /** - * Vanilla block tag representing all portals. - */ - Tag PORTALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("portals"), Material.class); - /** - * Vanilla block tag representing all fire blocks. - */ - Tag FIRE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fire"), Material.class); - /** - * Vanilla block tag representing all nylium blocks. - */ - Tag NYLIUM = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nylium"), Material.class); - /** - * Vanilla block tag representing all wart blocks. - */ - Tag WART_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wart_blocks"), Material.class); - /** - * Vanilla block tag representing all beacon base blocks. - */ - Tag BEACON_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beacon_base_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks affected by the soul speed - * enchantment. - */ - Tag SOUL_SPEED_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_speed_blocks"), Material.class); - /** - * Vanilla block tag representing all wall post overrides. - */ - Tag WALL_POST_OVERRIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_post_override"), Material.class); - /** - * Vanilla block tag representing all climbable blocks. - */ - Tag CLIMBABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("climbable"), Material.class); - /** - * Vanilla block tag representing all blocks which reset fall damage. - */ - Tag FALL_DAMAGE_RESETTING = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fall_damage_resetting"), Material.class); - /** - * Vanilla block tag representing all shulker boxes. - */ - Tag SHULKER_BOXES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("shulker_boxes"), Material.class); - /** - * Vanilla block tag representing all hoglin repellents. - */ - Tag HOGLIN_REPELLENTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("hoglin_repellents"), Material.class); - /** - * Vanilla block tag representing all soul fire base blocks. - */ - Tag SOUL_FIRE_BASE_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("soul_fire_base_blocks"), Material.class); - /** - * Vanilla block tag representing all warm strider blocks. - */ - Tag STRIDER_WARM_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("strider_warm_blocks"), Material.class); - /** - * Vanilla block tag representing all campfires. - */ - Tag CAMPFIRES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("campfires"), Material.class); - /** - * Vanilla block tag representing all blocks guarded by piglins. - */ - Tag GUARDED_BY_PIGLINS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("guarded_by_piglins"), Material.class); - /** - * Vanilla block tag representing all blocks that prevent inside mob - * spawning. - */ - Tag PREVENT_MOB_SPAWNING_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("prevent_mob_spawning_inside"), Material.class); - /** - * Vanilla block tag representing all fence gates. - */ - Tag FENCE_GATES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fence_gates"), Material.class); - /** - * Vanilla block tag representing all unstable bottom center blocks. - */ - Tag UNSTABLE_BOTTOM_CENTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("unstable_bottom_center"), Material.class); - Tag MUSHROOM_GROW_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mushroom_grow_block"), Material.class); - - /** - * Vanilla block tag representing all blocks that burn forever in the - * overworld. - */ - Tag INFINIBURN_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_overworld"), Material.class); - /** - * Vanilla block tag representing all blocks that burn forever in the - * nether. - */ - Tag INFINIBURN_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_nether"), Material.class); - /** - * Vanilla block tag representing all blocks that burn forever in the end. - */ - Tag INFINIBURN_END = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("infiniburn_end"), Material.class); - /** - * Vanilla block tag representing the overworld base material. - */ - Tag BASE_STONE_OVERWORLD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_overworld"), Material.class); - /** - * Vanilla block tag representing all blocks that may be replaced by ores. - */ - Tag STONE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("stone_ore_replaceables"), Material.class); - /** - * Vanilla block tag representing all blocks that may be replaced by - * deepslate ores. - */ - Tag DEEPSLATE_ORE_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("deepslate_ore_replaceables"), Material.class); - /** - * Vanilla block tag representing the nether base material. - */ - Tag BASE_STONE_NETHER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("base_stone_nether"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by the overworld - * carver. - */ - Tag OVERWORLD_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("overworld_carver_replaceables"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by the nether - * carver. - */ - Tag NETHER_CARVER_REPLACEABLES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("nether_carver_replaceables"), Material.class); - /** - * Vanilla block tag representing all candle cakes. - */ - Tag CANDLE_CAKES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("candle_cakes"), Material.class); - /** - * Vanilla block tag representing all cauldrons. - */ - Tag CAULDRONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cauldrons"), Material.class); - /** - * Vanilla block tag representing all blocks that make crystal sounds. - */ - Tag CRYSTAL_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("crystal_sound_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks that play muffled step sounds. - */ - Tag INSIDE_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("inside_step_sound_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks that play combination step sounds. - */ - Tag COMBINATION_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("combination_step_sound_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks that play step sounds with camels on sand. - */ - Tag CAMEL_SAND_STEP_SOUND_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("camel_sand_step_sound_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks that block vibration signals. - */ - Tag OCCLUDES_VIBRATION_SIGNALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("occludes_vibration_signals"), Material.class); - /** - * Vanilla block tag representing all blocks that dampen the propagation of - * vibration signals. - */ - Tag DAMPENS_VIBRATIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dampens_vibrations"), Material.class); + @Deprecated(since = "1.21.5", forRemoval = true) + Tag DEAD_BUSH_MAY_PLACE_ON = DRY_VEGETATION_MAY_PLACE_ON; /** * Vanilla block tag representing all blocks that are replaceable by * dripstone. + * + * @deprecated use {@link #DRIPSTONE_REPLACEABLE_BLOCKS} */ - Tag DRIPSTONE_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dripstone_replaceable_blocks"), Material.class); - /** - * Vanilla block tag representing all cave vines. - */ - Tag CAVE_VINES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("cave_vines"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by moss. - */ - Tag MOSS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("moss_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by lush ground. - */ - Tag LUSH_GROUND_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lush_ground_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by azalea root. - */ - Tag AZALEA_ROOT_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_root_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks which small dripleaf can be - * placed on. - */ - Tag SMALL_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_dripleaf_placeable"), Material.class); - /** - * Vanilla block tag representing all blocks which big dripleaf can be - * placed on. - */ - Tag BIG_DRIPLEAF_PLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("big_dripleaf_placeable"), Material.class); - /** - * Vanilla block tag representing all snow blocks. - */ - Tag SNOW = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow"), Material.class); - /** - * Vanilla block tag representing all blocks mineable with an axe. - */ - Tag MINEABLE_AXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/axe"), Material.class); - /** - * Vanilla block tag representing all blocks mineable with a hoe. - */ - Tag MINEABLE_HOE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/hoe"), Material.class); - /** - * Vanilla block tag representing all blocks mineable with a pickaxe. - */ - Tag MINEABLE_PICKAXE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/pickaxe"), Material.class); - /** - * Vanilla block tag representing all blocks mineable with a shovel. - */ - Tag MINEABLE_SHOVEL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mineable/shovel"), Material.class); - /** - * Vanilla block tag representing all blocks that can be efficiently mined with a sword. - */ - Tag SWORD_EFFICIENT = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sword_efficient"), Material.class); - /** - * Vanilla block tag representing all blocks which require a diamond tool. - */ - Tag NEEDS_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_diamond_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which require an iron tool. - */ - Tag NEEDS_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_iron_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which require a stone tool. - */ - Tag NEEDS_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("needs_stone_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a netherite tool. - */ - Tag INCORRECT_FOR_NETHERITE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_netherite_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a diamond tool. - */ - Tag INCORRECT_FOR_DIAMOND_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_diamond_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a iron tool. - */ - Tag INCORRECT_FOR_IRON_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_iron_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a stone tool. - */ - Tag INCORRECT_FOR_STONE_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_stone_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a gold tool. - */ - Tag INCORRECT_FOR_GOLD_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_gold_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not drop items with a wooden tool. - */ - Tag INCORRECT_FOR_WOODEN_TOOL = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("incorrect_for_wooden_tool"), Material.class); - /** - * Vanilla block tag representing all blocks which will not be replaced by - * world generation features. - */ - Tag FEATURES_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("features_cannot_replace"), Material.class); - /** - * Vanilla block tag representing all blocks which lava pools will not - * replace. - */ - Tag LAVA_POOL_STONE_CANNOT_REPLACE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("lava_pool_stone_cannot_replace"), Material.class); - /** - * Vanilla block tag representing all blocks which geodes will not spawn in. - */ - Tag GEODE_INVALID_BLOCKS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("geode_invalid_blocks"), Material.class); - /** - * Vanilla block tag representing all blocks which frogs prefer to jump to. - */ - Tag FROG_PREFER_JUMP_TO = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frog_prefer_jump_to"), Material.class); - /** - * Vanilla block tag representing all blocks which can be replaced by skulk. - */ - Tag SCULK_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks which can be replaced by skulk - * during world generation. - */ - Tag SCULK_REPLACEABLE_WORLD_GEN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sculk_replaceable_world_gen"), Material.class); - /** - * Vanilla block tag representing all blocks which can be replaced by - * ancient cities. - */ - Tag ANCIENT_CITY_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("ancient_city_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks which resonate vibrations. - */ - Tag VIBRATION_RESONATORS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("vibration_resonators"), Material.class); - /** - * Vanilla block tag representing all blocks which animals will spawn on. - */ - Tag ANIMALS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("animals_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which armadillos will spawn on. - */ - Tag ARMADILLO_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("armadillo_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which axolotls will spawn on. - */ - Tag AXOLOTLS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("axolotls_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which goats will spawn on. - */ - Tag GOATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("goats_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which mooshrooms will spawn on. - */ - Tag MOOSHROOMS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mooshrooms_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which parrots will spawn on. - */ - Tag PARROTS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("parrots_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which polar bears will spawn - * on. - */ - Tag POLAR_BEARS_SPAWNABLE_ON_ALTERNATE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("polar_bears_spawnable_on_alternate"), Material.class); - /** - * Vanilla block tag representing all blocks which rabbits will spawn on. - */ - Tag RABBITS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("rabbits_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which foxes will spawn on. - */ - Tag FOXES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("foxes_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which wolves will spawn on. - */ - Tag WOLVES_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wolves_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which frogs will spawn on. - */ - Tag FROGS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("frogs_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which bats will spawn on. - */ - Tag BATS_SPAWNABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bats_spawnable_on"), Material.class); - /** - * Vanilla block tag representing all blocks which azaleas will grow on. - */ - Tag AZALEA_GROWS_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("azalea_grows_on"), Material.class); - /** - * Vanilla block tag representing all blocks which may be converted to mud. - */ - Tag CONVERTABLE_TO_MUD = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("convertable_to_mud"), Material.class); - /** - * Vanilla block tag representing all blocks which mangrove logs can grow - * through. - */ - Tag MANGROVE_LOGS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_logs_can_grow_through"), Material.class); - /** - * Vanilla block tag representing all blocks which mangrove roots can grow - * through. - */ - Tag MANGROVE_ROOTS_CAN_GROW_THROUGH = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("mangrove_roots_can_grow_through"), Material.class); - /** - * Vanilla block tag representing all blocks which dead bushes may be placed - * on. - */ - Tag DEAD_BUSH_MAY_PLACE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dead_bush_may_place_on"), Material.class); - /** - * Vanilla block tag representing all blocks which snap dropped goat horns. - */ - Tag SNAPS_GOAT_HORN = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snaps_goat_horn"), Material.class); - /** - * Vanilla block tag representing all blocks replaceable by growing trees. - */ - Tag REPLACEABLE_BY_TREES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable_by_trees"), Material.class); - /** - * Vanilla block tag representing blocks which snow cannot survive on. - */ - Tag SNOW_LAYER_CANNOT_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_cannot_survive_on"), Material.class); - /** - * Vanilla block tag representing blocks which snow can survive on. - */ - Tag SNOW_LAYER_CAN_SURVIVE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("snow_layer_can_survive_on"), Material.class); - /** - * Vanilla block tag representing blocks which cannot be dismounted into. - */ - Tag INVALID_SPAWN_INSIDE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("invalid_spawn_inside"), Material.class); - /** - * Vanilla block tag representing blocks which can be dug by sniffers. - */ - Tag SNIFFER_DIGGABLE_BLOCK = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_diggable_block"), Material.class); - /** - * Vanilla block tag representing all blocks which booster sniffer egg hatching. - */ - Tag SNIFFER_EGG_HATCH_BOOST = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("sniffer_egg_hatch_boost"), Material.class); - /** - * Vanilla block tag representing all blocks which can be replaced by trail ruins. - */ - Tag TRAIL_RUINS_REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("trail_ruins_replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks which are replaceable. - */ - Tag REPLACEABLE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("replaceable"), Material.class); - /** - * Vanilla block tag representing all blocks which provide enchantment power. - */ - Tag ENCHANTMENT_POWER_PROVIDER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_provider"), Material.class); - /** - * Vanilla block tag representing all blocks which transmit enchantment power. - */ - Tag ENCHANTMENT_POWER_TRANSMITTER = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("enchantment_power_transmitter"), Material.class); - /** - * Vanilla block tag representing all blocks which do not destroy farmland when placed. - */ - Tag MAINTAINS_FARMLAND = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("maintains_farmland"), Material.class); - /** - * Vanilla block tag representing all blocks which block wind charge explosions. - */ - Tag BLOCKS_WIND_CHARGE_EXPLOSIONS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("blocks_wind_charge_explosions"), Material.class); - /** - * Vanilla block tag representing solid blocks which do not block hopper operation. - */ - Tag DOES_NOT_BLOCK_HOPPERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("does_not_block_hoppers"), Material.class); - /** - * Vanilla block tag representing all blocks that resemble air. - */ - Tag AIR = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("air"), Material.class); - /** - * Key for the built in item registry. - */ - String REGISTRY_ITEMS = "items"; - /** - * Vanilla item tag representing all items loved by piglins. - */ - Tag ITEMS_PIGLIN_LOVED = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_loved"), Material.class); - /** - * Vanilla item tag representing all items ignored by piglin babies. - */ - Tag IGNORED_BY_PIGLIN_BABIES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ignored_by_piglin_babies"), Material.class); - /** - * Vanilla item tag representing all items which will prevent piglins from being angered. - */ - Tag ITEMS_PIGLIN_SAFE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_safe_armor"), Material.class); - /** - * Vanilla item tag representing all items which can be used to duplicate Allays when they are dancing. - */ - Tag ITEMS_DUPLICATES_ALLAYS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("duplicates_allays"), Material.class); - /** - * Vanilla item tag representing all brewing stand fuel items. - */ - Tag ITEMS_BREWING_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("brewing_fuel"), Material.class); - /** - * Vanilla item tag representing all meat. - */ - Tag ITEMS_MEAT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("meat"), Material.class); - /** - * Vanilla item tag representing all sniffer food. - */ - Tag ITEMS_SNIFFER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sniffer_food"), Material.class); - /** - * Vanilla item tag representing all piglin food. - */ - Tag ITEMS_PIGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_food"), Material.class); + @Deprecated(since = "1.21.4", forRemoval = true) + Tag DRIPSTONE_REPLACEABLE = DRIPSTONE_REPLACEABLE_BLOCKS; /** * Vanilla item tag representing all piglin food. * @@ -834,10 +880,6 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.20.5") Tag PIGLIN_FOOD = ITEMS_PIGLIN_FOOD; - /** - * Vanilla item tag representing all fox food. - */ - Tag ITEMS_FOX_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fox_food"), Material.class); /** * Vanilla item tag representing all fox food. * @@ -845,214 +887,6 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.20.5") Tag FOX_FOOD = ITEMS_FOX_FOOD; - /** - * Vanilla item tag representing all cow food. - */ - Tag ITEMS_COW_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cow_food"), Material.class); - /** - * Vanilla item tag representing all goat food. - */ - Tag ITEMS_GOAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("goat_food"), Material.class); - /** - * Vanilla item tag representing all sheep food. - */ - Tag ITEMS_SHEEP_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("sheep_food"), Material.class); - /** - * Vanilla item tag representing all wolf food. - */ - Tag ITEMS_WOLF_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wolf_food"), Material.class); - /** - * Vanilla item tag representing all cat food. - */ - Tag ITEMS_CAT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cat_food"), Material.class); - /** - * Vanilla item tag representing all horse food. - */ - Tag ITEMS_HORSE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_food"), Material.class); - /** - * Vanilla item tag representing all horse tempt items. - */ - Tag ITEMS_HORSE_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("horse_tempt_items"), Material.class); - /** - * Vanilla item tag representing all camel food. - */ - Tag ITEMS_CAMEL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("camel_food"), Material.class); - /** - * Vanilla item tag representing all armadillo food. - */ - Tag ITEMS_ARMADILLO_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("armadillo_food"), Material.class); - /** - * Vanilla item tag representing all bee food. - */ - Tag ITEMS_BEE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bee_food"), Material.class); - /** - * Vanilla item tag representing all chicken food. - */ - Tag ITEMS_CHICKEN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chicken_food"), Material.class); - /** - * Vanilla item tag representing all frog food. - */ - Tag ITEMS_FROG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("frog_food"), Material.class); - /** - * Vanilla item tag representing all hoglin food. - */ - Tag ITEMS_HOGLIN_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoglin_food"), Material.class); - /** - * Vanilla item tag representing all llama food. - */ - Tag ITEMS_LLAMA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_food"), Material.class); - /** - * Vanilla item tag representing all llama tempt items. - */ - Tag ITEMS_LLAMA_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("llama_tempt_items"), Material.class); - /** - * Vanilla item tag representing all ocelot food. - */ - Tag ITEMS_OCELOT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("ocelot_food"), Material.class); - /** - * Vanilla item tag representing all panda food. - */ - Tag ITEMS_PANDA_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_food"), Material.class); - /** - * Vanilla item tag representing all items that a panda will pick up and eat from the ground. - */ - Tag ITEMS_PANDA_EATS_FROM_GROUND = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("panda_eats_from_ground"), Material.class); - /** - * Vanilla item tag representing all pig food. - */ - Tag ITEMS_PIG_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pig_food"), Material.class); - /** - * Vanilla item tag representing all rabbit food. - */ - Tag ITEMS_RABBIT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("rabbit_food"), Material.class); - /** - * Vanilla item tag representing all strider food. - */ - Tag ITEMS_STRIDER_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_food"), Material.class); - /** - * Vanilla item tag representing all strider tempt items. - */ - Tag ITEMS_STRIDER_TEMPT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("strider_tempt_items"), Material.class); - /** - * Vanilla item tag representing all turtle food. - */ - Tag ITEMS_TURTLE_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("turtle_food"), Material.class); - /** - * Vanilla item tag representing all parrot food. - */ - Tag ITEMS_PARROT_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_food"), Material.class); - /** - * Vanilla item tag representing all parrot poisonous food. - */ - Tag ITEMS_PARROT_POISONOUS_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("parrot_poisonous_food"), Material.class); - /** - * Vanilla item tag representing all axolotl food. - */ - Tag ITEMS_AXOLOTL_FOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axolotl_food"), Material.class); - /** - * Vanilla item tag representing all banner items. - */ - Tag ITEMS_BANNERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("banners"), Material.class); - /** - * Vanilla item tag representing all non flammable wood items. - */ - Tag ITEMS_NON_FLAMMABLE_WOOD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("non_flammable_wood"), Material.class); - /** - * Vanilla item tag representing all boat items. - */ - Tag ITEMS_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("boats"), Material.class); - /** - * Vanilla item tag representing all chest boat items. - */ - Tag ITEMS_CHEST_BOATS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_boats"), Material.class); - /** - * Vanilla item tag representing all fish items. - */ - Tag ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class); - /** - * Vanilla item tag representing all music disc items dropped by creepers. - */ - Tag ITEMS_CREEPER_DROP_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_drop_music_discs"), Material.class); - /** - * Vanilla item tag representing all coal items. - */ - Tag ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class); - /** - * Vanilla item tag representing all arrow items. - */ - Tag ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class); - /** - * Vanilla item tag representing all books that may be placed on lecterns. - */ - Tag ITEMS_LECTERN_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("lectern_books"), Material.class); - /** - * Vanilla item tag representing all books that may be placed on bookshelves. - */ - Tag ITEMS_BOOKSHELF_BOOKS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bookshelf_books"), Material.class); - /** - * Vanilla item tag representing all items that may be placed in beacons. - */ - Tag ITEMS_BEACON_PAYMENT_ITEMS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("beacon_payment_items"), Material.class); - /** - * Vanilla item tag representing all wooden tool materials. - */ - Tag ITEMS_WOODEN_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wooden_tool_materials"), Material.class); - /** - * Vanilla item tag representing all stone tool materials. - */ - Tag ITEMS_STONE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_tool_materials"), Material.class); - /** - * Vanilla item tag representing all iron tool materials. - */ - Tag ITEMS_IRON_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("iron_tool_materials"), Material.class); - /** - * Vanilla item tag representing all gold tool materials. - */ - Tag ITEMS_GOLD_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gold_tool_materials"), Material.class); - /** - * Vanilla item tag representing all diamond tool materials. - */ - Tag ITEMS_DIAMOND_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("diamond_tool_materials"), Material.class); - /** - * Vanilla item tag representing all netherite tool materials. - */ - Tag ITEMS_NETHERITE_TOOL_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("netherite_tool_materials"), Material.class); - /** - * Vanilla item tag representing all items which repair leather armor. - */ - Tag ITEMS_REPAIRS_LEATHER_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_leather_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair chain armor. - */ - Tag ITEMS_REPAIRS_CHAIN_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_chain_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair iron armor. - */ - Tag ITEMS_REPAIRS_IRON_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_iron_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair gold armor. - */ - Tag ITEMS_REPAIRS_GOLD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_gold_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair diamond armor. - */ - Tag ITEMS_REPAIRS_DIAMOND_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_diamond_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair netherite armor. - */ - Tag ITEMS_REPAIRS_NETHERITE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_netherite_armor"), Material.class); - /** - * Vanilla item tag representing all items which repair turtle helmets. - */ - Tag ITEMS_REPAIRS_TURTLE_HELMET = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_turtle_helmet"), Material.class); - /** - * Vanilla item tag representing all items which repair wolf armor. - */ - Tag ITEMS_REPAIRS_WOLF_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("repairs_wolf_armor"), Material.class); - /** - * Vanilla item tag representing all stone based materials for crafting. - */ - Tag ITEMS_STONE_CRAFTING_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("stone_crafting_materials"), Material.class); /** * Vanilla item tag representing all furnace materials. * @@ -1060,83 +894,13 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.16.2", forRemoval = true) Tag ITEMS_FURNACE_MATERIALS = ITEMS_STONE_CRAFTING_MATERIALS; - /** - * Vanilla item tag representing all compasses. - */ - Tag ITEMS_COMPASSES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("compasses"), Material.class); - /** - * Vanilla item tag representing all hanging signs. - */ - Tag ITEMS_HANGING_SIGNS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hanging_signs"), Material.class); - /** - * Vanilla item tag representing all items which will ignite creepers when - * interacted with. - */ - Tag ITEMS_CREEPER_IGNITERS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("creeper_igniters"), Material.class); /** * Vanilla item tag representing all items which modify note block sounds when placed on top. + * + * @deprecated use {@link #ITEMS_NOTEBLOCK_TOP_INSTRUMENTS} */ - Tag ITEMS_NOTE_BLOCK_TOP_INSTRUMENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("noteblock_top_instruments"), Material.class); - /** - * Vanilla item tag representing all foot armor. - */ - Tag ITEMS_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("foot_armor"), Material.class); - /** - * Vanilla item tag representing all leg armor. - */ - Tag ITEMS_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("leg_armor"), Material.class); - /** - * Vanilla item tag representing all chest armor. - */ - Tag ITEMS_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("chest_armor"), Material.class); - /** - * Vanilla item tag representing all head armor. - */ - Tag ITEMS_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("head_armor"), Material.class); - /** - * Vanilla item tag representing all skulls. - */ - Tag ITEMS_SKULLS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("skulls"), Material.class); - /** - * Vanilla item tag representing all trimmable armor items. - */ - Tag ITEMS_TRIMMABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trimmable_armor"), Material.class); - /** - * Vanilla item tag representing all materials which can be used for trimming armor. - */ - Tag ITEMS_TRIM_MATERIALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("trim_materials"), Material.class); - /** - * Vanilla item tag representing all decorated pot sherds. - */ - Tag ITEMS_DECORATED_POT_SHERDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_sherds"), Material.class); - /** - * Vanilla item tag representing all decorated pot ingredients. - */ - Tag ITEMS_DECORATED_POT_INGREDIENTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("decorated_pot_ingredients"), Material.class); - /** - * Vanilla item tag representing all swords. - */ - Tag ITEMS_SWORDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("swords"), Material.class); - /** - * Vanilla item tag representing all axes. - */ - Tag ITEMS_AXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("axes"), Material.class); - /** - * Vanilla item tag representing all hoes. - */ - Tag ITEMS_HOES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("hoes"), Material.class); - /** - * Vanilla item tag representing all pickaxes. - */ - Tag ITEMS_PICKAXES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pickaxes"), Material.class); - /** - * Vanilla item tag representing all shovels. - */ - Tag ITEMS_SHOVELS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("shovels"), Material.class); - /** - * Vanilla item tag representing all items which break decorated pots. - */ - Tag ITEMS_BREAKS_DECORATED_POTS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("breaks_decorated_pots"), Material.class); + @Deprecated(since = "1.21.4", forRemoval = true) + Tag ITEMS_NOTE_BLOCK_TOP_INSTRUMENTS = ITEMS_NOTEBLOCK_TOP_INSTRUMENTS; /** * Vanilla item tag representing all tools. * @@ -1146,135 +910,6 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.20.6", forRemoval = true) Tag ITEMS_TOOLS = ITEMS_BREAKS_DECORATED_POTS; - /** - * Vanilla item tag representing all seeds plantable by villagers. - */ - Tag ITEMS_VILLAGER_PLANTABLE_SEEDS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_plantable_seeds"), Material.class); - /** - * Vanilla item tag representing all items which villagers pick up. - */ - Tag ITEMS_VILLAGER_PICKS_UP = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("villager_picks_up"), Material.class); - /** - * Vanilla item tag representing all dyeable items. - */ - Tag ITEMS_DYEABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("dyeable"), Material.class); - /** - * Vanilla item tag representing all furnace minecart fuel. - */ - Tag ITEMS_FURNACE_MINECART_FUEL = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("furnace_minecart_fuel"), Material.class); - /** - * Vanilla item tag representing all bundle items. - */ - Tag ITEMS_BUNDLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("bundles"), Material.class); - /** - * Vanilla item tag representing all skeleton preferred weapons. - */ - Tag ITEMS_SKELETON_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("skeleton_preferred_weapons"), Material.class); - /** - * Vanilla item tag representing all drowned preferred weapons. - */ - Tag ITEMS_DROWNED_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("drowned_preferred_weapons"), Material.class); - /** - * Vanilla item tag representing all piglin preferred weapons. - */ - Tag ITEMS_PIGLIN_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("piglin_preferred_weapons"), Material.class); - /** - * Vanilla item tag representing all pillager preferred weapons. - */ - Tag ITEMS_PILLAGER_PREFERRED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("pillager_preferred_weapons"), Material.class); - /** - * Vanilla item tag representing all wither skeleton disliked weapons. - */ - Tag ITEMS_WITHER_SKELETON_DISLIKED_WEAPONS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("wither_skeleton_disliked_weapons"), Material.class); - /** - * Vanilla item tag representing all enchantable foot armor. - */ - Tag ITEMS_ENCHANTABLE_FOOT_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/foot_armor"), Material.class); - /** - * Vanilla item tag representing all enchantable leg armor. - */ - Tag ITEMS_ENCHANTABLE_LEG_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/leg_armor"), Material.class); - /** - * Vanilla item tag representing all enchantable chest armor. - */ - Tag ITEMS_ENCHANTABLE_CHEST_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/chest_armor"), Material.class); - /** - * Vanilla item tag representing all enchantable head armor. - */ - Tag ITEMS_ENCHANTABLE_HEAD_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/head_armor"), Material.class); - /** - * Vanilla item tag representing all enchantable armor. - */ - Tag ITEMS_ENCHANTABLE_ARMOR = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/armor"), Material.class); - /** - * Vanilla item tag representing all enchantable swords. - */ - Tag ITEMS_ENCHANTABLE_SWORD = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sword"), Material.class); - /** - * Vanilla item tag representing all items enchantable with the fire aspect enchantment. - */ - Tag ITEMS_ENCHANTABLE_FIRE_ASPECT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fire_aspect"), Material.class); - /** - * Vanilla item tag representing all items enchantable with the sharpness enchantment. - */ - Tag ITEMS_ENCHANTABLE_SHARP_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/sharp_weapon"), Material.class); - /** - * Vanilla item tag representing all enchantable weapons. - */ - Tag ITEMS_ENCHANTABLE_WEAPON = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/weapon"), Material.class); - /** - * Vanilla item tag representing all enchantable mining tools. - */ - Tag ITEMS_ENCHANTABLE_MINING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining"), Material.class); - /** - * Vanilla item tag representing all items enchantable with the mining_loot enchantment. - */ - Tag ITEMS_ENCHANTABLE_MINING_LOOT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mining_loot"), Material.class); - /** - * Vanilla item tag representing all items enchantable with fishing enchantments. - */ - Tag ITEMS_ENCHANTABLE_FISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/fishing"), Material.class); - /** - * Vanilla item tag representing all items enchantable with trident enchantments. - */ - Tag ITEMS_ENCHANTABLE_TRIDENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/trident"), Material.class); - /** - * Vanilla item tag representing all items enchantable with durability enchantments. - */ - Tag ITEMS_ENCHANTABLE_DURABILITY = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/durability"), Material.class); - /** - * Vanilla item tag representing all items enchantable with bow enchantments. - */ - Tag ITEMS_ENCHANTABLE_BOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/bow"), Material.class); - /** - * Vanilla item tag representing all items enchantable with the binding enchantment. - */ - Tag ITEMS_ENCHANTABLE_EQUIPPABLE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/equippable"), Material.class); - /** - * Vanilla item tag representing all items enchantable with crossbow enchantments. - */ - Tag ITEMS_ENCHANTABLE_CROSSBOW = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/crossbow"), Material.class); - /** - * Vanilla item tag representing all items enchantable with the vanishing enchantment. - */ - Tag ITEMS_ENCHANTABLE_VANISHING = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/vanishing"), Material.class); - /** - * Vanilla item tag representing all items enchantable with mace enchantments. - */ - Tag ITEMS_ENCHANTABLE_MACE = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("enchantable/mace"), Material.class); - /** - * Vanilla item tag representing all items which when equipped will hide the entity from maps. - */ - Tag ITEMS_MAP_INVISIBILITY_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("map_invisibility_equipment"), Material.class); - /** - * Vanilla item tag representing all items which disguise the wearer's gaze from other entities. - */ - Tag ITEMS_GAZE_DISGUISE_EQUIPMENT = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("gaze_disguise_equipment"), Material.class); - /** - * Vanilla item tag representing all items that confer freeze immunity on - * the wearer. - */ - Tag FREEZE_IMMUNE_WEARABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("freeze_immune_wearables"), Material.class); /** * Vanilla item tag representing all items which tempt axolotls. * @@ -1282,176 +917,12 @@ public interface Tag extends Keyed { */ @Deprecated(since = "1.20.5") Tag AXOLOTL_TEMPT_ITEMS = ITEMS_AXOLOTL_FOOD; - /** - * Vanilla item tag representing all items which are preferred for - * harvesting clusters (unused). - */ - Tag CLUSTER_MAX_HARVESTABLES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("cluster_max_harvestables"), Material.class); - /** - * Key for the built in fluid registry. - */ - String REGISTRY_FLUIDS = "fluids"; - /** - * Vanilla fluid tag representing lava and flowing lava. - */ - Tag FLUIDS_LAVA = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("lava"), Fluid.class); - /** - * Vanilla fluid tag representing water and flowing water. - */ - Tag FLUIDS_WATER = Bukkit.getTag(REGISTRY_FLUIDS, NamespacedKey.minecraft("water"), Fluid.class); - /** - * Key for the built in entity registry. - */ - String REGISTRY_ENTITY_TYPES = "entity_types"; - /** - * Vanilla tag representing skeletons. - */ - Tag ENTITY_TYPES_SKELETONS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("skeletons"), EntityType.class); - /** - * Vanilla tag representing raiders. - */ - Tag ENTITY_TYPES_RAIDERS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("raiders"), EntityType.class); - /** - * Vanilla tag representing entities which can live in beehives. - */ - Tag ENTITY_TYPES_BEEHIVE_INHABITORS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("beehive_inhabitors"), EntityType.class); - /** - * Vanilla tag representing arrows. - */ - Tag ENTITY_TYPES_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arrows"), EntityType.class); - /** - * Vanilla tag representing projectiles. - */ - Tag ENTITY_TYPES_IMPACT_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("impact_projectiles"), EntityType.class); - /** - * Vanilla tag representing mobs which can walk on powder snow. - */ - Tag ENTITY_TYPES_POWDER_SNOW_WALKABLE_MOBS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("powder_snow_walkable_mobs"), EntityType.class); - /** - * Vanilla tag representing which entities axolotls are always hostile to. - */ - Tag ENTITY_TYPES_AXOLOTL_ALWAYS_HOSTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_always_hostiles"), EntityType.class); - /** - * Vanilla tag representing axolotl targets. - */ - Tag ENTITY_TYPES_AXOLOTL_HUNT_TARGETS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("axolotl_hunt_targets"), EntityType.class); - /** - * Vanilla tag representing entities immune from freezing. - */ - Tag ENTITY_TYPES_FREEZE_IMMUNE_ENTITY_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_immune_entity_types"), EntityType.class); - /** - * Vanilla tag representing entities extra susceptible to freezing. - */ - Tag ENTITY_TYPES_FREEZE_HURTS_EXTRA_TYPES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("freeze_hurts_extra_types"), EntityType.class); - /** - * Vanilla tag representing entities which can be eaten by frogs. - */ - Tag ENTITY_TYPES_FROG_FOOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("frog_food"), EntityType.class); - /** - * Vanilla tag representing entities which are immune from fall damage. - */ - Tag ENTITY_TYPES_FALL_DAMAGE_IMMUNE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("fall_damage_immune"), EntityType.class); - /** - * Vanilla tag representing entities which are dismounted when underwater. - */ - Tag ENTITY_TYPES_DISMOUNTS_UNDERWATER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("dismounts_underwater"), EntityType.class); - /** - * Vanilla tag representing entities which are not controlled by their mount. - */ - Tag ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); - /** - * Vanilla tag representing entities which deflect projectiles. - */ - Tag ENTITY_TYPES_DEFLECTS_PROJECTILES = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_projectiles"), EntityType.class); /** * Vanilla tag representing entities which deflect arrows. * @deprecated use {@link #ENTITY_TYPES_DEFLECTS_PROJECTILES} */ @Deprecated(since = "1.20.5") Tag ENTITY_TYPES_DEFLECTS_ARROWS = ENTITY_TYPES_DEFLECTS_PROJECTILES; - /** - * Vanilla tag representing entities which can turn in boats. - */ - Tag ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class); - /** - * Vanilla tag representing all entities sensitive to illager enchantments. - */ - Tag ENTITY_TYPES_ILLAGER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager"), EntityType.class); - /** - * Vanilla tag representing all entities sensitive to aquatic enchantments.. - */ - Tag ENTITY_TYPES_AQUATIC = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("aquatic"), EntityType.class); - /** - * Vanilla tag representing all entities sensitive to arthropod enchantments.. - */ - Tag ENTITY_TYPES_ARTHROPOD = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("arthropod"), EntityType.class); - /** - * Vanilla tag representing all entities which ignores poison and regeneration effects. - */ - Tag ENTITY_TYPES_IGNORES_POISON_AND_REGEN = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("ignores_poison_and_regen"), EntityType.class); - /** - * Vanilla tag representing all entities which are sensitive to inverted healing and harm potion effects. - */ - Tag ENTITY_TYPES_INVERTED_HEALING_AND_HARM = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("inverted_healing_and_harm"), EntityType.class); - /** - * Vanilla tag representing all entities which are friendly with withers. - */ - Tag ENTITY_TYPES_WITHER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("wither_friends"), EntityType.class); - /** - * Vanilla tag representing all entities which are friendly with illagers. - */ - Tag ENTITY_TYPES_ILLAGER_FRIENDS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("illager_friends"), EntityType.class); - /** - * Vanilla tag representing all entities which are not scary for pufferfish. - */ - Tag ENTITY_TYPES_NOT_SCARY_FOR_PUFFERFISH = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("not_scary_for_pufferfish"), EntityType.class); - /** - * Vanilla tag representing all entities which are sensitive to impaling. - */ - Tag ENTITY_TYPES_SENSITIVE_TO_IMPALING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_impaling"), EntityType.class); - /** - * Vanilla tag representing all entities which are sensitive to the bane_of_arthropods enchantment. - */ - Tag ENTITY_TYPES_SENSITIVE_TO_BANE_OF_ARTHROPODS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_bane_of_arthropods"), EntityType.class); - /** - * Vanilla tag representing all entities which are sensitive to the smite enchantment. - */ - Tag ENTITY_TYPES_SENSITIVE_TO_SMITE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("sensitive_to_smite"), EntityType.class); - /** - * Vanilla tag representing all entities which do not receive anger from wind charges. - */ - Tag ENTITY_TYPES_NO_ANGER_FROM_WIND_CHARGE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("no_anger_from_wind_charge"), EntityType.class); - /** - * Vanilla tag representing all entities which are immune from the oozing effect. - */ - Tag ENTITY_TYPES_IMMUNE_TO_OOZING = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_oozing"), EntityType.class); - /** - * Vanilla tag representing all entities which are immune from the infested effect. - */ - Tag ENTITY_TYPES_IMMUNE_TO_INFESTED = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("immune_to_infested"), EntityType.class); - /** - * Vanilla tag representing all projectiles which can be punched back. - */ - Tag ENTITY_TYPES_REDIRECTABLE_PROJECTILE = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("redirectable_projectile"), EntityType.class); - - // Paper start - String REGISTRY_GAME_EVENTS = "game_events"; - - /** - * Tag for game events that trigger sculk sensors - */ - Tag GAME_EVENT_VIBRATIONS = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("vibrations"), GameEvent.class); - - /** - * Tag for game events that are ignored if the entity is sneaking - */ - Tag GAME_EVENT_IGNORE_VIBRATIONS_SNEAKING = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("ignore_vibrations_sneaking"), GameEvent.class); - - /** - * Tag for game events that an allay can listen to - */ - Tag GAME_EVENT_ALLAY_CAN_LISTEN = Bukkit.getTag(REGISTRY_GAME_EVENTS, NamespacedKey.minecraft("allay_can_listen"), GameEvent.class); - // Paper end /** * Returns whether or not this tag has an entry for the specified item. diff --git a/paper-api/src/main/java/org/bukkit/UnsafeValues.java b/paper-api/src/main/java/org/bukkit/UnsafeValues.java index 451ba8f49..f342b8541 100644 --- a/paper-api/src/main/java/org/bukkit/UnsafeValues.java +++ b/paper-api/src/main/java/org/bukkit/UnsafeValues.java @@ -23,6 +23,7 @@ import org.bukkit.potion.PotionType; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Map; /** * This interface provides value conversions that may be specific to a @@ -142,9 +143,6 @@ public interface UnsafeValues { @ApiStatus.Internal B get(RegistryKey registry, NamespacedKey key); - @ApiStatus.Internal - Biome getCustomBiome(); - // Paper start @Deprecated(forRemoval = true) boolean isSupportedApiVersion(String apiVersion); @@ -382,4 +380,8 @@ public interface UnsafeValues { @NotNull java.util.List computeTooltipLines(@NotNull ItemStack itemStack, @NotNull io.papermc.paper.inventory.tooltip.TooltipContext tooltipContext, @Nullable org.bukkit.entity.Player player); // Paper - expose itemstack tooltip lines ItemStack createEmptyStack(); // Paper - proxy ItemStack + + @NotNull Map serializeStack(ItemStack itemStack); + + @NotNull ItemStack deserializeStack(@NotNull Map args); } diff --git a/paper-api/src/main/java/org/bukkit/World.java b/paper-api/src/main/java/org/bukkit/World.java index bff01411f..50f9f8408 100644 --- a/paper-api/src/main/java/org/bukkit/World.java +++ b/paper-api/src/main/java/org/bukkit/World.java @@ -67,7 +67,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient void setVoidDamageEnabled(boolean enabled); /** - * Gets the damage applied to the player when they are in the void in this world. + * Gets the damage applied to the entities when they are in the void in this world. * Check {@link #isVoidDamageEnabled()} to see if void damage is enabled. * * @return amount of damage to apply @@ -76,7 +76,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient float getVoidDamageAmount(); /** - * Sets the damage applied to the player when they are in the void in this world. + * Sets the damage applied to the entities when they are in the void in this world. * Check {@link #isVoidDamageEnabled()} to see if void damage is enabled. * * @param voidDamageAmount amount of damage to apply @@ -101,27 +101,27 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient // Paper start /** - * @return The amount of Entities in this world + * @return The amount of entities in this world */ int getEntityCount(); /** - * @return The amount of Tile Entities in this world + * @return The amount of block entities in this world */ int getTileEntityCount(); /** - * @return The amount of Tickable Tile Entities in this world + * @return The amount of tickable block entities in this world */ int getTickableTileEntityCount(); /** - * @return The amount of Chunks in this world + * @return The amount of chunks in this world */ int getChunkCount(); /** - * @return The amount of Players in this world + * @return The amount of players in this world */ int getPlayerCount(); // Paper end @@ -741,7 +741,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * this method * @return true if the tree was created successfully, otherwise false * @see #generateTree(org.bukkit.Location, java.util.Random, org.bukkit.TreeType, java.util.function.Consumer) - * @deprecated this method does not handle tile entities (bee nests) + * @deprecated this method does not handle block entities (bee nests) */ @Deprecated(since = "1.17.1") public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate); diff --git a/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java b/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java index c60f2170f..4ad09a267 100644 --- a/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java +++ b/paper-api/src/main/java/org/bukkit/attribute/AttributeModifier.java @@ -130,7 +130,6 @@ public class AttributeModifier implements ConfigurationSerializable, Keyed { */ @Nullable @Deprecated(since = "1.20.5") - @io.papermc.paper.annotation.DoNotUse // Paper public EquipmentSlot getSlot() { return slot == EquipmentSlotGroup.ANY ? null : slot.getExample(); } diff --git a/paper-api/src/main/java/org/bukkit/block/Bell.java b/paper-api/src/main/java/org/bukkit/block/Bell.java index ba2db68bb..040addb46 100644 --- a/paper-api/src/main/java/org/bukkit/block/Bell.java +++ b/paper-api/src/main/java/org/bukkit/block/Bell.java @@ -26,7 +26,9 @@ public interface Bell extends TileState { * @param entity the entity ringing the bell * @return true if rung successfully, false if the event was cancelled */ - public boolean ring(@Nullable Entity entity); + default boolean ring(@Nullable Entity entity) { + return this.ring(entity, null); + } /** * Ring this bell. This will call a {@link BellRingEvent}. @@ -35,7 +37,9 @@ public interface Bell extends TileState { * ring in the direction that the bell is facing * @return true if rung successfully, false if the event was cancelled */ - public boolean ring(@Nullable BlockFace direction); + default boolean ring(@Nullable BlockFace direction) { + return this.ring(null, direction); + } /** * Ring this bell in the direction that the bell is facing. This will call a @@ -43,7 +47,9 @@ public interface Bell extends TileState { * * @return true if rung successfully, false if the event was cancelled */ - public boolean ring(); + default boolean ring() { + return this.ring(null, null); + } /** * Check whether or not this bell is shaking. A bell is considered to be diff --git a/paper-api/src/main/java/org/bukkit/block/Biome.java b/paper-api/src/main/java/org/bukkit/block/Biome.java index 1387559c3..3ab2c7364 100644 --- a/paper-api/src/main/java/org/bukkit/block/Biome.java +++ b/paper-api/src/main/java/org/bukkit/block/Biome.java @@ -2,6 +2,7 @@ package org.bukkit.block; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; +import io.papermc.paper.InternalAPIBridge; import io.papermc.paper.registry.RegistryAccess; import io.papermc.paper.registry.RegistryKey; import java.util.Locale; @@ -23,79 +24,146 @@ import org.jetbrains.annotations.NotNull; */ public interface Biome extends OldEnum, Keyed, net.kyori.adventure.translation.Translatable { // Paper - Adventure translations - Biome OCEAN = getBiome("ocean"); - Biome PLAINS = getBiome("plains"); - Biome DESERT = getBiome("desert"); - Biome WINDSWEPT_HILLS = getBiome("windswept_hills"); - Biome FOREST = getBiome("forest"); - Biome TAIGA = getBiome("taiga"); - Biome SWAMP = getBiome("swamp"); - Biome MANGROVE_SWAMP = getBiome("mangrove_swamp"); - Biome RIVER = getBiome("river"); - Biome NETHER_WASTES = getBiome("nether_wastes"); - Biome THE_END = getBiome("the_end"); - Biome FROZEN_OCEAN = getBiome("frozen_ocean"); - Biome FROZEN_RIVER = getBiome("frozen_river"); - Biome SNOWY_PLAINS = getBiome("snowy_plains"); - Biome MUSHROOM_FIELDS = getBiome("mushroom_fields"); - Biome BEACH = getBiome("beach"); - Biome JUNGLE = getBiome("jungle"); - Biome SPARSE_JUNGLE = getBiome("sparse_jungle"); - Biome DEEP_OCEAN = getBiome("deep_ocean"); - Biome STONY_SHORE = getBiome("stony_shore"); - Biome SNOWY_BEACH = getBiome("snowy_beach"); - Biome BIRCH_FOREST = getBiome("birch_forest"); - Biome DARK_FOREST = getBiome("dark_forest"); - Biome PALE_GARDEN = getBiome("pale_garden"); - Biome SNOWY_TAIGA = getBiome("snowy_taiga"); - Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga"); - Biome WINDSWEPT_FOREST = getBiome("windswept_forest"); - Biome SAVANNA = getBiome("savanna"); - Biome SAVANNA_PLATEAU = getBiome("savanna_plateau"); + // Start generate - Biome + // @GeneratedFrom 1.21.5 Biome BADLANDS = getBiome("badlands"); - Biome WOODED_BADLANDS = getBiome("wooded_badlands"); - Biome SMALL_END_ISLANDS = getBiome("small_end_islands"); - Biome END_MIDLANDS = getBiome("end_midlands"); - Biome END_HIGHLANDS = getBiome("end_highlands"); - Biome END_BARRENS = getBiome("end_barrens"); - Biome WARM_OCEAN = getBiome("warm_ocean"); - Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean"); - Biome COLD_OCEAN = getBiome("cold_ocean"); - Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean"); - Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean"); - Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean"); - Biome THE_VOID = getBiome("the_void"); - Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains"); - Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills"); - Biome FLOWER_FOREST = getBiome("flower_forest"); - Biome ICE_SPIKES = getBiome("ice_spikes"); - Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest"); - Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga"); - Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna"); - Biome ERODED_BADLANDS = getBiome("eroded_badlands"); + Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle"); - Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley"); - Biome CRIMSON_FOREST = getBiome("crimson_forest"); - Biome WARPED_FOREST = getBiome("warped_forest"); + Biome BASALT_DELTAS = getBiome("basalt_deltas"); - Biome DRIPSTONE_CAVES = getBiome("dripstone_caves"); - Biome LUSH_CAVES = getBiome("lush_caves"); - Biome DEEP_DARK = getBiome("deep_dark"); - Biome MEADOW = getBiome("meadow"); - Biome GROVE = getBiome("grove"); - Biome SNOWY_SLOPES = getBiome("snowy_slopes"); - Biome FROZEN_PEAKS = getBiome("frozen_peaks"); - Biome JAGGED_PEAKS = getBiome("jagged_peaks"); - Biome STONY_PEAKS = getBiome("stony_peaks"); + + Biome BEACH = getBiome("beach"); + + Biome BIRCH_FOREST = getBiome("birch_forest"); + Biome CHERRY_GROVE = getBiome("cherry_grove"); + Biome COLD_OCEAN = getBiome("cold_ocean"); + + Biome CRIMSON_FOREST = getBiome("crimson_forest"); + + Biome DARK_FOREST = getBiome("dark_forest"); + + Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean"); + + Biome DEEP_DARK = getBiome("deep_dark"); + + Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean"); + + Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean"); + + Biome DEEP_OCEAN = getBiome("deep_ocean"); + + Biome DESERT = getBiome("desert"); + + Biome DRIPSTONE_CAVES = getBiome("dripstone_caves"); + + Biome END_BARRENS = getBiome("end_barrens"); + + Biome END_HIGHLANDS = getBiome("end_highlands"); + + Biome END_MIDLANDS = getBiome("end_midlands"); + + Biome ERODED_BADLANDS = getBiome("eroded_badlands"); + + Biome FLOWER_FOREST = getBiome("flower_forest"); + + Biome FOREST = getBiome("forest"); + + Biome FROZEN_OCEAN = getBiome("frozen_ocean"); + + Biome FROZEN_PEAKS = getBiome("frozen_peaks"); + + Biome FROZEN_RIVER = getBiome("frozen_river"); + + Biome GROVE = getBiome("grove"); + + Biome ICE_SPIKES = getBiome("ice_spikes"); + + Biome JAGGED_PEAKS = getBiome("jagged_peaks"); + + Biome JUNGLE = getBiome("jungle"); + + Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean"); + + Biome LUSH_CAVES = getBiome("lush_caves"); + + Biome MANGROVE_SWAMP = getBiome("mangrove_swamp"); + + Biome MEADOW = getBiome("meadow"); + + Biome MUSHROOM_FIELDS = getBiome("mushroom_fields"); + + Biome NETHER_WASTES = getBiome("nether_wastes"); + + Biome OCEAN = getBiome("ocean"); + + Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest"); + + Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga"); + + Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga"); + + Biome PALE_GARDEN = getBiome("pale_garden"); + + Biome PLAINS = getBiome("plains"); + + Biome RIVER = getBiome("river"); + + Biome SAVANNA = getBiome("savanna"); + + Biome SAVANNA_PLATEAU = getBiome("savanna_plateau"); + + Biome SMALL_END_ISLANDS = getBiome("small_end_islands"); + + Biome SNOWY_BEACH = getBiome("snowy_beach"); + + Biome SNOWY_PLAINS = getBiome("snowy_plains"); + + Biome SNOWY_SLOPES = getBiome("snowy_slopes"); + + Biome SNOWY_TAIGA = getBiome("snowy_taiga"); + + Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley"); + + Biome SPARSE_JUNGLE = getBiome("sparse_jungle"); + + Biome STONY_PEAKS = getBiome("stony_peaks"); + + Biome STONY_SHORE = getBiome("stony_shore"); + + Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains"); + + Biome SWAMP = getBiome("swamp"); + + Biome TAIGA = getBiome("taiga"); + + Biome THE_END = getBiome("the_end"); + + Biome THE_VOID = getBiome("the_void"); + + Biome WARM_OCEAN = getBiome("warm_ocean"); + + Biome WARPED_FOREST = getBiome("warped_forest"); + + Biome WINDSWEPT_FOREST = getBiome("windswept_forest"); + + Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills"); + + Biome WINDSWEPT_HILLS = getBiome("windswept_hills"); + + Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna"); + + Biome WOODED_BADLANDS = getBiome("wooded_badlands"); + // End generate - Biome + /** * Represents a custom Biome * * @deprecated Biome is no longer an enum, custom biomes will have their own biome instance. */ @Deprecated(since = "1.21.3", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils - Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome(); + Biome CUSTOM = InternalAPIBridge.get().constructLegacyCustomBiome(); @NotNull private static Biome getBiome(@NotNull String key) { diff --git a/paper-api/src/main/java/org/bukkit/block/Block.java b/paper-api/src/main/java/org/bukkit/block/Block.java index c6e9ca88e..d309e28d7 100644 --- a/paper-api/src/main/java/org/bukkit/block/Block.java +++ b/paper-api/src/main/java/org/bukkit/block/Block.java @@ -364,7 +364,7 @@ public interface Block extends Metadatable, Translatable, net.kyori.adventure.tr // Paper start /** * @see #getState() optionally disables use of snapshot, to operate on real block data - * @param useSnapshot if this block is a TE, should we create a fully copy of the TileEntity + * @param useSnapshot if this block is a block entity, should we create a full copy of the BlockEntity * @return BlockState with the current state of this block */ @NotNull diff --git a/paper-api/src/main/java/org/bukkit/block/BlockType.java b/paper-api/src/main/java/org/bukkit/block/BlockType.java index d8fde88e3..79257ed47 100644 --- a/paper-api/src/main/java/org/bukkit/block/BlockType.java +++ b/paper-api/src/main/java/org/bukkit/block/BlockType.java @@ -59,6 +59,7 @@ import org.bukkit.block.data.type.EnderChest; import org.bukkit.block.data.type.Farmland; import org.bukkit.block.data.type.Fence; import org.bukkit.block.data.type.Fire; +import org.bukkit.block.data.type.FlowerBed; import org.bukkit.block.data.type.Furnace; import org.bukkit.block.data.type.Gate; import org.bukkit.block.data.type.GlassPane; @@ -71,6 +72,7 @@ import org.bukkit.block.data.type.Jigsaw; import org.bukkit.block.data.type.Jukebox; import org.bukkit.block.data.type.Ladder; import org.bukkit.block.data.type.Lantern; +import org.bukkit.block.data.type.LeafLitter; import org.bukkit.block.data.type.Leaves; import org.bukkit.block.data.type.Lectern; import org.bukkit.block.data.type.Light; @@ -107,6 +109,7 @@ import org.bukkit.block.data.type.StructureBlock; import org.bukkit.block.data.type.Switch; import org.bukkit.block.data.type.TNT; import org.bukkit.block.data.type.TechnicalPiston; +import org.bukkit.block.data.type.TestBlock; import org.bukkit.block.data.type.TrapDoor; import org.bukkit.block.data.type.TrialSpawner; import org.bukkit.block.data.type.Tripwire; @@ -194,3240 +197,2216 @@ public interface BlockType extends Keyed, Translatable, net.kyori.adventure.tran } // - BlockType.Typed AIR = getBlockType("air"); - BlockType.Typed STONE = getBlockType("stone"); - BlockType.Typed GRANITE = getBlockType("granite"); - BlockType.Typed POLISHED_GRANITE = getBlockType("polished_granite"); - BlockType.Typed DIORITE = getBlockType("diorite"); - BlockType.Typed POLISHED_DIORITE = getBlockType("polished_diorite"); - BlockType.Typed ANDESITE = getBlockType("andesite"); - BlockType.Typed POLISHED_ANDESITE = getBlockType("polished_andesite"); - /** - * BlockData: {@link Snowable} - */ - BlockType.Typed GRASS_BLOCK = getBlockType("grass_block"); - BlockType.Typed DIRT = getBlockType("dirt"); - BlockType.Typed COARSE_DIRT = getBlockType("coarse_dirt"); - /** - * BlockData: {@link Snowable} - */ - BlockType.Typed PODZOL = getBlockType("podzol"); - BlockType.Typed COBBLESTONE = getBlockType("cobblestone"); - BlockType.Typed OAK_PLANKS = getBlockType("oak_planks"); - BlockType.Typed SPRUCE_PLANKS = getBlockType("spruce_planks"); - BlockType.Typed BIRCH_PLANKS = getBlockType("birch_planks"); - BlockType.Typed JUNGLE_PLANKS = getBlockType("jungle_planks"); - BlockType.Typed ACACIA_PLANKS = getBlockType("acacia_planks"); - BlockType.Typed CHERRY_PLANKS = getBlockType("cherry_planks"); - BlockType.Typed DARK_OAK_PLANKS = getBlockType("dark_oak_planks"); - BlockType.Typed PALE_OAK_PLANKS = getBlockType("pale_oak_planks"); - BlockType.Typed MANGROVE_PLANKS = getBlockType("mangrove_planks"); - BlockType.Typed BAMBOO_PLANKS = getBlockType("bamboo_planks"); - BlockType.Typed BAMBOO_MOSAIC = getBlockType("bamboo_mosaic"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed OAK_SAPLING = getBlockType("oak_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed SPRUCE_SAPLING = getBlockType("spruce_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed BIRCH_SAPLING = getBlockType("birch_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed JUNGLE_SAPLING = getBlockType("jungle_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed ACACIA_SAPLING = getBlockType("acacia_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed CHERRY_SAPLING = getBlockType("cherry_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed DARK_OAK_SAPLING = getBlockType("dark_oak_sapling"); - /** - * BlockData: {@link Sapling} - */ - BlockType.Typed PALE_OAK_SAPLING = getBlockType("pale_oak_sapling"); - /** - * BlockData: {@link MangrovePropagule} - */ - BlockType.Typed MANGROVE_PROPAGULE = getBlockType("mangrove_propagule"); - BlockType.Typed BEDROCK = getBlockType("bedrock"); - /** - * BlockData: {@link Levelled} - */ - BlockType.Typed WATER = getBlockType("water"); - /** - * BlockData: {@link Levelled} - */ - BlockType.Typed LAVA = getBlockType("lava"); - BlockType.Typed SAND = getBlockType("sand"); - /** - * BlockData: {@link Brushable} - */ - BlockType.Typed SUSPICIOUS_SAND = getBlockType("suspicious_sand"); - BlockType.Typed RED_SAND = getBlockType("red_sand"); - BlockType.Typed GRAVEL = getBlockType("gravel"); - /** - * BlockData: {@link Brushable} - */ - BlockType.Typed SUSPICIOUS_GRAVEL = getBlockType("suspicious_gravel"); - BlockType.Typed GOLD_ORE = getBlockType("gold_ore"); - BlockType.Typed DEEPSLATE_GOLD_ORE = getBlockType("deepslate_gold_ore"); - BlockType.Typed IRON_ORE = getBlockType("iron_ore"); - BlockType.Typed DEEPSLATE_IRON_ORE = getBlockType("deepslate_iron_ore"); - BlockType.Typed COAL_ORE = getBlockType("coal_ore"); - BlockType.Typed DEEPSLATE_COAL_ORE = getBlockType("deepslate_coal_ore"); - BlockType.Typed NETHER_GOLD_ORE = getBlockType("nether_gold_ore"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed OAK_LOG = getBlockType("oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed SPRUCE_LOG = getBlockType("spruce_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed BIRCH_LOG = getBlockType("birch_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed JUNGLE_LOG = getBlockType("jungle_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed ACACIA_LOG = getBlockType("acacia_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed CHERRY_LOG = getBlockType("cherry_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed DARK_OAK_LOG = getBlockType("dark_oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed PALE_OAK_LOG = getBlockType("pale_oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed MANGROVE_LOG = getBlockType("mangrove_log"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed MANGROVE_ROOTS = getBlockType("mangrove_roots"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed MUDDY_MANGROVE_ROOTS = getBlockType("muddy_mangrove_roots"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed BAMBOO_BLOCK = getBlockType("bamboo_block"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_SPRUCE_LOG = getBlockType("stripped_spruce_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_BIRCH_LOG = getBlockType("stripped_birch_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_JUNGLE_LOG = getBlockType("stripped_jungle_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_ACACIA_LOG = getBlockType("stripped_acacia_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_CHERRY_LOG = getBlockType("stripped_cherry_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_DARK_OAK_LOG = getBlockType("stripped_dark_oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_PALE_OAK_LOG = getBlockType("stripped_pale_oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_OAK_LOG = getBlockType("stripped_oak_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_MANGROVE_LOG = getBlockType("stripped_mangrove_log"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_BAMBOO_BLOCK = getBlockType("stripped_bamboo_block"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed OAK_WOOD = getBlockType("oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed SPRUCE_WOOD = getBlockType("spruce_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed BIRCH_WOOD = getBlockType("birch_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed JUNGLE_WOOD = getBlockType("jungle_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed ACACIA_WOOD = getBlockType("acacia_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed CHERRY_WOOD = getBlockType("cherry_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed DARK_OAK_WOOD = getBlockType("dark_oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed PALE_OAK_WOOD = getBlockType("pale_oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed MANGROVE_WOOD = getBlockType("mangrove_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_OAK_WOOD = getBlockType("stripped_oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_SPRUCE_WOOD = getBlockType("stripped_spruce_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_BIRCH_WOOD = getBlockType("stripped_birch_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_JUNGLE_WOOD = getBlockType("stripped_jungle_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_ACACIA_WOOD = getBlockType("stripped_acacia_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_CHERRY_WOOD = getBlockType("stripped_cherry_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_DARK_OAK_WOOD = getBlockType("stripped_dark_oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_PALE_OAK_WOOD = getBlockType("stripped_pale_oak_wood"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_MANGROVE_WOOD = getBlockType("stripped_mangrove_wood"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed OAK_LEAVES = getBlockType("oak_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed SPRUCE_LEAVES = getBlockType("spruce_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed BIRCH_LEAVES = getBlockType("birch_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed JUNGLE_LEAVES = getBlockType("jungle_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed ACACIA_LEAVES = getBlockType("acacia_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed CHERRY_LEAVES = getBlockType("cherry_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed DARK_OAK_LEAVES = getBlockType("dark_oak_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed PALE_OAK_LEAVES = getBlockType("pale_oak_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed MANGROVE_LEAVES = getBlockType("mangrove_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed AZALEA_LEAVES = getBlockType("azalea_leaves"); - /** - * BlockData: {@link Leaves} - */ - BlockType.Typed FLOWERING_AZALEA_LEAVES = getBlockType("flowering_azalea_leaves"); - BlockType.Typed SPONGE = getBlockType("sponge"); - BlockType.Typed WET_SPONGE = getBlockType("wet_sponge"); - BlockType.Typed GLASS = getBlockType("glass"); - BlockType.Typed LAPIS_ORE = getBlockType("lapis_ore"); - BlockType.Typed DEEPSLATE_LAPIS_ORE = getBlockType("deepslate_lapis_ore"); - BlockType.Typed LAPIS_BLOCK = getBlockType("lapis_block"); - /** - * BlockData: {@link Dispenser} - */ - BlockType.Typed DISPENSER = getBlockType("dispenser"); - BlockType.Typed SANDSTONE = getBlockType("sandstone"); - BlockType.Typed CHISELED_SANDSTONE = getBlockType("chiseled_sandstone"); - BlockType.Typed CUT_SANDSTONE = getBlockType("cut_sandstone"); - /** - * BlockData: {@link NoteBlock} - */ - BlockType.Typed NOTE_BLOCK = getBlockType("note_block"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed WHITE_BED = getBlockType("white_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed ORANGE_BED = getBlockType("orange_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed MAGENTA_BED = getBlockType("magenta_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed LIGHT_BLUE_BED = getBlockType("light_blue_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed YELLOW_BED = getBlockType("yellow_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed LIME_BED = getBlockType("lime_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed PINK_BED = getBlockType("pink_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed GRAY_BED = getBlockType("gray_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed LIGHT_GRAY_BED = getBlockType("light_gray_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed CYAN_BED = getBlockType("cyan_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed PURPLE_BED = getBlockType("purple_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed BLUE_BED = getBlockType("blue_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed BROWN_BED = getBlockType("brown_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed GREEN_BED = getBlockType("green_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed RED_BED = getBlockType("red_bed"); - /** - * BlockData: {@link Bed} - */ - BlockType.Typed BLACK_BED = getBlockType("black_bed"); - /** - * BlockData: {@link RedstoneRail} - */ - BlockType.Typed POWERED_RAIL = getBlockType("powered_rail"); - /** - * BlockData: {@link RedstoneRail} - */ - BlockType.Typed DETECTOR_RAIL = getBlockType("detector_rail"); - /** - * BlockData: {@link Piston} - */ - BlockType.Typed STICKY_PISTON = getBlockType("sticky_piston"); - BlockType.Typed COBWEB = getBlockType("cobweb"); - BlockType.Typed SHORT_GRASS = getBlockType("short_grass"); - BlockType.Typed FERN = getBlockType("fern"); - BlockType.Typed DEAD_BUSH = getBlockType("dead_bush"); - BlockType.Typed SEAGRASS = getBlockType("seagrass"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed TALL_SEAGRASS = getBlockType("tall_seagrass"); - /** - * BlockData: {@link Piston} - */ - BlockType.Typed PISTON = getBlockType("piston"); - /** - * BlockData: {@link PistonHead} - */ - BlockType.Typed PISTON_HEAD = getBlockType("piston_head"); - BlockType.Typed WHITE_WOOL = getBlockType("white_wool"); - BlockType.Typed ORANGE_WOOL = getBlockType("orange_wool"); - BlockType.Typed MAGENTA_WOOL = getBlockType("magenta_wool"); - BlockType.Typed LIGHT_BLUE_WOOL = getBlockType("light_blue_wool"); - BlockType.Typed YELLOW_WOOL = getBlockType("yellow_wool"); - BlockType.Typed LIME_WOOL = getBlockType("lime_wool"); - BlockType.Typed PINK_WOOL = getBlockType("pink_wool"); - BlockType.Typed GRAY_WOOL = getBlockType("gray_wool"); - BlockType.Typed LIGHT_GRAY_WOOL = getBlockType("light_gray_wool"); - BlockType.Typed CYAN_WOOL = getBlockType("cyan_wool"); - BlockType.Typed PURPLE_WOOL = getBlockType("purple_wool"); - BlockType.Typed BLUE_WOOL = getBlockType("blue_wool"); - BlockType.Typed BROWN_WOOL = getBlockType("brown_wool"); - BlockType.Typed GREEN_WOOL = getBlockType("green_wool"); - BlockType.Typed RED_WOOL = getBlockType("red_wool"); - BlockType.Typed BLACK_WOOL = getBlockType("black_wool"); - /** - * BlockData: {@link TechnicalPiston} - */ - BlockType.Typed MOVING_PISTON = getBlockType("moving_piston"); - BlockType.Typed DANDELION = getBlockType("dandelion"); - BlockType.Typed TORCHFLOWER = getBlockType("torchflower"); - BlockType.Typed POPPY = getBlockType("poppy"); - BlockType.Typed BLUE_ORCHID = getBlockType("blue_orchid"); - BlockType.Typed ALLIUM = getBlockType("allium"); - BlockType.Typed AZURE_BLUET = getBlockType("azure_bluet"); - BlockType.Typed RED_TULIP = getBlockType("red_tulip"); - BlockType.Typed ORANGE_TULIP = getBlockType("orange_tulip"); - BlockType.Typed WHITE_TULIP = getBlockType("white_tulip"); - BlockType.Typed PINK_TULIP = getBlockType("pink_tulip"); - BlockType.Typed OXEYE_DAISY = getBlockType("oxeye_daisy"); - BlockType.Typed CORNFLOWER = getBlockType("cornflower"); - BlockType.Typed WITHER_ROSE = getBlockType("wither_rose"); - BlockType.Typed LILY_OF_THE_VALLEY = getBlockType("lily_of_the_valley"); - BlockType.Typed BROWN_MUSHROOM = getBlockType("brown_mushroom"); - BlockType.Typed RED_MUSHROOM = getBlockType("red_mushroom"); - BlockType.Typed GOLD_BLOCK = getBlockType("gold_block"); - BlockType.Typed IRON_BLOCK = getBlockType("iron_block"); - BlockType.Typed BRICKS = getBlockType("bricks"); - /** - * BlockData: {@link TNT} - */ - BlockType.Typed TNT = getBlockType("tnt"); - BlockType.Typed BOOKSHELF = getBlockType("bookshelf"); - /** - * BlockData: {@link ChiseledBookshelf} - */ - BlockType.Typed CHISELED_BOOKSHELF = getBlockType("chiseled_bookshelf"); - BlockType.Typed MOSSY_COBBLESTONE = getBlockType("mossy_cobblestone"); - BlockType.Typed OBSIDIAN = getBlockType("obsidian"); - BlockType.Typed TORCH = getBlockType("torch"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed WALL_TORCH = getBlockType("wall_torch"); - /** - * BlockData: {@link Fire} - */ - BlockType.Typed FIRE = getBlockType("fire"); - BlockType.Typed SOUL_FIRE = getBlockType("soul_fire"); - BlockType.Typed SPAWNER = getBlockType("spawner"); - /** - * BlockData: {@link Fire} - */ - BlockType.Typed CREAKING_HEART = getBlockType("creaking_heart"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed OAK_STAIRS = getBlockType("oak_stairs"); - /** - * BlockData: {@link Chest} - */ - BlockType.Typed CHEST = getBlockType("chest"); - /** - * BlockData: {@link RedstoneWire} - */ - BlockType.Typed REDSTONE_WIRE = getBlockType("redstone_wire"); - BlockType.Typed DIAMOND_ORE = getBlockType("diamond_ore"); - BlockType.Typed DEEPSLATE_DIAMOND_ORE = getBlockType("deepslate_diamond_ore"); - BlockType.Typed DIAMOND_BLOCK = getBlockType("diamond_block"); - BlockType.Typed CRAFTING_TABLE = getBlockType("crafting_table"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed WHEAT = getBlockType("wheat"); - /** - * BlockData: {@link Farmland} - */ - BlockType.Typed FARMLAND = getBlockType("farmland"); - /** - * BlockData: {@link Furnace} - */ - BlockType.Typed FURNACE = getBlockType("furnace"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed OAK_SIGN = getBlockType("oak_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed SPRUCE_SIGN = getBlockType("spruce_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed BIRCH_SIGN = getBlockType("birch_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed ACACIA_SIGN = getBlockType("acacia_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed CHERRY_SIGN = getBlockType("cherry_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed JUNGLE_SIGN = getBlockType("jungle_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed DARK_OAK_SIGN = getBlockType("dark_oak_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed PALE_OAK_SIGN = getBlockType("pale_oak_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed MANGROVE_SIGN = getBlockType("mangrove_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed BAMBOO_SIGN = getBlockType("bamboo_sign"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed OAK_DOOR = getBlockType("oak_door"); - /** - * BlockData: {@link Ladder} - */ - BlockType.Typed LADDER = getBlockType("ladder"); - /** - * BlockData: {@link Rail} - */ - BlockType.Typed RAIL = getBlockType("rail"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed COBBLESTONE_STAIRS = getBlockType("cobblestone_stairs"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed OAK_WALL_SIGN = getBlockType("oak_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed SPRUCE_WALL_SIGN = getBlockType("spruce_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed BIRCH_WALL_SIGN = getBlockType("birch_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed ACACIA_WALL_SIGN = getBlockType("acacia_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed CHERRY_WALL_SIGN = getBlockType("cherry_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed JUNGLE_WALL_SIGN = getBlockType("jungle_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed DARK_OAK_WALL_SIGN = getBlockType("dark_oak_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed PALE_OAK_WALL_SIGN = getBlockType("pale_oak_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed MANGROVE_WALL_SIGN = getBlockType("mangrove_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed BAMBOO_WALL_SIGN = getBlockType("bamboo_wall_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed OAK_HANGING_SIGN = getBlockType("oak_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed SPRUCE_HANGING_SIGN = getBlockType("spruce_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed BIRCH_HANGING_SIGN = getBlockType("birch_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed ACACIA_HANGING_SIGN = getBlockType("acacia_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed CHERRY_HANGING_SIGN = getBlockType("cherry_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed JUNGLE_HANGING_SIGN = getBlockType("jungle_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed DARK_OAK_HANGING_SIGN = getBlockType("dark_oak_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed PALE_OAK_HANGING_SIGN = getBlockType("pale_oak_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed CRIMSON_HANGING_SIGN = getBlockType("crimson_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed WARPED_HANGING_SIGN = getBlockType("warped_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed MANGROVE_HANGING_SIGN = getBlockType("mangrove_hanging_sign"); - /** - * BlockData: {@link HangingSign} - */ - BlockType.Typed BAMBOO_HANGING_SIGN = getBlockType("bamboo_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed OAK_WALL_HANGING_SIGN = getBlockType("oak_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed SPRUCE_WALL_HANGING_SIGN = getBlockType("spruce_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed BIRCH_WALL_HANGING_SIGN = getBlockType("birch_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed ACACIA_WALL_HANGING_SIGN = getBlockType("acacia_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed CHERRY_WALL_HANGING_SIGN = getBlockType("cherry_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed JUNGLE_WALL_HANGING_SIGN = getBlockType("jungle_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed DARK_OAK_WALL_HANGING_SIGN = getBlockType("dark_oak_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed PALE_OAK_WALL_HANGING_SIGN = getBlockType("pale_oak_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed MANGROVE_WALL_HANGING_SIGN = getBlockType("mangrove_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed CRIMSON_WALL_HANGING_SIGN = getBlockType("crimson_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed WARPED_WALL_HANGING_SIGN = getBlockType("warped_wall_hanging_sign"); - /** - * BlockData: {@link WallHangingSign} - */ - BlockType.Typed BAMBOO_WALL_HANGING_SIGN = getBlockType("bamboo_wall_hanging_sign"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed LEVER = getBlockType("lever"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed STONE_PRESSURE_PLATE = getBlockType("stone_pressure_plate"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed IRON_DOOR = getBlockType("iron_door"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed OAK_PRESSURE_PLATE = getBlockType("oak_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed SPRUCE_PRESSURE_PLATE = getBlockType("spruce_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed BIRCH_PRESSURE_PLATE = getBlockType("birch_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed JUNGLE_PRESSURE_PLATE = getBlockType("jungle_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed ACACIA_PRESSURE_PLATE = getBlockType("acacia_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed CHERRY_PRESSURE_PLATE = getBlockType("cherry_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed DARK_OAK_PRESSURE_PLATE = getBlockType("dark_oak_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed PALE_OAK_PRESSURE_PLATE = getBlockType("pale_oak_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed MANGROVE_PRESSURE_PLATE = getBlockType("mangrove_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed BAMBOO_PRESSURE_PLATE = getBlockType("bamboo_pressure_plate"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed REDSTONE_ORE = getBlockType("redstone_ore"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed DEEPSLATE_REDSTONE_ORE = getBlockType("deepslate_redstone_ore"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed REDSTONE_TORCH = getBlockType("redstone_torch"); - /** - * BlockData: {@link RedstoneWallTorch} - */ - BlockType.Typed REDSTONE_WALL_TORCH = getBlockType("redstone_wall_torch"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed STONE_BUTTON = getBlockType("stone_button"); - /** - * BlockData: {@link Snow} - */ - BlockType.Typed SNOW = getBlockType("snow"); - BlockType.Typed ICE = getBlockType("ice"); - BlockType.Typed SNOW_BLOCK = getBlockType("snow_block"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed CACTUS = getBlockType("cactus"); - BlockType.Typed CLAY = getBlockType("clay"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed SUGAR_CANE = getBlockType("sugar_cane"); - /** - * BlockData: {@link Jukebox} - */ - BlockType.Typed JUKEBOX = getBlockType("jukebox"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed OAK_FENCE = getBlockType("oak_fence"); - BlockType.Typed NETHERRACK = getBlockType("netherrack"); - BlockType.Typed SOUL_SAND = getBlockType("soul_sand"); - BlockType.Typed SOUL_SOIL = getBlockType("soul_soil"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed BASALT = getBlockType("basalt"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed POLISHED_BASALT = getBlockType("polished_basalt"); - BlockType.Typed SOUL_TORCH = getBlockType("soul_torch"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed SOUL_WALL_TORCH = getBlockType("soul_wall_torch"); - BlockType.Typed GLOWSTONE = getBlockType("glowstone"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed NETHER_PORTAL = getBlockType("nether_portal"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed CARVED_PUMPKIN = getBlockType("carved_pumpkin"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed JACK_O_LANTERN = getBlockType("jack_o_lantern"); - /** - * BlockData: {@link Cake} - */ - BlockType.Typed CAKE = getBlockType("cake"); - /** - * BlockData: {@link Repeater} - */ - BlockType.Typed REPEATER = getBlockType("repeater"); - BlockType.Typed WHITE_STAINED_GLASS = getBlockType("white_stained_glass"); - BlockType.Typed ORANGE_STAINED_GLASS = getBlockType("orange_stained_glass"); - BlockType.Typed MAGENTA_STAINED_GLASS = getBlockType("magenta_stained_glass"); - BlockType.Typed LIGHT_BLUE_STAINED_GLASS = getBlockType("light_blue_stained_glass"); - BlockType.Typed YELLOW_STAINED_GLASS = getBlockType("yellow_stained_glass"); - BlockType.Typed LIME_STAINED_GLASS = getBlockType("lime_stained_glass"); - BlockType.Typed PINK_STAINED_GLASS = getBlockType("pink_stained_glass"); - BlockType.Typed GRAY_STAINED_GLASS = getBlockType("gray_stained_glass"); - BlockType.Typed LIGHT_GRAY_STAINED_GLASS = getBlockType("light_gray_stained_glass"); - BlockType.Typed CYAN_STAINED_GLASS = getBlockType("cyan_stained_glass"); - BlockType.Typed PURPLE_STAINED_GLASS = getBlockType("purple_stained_glass"); - BlockType.Typed BLUE_STAINED_GLASS = getBlockType("blue_stained_glass"); - BlockType.Typed BROWN_STAINED_GLASS = getBlockType("brown_stained_glass"); - BlockType.Typed GREEN_STAINED_GLASS = getBlockType("green_stained_glass"); - BlockType.Typed RED_STAINED_GLASS = getBlockType("red_stained_glass"); - BlockType.Typed BLACK_STAINED_GLASS = getBlockType("black_stained_glass"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed OAK_TRAPDOOR = getBlockType("oak_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed SPRUCE_TRAPDOOR = getBlockType("spruce_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed BIRCH_TRAPDOOR = getBlockType("birch_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed JUNGLE_TRAPDOOR = getBlockType("jungle_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed ACACIA_TRAPDOOR = getBlockType("acacia_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed CHERRY_TRAPDOOR = getBlockType("cherry_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed DARK_OAK_TRAPDOOR = getBlockType("dark_oak_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed PALE_OAK_TRAPDOOR = getBlockType("pale_oak_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed MANGROVE_TRAPDOOR = getBlockType("mangrove_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed BAMBOO_TRAPDOOR = getBlockType("bamboo_trapdoor"); - BlockType.Typed STONE_BRICKS = getBlockType("stone_bricks"); - BlockType.Typed MOSSY_STONE_BRICKS = getBlockType("mossy_stone_bricks"); - BlockType.Typed CRACKED_STONE_BRICKS = getBlockType("cracked_stone_bricks"); - BlockType.Typed CHISELED_STONE_BRICKS = getBlockType("chiseled_stone_bricks"); - BlockType.Typed PACKED_MUD = getBlockType("packed_mud"); - BlockType.Typed MUD_BRICKS = getBlockType("mud_bricks"); - BlockType.Typed INFESTED_STONE = getBlockType("infested_stone"); - BlockType.Typed INFESTED_COBBLESTONE = getBlockType("infested_cobblestone"); - BlockType.Typed INFESTED_STONE_BRICKS = getBlockType("infested_stone_bricks"); - BlockType.Typed INFESTED_MOSSY_STONE_BRICKS = getBlockType("infested_mossy_stone_bricks"); - BlockType.Typed INFESTED_CRACKED_STONE_BRICKS = getBlockType("infested_cracked_stone_bricks"); - BlockType.Typed INFESTED_CHISELED_STONE_BRICKS = getBlockType("infested_chiseled_stone_bricks"); - /** - * BlockData: {@link MultipleFacing} - */ - BlockType.Typed BROWN_MUSHROOM_BLOCK = getBlockType("brown_mushroom_block"); - /** - * BlockData: {@link MultipleFacing} - */ - BlockType.Typed RED_MUSHROOM_BLOCK = getBlockType("red_mushroom_block"); - /** - * BlockData: {@link MultipleFacing} - */ - BlockType.Typed MUSHROOM_STEM = getBlockType("mushroom_stem"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed IRON_BARS = getBlockType("iron_bars"); - /** - * BlockData: {@link Chain} - */ - BlockType.Typed CHAIN = getBlockType("chain"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed GLASS_PANE = getBlockType("glass_pane"); - BlockType.Typed PUMPKIN = getBlockType("pumpkin"); - BlockType.Typed MELON = getBlockType("melon"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ATTACHED_PUMPKIN_STEM = getBlockType("attached_pumpkin_stem"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ATTACHED_MELON_STEM = getBlockType("attached_melon_stem"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed PUMPKIN_STEM = getBlockType("pumpkin_stem"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed MELON_STEM = getBlockType("melon_stem"); - /** - * BlockData: {@link MultipleFacing} - */ - BlockType.Typed VINE = getBlockType("vine"); - /** - * BlockData: {@link GlowLichen} - */ - BlockType.Typed GLOW_LICHEN = getBlockType("glow_lichen"); - /** - * BlockData: {@link ResinClump} - */ - BlockType.Typed RESIN_CLUMP = getBlockType("resin_clump"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed OAK_FENCE_GATE = getBlockType("oak_fence_gate"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed BRICK_STAIRS = getBlockType("brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed STONE_BRICK_STAIRS = getBlockType("stone_brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed MUD_BRICK_STAIRS = getBlockType("mud_brick_stairs"); - /** - * BlockData: {@link Snowable} - */ - BlockType.Typed MYCELIUM = getBlockType("mycelium"); - BlockType.Typed LILY_PAD = getBlockType("lily_pad"); - BlockType.Typed RESIN_BLOCK = getBlockType("resin_block"); - BlockType.Typed RESIN_BRICKS = getBlockType("resin_bricks"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed RESIN_BRICK_STAIRS = getBlockType("resin_brick_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed RESIN_BRICK_SLAB = getBlockType("resin_brick_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed RESIN_BRICK_WALL = getBlockType("resin_brick_wall"); - BlockType.Typed CHISELED_RESIN_BRICKS = getBlockType("chiseled_resin_bricks"); - BlockType.Typed NETHER_BRICKS = getBlockType("nether_bricks"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed NETHER_BRICK_FENCE = getBlockType("nether_brick_fence"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed NETHER_BRICK_STAIRS = getBlockType("nether_brick_stairs"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed NETHER_WART = getBlockType("nether_wart"); - BlockType.Typed ENCHANTING_TABLE = getBlockType("enchanting_table"); - /** - * BlockData: {@link BrewingStand} - */ - BlockType.Typed BREWING_STAND = getBlockType("brewing_stand"); - BlockType.Typed CAULDRON = getBlockType("cauldron"); - /** - * BlockData: {@link Levelled} - */ - BlockType.Typed WATER_CAULDRON = getBlockType("water_cauldron"); - BlockType.Typed LAVA_CAULDRON = getBlockType("lava_cauldron"); - /** - * BlockData: {@link Levelled} - */ - BlockType.Typed POWDER_SNOW_CAULDRON = getBlockType("powder_snow_cauldron"); - BlockType.Typed END_PORTAL = getBlockType("end_portal"); - /** - * BlockData: {@link EndPortalFrame} - */ - BlockType.Typed END_PORTAL_FRAME = getBlockType("end_portal_frame"); - BlockType.Typed END_STONE = getBlockType("end_stone"); - BlockType.Typed DRAGON_EGG = getBlockType("dragon_egg"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed REDSTONE_LAMP = getBlockType("redstone_lamp"); - /** - * BlockData: {@link Cocoa} - */ - BlockType.Typed COCOA = getBlockType("cocoa"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed SANDSTONE_STAIRS = getBlockType("sandstone_stairs"); - BlockType.Typed EMERALD_ORE = getBlockType("emerald_ore"); - BlockType.Typed DEEPSLATE_EMERALD_ORE = getBlockType("deepslate_emerald_ore"); - /** - * BlockData: {@link EnderChest} - */ - BlockType.Typed ENDER_CHEST = getBlockType("ender_chest"); - /** - * BlockData: {@link TripwireHook} - */ - BlockType.Typed TRIPWIRE_HOOK = getBlockType("tripwire_hook"); - /** - * BlockData: {@link Tripwire} - */ - BlockType.Typed TRIPWIRE = getBlockType("tripwire"); - BlockType.Typed EMERALD_BLOCK = getBlockType("emerald_block"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed SPRUCE_STAIRS = getBlockType("spruce_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed BIRCH_STAIRS = getBlockType("birch_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed JUNGLE_STAIRS = getBlockType("jungle_stairs"); - /** - * BlockData: {@link CommandBlock} - */ - BlockType.Typed COMMAND_BLOCK = getBlockType("command_block"); - BlockType.Typed BEACON = getBlockType("beacon"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed COBBLESTONE_WALL = getBlockType("cobblestone_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed MOSSY_COBBLESTONE_WALL = getBlockType("mossy_cobblestone_wall"); - BlockType.Typed FLOWER_POT = getBlockType("flower_pot"); - BlockType.Typed POTTED_TORCHFLOWER = getBlockType("potted_torchflower"); - BlockType.Typed POTTED_OAK_SAPLING = getBlockType("potted_oak_sapling"); - BlockType.Typed POTTED_SPRUCE_SAPLING = getBlockType("potted_spruce_sapling"); - BlockType.Typed POTTED_BIRCH_SAPLING = getBlockType("potted_birch_sapling"); - BlockType.Typed POTTED_JUNGLE_SAPLING = getBlockType("potted_jungle_sapling"); - BlockType.Typed POTTED_ACACIA_SAPLING = getBlockType("potted_acacia_sapling"); - BlockType.Typed POTTED_CHERRY_SAPLING = getBlockType("potted_cherry_sapling"); - BlockType.Typed POTTED_DARK_OAK_SAPLING = getBlockType("potted_dark_oak_sapling"); - BlockType.Typed POTTED_PALE_OAK_SAPLING = getBlockType("potted_pale_oak_sapling"); - BlockType.Typed POTTED_MANGROVE_PROPAGULE = getBlockType("potted_mangrove_propagule"); - BlockType.Typed POTTED_FERN = getBlockType("potted_fern"); - BlockType.Typed POTTED_DANDELION = getBlockType("potted_dandelion"); - BlockType.Typed POTTED_POPPY = getBlockType("potted_poppy"); - BlockType.Typed POTTED_BLUE_ORCHID = getBlockType("potted_blue_orchid"); - BlockType.Typed POTTED_ALLIUM = getBlockType("potted_allium"); - BlockType.Typed POTTED_AZURE_BLUET = getBlockType("potted_azure_bluet"); - BlockType.Typed POTTED_RED_TULIP = getBlockType("potted_red_tulip"); - BlockType.Typed POTTED_ORANGE_TULIP = getBlockType("potted_orange_tulip"); - BlockType.Typed POTTED_WHITE_TULIP = getBlockType("potted_white_tulip"); - BlockType.Typed POTTED_PINK_TULIP = getBlockType("potted_pink_tulip"); - BlockType.Typed POTTED_OXEYE_DAISY = getBlockType("potted_oxeye_daisy"); - BlockType.Typed POTTED_CORNFLOWER = getBlockType("potted_cornflower"); - BlockType.Typed POTTED_LILY_OF_THE_VALLEY = getBlockType("potted_lily_of_the_valley"); - BlockType.Typed POTTED_WITHER_ROSE = getBlockType("potted_wither_rose"); - BlockType.Typed POTTED_RED_MUSHROOM = getBlockType("potted_red_mushroom"); - BlockType.Typed POTTED_BROWN_MUSHROOM = getBlockType("potted_brown_mushroom"); - BlockType.Typed POTTED_DEAD_BUSH = getBlockType("potted_dead_bush"); - BlockType.Typed POTTED_CACTUS = getBlockType("potted_cactus"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed CARROTS = getBlockType("carrots"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed POTATOES = getBlockType("potatoes"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed OAK_BUTTON = getBlockType("oak_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed SPRUCE_BUTTON = getBlockType("spruce_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed BIRCH_BUTTON = getBlockType("birch_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed JUNGLE_BUTTON = getBlockType("jungle_button"); - /** - * BlockData: {@link Switch} - */ + // Start generate - BlockType + // @GeneratedFrom 1.21.5 BlockType.Typed ACACIA_BUTTON = getBlockType("acacia_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed CHERRY_BUTTON = getBlockType("cherry_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed DARK_OAK_BUTTON = getBlockType("dark_oak_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed PALE_OAK_BUTTON = getBlockType("pale_oak_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed MANGROVE_BUTTON = getBlockType("mangrove_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed BAMBOO_BUTTON = getBlockType("bamboo_button"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed SKELETON_SKULL = getBlockType("skeleton_skull"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed SKELETON_WALL_SKULL = getBlockType("skeleton_wall_skull"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed WITHER_SKELETON_SKULL = getBlockType("wither_skeleton_skull"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed WITHER_SKELETON_WALL_SKULL = getBlockType("wither_skeleton_wall_skull"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed ZOMBIE_HEAD = getBlockType("zombie_head"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed ZOMBIE_WALL_HEAD = getBlockType("zombie_wall_head"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed PLAYER_HEAD = getBlockType("player_head"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed PLAYER_WALL_HEAD = getBlockType("player_wall_head"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed CREEPER_HEAD = getBlockType("creeper_head"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed CREEPER_WALL_HEAD = getBlockType("creeper_wall_head"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed DRAGON_HEAD = getBlockType("dragon_head"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed DRAGON_WALL_HEAD = getBlockType("dragon_wall_head"); - /** - * BlockData: {@link Skull} - */ - BlockType.Typed PIGLIN_HEAD = getBlockType("piglin_head"); - /** - * BlockData: {@link WallSkull} - */ - BlockType.Typed PIGLIN_WALL_HEAD = getBlockType("piglin_wall_head"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ANVIL = getBlockType("anvil"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed CHIPPED_ANVIL = getBlockType("chipped_anvil"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed DAMAGED_ANVIL = getBlockType("damaged_anvil"); - /** - * BlockData: {@link Chest} - */ - BlockType.Typed TRAPPED_CHEST = getBlockType("trapped_chest"); - /** - * BlockData: {@link AnaloguePowerable} - */ - BlockType.Typed LIGHT_WEIGHTED_PRESSURE_PLATE = getBlockType("light_weighted_pressure_plate"); - /** - * BlockData: {@link AnaloguePowerable} - */ - BlockType.Typed HEAVY_WEIGHTED_PRESSURE_PLATE = getBlockType("heavy_weighted_pressure_plate"); - /** - * BlockData: {@link Comparator} - */ - BlockType.Typed COMPARATOR = getBlockType("comparator"); - /** - * BlockData: {@link DaylightDetector} - */ - BlockType.Typed DAYLIGHT_DETECTOR = getBlockType("daylight_detector"); - BlockType.Typed REDSTONE_BLOCK = getBlockType("redstone_block"); - BlockType.Typed NETHER_QUARTZ_ORE = getBlockType("nether_quartz_ore"); - /** - * BlockData: {@link Hopper} - */ - BlockType.Typed HOPPER = getBlockType("hopper"); - BlockType.Typed QUARTZ_BLOCK = getBlockType("quartz_block"); - BlockType.Typed CHISELED_QUARTZ_BLOCK = getBlockType("chiseled_quartz_block"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed QUARTZ_PILLAR = getBlockType("quartz_pillar"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed QUARTZ_STAIRS = getBlockType("quartz_stairs"); - /** - * BlockData: {@link RedstoneRail} - */ - BlockType.Typed ACTIVATOR_RAIL = getBlockType("activator_rail"); - /** - * BlockData: {@link Dispenser} - */ - BlockType.Typed DROPPER = getBlockType("dropper"); - BlockType.Typed WHITE_TERRACOTTA = getBlockType("white_terracotta"); - BlockType.Typed ORANGE_TERRACOTTA = getBlockType("orange_terracotta"); - BlockType.Typed MAGENTA_TERRACOTTA = getBlockType("magenta_terracotta"); - BlockType.Typed LIGHT_BLUE_TERRACOTTA = getBlockType("light_blue_terracotta"); - BlockType.Typed YELLOW_TERRACOTTA = getBlockType("yellow_terracotta"); - BlockType.Typed LIME_TERRACOTTA = getBlockType("lime_terracotta"); - BlockType.Typed PINK_TERRACOTTA = getBlockType("pink_terracotta"); - BlockType.Typed GRAY_TERRACOTTA = getBlockType("gray_terracotta"); - BlockType.Typed LIGHT_GRAY_TERRACOTTA = getBlockType("light_gray_terracotta"); - BlockType.Typed CYAN_TERRACOTTA = getBlockType("cyan_terracotta"); - BlockType.Typed PURPLE_TERRACOTTA = getBlockType("purple_terracotta"); - BlockType.Typed BLUE_TERRACOTTA = getBlockType("blue_terracotta"); - BlockType.Typed BROWN_TERRACOTTA = getBlockType("brown_terracotta"); - BlockType.Typed GREEN_TERRACOTTA = getBlockType("green_terracotta"); - BlockType.Typed RED_TERRACOTTA = getBlockType("red_terracotta"); - BlockType.Typed BLACK_TERRACOTTA = getBlockType("black_terracotta"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed WHITE_STAINED_GLASS_PANE = getBlockType("white_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed ORANGE_STAINED_GLASS_PANE = getBlockType("orange_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed MAGENTA_STAINED_GLASS_PANE = getBlockType("magenta_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed LIGHT_BLUE_STAINED_GLASS_PANE = getBlockType("light_blue_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed YELLOW_STAINED_GLASS_PANE = getBlockType("yellow_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed LIME_STAINED_GLASS_PANE = getBlockType("lime_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed PINK_STAINED_GLASS_PANE = getBlockType("pink_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed GRAY_STAINED_GLASS_PANE = getBlockType("gray_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed LIGHT_GRAY_STAINED_GLASS_PANE = getBlockType("light_gray_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed CYAN_STAINED_GLASS_PANE = getBlockType("cyan_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed PURPLE_STAINED_GLASS_PANE = getBlockType("purple_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed BLUE_STAINED_GLASS_PANE = getBlockType("blue_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed BROWN_STAINED_GLASS_PANE = getBlockType("brown_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed GREEN_STAINED_GLASS_PANE = getBlockType("green_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed RED_STAINED_GLASS_PANE = getBlockType("red_stained_glass_pane"); - /** - * BlockData: {@link GlassPane} - */ - BlockType.Typed BLACK_STAINED_GLASS_PANE = getBlockType("black_stained_glass_pane"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed ACACIA_STAIRS = getBlockType("acacia_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed CHERRY_STAIRS = getBlockType("cherry_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed DARK_OAK_STAIRS = getBlockType("dark_oak_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed PALE_OAK_STAIRS = getBlockType("pale_oak_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed MANGROVE_STAIRS = getBlockType("mangrove_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed BAMBOO_STAIRS = getBlockType("bamboo_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed BAMBOO_MOSAIC_STAIRS = getBlockType("bamboo_mosaic_stairs"); - BlockType.Typed SLIME_BLOCK = getBlockType("slime_block"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed BARRIER = getBlockType("barrier"); - /** - * BlockData: {@link Light} - */ - BlockType.Typed LIGHT = getBlockType("light"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed IRON_TRAPDOOR = getBlockType("iron_trapdoor"); - BlockType.Typed PRISMARINE = getBlockType("prismarine"); - BlockType.Typed PRISMARINE_BRICKS = getBlockType("prismarine_bricks"); - BlockType.Typed DARK_PRISMARINE = getBlockType("dark_prismarine"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed PRISMARINE_STAIRS = getBlockType("prismarine_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed PRISMARINE_BRICK_STAIRS = getBlockType("prismarine_brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed DARK_PRISMARINE_STAIRS = getBlockType("dark_prismarine_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed PRISMARINE_SLAB = getBlockType("prismarine_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed PRISMARINE_BRICK_SLAB = getBlockType("prismarine_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed DARK_PRISMARINE_SLAB = getBlockType("dark_prismarine_slab"); - BlockType.Typed SEA_LANTERN = getBlockType("sea_lantern"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed HAY_BLOCK = getBlockType("hay_block"); - BlockType.Typed WHITE_CARPET = getBlockType("white_carpet"); - BlockType.Typed ORANGE_CARPET = getBlockType("orange_carpet"); - BlockType.Typed MAGENTA_CARPET = getBlockType("magenta_carpet"); - BlockType.Typed LIGHT_BLUE_CARPET = getBlockType("light_blue_carpet"); - BlockType.Typed YELLOW_CARPET = getBlockType("yellow_carpet"); - BlockType.Typed LIME_CARPET = getBlockType("lime_carpet"); - BlockType.Typed PINK_CARPET = getBlockType("pink_carpet"); - BlockType.Typed GRAY_CARPET = getBlockType("gray_carpet"); - BlockType.Typed LIGHT_GRAY_CARPET = getBlockType("light_gray_carpet"); - BlockType.Typed CYAN_CARPET = getBlockType("cyan_carpet"); - BlockType.Typed PURPLE_CARPET = getBlockType("purple_carpet"); - BlockType.Typed BLUE_CARPET = getBlockType("blue_carpet"); - BlockType.Typed BROWN_CARPET = getBlockType("brown_carpet"); - BlockType.Typed GREEN_CARPET = getBlockType("green_carpet"); - BlockType.Typed RED_CARPET = getBlockType("red_carpet"); - BlockType.Typed BLACK_CARPET = getBlockType("black_carpet"); - BlockType.Typed TERRACOTTA = getBlockType("terracotta"); - BlockType.Typed COAL_BLOCK = getBlockType("coal_block"); - BlockType.Typed PACKED_ICE = getBlockType("packed_ice"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed SUNFLOWER = getBlockType("sunflower"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed LILAC = getBlockType("lilac"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed ROSE_BUSH = getBlockType("rose_bush"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed PEONY = getBlockType("peony"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed TALL_GRASS = getBlockType("tall_grass"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed LARGE_FERN = getBlockType("large_fern"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed WHITE_BANNER = getBlockType("white_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed ORANGE_BANNER = getBlockType("orange_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed MAGENTA_BANNER = getBlockType("magenta_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed LIGHT_BLUE_BANNER = getBlockType("light_blue_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed YELLOW_BANNER = getBlockType("yellow_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed LIME_BANNER = getBlockType("lime_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed PINK_BANNER = getBlockType("pink_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed GRAY_BANNER = getBlockType("gray_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed LIGHT_GRAY_BANNER = getBlockType("light_gray_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed CYAN_BANNER = getBlockType("cyan_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed PURPLE_BANNER = getBlockType("purple_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed BLUE_BANNER = getBlockType("blue_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed BROWN_BANNER = getBlockType("brown_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed GREEN_BANNER = getBlockType("green_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed RED_BANNER = getBlockType("red_banner"); - /** - * BlockData: {@link Rotatable} - */ - BlockType.Typed BLACK_BANNER = getBlockType("black_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed WHITE_WALL_BANNER = getBlockType("white_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ORANGE_WALL_BANNER = getBlockType("orange_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed MAGENTA_WALL_BANNER = getBlockType("magenta_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_BLUE_WALL_BANNER = getBlockType("light_blue_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed YELLOW_WALL_BANNER = getBlockType("yellow_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIME_WALL_BANNER = getBlockType("lime_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PINK_WALL_BANNER = getBlockType("pink_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GRAY_WALL_BANNER = getBlockType("gray_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_GRAY_WALL_BANNER = getBlockType("light_gray_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed CYAN_WALL_BANNER = getBlockType("cyan_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PURPLE_WALL_BANNER = getBlockType("purple_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLUE_WALL_BANNER = getBlockType("blue_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BROWN_WALL_BANNER = getBlockType("brown_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GREEN_WALL_BANNER = getBlockType("green_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed RED_WALL_BANNER = getBlockType("red_wall_banner"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLACK_WALL_BANNER = getBlockType("black_wall_banner"); - BlockType.Typed RED_SANDSTONE = getBlockType("red_sandstone"); - BlockType.Typed CHISELED_RED_SANDSTONE = getBlockType("chiseled_red_sandstone"); - BlockType.Typed CUT_RED_SANDSTONE = getBlockType("cut_red_sandstone"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed RED_SANDSTONE_STAIRS = getBlockType("red_sandstone_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed OAK_SLAB = getBlockType("oak_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SPRUCE_SLAB = getBlockType("spruce_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed BIRCH_SLAB = getBlockType("birch_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed JUNGLE_SLAB = getBlockType("jungle_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed ACACIA_SLAB = getBlockType("acacia_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed CHERRY_SLAB = getBlockType("cherry_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed DARK_OAK_SLAB = getBlockType("dark_oak_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed PALE_OAK_SLAB = getBlockType("pale_oak_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed MANGROVE_SLAB = getBlockType("mangrove_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed BAMBOO_SLAB = getBlockType("bamboo_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed BAMBOO_MOSAIC_SLAB = getBlockType("bamboo_mosaic_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed STONE_SLAB = getBlockType("stone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SMOOTH_STONE_SLAB = getBlockType("smooth_stone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SANDSTONE_SLAB = getBlockType("sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed CUT_SANDSTONE_SLAB = getBlockType("cut_sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed PETRIFIED_OAK_SLAB = getBlockType("petrified_oak_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed COBBLESTONE_SLAB = getBlockType("cobblestone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed BRICK_SLAB = getBlockType("brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed STONE_BRICK_SLAB = getBlockType("stone_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed MUD_BRICK_SLAB = getBlockType("mud_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed NETHER_BRICK_SLAB = getBlockType("nether_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed QUARTZ_SLAB = getBlockType("quartz_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed RED_SANDSTONE_SLAB = getBlockType("red_sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed CUT_RED_SANDSTONE_SLAB = getBlockType("cut_red_sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed PURPUR_SLAB = getBlockType("purpur_slab"); - BlockType.Typed SMOOTH_STONE = getBlockType("smooth_stone"); - BlockType.Typed SMOOTH_SANDSTONE = getBlockType("smooth_sandstone"); - BlockType.Typed SMOOTH_QUARTZ = getBlockType("smooth_quartz"); - BlockType.Typed SMOOTH_RED_SANDSTONE = getBlockType("smooth_red_sandstone"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed SPRUCE_FENCE_GATE = getBlockType("spruce_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed BIRCH_FENCE_GATE = getBlockType("birch_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed JUNGLE_FENCE_GATE = getBlockType("jungle_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed ACACIA_FENCE_GATE = getBlockType("acacia_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed CHERRY_FENCE_GATE = getBlockType("cherry_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed DARK_OAK_FENCE_GATE = getBlockType("dark_oak_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed PALE_OAK_FENCE_GATE = getBlockType("pale_oak_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed MANGROVE_FENCE_GATE = getBlockType("mangrove_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed BAMBOO_FENCE_GATE = getBlockType("bamboo_fence_gate"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed SPRUCE_FENCE = getBlockType("spruce_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed BIRCH_FENCE = getBlockType("birch_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed JUNGLE_FENCE = getBlockType("jungle_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed ACACIA_FENCE = getBlockType("acacia_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed CHERRY_FENCE = getBlockType("cherry_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed DARK_OAK_FENCE = getBlockType("dark_oak_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed PALE_OAK_FENCE = getBlockType("pale_oak_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed MANGROVE_FENCE = getBlockType("mangrove_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed BAMBOO_FENCE = getBlockType("bamboo_fence"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed SPRUCE_DOOR = getBlockType("spruce_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed BIRCH_DOOR = getBlockType("birch_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed JUNGLE_DOOR = getBlockType("jungle_door"); - /** - * BlockData: {@link Door} - */ + BlockType.Typed ACACIA_DOOR = getBlockType("acacia_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed CHERRY_DOOR = getBlockType("cherry_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed DARK_OAK_DOOR = getBlockType("dark_oak_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed PALE_OAK_DOOR = getBlockType("pale_oak_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed MANGROVE_DOOR = getBlockType("mangrove_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed BAMBOO_DOOR = getBlockType("bamboo_door"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed END_ROD = getBlockType("end_rod"); - /** - * BlockData: {@link MultipleFacing} - */ - BlockType.Typed CHORUS_PLANT = getBlockType("chorus_plant"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed CHORUS_FLOWER = getBlockType("chorus_flower"); - BlockType.Typed PURPUR_BLOCK = getBlockType("purpur_block"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed PURPUR_PILLAR = getBlockType("purpur_pillar"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed PURPUR_STAIRS = getBlockType("purpur_stairs"); - BlockType.Typed END_STONE_BRICKS = getBlockType("end_stone_bricks"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed TORCHFLOWER_CROP = getBlockType("torchflower_crop"); - /** - * BlockData: {@link PitcherCrop} - */ - BlockType.Typed PITCHER_CROP = getBlockType("pitcher_crop"); - /** - * BlockData: {@link Bisected} - */ - BlockType.Typed PITCHER_PLANT = getBlockType("pitcher_plant"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed BEETROOTS = getBlockType("beetroots"); - BlockType.Typed DIRT_PATH = getBlockType("dirt_path"); - BlockType.Typed END_GATEWAY = getBlockType("end_gateway"); - /** - * BlockData: {@link CommandBlock} - */ - BlockType.Typed REPEATING_COMMAND_BLOCK = getBlockType("repeating_command_block"); - /** - * BlockData: {@link CommandBlock} - */ - BlockType.Typed CHAIN_COMMAND_BLOCK = getBlockType("chain_command_block"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed FROSTED_ICE = getBlockType("frosted_ice"); - BlockType.Typed MAGMA_BLOCK = getBlockType("magma_block"); - BlockType.Typed NETHER_WART_BLOCK = getBlockType("nether_wart_block"); - BlockType.Typed RED_NETHER_BRICKS = getBlockType("red_nether_bricks"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed BONE_BLOCK = getBlockType("bone_block"); - BlockType.Typed STRUCTURE_VOID = getBlockType("structure_void"); - /** - * BlockData: {@link Observer} - */ - BlockType.Typed OBSERVER = getBlockType("observer"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed SHULKER_BOX = getBlockType("shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed WHITE_SHULKER_BOX = getBlockType("white_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ORANGE_SHULKER_BOX = getBlockType("orange_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed MAGENTA_SHULKER_BOX = getBlockType("magenta_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_BLUE_SHULKER_BOX = getBlockType("light_blue_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed YELLOW_SHULKER_BOX = getBlockType("yellow_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIME_SHULKER_BOX = getBlockType("lime_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PINK_SHULKER_BOX = getBlockType("pink_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GRAY_SHULKER_BOX = getBlockType("gray_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_GRAY_SHULKER_BOX = getBlockType("light_gray_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed CYAN_SHULKER_BOX = getBlockType("cyan_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PURPLE_SHULKER_BOX = getBlockType("purple_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLUE_SHULKER_BOX = getBlockType("blue_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BROWN_SHULKER_BOX = getBlockType("brown_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GREEN_SHULKER_BOX = getBlockType("green_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed RED_SHULKER_BOX = getBlockType("red_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLACK_SHULKER_BOX = getBlockType("black_shulker_box"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed WHITE_GLAZED_TERRACOTTA = getBlockType("white_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed ORANGE_GLAZED_TERRACOTTA = getBlockType("orange_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed MAGENTA_GLAZED_TERRACOTTA = getBlockType("magenta_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_BLUE_GLAZED_TERRACOTTA = getBlockType("light_blue_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed YELLOW_GLAZED_TERRACOTTA = getBlockType("yellow_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIME_GLAZED_TERRACOTTA = getBlockType("lime_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PINK_GLAZED_TERRACOTTA = getBlockType("pink_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GRAY_GLAZED_TERRACOTTA = getBlockType("gray_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LIGHT_GRAY_GLAZED_TERRACOTTA = getBlockType("light_gray_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed CYAN_GLAZED_TERRACOTTA = getBlockType("cyan_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed PURPLE_GLAZED_TERRACOTTA = getBlockType("purple_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLUE_GLAZED_TERRACOTTA = getBlockType("blue_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BROWN_GLAZED_TERRACOTTA = getBlockType("brown_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed GREEN_GLAZED_TERRACOTTA = getBlockType("green_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed RED_GLAZED_TERRACOTTA = getBlockType("red_glazed_terracotta"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed BLACK_GLAZED_TERRACOTTA = getBlockType("black_glazed_terracotta"); - BlockType.Typed WHITE_CONCRETE = getBlockType("white_concrete"); - BlockType.Typed ORANGE_CONCRETE = getBlockType("orange_concrete"); - BlockType.Typed MAGENTA_CONCRETE = getBlockType("magenta_concrete"); - BlockType.Typed LIGHT_BLUE_CONCRETE = getBlockType("light_blue_concrete"); - BlockType.Typed YELLOW_CONCRETE = getBlockType("yellow_concrete"); - BlockType.Typed LIME_CONCRETE = getBlockType("lime_concrete"); - BlockType.Typed PINK_CONCRETE = getBlockType("pink_concrete"); - BlockType.Typed GRAY_CONCRETE = getBlockType("gray_concrete"); - BlockType.Typed LIGHT_GRAY_CONCRETE = getBlockType("light_gray_concrete"); - BlockType.Typed CYAN_CONCRETE = getBlockType("cyan_concrete"); - BlockType.Typed PURPLE_CONCRETE = getBlockType("purple_concrete"); - BlockType.Typed BLUE_CONCRETE = getBlockType("blue_concrete"); - BlockType.Typed BROWN_CONCRETE = getBlockType("brown_concrete"); - BlockType.Typed GREEN_CONCRETE = getBlockType("green_concrete"); - BlockType.Typed RED_CONCRETE = getBlockType("red_concrete"); - BlockType.Typed BLACK_CONCRETE = getBlockType("black_concrete"); - BlockType.Typed WHITE_CONCRETE_POWDER = getBlockType("white_concrete_powder"); - BlockType.Typed ORANGE_CONCRETE_POWDER = getBlockType("orange_concrete_powder"); - BlockType.Typed MAGENTA_CONCRETE_POWDER = getBlockType("magenta_concrete_powder"); - BlockType.Typed LIGHT_BLUE_CONCRETE_POWDER = getBlockType("light_blue_concrete_powder"); - BlockType.Typed YELLOW_CONCRETE_POWDER = getBlockType("yellow_concrete_powder"); - BlockType.Typed LIME_CONCRETE_POWDER = getBlockType("lime_concrete_powder"); - BlockType.Typed PINK_CONCRETE_POWDER = getBlockType("pink_concrete_powder"); - BlockType.Typed GRAY_CONCRETE_POWDER = getBlockType("gray_concrete_powder"); - BlockType.Typed LIGHT_GRAY_CONCRETE_POWDER = getBlockType("light_gray_concrete_powder"); - BlockType.Typed CYAN_CONCRETE_POWDER = getBlockType("cyan_concrete_powder"); - BlockType.Typed PURPLE_CONCRETE_POWDER = getBlockType("purple_concrete_powder"); - BlockType.Typed BLUE_CONCRETE_POWDER = getBlockType("blue_concrete_powder"); - BlockType.Typed BROWN_CONCRETE_POWDER = getBlockType("brown_concrete_powder"); - BlockType.Typed GREEN_CONCRETE_POWDER = getBlockType("green_concrete_powder"); - BlockType.Typed RED_CONCRETE_POWDER = getBlockType("red_concrete_powder"); - BlockType.Typed BLACK_CONCRETE_POWDER = getBlockType("black_concrete_powder"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed KELP = getBlockType("kelp"); - BlockType.Typed KELP_PLANT = getBlockType("kelp_plant"); - BlockType.Typed DRIED_KELP_BLOCK = getBlockType("dried_kelp_block"); - /** - * BlockData: {@link TurtleEgg} - */ - BlockType.Typed TURTLE_EGG = getBlockType("turtle_egg"); - /** - * BlockData: {@link Hatchable} - */ - BlockType.Typed SNIFFER_EGG = getBlockType("sniffer_egg"); - BlockType.Typed DEAD_TUBE_CORAL_BLOCK = getBlockType("dead_tube_coral_block"); - BlockType.Typed DEAD_BRAIN_CORAL_BLOCK = getBlockType("dead_brain_coral_block"); - BlockType.Typed DEAD_BUBBLE_CORAL_BLOCK = getBlockType("dead_bubble_coral_block"); - BlockType.Typed DEAD_FIRE_CORAL_BLOCK = getBlockType("dead_fire_coral_block"); - BlockType.Typed DEAD_HORN_CORAL_BLOCK = getBlockType("dead_horn_coral_block"); - BlockType.Typed TUBE_CORAL_BLOCK = getBlockType("tube_coral_block"); - BlockType.Typed BRAIN_CORAL_BLOCK = getBlockType("brain_coral_block"); - BlockType.Typed BUBBLE_CORAL_BLOCK = getBlockType("bubble_coral_block"); - BlockType.Typed FIRE_CORAL_BLOCK = getBlockType("fire_coral_block"); - BlockType.Typed HORN_CORAL_BLOCK = getBlockType("horn_coral_block"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_TUBE_CORAL = getBlockType("dead_tube_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_BRAIN_CORAL = getBlockType("dead_brain_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_BUBBLE_CORAL = getBlockType("dead_bubble_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_FIRE_CORAL = getBlockType("dead_fire_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_HORN_CORAL = getBlockType("dead_horn_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed TUBE_CORAL = getBlockType("tube_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed BRAIN_CORAL = getBlockType("brain_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed BUBBLE_CORAL = getBlockType("bubble_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed FIRE_CORAL = getBlockType("fire_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed HORN_CORAL = getBlockType("horn_coral"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_TUBE_CORAL_FAN = getBlockType("dead_tube_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_BRAIN_CORAL_FAN = getBlockType("dead_brain_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_BUBBLE_CORAL_FAN = getBlockType("dead_bubble_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_FIRE_CORAL_FAN = getBlockType("dead_fire_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed DEAD_HORN_CORAL_FAN = getBlockType("dead_horn_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed TUBE_CORAL_FAN = getBlockType("tube_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed BRAIN_CORAL_FAN = getBlockType("brain_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed BUBBLE_CORAL_FAN = getBlockType("bubble_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed FIRE_CORAL_FAN = getBlockType("fire_coral_fan"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed HORN_CORAL_FAN = getBlockType("horn_coral_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed DEAD_TUBE_CORAL_WALL_FAN = getBlockType("dead_tube_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed DEAD_BRAIN_CORAL_WALL_FAN = getBlockType("dead_brain_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed DEAD_BUBBLE_CORAL_WALL_FAN = getBlockType("dead_bubble_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed DEAD_FIRE_CORAL_WALL_FAN = getBlockType("dead_fire_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed DEAD_HORN_CORAL_WALL_FAN = getBlockType("dead_horn_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed TUBE_CORAL_WALL_FAN = getBlockType("tube_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed BRAIN_CORAL_WALL_FAN = getBlockType("brain_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed BUBBLE_CORAL_WALL_FAN = getBlockType("bubble_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed FIRE_CORAL_WALL_FAN = getBlockType("fire_coral_wall_fan"); - /** - * BlockData: {@link CoralWallFan} - */ - BlockType.Typed HORN_CORAL_WALL_FAN = getBlockType("horn_coral_wall_fan"); - /** - * BlockData: {@link SeaPickle} - */ - BlockType.Typed SEA_PICKLE = getBlockType("sea_pickle"); - BlockType.Typed BLUE_ICE = getBlockType("blue_ice"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed CONDUIT = getBlockType("conduit"); - BlockType.Typed BAMBOO_SAPLING = getBlockType("bamboo_sapling"); - /** - * BlockData: {@link Bamboo} - */ - BlockType.Typed BAMBOO = getBlockType("bamboo"); - BlockType.Typed POTTED_BAMBOO = getBlockType("potted_bamboo"); - BlockType.Typed VOID_AIR = getBlockType("void_air"); - BlockType.Typed CAVE_AIR = getBlockType("cave_air"); - /** - * BlockData: {@link BubbleColumn} - */ - BlockType.Typed BUBBLE_COLUMN = getBlockType("bubble_column"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_GRANITE_STAIRS = getBlockType("polished_granite_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed SMOOTH_RED_SANDSTONE_STAIRS = getBlockType("smooth_red_sandstone_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed MOSSY_STONE_BRICK_STAIRS = getBlockType("mossy_stone_brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_DIORITE_STAIRS = getBlockType("polished_diorite_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed MOSSY_COBBLESTONE_STAIRS = getBlockType("mossy_cobblestone_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed END_STONE_BRICK_STAIRS = getBlockType("end_stone_brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed STONE_STAIRS = getBlockType("stone_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed SMOOTH_SANDSTONE_STAIRS = getBlockType("smooth_sandstone_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed SMOOTH_QUARTZ_STAIRS = getBlockType("smooth_quartz_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed GRANITE_STAIRS = getBlockType("granite_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed ANDESITE_STAIRS = getBlockType("andesite_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed RED_NETHER_BRICK_STAIRS = getBlockType("red_nether_brick_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_ANDESITE_STAIRS = getBlockType("polished_andesite_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed DIORITE_STAIRS = getBlockType("diorite_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_GRANITE_SLAB = getBlockType("polished_granite_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SMOOTH_RED_SANDSTONE_SLAB = getBlockType("smooth_red_sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed MOSSY_STONE_BRICK_SLAB = getBlockType("mossy_stone_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_DIORITE_SLAB = getBlockType("polished_diorite_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed MOSSY_COBBLESTONE_SLAB = getBlockType("mossy_cobblestone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed END_STONE_BRICK_SLAB = getBlockType("end_stone_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SMOOTH_SANDSTONE_SLAB = getBlockType("smooth_sandstone_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed SMOOTH_QUARTZ_SLAB = getBlockType("smooth_quartz_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed GRANITE_SLAB = getBlockType("granite_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed ANDESITE_SLAB = getBlockType("andesite_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed RED_NETHER_BRICK_SLAB = getBlockType("red_nether_brick_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_ANDESITE_SLAB = getBlockType("polished_andesite_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed DIORITE_SLAB = getBlockType("diorite_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed BRICK_WALL = getBlockType("brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed PRISMARINE_WALL = getBlockType("prismarine_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed RED_SANDSTONE_WALL = getBlockType("red_sandstone_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed MOSSY_STONE_BRICK_WALL = getBlockType("mossy_stone_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed GRANITE_WALL = getBlockType("granite_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed STONE_BRICK_WALL = getBlockType("stone_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed MUD_BRICK_WALL = getBlockType("mud_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed NETHER_BRICK_WALL = getBlockType("nether_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed ANDESITE_WALL = getBlockType("andesite_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed RED_NETHER_BRICK_WALL = getBlockType("red_nether_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed SANDSTONE_WALL = getBlockType("sandstone_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed END_STONE_BRICK_WALL = getBlockType("end_stone_brick_wall"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed DIORITE_WALL = getBlockType("diorite_wall"); - /** - * BlockData: {@link Scaffolding} - */ - BlockType.Typed SCAFFOLDING = getBlockType("scaffolding"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed LOOM = getBlockType("loom"); - /** - * BlockData: {@link Barrel} - */ - BlockType.Typed BARREL = getBlockType("barrel"); - /** - * BlockData: {@link Furnace} - */ - BlockType.Typed SMOKER = getBlockType("smoker"); - /** - * BlockData: {@link Furnace} - */ - BlockType.Typed BLAST_FURNACE = getBlockType("blast_furnace"); - BlockType.Typed CARTOGRAPHY_TABLE = getBlockType("cartography_table"); - BlockType.Typed FLETCHING_TABLE = getBlockType("fletching_table"); - /** - * BlockData: {@link Grindstone} - */ - BlockType.Typed GRINDSTONE = getBlockType("grindstone"); - /** - * BlockData: {@link Lectern} - */ - BlockType.Typed LECTERN = getBlockType("lectern"); - BlockType.Typed SMITHING_TABLE = getBlockType("smithing_table"); - /** - * BlockData: {@link Directional} - */ - BlockType.Typed STONECUTTER = getBlockType("stonecutter"); - /** - * BlockData: {@link Bell} - */ - BlockType.Typed BELL = getBlockType("bell"); - /** - * BlockData: {@link Lantern} - */ - BlockType.Typed LANTERN = getBlockType("lantern"); - /** - * BlockData: {@link Lantern} - */ - BlockType.Typed SOUL_LANTERN = getBlockType("soul_lantern"); - /** - * BlockData: {@link Campfire} - */ - BlockType.Typed CAMPFIRE = getBlockType("campfire"); - /** - * BlockData: {@link Campfire} - */ - BlockType.Typed SOUL_CAMPFIRE = getBlockType("soul_campfire"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed SWEET_BERRY_BUSH = getBlockType("sweet_berry_bush"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed WARPED_STEM = getBlockType("warped_stem"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_WARPED_STEM = getBlockType("stripped_warped_stem"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed WARPED_HYPHAE = getBlockType("warped_hyphae"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_WARPED_HYPHAE = getBlockType("stripped_warped_hyphae"); - BlockType.Typed WARPED_NYLIUM = getBlockType("warped_nylium"); - BlockType.Typed WARPED_FUNGUS = getBlockType("warped_fungus"); - BlockType.Typed WARPED_WART_BLOCK = getBlockType("warped_wart_block"); - BlockType.Typed WARPED_ROOTS = getBlockType("warped_roots"); - BlockType.Typed NETHER_SPROUTS = getBlockType("nether_sprouts"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed CRIMSON_STEM = getBlockType("crimson_stem"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_CRIMSON_STEM = getBlockType("stripped_crimson_stem"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed CRIMSON_HYPHAE = getBlockType("crimson_hyphae"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed STRIPPED_CRIMSON_HYPHAE = getBlockType("stripped_crimson_hyphae"); - BlockType.Typed CRIMSON_NYLIUM = getBlockType("crimson_nylium"); - BlockType.Typed CRIMSON_FUNGUS = getBlockType("crimson_fungus"); - BlockType.Typed SHROOMLIGHT = getBlockType("shroomlight"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed WEEPING_VINES = getBlockType("weeping_vines"); - BlockType.Typed WEEPING_VINES_PLANT = getBlockType("weeping_vines_plant"); - /** - * BlockData: {@link Ageable} - */ - BlockType.Typed TWISTING_VINES = getBlockType("twisting_vines"); - BlockType.Typed TWISTING_VINES_PLANT = getBlockType("twisting_vines_plant"); - BlockType.Typed CRIMSON_ROOTS = getBlockType("crimson_roots"); - BlockType.Typed CRIMSON_PLANKS = getBlockType("crimson_planks"); - BlockType.Typed WARPED_PLANKS = getBlockType("warped_planks"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed CRIMSON_SLAB = getBlockType("crimson_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WARPED_SLAB = getBlockType("warped_slab"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed CRIMSON_PRESSURE_PLATE = getBlockType("crimson_pressure_plate"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed WARPED_PRESSURE_PLATE = getBlockType("warped_pressure_plate"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed CRIMSON_FENCE = getBlockType("crimson_fence"); - /** - * BlockData: {@link Fence} - */ - BlockType.Typed WARPED_FENCE = getBlockType("warped_fence"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed CRIMSON_TRAPDOOR = getBlockType("crimson_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WARPED_TRAPDOOR = getBlockType("warped_trapdoor"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed CRIMSON_FENCE_GATE = getBlockType("crimson_fence_gate"); - /** - * BlockData: {@link Gate} - */ - BlockType.Typed WARPED_FENCE_GATE = getBlockType("warped_fence_gate"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed CRIMSON_STAIRS = getBlockType("crimson_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WARPED_STAIRS = getBlockType("warped_stairs"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed CRIMSON_BUTTON = getBlockType("crimson_button"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed WARPED_BUTTON = getBlockType("warped_button"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed CRIMSON_DOOR = getBlockType("crimson_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WARPED_DOOR = getBlockType("warped_door"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed CRIMSON_SIGN = getBlockType("crimson_sign"); - /** - * BlockData: {@link Sign} - */ - BlockType.Typed WARPED_SIGN = getBlockType("warped_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed CRIMSON_WALL_SIGN = getBlockType("crimson_wall_sign"); - /** - * BlockData: {@link WallSign} - */ - BlockType.Typed WARPED_WALL_SIGN = getBlockType("warped_wall_sign"); - /** - * BlockData: {@link StructureBlock} - */ - BlockType.Typed STRUCTURE_BLOCK = getBlockType("structure_block"); - /** - * BlockData: {@link Jigsaw} - */ - BlockType.Typed JIGSAW = getBlockType("jigsaw"); - /** - * BlockData: {@link Levelled} - */ - BlockType.Typed COMPOSTER = getBlockType("composter"); - /** - * BlockData: {@link AnaloguePowerable} - */ - BlockType.Typed TARGET = getBlockType("target"); - /** - * BlockData: {@link Beehive} - */ - BlockType.Typed BEE_NEST = getBlockType("bee_nest"); - /** - * BlockData: {@link Beehive} - */ - BlockType.Typed BEEHIVE = getBlockType("beehive"); - BlockType.Typed HONEY_BLOCK = getBlockType("honey_block"); - BlockType.Typed HONEYCOMB_BLOCK = getBlockType("honeycomb_block"); - BlockType.Typed NETHERITE_BLOCK = getBlockType("netherite_block"); - BlockType.Typed ANCIENT_DEBRIS = getBlockType("ancient_debris"); - BlockType.Typed CRYING_OBSIDIAN = getBlockType("crying_obsidian"); - /** - * BlockData: {@link RespawnAnchor} - */ - BlockType.Typed RESPAWN_ANCHOR = getBlockType("respawn_anchor"); - BlockType.Typed POTTED_CRIMSON_FUNGUS = getBlockType("potted_crimson_fungus"); - BlockType.Typed POTTED_WARPED_FUNGUS = getBlockType("potted_warped_fungus"); - BlockType.Typed POTTED_CRIMSON_ROOTS = getBlockType("potted_crimson_roots"); - BlockType.Typed POTTED_WARPED_ROOTS = getBlockType("potted_warped_roots"); - BlockType.Typed LODESTONE = getBlockType("lodestone"); - BlockType.Typed BLACKSTONE = getBlockType("blackstone"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed BLACKSTONE_STAIRS = getBlockType("blackstone_stairs"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed BLACKSTONE_WALL = getBlockType("blackstone_wall"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed BLACKSTONE_SLAB = getBlockType("blackstone_slab"); - BlockType.Typed POLISHED_BLACKSTONE = getBlockType("polished_blackstone"); - BlockType.Typed POLISHED_BLACKSTONE_BRICKS = getBlockType("polished_blackstone_bricks"); - BlockType.Typed CRACKED_POLISHED_BLACKSTONE_BRICKS = getBlockType("cracked_polished_blackstone_bricks"); - BlockType.Typed CHISELED_POLISHED_BLACKSTONE = getBlockType("chiseled_polished_blackstone"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_BLACKSTONE_BRICK_SLAB = getBlockType("polished_blackstone_brick_slab"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_BLACKSTONE_BRICK_STAIRS = getBlockType("polished_blackstone_brick_stairs"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed POLISHED_BLACKSTONE_BRICK_WALL = getBlockType("polished_blackstone_brick_wall"); - BlockType.Typed GILDED_BLACKSTONE = getBlockType("gilded_blackstone"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_BLACKSTONE_STAIRS = getBlockType("polished_blackstone_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_BLACKSTONE_SLAB = getBlockType("polished_blackstone_slab"); - /** - * BlockData: {@link Powerable} - */ - BlockType.Typed POLISHED_BLACKSTONE_PRESSURE_PLATE = getBlockType("polished_blackstone_pressure_plate"); - /** - * BlockData: {@link Switch} - */ - BlockType.Typed POLISHED_BLACKSTONE_BUTTON = getBlockType("polished_blackstone_button"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed POLISHED_BLACKSTONE_WALL = getBlockType("polished_blackstone_wall"); - BlockType.Typed CHISELED_NETHER_BRICKS = getBlockType("chiseled_nether_bricks"); - BlockType.Typed CRACKED_NETHER_BRICKS = getBlockType("cracked_nether_bricks"); - BlockType.Typed QUARTZ_BRICKS = getBlockType("quartz_bricks"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed CANDLE = getBlockType("candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed WHITE_CANDLE = getBlockType("white_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed ORANGE_CANDLE = getBlockType("orange_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed MAGENTA_CANDLE = getBlockType("magenta_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed LIGHT_BLUE_CANDLE = getBlockType("light_blue_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed YELLOW_CANDLE = getBlockType("yellow_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed LIME_CANDLE = getBlockType("lime_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed PINK_CANDLE = getBlockType("pink_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed GRAY_CANDLE = getBlockType("gray_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed LIGHT_GRAY_CANDLE = getBlockType("light_gray_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed CYAN_CANDLE = getBlockType("cyan_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed PURPLE_CANDLE = getBlockType("purple_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed BLUE_CANDLE = getBlockType("blue_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed BROWN_CANDLE = getBlockType("brown_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed GREEN_CANDLE = getBlockType("green_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed RED_CANDLE = getBlockType("red_candle"); - /** - * BlockData: {@link Candle} - */ - BlockType.Typed BLACK_CANDLE = getBlockType("black_candle"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed CANDLE_CAKE = getBlockType("candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed WHITE_CANDLE_CAKE = getBlockType("white_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed ORANGE_CANDLE_CAKE = getBlockType("orange_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed MAGENTA_CANDLE_CAKE = getBlockType("magenta_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed LIGHT_BLUE_CANDLE_CAKE = getBlockType("light_blue_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed YELLOW_CANDLE_CAKE = getBlockType("yellow_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed LIME_CANDLE_CAKE = getBlockType("lime_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed PINK_CANDLE_CAKE = getBlockType("pink_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed GRAY_CANDLE_CAKE = getBlockType("gray_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed LIGHT_GRAY_CANDLE_CAKE = getBlockType("light_gray_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed CYAN_CANDLE_CAKE = getBlockType("cyan_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed PURPLE_CANDLE_CAKE = getBlockType("purple_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed BLUE_CANDLE_CAKE = getBlockType("blue_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed BROWN_CANDLE_CAKE = getBlockType("brown_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed GREEN_CANDLE_CAKE = getBlockType("green_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed RED_CANDLE_CAKE = getBlockType("red_candle_cake"); - /** - * BlockData: {@link Lightable} - */ - BlockType.Typed BLACK_CANDLE_CAKE = getBlockType("black_candle_cake"); + + BlockType.Typed ACACIA_FENCE = getBlockType("acacia_fence"); + + BlockType.Typed ACACIA_FENCE_GATE = getBlockType("acacia_fence_gate"); + + BlockType.Typed ACACIA_HANGING_SIGN = getBlockType("acacia_hanging_sign"); + + BlockType.Typed ACACIA_LEAVES = getBlockType("acacia_leaves"); + + BlockType.Typed ACACIA_LOG = getBlockType("acacia_log"); + + BlockType.Typed ACACIA_PLANKS = getBlockType("acacia_planks"); + + BlockType.Typed ACACIA_PRESSURE_PLATE = getBlockType("acacia_pressure_plate"); + + BlockType.Typed ACACIA_SAPLING = getBlockType("acacia_sapling"); + + BlockType.Typed ACACIA_SIGN = getBlockType("acacia_sign"); + + BlockType.Typed ACACIA_SLAB = getBlockType("acacia_slab"); + + BlockType.Typed ACACIA_STAIRS = getBlockType("acacia_stairs"); + + BlockType.Typed ACACIA_TRAPDOOR = getBlockType("acacia_trapdoor"); + + BlockType.Typed ACACIA_WALL_HANGING_SIGN = getBlockType("acacia_wall_hanging_sign"); + + BlockType.Typed ACACIA_WALL_SIGN = getBlockType("acacia_wall_sign"); + + BlockType.Typed ACACIA_WOOD = getBlockType("acacia_wood"); + + BlockType.Typed ACTIVATOR_RAIL = getBlockType("activator_rail"); + + BlockType.Typed AIR = getBlockType("air"); + + BlockType.Typed ALLIUM = getBlockType("allium"); + BlockType.Typed AMETHYST_BLOCK = getBlockType("amethyst_block"); - BlockType.Typed BUDDING_AMETHYST = getBlockType("budding_amethyst"); - /** - * BlockData: {@link AmethystCluster} - */ + BlockType.Typed AMETHYST_CLUSTER = getBlockType("amethyst_cluster"); - /** - * BlockData: {@link AmethystCluster} - */ - BlockType.Typed LARGE_AMETHYST_BUD = getBlockType("large_amethyst_bud"); - /** - * BlockData: {@link AmethystCluster} - */ - BlockType.Typed MEDIUM_AMETHYST_BUD = getBlockType("medium_amethyst_bud"); - /** - * BlockData: {@link AmethystCluster} - */ - BlockType.Typed SMALL_AMETHYST_BUD = getBlockType("small_amethyst_bud"); - BlockType.Typed TUFF = getBlockType("tuff"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed TUFF_SLAB = getBlockType("tuff_slab"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed TUFF_STAIRS = getBlockType("tuff_stairs"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed TUFF_WALL = getBlockType("tuff_wall"); - BlockType.Typed POLISHED_TUFF = getBlockType("polished_tuff"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_TUFF_SLAB = getBlockType("polished_tuff_slab"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_TUFF_STAIRS = getBlockType("polished_tuff_stairs"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed POLISHED_TUFF_WALL = getBlockType("polished_tuff_wall"); - BlockType.Typed CHISELED_TUFF = getBlockType("chiseled_tuff"); - BlockType.Typed TUFF_BRICKS = getBlockType("tuff_bricks"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed TUFF_BRICK_SLAB = getBlockType("tuff_brick_slab"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed TUFF_BRICK_STAIRS = getBlockType("tuff_brick_stairs"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed TUFF_BRICK_WALL = getBlockType("tuff_brick_wall"); - BlockType.Typed CHISELED_TUFF_BRICKS = getBlockType("chiseled_tuff_bricks"); - BlockType.Typed CALCITE = getBlockType("calcite"); - BlockType.Typed TINTED_GLASS = getBlockType("tinted_glass"); - BlockType.Typed POWDER_SNOW = getBlockType("powder_snow"); - /** - * BlockData: {@link SculkSensor} - */ - BlockType.Typed SCULK_SENSOR = getBlockType("sculk_sensor"); - /** - * BlockData: {@link CalibratedSculkSensor} - */ - BlockType.Typed CALIBRATED_SCULK_SENSOR = getBlockType("calibrated_sculk_sensor"); - BlockType.Typed SCULK = getBlockType("sculk"); - /** - * BlockData: {@link SculkVein} - */ - BlockType.Typed SCULK_VEIN = getBlockType("sculk_vein"); - /** - * BlockData: {@link SculkCatalyst} - */ - BlockType.Typed SCULK_CATALYST = getBlockType("sculk_catalyst"); - /** - * BlockData: {@link SculkShrieker} - */ - BlockType.Typed SCULK_SHRIEKER = getBlockType("sculk_shrieker"); - BlockType.Typed COPPER_BLOCK = getBlockType("copper_block"); - BlockType.Typed EXPOSED_COPPER = getBlockType("exposed_copper"); - BlockType.Typed WEATHERED_COPPER = getBlockType("weathered_copper"); - BlockType.Typed OXIDIZED_COPPER = getBlockType("oxidized_copper"); - BlockType.Typed COPPER_ORE = getBlockType("copper_ore"); - BlockType.Typed DEEPSLATE_COPPER_ORE = getBlockType("deepslate_copper_ore"); - BlockType.Typed OXIDIZED_CUT_COPPER = getBlockType("oxidized_cut_copper"); - BlockType.Typed WEATHERED_CUT_COPPER = getBlockType("weathered_cut_copper"); - BlockType.Typed EXPOSED_CUT_COPPER = getBlockType("exposed_cut_copper"); - BlockType.Typed CUT_COPPER = getBlockType("cut_copper"); - BlockType.Typed OXIDIZED_CHISELED_COPPER = getBlockType("oxidized_chiseled_copper"); - BlockType.Typed WEATHERED_CHISELED_COPPER = getBlockType("weathered_chiseled_copper"); - BlockType.Typed EXPOSED_CHISELED_COPPER = getBlockType("exposed_chiseled_copper"); - BlockType.Typed CHISELED_COPPER = getBlockType("chiseled_copper"); - BlockType.Typed WAXED_OXIDIZED_CHISELED_COPPER = getBlockType("waxed_oxidized_chiseled_copper"); - BlockType.Typed WAXED_WEATHERED_CHISELED_COPPER = getBlockType("waxed_weathered_chiseled_copper"); - BlockType.Typed WAXED_EXPOSED_CHISELED_COPPER = getBlockType("waxed_exposed_chiseled_copper"); - BlockType.Typed WAXED_CHISELED_COPPER = getBlockType("waxed_chiseled_copper"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed OXIDIZED_CUT_COPPER_STAIRS = getBlockType("oxidized_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WEATHERED_CUT_COPPER_STAIRS = getBlockType("weathered_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed EXPOSED_CUT_COPPER_STAIRS = getBlockType("exposed_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed CUT_COPPER_STAIRS = getBlockType("cut_copper_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed OXIDIZED_CUT_COPPER_SLAB = getBlockType("oxidized_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WEATHERED_CUT_COPPER_SLAB = getBlockType("weathered_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed EXPOSED_CUT_COPPER_SLAB = getBlockType("exposed_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed CUT_COPPER_SLAB = getBlockType("cut_copper_slab"); - BlockType.Typed WAXED_COPPER_BLOCK = getBlockType("waxed_copper_block"); - BlockType.Typed WAXED_WEATHERED_COPPER = getBlockType("waxed_weathered_copper"); - BlockType.Typed WAXED_EXPOSED_COPPER = getBlockType("waxed_exposed_copper"); - BlockType.Typed WAXED_OXIDIZED_COPPER = getBlockType("waxed_oxidized_copper"); - BlockType.Typed WAXED_OXIDIZED_CUT_COPPER = getBlockType("waxed_oxidized_cut_copper"); - BlockType.Typed WAXED_WEATHERED_CUT_COPPER = getBlockType("waxed_weathered_cut_copper"); - BlockType.Typed WAXED_EXPOSED_CUT_COPPER = getBlockType("waxed_exposed_cut_copper"); - BlockType.Typed WAXED_CUT_COPPER = getBlockType("waxed_cut_copper"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WAXED_OXIDIZED_CUT_COPPER_STAIRS = getBlockType("waxed_oxidized_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WAXED_WEATHERED_CUT_COPPER_STAIRS = getBlockType("waxed_weathered_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WAXED_EXPOSED_CUT_COPPER_STAIRS = getBlockType("waxed_exposed_cut_copper_stairs"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed WAXED_CUT_COPPER_STAIRS = getBlockType("waxed_cut_copper_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WAXED_OXIDIZED_CUT_COPPER_SLAB = getBlockType("waxed_oxidized_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WAXED_WEATHERED_CUT_COPPER_SLAB = getBlockType("waxed_weathered_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WAXED_EXPOSED_CUT_COPPER_SLAB = getBlockType("waxed_exposed_cut_copper_slab"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed WAXED_CUT_COPPER_SLAB = getBlockType("waxed_cut_copper_slab"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed COPPER_DOOR = getBlockType("copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed EXPOSED_COPPER_DOOR = getBlockType("exposed_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed OXIDIZED_COPPER_DOOR = getBlockType("oxidized_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WEATHERED_COPPER_DOOR = getBlockType("weathered_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WAXED_COPPER_DOOR = getBlockType("waxed_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WAXED_EXPOSED_COPPER_DOOR = getBlockType("waxed_exposed_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WAXED_OXIDIZED_COPPER_DOOR = getBlockType("waxed_oxidized_copper_door"); - /** - * BlockData: {@link Door} - */ - BlockType.Typed WAXED_WEATHERED_COPPER_DOOR = getBlockType("waxed_weathered_copper_door"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed COPPER_TRAPDOOR = getBlockType("copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed EXPOSED_COPPER_TRAPDOOR = getBlockType("exposed_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed OXIDIZED_COPPER_TRAPDOOR = getBlockType("oxidized_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WEATHERED_COPPER_TRAPDOOR = getBlockType("weathered_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WAXED_COPPER_TRAPDOOR = getBlockType("waxed_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WAXED_EXPOSED_COPPER_TRAPDOOR = getBlockType("waxed_exposed_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WAXED_OXIDIZED_COPPER_TRAPDOOR = getBlockType("waxed_oxidized_copper_trapdoor"); - /** - * BlockData: {@link TrapDoor} - */ - BlockType.Typed WAXED_WEATHERED_COPPER_TRAPDOOR = getBlockType("waxed_weathered_copper_trapdoor"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed COPPER_GRATE = getBlockType("copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed EXPOSED_COPPER_GRATE = getBlockType("exposed_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed WEATHERED_COPPER_GRATE = getBlockType("weathered_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed OXIDIZED_COPPER_GRATE = getBlockType("oxidized_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed WAXED_COPPER_GRATE = getBlockType("waxed_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed WAXED_EXPOSED_COPPER_GRATE = getBlockType("waxed_exposed_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed WAXED_WEATHERED_COPPER_GRATE = getBlockType("waxed_weathered_copper_grate"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed WAXED_OXIDIZED_COPPER_GRATE = getBlockType("waxed_oxidized_copper_grate"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed COPPER_BULB = getBlockType("copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed EXPOSED_COPPER_BULB = getBlockType("exposed_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed WEATHERED_COPPER_BULB = getBlockType("weathered_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed OXIDIZED_COPPER_BULB = getBlockType("oxidized_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed WAXED_COPPER_BULB = getBlockType("waxed_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed WAXED_EXPOSED_COPPER_BULB = getBlockType("waxed_exposed_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed WAXED_WEATHERED_COPPER_BULB = getBlockType("waxed_weathered_copper_bulb"); - /** - * BlockData: {@link CopperBulb} - */ - BlockType.Typed WAXED_OXIDIZED_COPPER_BULB = getBlockType("waxed_oxidized_copper_bulb"); - /** - * BlockData: {@link LightningRod} - */ - BlockType.Typed LIGHTNING_ROD = getBlockType("lightning_rod"); - /** - * BlockData: {@link PointedDripstone} - */ - BlockType.Typed POINTED_DRIPSTONE = getBlockType("pointed_dripstone"); - BlockType.Typed DRIPSTONE_BLOCK = getBlockType("dripstone_block"); - /** - * BlockData: {@link CaveVines} - */ - BlockType.Typed CAVE_VINES = getBlockType("cave_vines"); - /** - * BlockData: {@link CaveVinesPlant} - */ - BlockType.Typed CAVE_VINES_PLANT = getBlockType("cave_vines_plant"); - BlockType.Typed SPORE_BLOSSOM = getBlockType("spore_blossom"); + + BlockType.Typed ANCIENT_DEBRIS = getBlockType("ancient_debris"); + + BlockType.Typed ANDESITE = getBlockType("andesite"); + + BlockType.Typed ANDESITE_SLAB = getBlockType("andesite_slab"); + + BlockType.Typed ANDESITE_STAIRS = getBlockType("andesite_stairs"); + + BlockType.Typed ANDESITE_WALL = getBlockType("andesite_wall"); + + BlockType.Typed ANVIL = getBlockType("anvil"); + + BlockType.Typed ATTACHED_MELON_STEM = getBlockType("attached_melon_stem"); + + BlockType.Typed ATTACHED_PUMPKIN_STEM = getBlockType("attached_pumpkin_stem"); + BlockType.Typed AZALEA = getBlockType("azalea"); - BlockType.Typed FLOWERING_AZALEA = getBlockType("flowering_azalea"); - /** - * BlockData: {@link PinkPetals} - */ - BlockType.Typed PINK_PETALS = getBlockType("pink_petals"); - BlockType.Typed MOSS_CARPET = getBlockType("moss_carpet"); - BlockType.Typed MOSS_BLOCK = getBlockType("moss_block"); - /** - * BlockData: {@link MossyCarpet} - */ - BlockType.Typed PALE_MOSS_CARPET = getBlockType("pale_moss_carpet"); - /** - * BlockData: {@link HangingMoss} - */ - BlockType.Typed PALE_HANGING_MOSS = getBlockType("pale_hanging_moss"); - BlockType.Typed PALE_MOSS_BLOCK = getBlockType("pale_moss_block"); - /** - * BlockData: {@link BigDripleaf} - */ + + BlockType.Typed AZALEA_LEAVES = getBlockType("azalea_leaves"); + + BlockType.Typed AZURE_BLUET = getBlockType("azure_bluet"); + + BlockType.Typed BAMBOO = getBlockType("bamboo"); + + BlockType.Typed BAMBOO_BLOCK = getBlockType("bamboo_block"); + + BlockType.Typed BAMBOO_BUTTON = getBlockType("bamboo_button"); + + BlockType.Typed BAMBOO_DOOR = getBlockType("bamboo_door"); + + BlockType.Typed BAMBOO_FENCE = getBlockType("bamboo_fence"); + + BlockType.Typed BAMBOO_FENCE_GATE = getBlockType("bamboo_fence_gate"); + + BlockType.Typed BAMBOO_HANGING_SIGN = getBlockType("bamboo_hanging_sign"); + + BlockType.Typed BAMBOO_MOSAIC = getBlockType("bamboo_mosaic"); + + BlockType.Typed BAMBOO_MOSAIC_SLAB = getBlockType("bamboo_mosaic_slab"); + + BlockType.Typed BAMBOO_MOSAIC_STAIRS = getBlockType("bamboo_mosaic_stairs"); + + BlockType.Typed BAMBOO_PLANKS = getBlockType("bamboo_planks"); + + BlockType.Typed BAMBOO_PRESSURE_PLATE = getBlockType("bamboo_pressure_plate"); + + BlockType.Typed BAMBOO_SAPLING = getBlockType("bamboo_sapling"); + + BlockType.Typed BAMBOO_SIGN = getBlockType("bamboo_sign"); + + BlockType.Typed BAMBOO_SLAB = getBlockType("bamboo_slab"); + + BlockType.Typed BAMBOO_STAIRS = getBlockType("bamboo_stairs"); + + BlockType.Typed BAMBOO_TRAPDOOR = getBlockType("bamboo_trapdoor"); + + BlockType.Typed BAMBOO_WALL_HANGING_SIGN = getBlockType("bamboo_wall_hanging_sign"); + + BlockType.Typed BAMBOO_WALL_SIGN = getBlockType("bamboo_wall_sign"); + + BlockType.Typed BARREL = getBlockType("barrel"); + + BlockType.Typed BARRIER = getBlockType("barrier"); + + BlockType.Typed BASALT = getBlockType("basalt"); + + BlockType.Typed BEACON = getBlockType("beacon"); + + BlockType.Typed BEDROCK = getBlockType("bedrock"); + + BlockType.Typed BEE_NEST = getBlockType("bee_nest"); + + BlockType.Typed BEEHIVE = getBlockType("beehive"); + + BlockType.Typed BEETROOTS = getBlockType("beetroots"); + + BlockType.Typed BELL = getBlockType("bell"); + BlockType.Typed BIG_DRIPLEAF = getBlockType("big_dripleaf"); - /** - * BlockData: {@link Dripleaf} - */ + BlockType.Typed BIG_DRIPLEAF_STEM = getBlockType("big_dripleaf_stem"); - /** - * BlockData: {@link SmallDripleaf} - */ - BlockType.Typed SMALL_DRIPLEAF = getBlockType("small_dripleaf"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed HANGING_ROOTS = getBlockType("hanging_roots"); - BlockType.Typed ROOTED_DIRT = getBlockType("rooted_dirt"); - BlockType.Typed MUD = getBlockType("mud"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed DEEPSLATE = getBlockType("deepslate"); - BlockType.Typed COBBLED_DEEPSLATE = getBlockType("cobbled_deepslate"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed COBBLED_DEEPSLATE_STAIRS = getBlockType("cobbled_deepslate_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed COBBLED_DEEPSLATE_SLAB = getBlockType("cobbled_deepslate_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed COBBLED_DEEPSLATE_WALL = getBlockType("cobbled_deepslate_wall"); - BlockType.Typed POLISHED_DEEPSLATE = getBlockType("polished_deepslate"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed POLISHED_DEEPSLATE_STAIRS = getBlockType("polished_deepslate_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed POLISHED_DEEPSLATE_SLAB = getBlockType("polished_deepslate_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed POLISHED_DEEPSLATE_WALL = getBlockType("polished_deepslate_wall"); - BlockType.Typed DEEPSLATE_TILES = getBlockType("deepslate_tiles"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed DEEPSLATE_TILE_STAIRS = getBlockType("deepslate_tile_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed DEEPSLATE_TILE_SLAB = getBlockType("deepslate_tile_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed DEEPSLATE_TILE_WALL = getBlockType("deepslate_tile_wall"); - BlockType.Typed DEEPSLATE_BRICKS = getBlockType("deepslate_bricks"); - /** - * BlockData: {@link Stairs} - */ - BlockType.Typed DEEPSLATE_BRICK_STAIRS = getBlockType("deepslate_brick_stairs"); - /** - * BlockData: {@link Slab} - */ - BlockType.Typed DEEPSLATE_BRICK_SLAB = getBlockType("deepslate_brick_slab"); - /** - * BlockData: {@link Wall} - */ - BlockType.Typed DEEPSLATE_BRICK_WALL = getBlockType("deepslate_brick_wall"); + + BlockType.Typed BIRCH_BUTTON = getBlockType("birch_button"); + + BlockType.Typed BIRCH_DOOR = getBlockType("birch_door"); + + BlockType.Typed BIRCH_FENCE = getBlockType("birch_fence"); + + BlockType.Typed BIRCH_FENCE_GATE = getBlockType("birch_fence_gate"); + + BlockType.Typed BIRCH_HANGING_SIGN = getBlockType("birch_hanging_sign"); + + BlockType.Typed BIRCH_LEAVES = getBlockType("birch_leaves"); + + BlockType.Typed BIRCH_LOG = getBlockType("birch_log"); + + BlockType.Typed BIRCH_PLANKS = getBlockType("birch_planks"); + + BlockType.Typed BIRCH_PRESSURE_PLATE = getBlockType("birch_pressure_plate"); + + BlockType.Typed BIRCH_SAPLING = getBlockType("birch_sapling"); + + BlockType.Typed BIRCH_SIGN = getBlockType("birch_sign"); + + BlockType.Typed BIRCH_SLAB = getBlockType("birch_slab"); + + BlockType.Typed BIRCH_STAIRS = getBlockType("birch_stairs"); + + BlockType.Typed BIRCH_TRAPDOOR = getBlockType("birch_trapdoor"); + + BlockType.Typed BIRCH_WALL_HANGING_SIGN = getBlockType("birch_wall_hanging_sign"); + + BlockType.Typed BIRCH_WALL_SIGN = getBlockType("birch_wall_sign"); + + BlockType.Typed BIRCH_WOOD = getBlockType("birch_wood"); + + BlockType.Typed BLACK_BANNER = getBlockType("black_banner"); + + BlockType.Typed BLACK_BED = getBlockType("black_bed"); + + BlockType.Typed BLACK_CANDLE = getBlockType("black_candle"); + + BlockType.Typed BLACK_CANDLE_CAKE = getBlockType("black_candle_cake"); + + BlockType.Typed BLACK_CARPET = getBlockType("black_carpet"); + + BlockType.Typed BLACK_CONCRETE = getBlockType("black_concrete"); + + BlockType.Typed BLACK_CONCRETE_POWDER = getBlockType("black_concrete_powder"); + + BlockType.Typed BLACK_GLAZED_TERRACOTTA = getBlockType("black_glazed_terracotta"); + + BlockType.Typed BLACK_SHULKER_BOX = getBlockType("black_shulker_box"); + + BlockType.Typed BLACK_STAINED_GLASS = getBlockType("black_stained_glass"); + + BlockType.Typed BLACK_STAINED_GLASS_PANE = getBlockType("black_stained_glass_pane"); + + BlockType.Typed BLACK_TERRACOTTA = getBlockType("black_terracotta"); + + BlockType.Typed BLACK_WALL_BANNER = getBlockType("black_wall_banner"); + + BlockType.Typed BLACK_WOOL = getBlockType("black_wool"); + + BlockType.Typed BLACKSTONE = getBlockType("blackstone"); + + BlockType.Typed BLACKSTONE_SLAB = getBlockType("blackstone_slab"); + + BlockType.Typed BLACKSTONE_STAIRS = getBlockType("blackstone_stairs"); + + BlockType.Typed BLACKSTONE_WALL = getBlockType("blackstone_wall"); + + BlockType.Typed BLAST_FURNACE = getBlockType("blast_furnace"); + + BlockType.Typed BLUE_BANNER = getBlockType("blue_banner"); + + BlockType.Typed BLUE_BED = getBlockType("blue_bed"); + + BlockType.Typed BLUE_CANDLE = getBlockType("blue_candle"); + + BlockType.Typed BLUE_CANDLE_CAKE = getBlockType("blue_candle_cake"); + + BlockType.Typed BLUE_CARPET = getBlockType("blue_carpet"); + + BlockType.Typed BLUE_CONCRETE = getBlockType("blue_concrete"); + + BlockType.Typed BLUE_CONCRETE_POWDER = getBlockType("blue_concrete_powder"); + + BlockType.Typed BLUE_GLAZED_TERRACOTTA = getBlockType("blue_glazed_terracotta"); + + BlockType.Typed BLUE_ICE = getBlockType("blue_ice"); + + BlockType.Typed BLUE_ORCHID = getBlockType("blue_orchid"); + + BlockType.Typed BLUE_SHULKER_BOX = getBlockType("blue_shulker_box"); + + BlockType.Typed BLUE_STAINED_GLASS = getBlockType("blue_stained_glass"); + + BlockType.Typed BLUE_STAINED_GLASS_PANE = getBlockType("blue_stained_glass_pane"); + + BlockType.Typed BLUE_TERRACOTTA = getBlockType("blue_terracotta"); + + BlockType.Typed BLUE_WALL_BANNER = getBlockType("blue_wall_banner"); + + BlockType.Typed BLUE_WOOL = getBlockType("blue_wool"); + + BlockType.Typed BONE_BLOCK = getBlockType("bone_block"); + + BlockType.Typed BOOKSHELF = getBlockType("bookshelf"); + + BlockType.Typed BRAIN_CORAL = getBlockType("brain_coral"); + + BlockType.Typed BRAIN_CORAL_BLOCK = getBlockType("brain_coral_block"); + + BlockType.Typed BRAIN_CORAL_FAN = getBlockType("brain_coral_fan"); + + BlockType.Typed BRAIN_CORAL_WALL_FAN = getBlockType("brain_coral_wall_fan"); + + BlockType.Typed BREWING_STAND = getBlockType("brewing_stand"); + + BlockType.Typed BRICK_SLAB = getBlockType("brick_slab"); + + BlockType.Typed BRICK_STAIRS = getBlockType("brick_stairs"); + + BlockType.Typed BRICK_WALL = getBlockType("brick_wall"); + + BlockType.Typed BRICKS = getBlockType("bricks"); + + BlockType.Typed BROWN_BANNER = getBlockType("brown_banner"); + + BlockType.Typed BROWN_BED = getBlockType("brown_bed"); + + BlockType.Typed BROWN_CANDLE = getBlockType("brown_candle"); + + BlockType.Typed BROWN_CANDLE_CAKE = getBlockType("brown_candle_cake"); + + BlockType.Typed BROWN_CARPET = getBlockType("brown_carpet"); + + BlockType.Typed BROWN_CONCRETE = getBlockType("brown_concrete"); + + BlockType.Typed BROWN_CONCRETE_POWDER = getBlockType("brown_concrete_powder"); + + BlockType.Typed BROWN_GLAZED_TERRACOTTA = getBlockType("brown_glazed_terracotta"); + + BlockType.Typed BROWN_MUSHROOM = getBlockType("brown_mushroom"); + + BlockType.Typed BROWN_MUSHROOM_BLOCK = getBlockType("brown_mushroom_block"); + + BlockType.Typed BROWN_SHULKER_BOX = getBlockType("brown_shulker_box"); + + BlockType.Typed BROWN_STAINED_GLASS = getBlockType("brown_stained_glass"); + + BlockType.Typed BROWN_STAINED_GLASS_PANE = getBlockType("brown_stained_glass_pane"); + + BlockType.Typed BROWN_TERRACOTTA = getBlockType("brown_terracotta"); + + BlockType.Typed BROWN_WALL_BANNER = getBlockType("brown_wall_banner"); + + BlockType.Typed BROWN_WOOL = getBlockType("brown_wool"); + + BlockType.Typed BUBBLE_COLUMN = getBlockType("bubble_column"); + + BlockType.Typed BUBBLE_CORAL = getBlockType("bubble_coral"); + + BlockType.Typed BUBBLE_CORAL_BLOCK = getBlockType("bubble_coral_block"); + + BlockType.Typed BUBBLE_CORAL_FAN = getBlockType("bubble_coral_fan"); + + BlockType.Typed BUBBLE_CORAL_WALL_FAN = getBlockType("bubble_coral_wall_fan"); + + BlockType.Typed BUDDING_AMETHYST = getBlockType("budding_amethyst"); + + BlockType.Typed BUSH = getBlockType("bush"); + + BlockType.Typed CACTUS = getBlockType("cactus"); + + BlockType.Typed CACTUS_FLOWER = getBlockType("cactus_flower"); + + BlockType.Typed CAKE = getBlockType("cake"); + + BlockType.Typed CALCITE = getBlockType("calcite"); + + BlockType.Typed CALIBRATED_SCULK_SENSOR = getBlockType("calibrated_sculk_sensor"); + + BlockType.Typed CAMPFIRE = getBlockType("campfire"); + + BlockType.Typed CANDLE = getBlockType("candle"); + + BlockType.Typed CANDLE_CAKE = getBlockType("candle_cake"); + + BlockType.Typed CARROTS = getBlockType("carrots"); + + BlockType.Typed CARTOGRAPHY_TABLE = getBlockType("cartography_table"); + + BlockType.Typed CARVED_PUMPKIN = getBlockType("carved_pumpkin"); + + BlockType.Typed CAULDRON = getBlockType("cauldron"); + + BlockType.Typed CAVE_AIR = getBlockType("cave_air"); + + BlockType.Typed CAVE_VINES = getBlockType("cave_vines"); + + BlockType.Typed CAVE_VINES_PLANT = getBlockType("cave_vines_plant"); + + BlockType.Typed CHAIN = getBlockType("chain"); + + BlockType.Typed CHAIN_COMMAND_BLOCK = getBlockType("chain_command_block"); + + BlockType.Typed CHERRY_BUTTON = getBlockType("cherry_button"); + + BlockType.Typed CHERRY_DOOR = getBlockType("cherry_door"); + + BlockType.Typed CHERRY_FENCE = getBlockType("cherry_fence"); + + BlockType.Typed CHERRY_FENCE_GATE = getBlockType("cherry_fence_gate"); + + BlockType.Typed CHERRY_HANGING_SIGN = getBlockType("cherry_hanging_sign"); + + BlockType.Typed CHERRY_LEAVES = getBlockType("cherry_leaves"); + + BlockType.Typed CHERRY_LOG = getBlockType("cherry_log"); + + BlockType.Typed CHERRY_PLANKS = getBlockType("cherry_planks"); + + BlockType.Typed CHERRY_PRESSURE_PLATE = getBlockType("cherry_pressure_plate"); + + BlockType.Typed CHERRY_SAPLING = getBlockType("cherry_sapling"); + + BlockType.Typed CHERRY_SIGN = getBlockType("cherry_sign"); + + BlockType.Typed CHERRY_SLAB = getBlockType("cherry_slab"); + + BlockType.Typed CHERRY_STAIRS = getBlockType("cherry_stairs"); + + BlockType.Typed CHERRY_TRAPDOOR = getBlockType("cherry_trapdoor"); + + BlockType.Typed CHERRY_WALL_HANGING_SIGN = getBlockType("cherry_wall_hanging_sign"); + + BlockType.Typed CHERRY_WALL_SIGN = getBlockType("cherry_wall_sign"); + + BlockType.Typed CHERRY_WOOD = getBlockType("cherry_wood"); + + BlockType.Typed CHEST = getBlockType("chest"); + + BlockType.Typed CHIPPED_ANVIL = getBlockType("chipped_anvil"); + + BlockType.Typed CHISELED_BOOKSHELF = getBlockType("chiseled_bookshelf"); + + BlockType.Typed CHISELED_COPPER = getBlockType("chiseled_copper"); + BlockType.Typed CHISELED_DEEPSLATE = getBlockType("chiseled_deepslate"); - BlockType.Typed CRACKED_DEEPSLATE_BRICKS = getBlockType("cracked_deepslate_bricks"); - BlockType.Typed CRACKED_DEEPSLATE_TILES = getBlockType("cracked_deepslate_tiles"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed INFESTED_DEEPSLATE = getBlockType("infested_deepslate"); - BlockType.Typed SMOOTH_BASALT = getBlockType("smooth_basalt"); - BlockType.Typed RAW_IRON_BLOCK = getBlockType("raw_iron_block"); - BlockType.Typed RAW_COPPER_BLOCK = getBlockType("raw_copper_block"); - BlockType.Typed RAW_GOLD_BLOCK = getBlockType("raw_gold_block"); - BlockType.Typed POTTED_AZALEA_BUSH = getBlockType("potted_azalea_bush"); - BlockType.Typed POTTED_FLOWERING_AZALEA_BUSH = getBlockType("potted_flowering_azalea_bush"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed OCHRE_FROGLIGHT = getBlockType("ochre_froglight"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed VERDANT_FROGLIGHT = getBlockType("verdant_froglight"); - /** - * BlockData: {@link Orientable} - */ - BlockType.Typed PEARLESCENT_FROGLIGHT = getBlockType("pearlescent_froglight"); - BlockType.Typed FROGSPAWN = getBlockType("frogspawn"); - BlockType.Typed REINFORCED_DEEPSLATE = getBlockType("reinforced_deepslate"); - /** - * BlockData: {@link DecoratedPot} - */ - BlockType.Typed DECORATED_POT = getBlockType("decorated_pot"); - /** - * BlockData: {@link Crafter} - */ - BlockType.Typed CRAFTER = getBlockType("crafter"); - /** - * BlockData: {@link TrialSpawner} - */ - BlockType.Typed TRIAL_SPAWNER = getBlockType("trial_spawner"); - /** - * BlockData: {@link Vault} - */ - BlockType.Typed VAULT = getBlockType("vault"); - /** - * BlockData: {@link Waterlogged} - */ - BlockType.Typed HEAVY_CORE = getBlockType("heavy_core"); - BlockType.Typed OPEN_EYEBLOSSOM = getBlockType("open_eyeblossom"); + + BlockType.Typed CHISELED_NETHER_BRICKS = getBlockType("chiseled_nether_bricks"); + + BlockType.Typed CHISELED_POLISHED_BLACKSTONE = getBlockType("chiseled_polished_blackstone"); + + BlockType.Typed CHISELED_QUARTZ_BLOCK = getBlockType("chiseled_quartz_block"); + + BlockType.Typed CHISELED_RED_SANDSTONE = getBlockType("chiseled_red_sandstone"); + + BlockType.Typed CHISELED_RESIN_BRICKS = getBlockType("chiseled_resin_bricks"); + + BlockType.Typed CHISELED_SANDSTONE = getBlockType("chiseled_sandstone"); + + BlockType.Typed CHISELED_STONE_BRICKS = getBlockType("chiseled_stone_bricks"); + + BlockType.Typed CHISELED_TUFF = getBlockType("chiseled_tuff"); + + BlockType.Typed CHISELED_TUFF_BRICKS = getBlockType("chiseled_tuff_bricks"); + + BlockType.Typed CHORUS_FLOWER = getBlockType("chorus_flower"); + + BlockType.Typed CHORUS_PLANT = getBlockType("chorus_plant"); + + BlockType.Typed CLAY = getBlockType("clay"); + BlockType.Typed CLOSED_EYEBLOSSOM = getBlockType("closed_eyeblossom"); - BlockType.Typed POTTED_OPEN_EYEBLOSSOM = getBlockType("potted_open_eyeblossom"); + + BlockType.Typed COAL_BLOCK = getBlockType("coal_block"); + + BlockType.Typed COAL_ORE = getBlockType("coal_ore"); + + BlockType.Typed COARSE_DIRT = getBlockType("coarse_dirt"); + + BlockType.Typed COBBLED_DEEPSLATE = getBlockType("cobbled_deepslate"); + + BlockType.Typed COBBLED_DEEPSLATE_SLAB = getBlockType("cobbled_deepslate_slab"); + + BlockType.Typed COBBLED_DEEPSLATE_STAIRS = getBlockType("cobbled_deepslate_stairs"); + + BlockType.Typed COBBLED_DEEPSLATE_WALL = getBlockType("cobbled_deepslate_wall"); + + BlockType.Typed COBBLESTONE = getBlockType("cobblestone"); + + BlockType.Typed COBBLESTONE_SLAB = getBlockType("cobblestone_slab"); + + BlockType.Typed COBBLESTONE_STAIRS = getBlockType("cobblestone_stairs"); + + BlockType.Typed COBBLESTONE_WALL = getBlockType("cobblestone_wall"); + + BlockType.Typed COBWEB = getBlockType("cobweb"); + + BlockType.Typed COCOA = getBlockType("cocoa"); + + BlockType.Typed COMMAND_BLOCK = getBlockType("command_block"); + + BlockType.Typed COMPARATOR = getBlockType("comparator"); + + BlockType.Typed COMPOSTER = getBlockType("composter"); + + BlockType.Typed CONDUIT = getBlockType("conduit"); + + BlockType.Typed COPPER_BLOCK = getBlockType("copper_block"); + + BlockType.Typed COPPER_BULB = getBlockType("copper_bulb"); + + BlockType.Typed COPPER_DOOR = getBlockType("copper_door"); + + BlockType.Typed COPPER_GRATE = getBlockType("copper_grate"); + + BlockType.Typed COPPER_ORE = getBlockType("copper_ore"); + + BlockType.Typed COPPER_TRAPDOOR = getBlockType("copper_trapdoor"); + + BlockType.Typed CORNFLOWER = getBlockType("cornflower"); + + BlockType.Typed CRACKED_DEEPSLATE_BRICKS = getBlockType("cracked_deepslate_bricks"); + + BlockType.Typed CRACKED_DEEPSLATE_TILES = getBlockType("cracked_deepslate_tiles"); + + BlockType.Typed CRACKED_NETHER_BRICKS = getBlockType("cracked_nether_bricks"); + + BlockType.Typed CRACKED_POLISHED_BLACKSTONE_BRICKS = getBlockType("cracked_polished_blackstone_bricks"); + + BlockType.Typed CRACKED_STONE_BRICKS = getBlockType("cracked_stone_bricks"); + + BlockType.Typed CRAFTER = getBlockType("crafter"); + + BlockType.Typed CRAFTING_TABLE = getBlockType("crafting_table"); + + BlockType.Typed CREAKING_HEART = getBlockType("creaking_heart"); + + BlockType.Typed CREEPER_HEAD = getBlockType("creeper_head"); + + BlockType.Typed CREEPER_WALL_HEAD = getBlockType("creeper_wall_head"); + + BlockType.Typed CRIMSON_BUTTON = getBlockType("crimson_button"); + + BlockType.Typed CRIMSON_DOOR = getBlockType("crimson_door"); + + BlockType.Typed CRIMSON_FENCE = getBlockType("crimson_fence"); + + BlockType.Typed CRIMSON_FENCE_GATE = getBlockType("crimson_fence_gate"); + + BlockType.Typed CRIMSON_FUNGUS = getBlockType("crimson_fungus"); + + BlockType.Typed CRIMSON_HANGING_SIGN = getBlockType("crimson_hanging_sign"); + + BlockType.Typed CRIMSON_HYPHAE = getBlockType("crimson_hyphae"); + + BlockType.Typed CRIMSON_NYLIUM = getBlockType("crimson_nylium"); + + BlockType.Typed CRIMSON_PLANKS = getBlockType("crimson_planks"); + + BlockType.Typed CRIMSON_PRESSURE_PLATE = getBlockType("crimson_pressure_plate"); + + BlockType.Typed CRIMSON_ROOTS = getBlockType("crimson_roots"); + + BlockType.Typed CRIMSON_SIGN = getBlockType("crimson_sign"); + + BlockType.Typed CRIMSON_SLAB = getBlockType("crimson_slab"); + + BlockType.Typed CRIMSON_STAIRS = getBlockType("crimson_stairs"); + + BlockType.Typed CRIMSON_STEM = getBlockType("crimson_stem"); + + BlockType.Typed CRIMSON_TRAPDOOR = getBlockType("crimson_trapdoor"); + + BlockType.Typed CRIMSON_WALL_HANGING_SIGN = getBlockType("crimson_wall_hanging_sign"); + + BlockType.Typed CRIMSON_WALL_SIGN = getBlockType("crimson_wall_sign"); + + BlockType.Typed CRYING_OBSIDIAN = getBlockType("crying_obsidian"); + + BlockType.Typed CUT_COPPER = getBlockType("cut_copper"); + + BlockType.Typed CUT_COPPER_SLAB = getBlockType("cut_copper_slab"); + + BlockType.Typed CUT_COPPER_STAIRS = getBlockType("cut_copper_stairs"); + + BlockType.Typed CUT_RED_SANDSTONE = getBlockType("cut_red_sandstone"); + + BlockType.Typed CUT_RED_SANDSTONE_SLAB = getBlockType("cut_red_sandstone_slab"); + + BlockType.Typed CUT_SANDSTONE = getBlockType("cut_sandstone"); + + BlockType.Typed CUT_SANDSTONE_SLAB = getBlockType("cut_sandstone_slab"); + + BlockType.Typed CYAN_BANNER = getBlockType("cyan_banner"); + + BlockType.Typed CYAN_BED = getBlockType("cyan_bed"); + + BlockType.Typed CYAN_CANDLE = getBlockType("cyan_candle"); + + BlockType.Typed CYAN_CANDLE_CAKE = getBlockType("cyan_candle_cake"); + + BlockType.Typed CYAN_CARPET = getBlockType("cyan_carpet"); + + BlockType.Typed CYAN_CONCRETE = getBlockType("cyan_concrete"); + + BlockType.Typed CYAN_CONCRETE_POWDER = getBlockType("cyan_concrete_powder"); + + BlockType.Typed CYAN_GLAZED_TERRACOTTA = getBlockType("cyan_glazed_terracotta"); + + BlockType.Typed CYAN_SHULKER_BOX = getBlockType("cyan_shulker_box"); + + BlockType.Typed CYAN_STAINED_GLASS = getBlockType("cyan_stained_glass"); + + BlockType.Typed CYAN_STAINED_GLASS_PANE = getBlockType("cyan_stained_glass_pane"); + + BlockType.Typed CYAN_TERRACOTTA = getBlockType("cyan_terracotta"); + + BlockType.Typed CYAN_WALL_BANNER = getBlockType("cyan_wall_banner"); + + BlockType.Typed CYAN_WOOL = getBlockType("cyan_wool"); + + BlockType.Typed DAMAGED_ANVIL = getBlockType("damaged_anvil"); + + BlockType.Typed DANDELION = getBlockType("dandelion"); + + BlockType.Typed DARK_OAK_BUTTON = getBlockType("dark_oak_button"); + + BlockType.Typed DARK_OAK_DOOR = getBlockType("dark_oak_door"); + + BlockType.Typed DARK_OAK_FENCE = getBlockType("dark_oak_fence"); + + BlockType.Typed DARK_OAK_FENCE_GATE = getBlockType("dark_oak_fence_gate"); + + BlockType.Typed DARK_OAK_HANGING_SIGN = getBlockType("dark_oak_hanging_sign"); + + BlockType.Typed DARK_OAK_LEAVES = getBlockType("dark_oak_leaves"); + + BlockType.Typed DARK_OAK_LOG = getBlockType("dark_oak_log"); + + BlockType.Typed DARK_OAK_PLANKS = getBlockType("dark_oak_planks"); + + BlockType.Typed DARK_OAK_PRESSURE_PLATE = getBlockType("dark_oak_pressure_plate"); + + BlockType.Typed DARK_OAK_SAPLING = getBlockType("dark_oak_sapling"); + + BlockType.Typed DARK_OAK_SIGN = getBlockType("dark_oak_sign"); + + BlockType.Typed DARK_OAK_SLAB = getBlockType("dark_oak_slab"); + + BlockType.Typed DARK_OAK_STAIRS = getBlockType("dark_oak_stairs"); + + BlockType.Typed DARK_OAK_TRAPDOOR = getBlockType("dark_oak_trapdoor"); + + BlockType.Typed DARK_OAK_WALL_HANGING_SIGN = getBlockType("dark_oak_wall_hanging_sign"); + + BlockType.Typed DARK_OAK_WALL_SIGN = getBlockType("dark_oak_wall_sign"); + + BlockType.Typed DARK_OAK_WOOD = getBlockType("dark_oak_wood"); + + BlockType.Typed DARK_PRISMARINE = getBlockType("dark_prismarine"); + + BlockType.Typed DARK_PRISMARINE_SLAB = getBlockType("dark_prismarine_slab"); + + BlockType.Typed DARK_PRISMARINE_STAIRS = getBlockType("dark_prismarine_stairs"); + + BlockType.Typed DAYLIGHT_DETECTOR = getBlockType("daylight_detector"); + + BlockType.Typed DEAD_BRAIN_CORAL = getBlockType("dead_brain_coral"); + + BlockType.Typed DEAD_BRAIN_CORAL_BLOCK = getBlockType("dead_brain_coral_block"); + + BlockType.Typed DEAD_BRAIN_CORAL_FAN = getBlockType("dead_brain_coral_fan"); + + BlockType.Typed DEAD_BRAIN_CORAL_WALL_FAN = getBlockType("dead_brain_coral_wall_fan"); + + BlockType.Typed DEAD_BUBBLE_CORAL = getBlockType("dead_bubble_coral"); + + BlockType.Typed DEAD_BUBBLE_CORAL_BLOCK = getBlockType("dead_bubble_coral_block"); + + BlockType.Typed DEAD_BUBBLE_CORAL_FAN = getBlockType("dead_bubble_coral_fan"); + + BlockType.Typed DEAD_BUBBLE_CORAL_WALL_FAN = getBlockType("dead_bubble_coral_wall_fan"); + + BlockType.Typed DEAD_BUSH = getBlockType("dead_bush"); + + BlockType.Typed DEAD_FIRE_CORAL = getBlockType("dead_fire_coral"); + + BlockType.Typed DEAD_FIRE_CORAL_BLOCK = getBlockType("dead_fire_coral_block"); + + BlockType.Typed DEAD_FIRE_CORAL_FAN = getBlockType("dead_fire_coral_fan"); + + BlockType.Typed DEAD_FIRE_CORAL_WALL_FAN = getBlockType("dead_fire_coral_wall_fan"); + + BlockType.Typed DEAD_HORN_CORAL = getBlockType("dead_horn_coral"); + + BlockType.Typed DEAD_HORN_CORAL_BLOCK = getBlockType("dead_horn_coral_block"); + + BlockType.Typed DEAD_HORN_CORAL_FAN = getBlockType("dead_horn_coral_fan"); + + BlockType.Typed DEAD_HORN_CORAL_WALL_FAN = getBlockType("dead_horn_coral_wall_fan"); + + BlockType.Typed DEAD_TUBE_CORAL = getBlockType("dead_tube_coral"); + + BlockType.Typed DEAD_TUBE_CORAL_BLOCK = getBlockType("dead_tube_coral_block"); + + BlockType.Typed DEAD_TUBE_CORAL_FAN = getBlockType("dead_tube_coral_fan"); + + BlockType.Typed DEAD_TUBE_CORAL_WALL_FAN = getBlockType("dead_tube_coral_wall_fan"); + + BlockType.Typed DECORATED_POT = getBlockType("decorated_pot"); + + BlockType.Typed DEEPSLATE = getBlockType("deepslate"); + + BlockType.Typed DEEPSLATE_BRICK_SLAB = getBlockType("deepslate_brick_slab"); + + BlockType.Typed DEEPSLATE_BRICK_STAIRS = getBlockType("deepslate_brick_stairs"); + + BlockType.Typed DEEPSLATE_BRICK_WALL = getBlockType("deepslate_brick_wall"); + + BlockType.Typed DEEPSLATE_BRICKS = getBlockType("deepslate_bricks"); + + BlockType.Typed DEEPSLATE_COAL_ORE = getBlockType("deepslate_coal_ore"); + + BlockType.Typed DEEPSLATE_COPPER_ORE = getBlockType("deepslate_copper_ore"); + + BlockType.Typed DEEPSLATE_DIAMOND_ORE = getBlockType("deepslate_diamond_ore"); + + BlockType.Typed DEEPSLATE_EMERALD_ORE = getBlockType("deepslate_emerald_ore"); + + BlockType.Typed DEEPSLATE_GOLD_ORE = getBlockType("deepslate_gold_ore"); + + BlockType.Typed DEEPSLATE_IRON_ORE = getBlockType("deepslate_iron_ore"); + + BlockType.Typed DEEPSLATE_LAPIS_ORE = getBlockType("deepslate_lapis_ore"); + + BlockType.Typed DEEPSLATE_REDSTONE_ORE = getBlockType("deepslate_redstone_ore"); + + BlockType.Typed DEEPSLATE_TILE_SLAB = getBlockType("deepslate_tile_slab"); + + BlockType.Typed DEEPSLATE_TILE_STAIRS = getBlockType("deepslate_tile_stairs"); + + BlockType.Typed DEEPSLATE_TILE_WALL = getBlockType("deepslate_tile_wall"); + + BlockType.Typed DEEPSLATE_TILES = getBlockType("deepslate_tiles"); + + BlockType.Typed DETECTOR_RAIL = getBlockType("detector_rail"); + + BlockType.Typed DIAMOND_BLOCK = getBlockType("diamond_block"); + + BlockType.Typed DIAMOND_ORE = getBlockType("diamond_ore"); + + BlockType.Typed DIORITE = getBlockType("diorite"); + + BlockType.Typed DIORITE_SLAB = getBlockType("diorite_slab"); + + BlockType.Typed DIORITE_STAIRS = getBlockType("diorite_stairs"); + + BlockType.Typed DIORITE_WALL = getBlockType("diorite_wall"); + + BlockType.Typed DIRT = getBlockType("dirt"); + + BlockType.Typed DIRT_PATH = getBlockType("dirt_path"); + + BlockType.Typed DISPENSER = getBlockType("dispenser"); + + BlockType.Typed DRAGON_EGG = getBlockType("dragon_egg"); + + BlockType.Typed DRAGON_HEAD = getBlockType("dragon_head"); + + BlockType.Typed DRAGON_WALL_HEAD = getBlockType("dragon_wall_head"); + + BlockType.Typed DRIED_KELP_BLOCK = getBlockType("dried_kelp_block"); + + BlockType.Typed DRIPSTONE_BLOCK = getBlockType("dripstone_block"); + + BlockType.Typed DROPPER = getBlockType("dropper"); + + BlockType.Typed EMERALD_BLOCK = getBlockType("emerald_block"); + + BlockType.Typed EMERALD_ORE = getBlockType("emerald_ore"); + + BlockType.Typed ENCHANTING_TABLE = getBlockType("enchanting_table"); + + BlockType.Typed END_GATEWAY = getBlockType("end_gateway"); + + BlockType.Typed END_PORTAL = getBlockType("end_portal"); + + BlockType.Typed END_PORTAL_FRAME = getBlockType("end_portal_frame"); + + BlockType.Typed END_ROD = getBlockType("end_rod"); + + BlockType.Typed END_STONE = getBlockType("end_stone"); + + BlockType.Typed END_STONE_BRICK_SLAB = getBlockType("end_stone_brick_slab"); + + BlockType.Typed END_STONE_BRICK_STAIRS = getBlockType("end_stone_brick_stairs"); + + BlockType.Typed END_STONE_BRICK_WALL = getBlockType("end_stone_brick_wall"); + + BlockType.Typed END_STONE_BRICKS = getBlockType("end_stone_bricks"); + + BlockType.Typed ENDER_CHEST = getBlockType("ender_chest"); + + BlockType.Typed EXPOSED_CHISELED_COPPER = getBlockType("exposed_chiseled_copper"); + + BlockType.Typed EXPOSED_COPPER = getBlockType("exposed_copper"); + + BlockType.Typed EXPOSED_COPPER_BULB = getBlockType("exposed_copper_bulb"); + + BlockType.Typed EXPOSED_COPPER_DOOR = getBlockType("exposed_copper_door"); + + BlockType.Typed EXPOSED_COPPER_GRATE = getBlockType("exposed_copper_grate"); + + BlockType.Typed EXPOSED_COPPER_TRAPDOOR = getBlockType("exposed_copper_trapdoor"); + + BlockType.Typed EXPOSED_CUT_COPPER = getBlockType("exposed_cut_copper"); + + BlockType.Typed EXPOSED_CUT_COPPER_SLAB = getBlockType("exposed_cut_copper_slab"); + + BlockType.Typed EXPOSED_CUT_COPPER_STAIRS = getBlockType("exposed_cut_copper_stairs"); + + BlockType.Typed FARMLAND = getBlockType("farmland"); + + BlockType.Typed FERN = getBlockType("fern"); + + BlockType.Typed FIRE = getBlockType("fire"); + + BlockType.Typed FIRE_CORAL = getBlockType("fire_coral"); + + BlockType.Typed FIRE_CORAL_BLOCK = getBlockType("fire_coral_block"); + + BlockType.Typed FIRE_CORAL_FAN = getBlockType("fire_coral_fan"); + + BlockType.Typed FIRE_CORAL_WALL_FAN = getBlockType("fire_coral_wall_fan"); + + BlockType.Typed FIREFLY_BUSH = getBlockType("firefly_bush"); + + BlockType.Typed FLETCHING_TABLE = getBlockType("fletching_table"); + + BlockType.Typed FLOWER_POT = getBlockType("flower_pot"); + + BlockType.Typed FLOWERING_AZALEA = getBlockType("flowering_azalea"); + + BlockType.Typed FLOWERING_AZALEA_LEAVES = getBlockType("flowering_azalea_leaves"); + + BlockType.Typed FROGSPAWN = getBlockType("frogspawn"); + + BlockType.Typed FROSTED_ICE = getBlockType("frosted_ice"); + + BlockType.Typed FURNACE = getBlockType("furnace"); + + BlockType.Typed GILDED_BLACKSTONE = getBlockType("gilded_blackstone"); + + BlockType.Typed GLASS = getBlockType("glass"); + + BlockType.Typed GLASS_PANE = getBlockType("glass_pane"); + + BlockType.Typed GLOW_LICHEN = getBlockType("glow_lichen"); + + BlockType.Typed GLOWSTONE = getBlockType("glowstone"); + + BlockType.Typed GOLD_BLOCK = getBlockType("gold_block"); + + BlockType.Typed GOLD_ORE = getBlockType("gold_ore"); + + BlockType.Typed GRANITE = getBlockType("granite"); + + BlockType.Typed GRANITE_SLAB = getBlockType("granite_slab"); + + BlockType.Typed GRANITE_STAIRS = getBlockType("granite_stairs"); + + BlockType.Typed GRANITE_WALL = getBlockType("granite_wall"); + + BlockType.Typed GRASS_BLOCK = getBlockType("grass_block"); + + BlockType.Typed GRAVEL = getBlockType("gravel"); + + BlockType.Typed GRAY_BANNER = getBlockType("gray_banner"); + + BlockType.Typed GRAY_BED = getBlockType("gray_bed"); + + BlockType.Typed GRAY_CANDLE = getBlockType("gray_candle"); + + BlockType.Typed GRAY_CANDLE_CAKE = getBlockType("gray_candle_cake"); + + BlockType.Typed GRAY_CARPET = getBlockType("gray_carpet"); + + BlockType.Typed GRAY_CONCRETE = getBlockType("gray_concrete"); + + BlockType.Typed GRAY_CONCRETE_POWDER = getBlockType("gray_concrete_powder"); + + BlockType.Typed GRAY_GLAZED_TERRACOTTA = getBlockType("gray_glazed_terracotta"); + + BlockType.Typed GRAY_SHULKER_BOX = getBlockType("gray_shulker_box"); + + BlockType.Typed GRAY_STAINED_GLASS = getBlockType("gray_stained_glass"); + + BlockType.Typed GRAY_STAINED_GLASS_PANE = getBlockType("gray_stained_glass_pane"); + + BlockType.Typed GRAY_TERRACOTTA = getBlockType("gray_terracotta"); + + BlockType.Typed GRAY_WALL_BANNER = getBlockType("gray_wall_banner"); + + BlockType.Typed GRAY_WOOL = getBlockType("gray_wool"); + + BlockType.Typed GREEN_BANNER = getBlockType("green_banner"); + + BlockType.Typed GREEN_BED = getBlockType("green_bed"); + + BlockType.Typed GREEN_CANDLE = getBlockType("green_candle"); + + BlockType.Typed GREEN_CANDLE_CAKE = getBlockType("green_candle_cake"); + + BlockType.Typed GREEN_CARPET = getBlockType("green_carpet"); + + BlockType.Typed GREEN_CONCRETE = getBlockType("green_concrete"); + + BlockType.Typed GREEN_CONCRETE_POWDER = getBlockType("green_concrete_powder"); + + BlockType.Typed GREEN_GLAZED_TERRACOTTA = getBlockType("green_glazed_terracotta"); + + BlockType.Typed GREEN_SHULKER_BOX = getBlockType("green_shulker_box"); + + BlockType.Typed GREEN_STAINED_GLASS = getBlockType("green_stained_glass"); + + BlockType.Typed GREEN_STAINED_GLASS_PANE = getBlockType("green_stained_glass_pane"); + + BlockType.Typed GREEN_TERRACOTTA = getBlockType("green_terracotta"); + + BlockType.Typed GREEN_WALL_BANNER = getBlockType("green_wall_banner"); + + BlockType.Typed GREEN_WOOL = getBlockType("green_wool"); + + BlockType.Typed GRINDSTONE = getBlockType("grindstone"); + + BlockType.Typed HANGING_ROOTS = getBlockType("hanging_roots"); + + BlockType.Typed HAY_BLOCK = getBlockType("hay_block"); + + BlockType.Typed HEAVY_CORE = getBlockType("heavy_core"); + + BlockType.Typed HEAVY_WEIGHTED_PRESSURE_PLATE = getBlockType("heavy_weighted_pressure_plate"); + + BlockType.Typed HONEY_BLOCK = getBlockType("honey_block"); + + BlockType.Typed HONEYCOMB_BLOCK = getBlockType("honeycomb_block"); + + BlockType.Typed HOPPER = getBlockType("hopper"); + + BlockType.Typed HORN_CORAL = getBlockType("horn_coral"); + + BlockType.Typed HORN_CORAL_BLOCK = getBlockType("horn_coral_block"); + + BlockType.Typed HORN_CORAL_FAN = getBlockType("horn_coral_fan"); + + BlockType.Typed HORN_CORAL_WALL_FAN = getBlockType("horn_coral_wall_fan"); + + BlockType.Typed ICE = getBlockType("ice"); + + BlockType.Typed INFESTED_CHISELED_STONE_BRICKS = getBlockType("infested_chiseled_stone_bricks"); + + BlockType.Typed INFESTED_COBBLESTONE = getBlockType("infested_cobblestone"); + + BlockType.Typed INFESTED_CRACKED_STONE_BRICKS = getBlockType("infested_cracked_stone_bricks"); + + BlockType.Typed INFESTED_DEEPSLATE = getBlockType("infested_deepslate"); + + BlockType.Typed INFESTED_MOSSY_STONE_BRICKS = getBlockType("infested_mossy_stone_bricks"); + + BlockType.Typed INFESTED_STONE = getBlockType("infested_stone"); + + BlockType.Typed INFESTED_STONE_BRICKS = getBlockType("infested_stone_bricks"); + + BlockType.Typed IRON_BARS = getBlockType("iron_bars"); + + BlockType.Typed IRON_BLOCK = getBlockType("iron_block"); + + BlockType.Typed IRON_DOOR = getBlockType("iron_door"); + + BlockType.Typed IRON_ORE = getBlockType("iron_ore"); + + BlockType.Typed IRON_TRAPDOOR = getBlockType("iron_trapdoor"); + + BlockType.Typed JACK_O_LANTERN = getBlockType("jack_o_lantern"); + + BlockType.Typed JIGSAW = getBlockType("jigsaw"); + + BlockType.Typed JUKEBOX = getBlockType("jukebox"); + + BlockType.Typed JUNGLE_BUTTON = getBlockType("jungle_button"); + + BlockType.Typed JUNGLE_DOOR = getBlockType("jungle_door"); + + BlockType.Typed JUNGLE_FENCE = getBlockType("jungle_fence"); + + BlockType.Typed JUNGLE_FENCE_GATE = getBlockType("jungle_fence_gate"); + + BlockType.Typed JUNGLE_HANGING_SIGN = getBlockType("jungle_hanging_sign"); + + BlockType.Typed JUNGLE_LEAVES = getBlockType("jungle_leaves"); + + BlockType.Typed JUNGLE_LOG = getBlockType("jungle_log"); + + BlockType.Typed JUNGLE_PLANKS = getBlockType("jungle_planks"); + + BlockType.Typed JUNGLE_PRESSURE_PLATE = getBlockType("jungle_pressure_plate"); + + BlockType.Typed JUNGLE_SAPLING = getBlockType("jungle_sapling"); + + BlockType.Typed JUNGLE_SIGN = getBlockType("jungle_sign"); + + BlockType.Typed JUNGLE_SLAB = getBlockType("jungle_slab"); + + BlockType.Typed JUNGLE_STAIRS = getBlockType("jungle_stairs"); + + BlockType.Typed JUNGLE_TRAPDOOR = getBlockType("jungle_trapdoor"); + + BlockType.Typed JUNGLE_WALL_HANGING_SIGN = getBlockType("jungle_wall_hanging_sign"); + + BlockType.Typed JUNGLE_WALL_SIGN = getBlockType("jungle_wall_sign"); + + BlockType.Typed JUNGLE_WOOD = getBlockType("jungle_wood"); + + BlockType.Typed KELP = getBlockType("kelp"); + + BlockType.Typed KELP_PLANT = getBlockType("kelp_plant"); + + BlockType.Typed LADDER = getBlockType("ladder"); + + BlockType.Typed LANTERN = getBlockType("lantern"); + + BlockType.Typed LAPIS_BLOCK = getBlockType("lapis_block"); + + BlockType.Typed LAPIS_ORE = getBlockType("lapis_ore"); + + BlockType.Typed LARGE_AMETHYST_BUD = getBlockType("large_amethyst_bud"); + + BlockType.Typed LARGE_FERN = getBlockType("large_fern"); + + BlockType.Typed LAVA = getBlockType("lava"); + + BlockType.Typed LAVA_CAULDRON = getBlockType("lava_cauldron"); + + BlockType.Typed LEAF_LITTER = getBlockType("leaf_litter"); + + BlockType.Typed LECTERN = getBlockType("lectern"); + + BlockType.Typed LEVER = getBlockType("lever"); + + BlockType.Typed LIGHT = getBlockType("light"); + + BlockType.Typed LIGHT_BLUE_BANNER = getBlockType("light_blue_banner"); + + BlockType.Typed LIGHT_BLUE_BED = getBlockType("light_blue_bed"); + + BlockType.Typed LIGHT_BLUE_CANDLE = getBlockType("light_blue_candle"); + + BlockType.Typed LIGHT_BLUE_CANDLE_CAKE = getBlockType("light_blue_candle_cake"); + + BlockType.Typed LIGHT_BLUE_CARPET = getBlockType("light_blue_carpet"); + + BlockType.Typed LIGHT_BLUE_CONCRETE = getBlockType("light_blue_concrete"); + + BlockType.Typed LIGHT_BLUE_CONCRETE_POWDER = getBlockType("light_blue_concrete_powder"); + + BlockType.Typed LIGHT_BLUE_GLAZED_TERRACOTTA = getBlockType("light_blue_glazed_terracotta"); + + BlockType.Typed LIGHT_BLUE_SHULKER_BOX = getBlockType("light_blue_shulker_box"); + + BlockType.Typed LIGHT_BLUE_STAINED_GLASS = getBlockType("light_blue_stained_glass"); + + BlockType.Typed LIGHT_BLUE_STAINED_GLASS_PANE = getBlockType("light_blue_stained_glass_pane"); + + BlockType.Typed LIGHT_BLUE_TERRACOTTA = getBlockType("light_blue_terracotta"); + + BlockType.Typed LIGHT_BLUE_WALL_BANNER = getBlockType("light_blue_wall_banner"); + + BlockType.Typed LIGHT_BLUE_WOOL = getBlockType("light_blue_wool"); + + BlockType.Typed LIGHT_GRAY_BANNER = getBlockType("light_gray_banner"); + + BlockType.Typed LIGHT_GRAY_BED = getBlockType("light_gray_bed"); + + BlockType.Typed LIGHT_GRAY_CANDLE = getBlockType("light_gray_candle"); + + BlockType.Typed LIGHT_GRAY_CANDLE_CAKE = getBlockType("light_gray_candle_cake"); + + BlockType.Typed LIGHT_GRAY_CARPET = getBlockType("light_gray_carpet"); + + BlockType.Typed LIGHT_GRAY_CONCRETE = getBlockType("light_gray_concrete"); + + BlockType.Typed LIGHT_GRAY_CONCRETE_POWDER = getBlockType("light_gray_concrete_powder"); + + BlockType.Typed LIGHT_GRAY_GLAZED_TERRACOTTA = getBlockType("light_gray_glazed_terracotta"); + + BlockType.Typed LIGHT_GRAY_SHULKER_BOX = getBlockType("light_gray_shulker_box"); + + BlockType.Typed LIGHT_GRAY_STAINED_GLASS = getBlockType("light_gray_stained_glass"); + + BlockType.Typed LIGHT_GRAY_STAINED_GLASS_PANE = getBlockType("light_gray_stained_glass_pane"); + + BlockType.Typed LIGHT_GRAY_TERRACOTTA = getBlockType("light_gray_terracotta"); + + BlockType.Typed LIGHT_GRAY_WALL_BANNER = getBlockType("light_gray_wall_banner"); + + BlockType.Typed LIGHT_GRAY_WOOL = getBlockType("light_gray_wool"); + + BlockType.Typed LIGHT_WEIGHTED_PRESSURE_PLATE = getBlockType("light_weighted_pressure_plate"); + + BlockType.Typed LIGHTNING_ROD = getBlockType("lightning_rod"); + + BlockType.Typed LILAC = getBlockType("lilac"); + + BlockType.Typed LILY_OF_THE_VALLEY = getBlockType("lily_of_the_valley"); + + BlockType.Typed LILY_PAD = getBlockType("lily_pad"); + + BlockType.Typed LIME_BANNER = getBlockType("lime_banner"); + + BlockType.Typed LIME_BED = getBlockType("lime_bed"); + + BlockType.Typed LIME_CANDLE = getBlockType("lime_candle"); + + BlockType.Typed LIME_CANDLE_CAKE = getBlockType("lime_candle_cake"); + + BlockType.Typed LIME_CARPET = getBlockType("lime_carpet"); + + BlockType.Typed LIME_CONCRETE = getBlockType("lime_concrete"); + + BlockType.Typed LIME_CONCRETE_POWDER = getBlockType("lime_concrete_powder"); + + BlockType.Typed LIME_GLAZED_TERRACOTTA = getBlockType("lime_glazed_terracotta"); + + BlockType.Typed LIME_SHULKER_BOX = getBlockType("lime_shulker_box"); + + BlockType.Typed LIME_STAINED_GLASS = getBlockType("lime_stained_glass"); + + BlockType.Typed LIME_STAINED_GLASS_PANE = getBlockType("lime_stained_glass_pane"); + + BlockType.Typed LIME_TERRACOTTA = getBlockType("lime_terracotta"); + + BlockType.Typed LIME_WALL_BANNER = getBlockType("lime_wall_banner"); + + BlockType.Typed LIME_WOOL = getBlockType("lime_wool"); + + BlockType.Typed LODESTONE = getBlockType("lodestone"); + + BlockType.Typed LOOM = getBlockType("loom"); + + BlockType.Typed MAGENTA_BANNER = getBlockType("magenta_banner"); + + BlockType.Typed MAGENTA_BED = getBlockType("magenta_bed"); + + BlockType.Typed MAGENTA_CANDLE = getBlockType("magenta_candle"); + + BlockType.Typed MAGENTA_CANDLE_CAKE = getBlockType("magenta_candle_cake"); + + BlockType.Typed MAGENTA_CARPET = getBlockType("magenta_carpet"); + + BlockType.Typed MAGENTA_CONCRETE = getBlockType("magenta_concrete"); + + BlockType.Typed MAGENTA_CONCRETE_POWDER = getBlockType("magenta_concrete_powder"); + + BlockType.Typed MAGENTA_GLAZED_TERRACOTTA = getBlockType("magenta_glazed_terracotta"); + + BlockType.Typed MAGENTA_SHULKER_BOX = getBlockType("magenta_shulker_box"); + + BlockType.Typed MAGENTA_STAINED_GLASS = getBlockType("magenta_stained_glass"); + + BlockType.Typed MAGENTA_STAINED_GLASS_PANE = getBlockType("magenta_stained_glass_pane"); + + BlockType.Typed MAGENTA_TERRACOTTA = getBlockType("magenta_terracotta"); + + BlockType.Typed MAGENTA_WALL_BANNER = getBlockType("magenta_wall_banner"); + + BlockType.Typed MAGENTA_WOOL = getBlockType("magenta_wool"); + + BlockType.Typed MAGMA_BLOCK = getBlockType("magma_block"); + + BlockType.Typed MANGROVE_BUTTON = getBlockType("mangrove_button"); + + BlockType.Typed MANGROVE_DOOR = getBlockType("mangrove_door"); + + BlockType.Typed MANGROVE_FENCE = getBlockType("mangrove_fence"); + + BlockType.Typed MANGROVE_FENCE_GATE = getBlockType("mangrove_fence_gate"); + + BlockType.Typed MANGROVE_HANGING_SIGN = getBlockType("mangrove_hanging_sign"); + + BlockType.Typed MANGROVE_LEAVES = getBlockType("mangrove_leaves"); + + BlockType.Typed MANGROVE_LOG = getBlockType("mangrove_log"); + + BlockType.Typed MANGROVE_PLANKS = getBlockType("mangrove_planks"); + + BlockType.Typed MANGROVE_PRESSURE_PLATE = getBlockType("mangrove_pressure_plate"); + + BlockType.Typed MANGROVE_PROPAGULE = getBlockType("mangrove_propagule"); + + BlockType.Typed MANGROVE_ROOTS = getBlockType("mangrove_roots"); + + BlockType.Typed MANGROVE_SIGN = getBlockType("mangrove_sign"); + + BlockType.Typed MANGROVE_SLAB = getBlockType("mangrove_slab"); + + BlockType.Typed MANGROVE_STAIRS = getBlockType("mangrove_stairs"); + + BlockType.Typed MANGROVE_TRAPDOOR = getBlockType("mangrove_trapdoor"); + + BlockType.Typed MANGROVE_WALL_HANGING_SIGN = getBlockType("mangrove_wall_hanging_sign"); + + BlockType.Typed MANGROVE_WALL_SIGN = getBlockType("mangrove_wall_sign"); + + BlockType.Typed MANGROVE_WOOD = getBlockType("mangrove_wood"); + + BlockType.Typed MEDIUM_AMETHYST_BUD = getBlockType("medium_amethyst_bud"); + + BlockType.Typed MELON = getBlockType("melon"); + + BlockType.Typed MELON_STEM = getBlockType("melon_stem"); + + BlockType.Typed MOSS_BLOCK = getBlockType("moss_block"); + + BlockType.Typed MOSS_CARPET = getBlockType("moss_carpet"); + + BlockType.Typed MOSSY_COBBLESTONE = getBlockType("mossy_cobblestone"); + + BlockType.Typed MOSSY_COBBLESTONE_SLAB = getBlockType("mossy_cobblestone_slab"); + + BlockType.Typed MOSSY_COBBLESTONE_STAIRS = getBlockType("mossy_cobblestone_stairs"); + + BlockType.Typed MOSSY_COBBLESTONE_WALL = getBlockType("mossy_cobblestone_wall"); + + BlockType.Typed MOSSY_STONE_BRICK_SLAB = getBlockType("mossy_stone_brick_slab"); + + BlockType.Typed MOSSY_STONE_BRICK_STAIRS = getBlockType("mossy_stone_brick_stairs"); + + BlockType.Typed MOSSY_STONE_BRICK_WALL = getBlockType("mossy_stone_brick_wall"); + + BlockType.Typed MOSSY_STONE_BRICKS = getBlockType("mossy_stone_bricks"); + + BlockType.Typed MOVING_PISTON = getBlockType("moving_piston"); + + BlockType.Typed MUD = getBlockType("mud"); + + BlockType.Typed MUD_BRICK_SLAB = getBlockType("mud_brick_slab"); + + BlockType.Typed MUD_BRICK_STAIRS = getBlockType("mud_brick_stairs"); + + BlockType.Typed MUD_BRICK_WALL = getBlockType("mud_brick_wall"); + + BlockType.Typed MUD_BRICKS = getBlockType("mud_bricks"); + + BlockType.Typed MUDDY_MANGROVE_ROOTS = getBlockType("muddy_mangrove_roots"); + + BlockType.Typed MUSHROOM_STEM = getBlockType("mushroom_stem"); + + BlockType.Typed MYCELIUM = getBlockType("mycelium"); + + BlockType.Typed NETHER_BRICK_FENCE = getBlockType("nether_brick_fence"); + + BlockType.Typed NETHER_BRICK_SLAB = getBlockType("nether_brick_slab"); + + BlockType.Typed NETHER_BRICK_STAIRS = getBlockType("nether_brick_stairs"); + + BlockType.Typed NETHER_BRICK_WALL = getBlockType("nether_brick_wall"); + + BlockType.Typed NETHER_BRICKS = getBlockType("nether_bricks"); + + BlockType.Typed NETHER_GOLD_ORE = getBlockType("nether_gold_ore"); + + BlockType.Typed NETHER_PORTAL = getBlockType("nether_portal"); + + BlockType.Typed NETHER_QUARTZ_ORE = getBlockType("nether_quartz_ore"); + + BlockType.Typed NETHER_SPROUTS = getBlockType("nether_sprouts"); + + BlockType.Typed NETHER_WART = getBlockType("nether_wart"); + + BlockType.Typed NETHER_WART_BLOCK = getBlockType("nether_wart_block"); + + BlockType.Typed NETHERITE_BLOCK = getBlockType("netherite_block"); + + BlockType.Typed NETHERRACK = getBlockType("netherrack"); + + BlockType.Typed NOTE_BLOCK = getBlockType("note_block"); + + BlockType.Typed OAK_BUTTON = getBlockType("oak_button"); + + BlockType.Typed OAK_DOOR = getBlockType("oak_door"); + + BlockType.Typed OAK_FENCE = getBlockType("oak_fence"); + + BlockType.Typed OAK_FENCE_GATE = getBlockType("oak_fence_gate"); + + BlockType.Typed OAK_HANGING_SIGN = getBlockType("oak_hanging_sign"); + + BlockType.Typed OAK_LEAVES = getBlockType("oak_leaves"); + + BlockType.Typed OAK_LOG = getBlockType("oak_log"); + + BlockType.Typed OAK_PLANKS = getBlockType("oak_planks"); + + BlockType.Typed OAK_PRESSURE_PLATE = getBlockType("oak_pressure_plate"); + + BlockType.Typed OAK_SAPLING = getBlockType("oak_sapling"); + + BlockType.Typed OAK_SIGN = getBlockType("oak_sign"); + + BlockType.Typed OAK_SLAB = getBlockType("oak_slab"); + + BlockType.Typed OAK_STAIRS = getBlockType("oak_stairs"); + + BlockType.Typed OAK_TRAPDOOR = getBlockType("oak_trapdoor"); + + BlockType.Typed OAK_WALL_HANGING_SIGN = getBlockType("oak_wall_hanging_sign"); + + BlockType.Typed OAK_WALL_SIGN = getBlockType("oak_wall_sign"); + + BlockType.Typed OAK_WOOD = getBlockType("oak_wood"); + + BlockType.Typed OBSERVER = getBlockType("observer"); + + BlockType.Typed OBSIDIAN = getBlockType("obsidian"); + + BlockType.Typed OCHRE_FROGLIGHT = getBlockType("ochre_froglight"); + + BlockType.Typed OPEN_EYEBLOSSOM = getBlockType("open_eyeblossom"); + + BlockType.Typed ORANGE_BANNER = getBlockType("orange_banner"); + + BlockType.Typed ORANGE_BED = getBlockType("orange_bed"); + + BlockType.Typed ORANGE_CANDLE = getBlockType("orange_candle"); + + BlockType.Typed ORANGE_CANDLE_CAKE = getBlockType("orange_candle_cake"); + + BlockType.Typed ORANGE_CARPET = getBlockType("orange_carpet"); + + BlockType.Typed ORANGE_CONCRETE = getBlockType("orange_concrete"); + + BlockType.Typed ORANGE_CONCRETE_POWDER = getBlockType("orange_concrete_powder"); + + BlockType.Typed ORANGE_GLAZED_TERRACOTTA = getBlockType("orange_glazed_terracotta"); + + BlockType.Typed ORANGE_SHULKER_BOX = getBlockType("orange_shulker_box"); + + BlockType.Typed ORANGE_STAINED_GLASS = getBlockType("orange_stained_glass"); + + BlockType.Typed ORANGE_STAINED_GLASS_PANE = getBlockType("orange_stained_glass_pane"); + + BlockType.Typed ORANGE_TERRACOTTA = getBlockType("orange_terracotta"); + + BlockType.Typed ORANGE_TULIP = getBlockType("orange_tulip"); + + BlockType.Typed ORANGE_WALL_BANNER = getBlockType("orange_wall_banner"); + + BlockType.Typed ORANGE_WOOL = getBlockType("orange_wool"); + + BlockType.Typed OXEYE_DAISY = getBlockType("oxeye_daisy"); + + BlockType.Typed OXIDIZED_CHISELED_COPPER = getBlockType("oxidized_chiseled_copper"); + + BlockType.Typed OXIDIZED_COPPER = getBlockType("oxidized_copper"); + + BlockType.Typed OXIDIZED_COPPER_BULB = getBlockType("oxidized_copper_bulb"); + + BlockType.Typed OXIDIZED_COPPER_DOOR = getBlockType("oxidized_copper_door"); + + BlockType.Typed OXIDIZED_COPPER_GRATE = getBlockType("oxidized_copper_grate"); + + BlockType.Typed OXIDIZED_COPPER_TRAPDOOR = getBlockType("oxidized_copper_trapdoor"); + + BlockType.Typed OXIDIZED_CUT_COPPER = getBlockType("oxidized_cut_copper"); + + BlockType.Typed OXIDIZED_CUT_COPPER_SLAB = getBlockType("oxidized_cut_copper_slab"); + + BlockType.Typed OXIDIZED_CUT_COPPER_STAIRS = getBlockType("oxidized_cut_copper_stairs"); + + BlockType.Typed PACKED_ICE = getBlockType("packed_ice"); + + BlockType.Typed PACKED_MUD = getBlockType("packed_mud"); + + BlockType.Typed PALE_HANGING_MOSS = getBlockType("pale_hanging_moss"); + + BlockType.Typed PALE_MOSS_BLOCK = getBlockType("pale_moss_block"); + + BlockType.Typed PALE_MOSS_CARPET = getBlockType("pale_moss_carpet"); + + BlockType.Typed PALE_OAK_BUTTON = getBlockType("pale_oak_button"); + + BlockType.Typed PALE_OAK_DOOR = getBlockType("pale_oak_door"); + + BlockType.Typed PALE_OAK_FENCE = getBlockType("pale_oak_fence"); + + BlockType.Typed PALE_OAK_FENCE_GATE = getBlockType("pale_oak_fence_gate"); + + BlockType.Typed PALE_OAK_HANGING_SIGN = getBlockType("pale_oak_hanging_sign"); + + BlockType.Typed PALE_OAK_LEAVES = getBlockType("pale_oak_leaves"); + + BlockType.Typed PALE_OAK_LOG = getBlockType("pale_oak_log"); + + BlockType.Typed PALE_OAK_PLANKS = getBlockType("pale_oak_planks"); + + BlockType.Typed PALE_OAK_PRESSURE_PLATE = getBlockType("pale_oak_pressure_plate"); + + BlockType.Typed PALE_OAK_SAPLING = getBlockType("pale_oak_sapling"); + + BlockType.Typed PALE_OAK_SIGN = getBlockType("pale_oak_sign"); + + BlockType.Typed PALE_OAK_SLAB = getBlockType("pale_oak_slab"); + + BlockType.Typed PALE_OAK_STAIRS = getBlockType("pale_oak_stairs"); + + BlockType.Typed PALE_OAK_TRAPDOOR = getBlockType("pale_oak_trapdoor"); + + BlockType.Typed PALE_OAK_WALL_HANGING_SIGN = getBlockType("pale_oak_wall_hanging_sign"); + + BlockType.Typed PALE_OAK_WALL_SIGN = getBlockType("pale_oak_wall_sign"); + + BlockType.Typed PALE_OAK_WOOD = getBlockType("pale_oak_wood"); + + BlockType.Typed PEARLESCENT_FROGLIGHT = getBlockType("pearlescent_froglight"); + + BlockType.Typed PEONY = getBlockType("peony"); + + BlockType.Typed PETRIFIED_OAK_SLAB = getBlockType("petrified_oak_slab"); + + BlockType.Typed PIGLIN_HEAD = getBlockType("piglin_head"); + + BlockType.Typed PIGLIN_WALL_HEAD = getBlockType("piglin_wall_head"); + + BlockType.Typed PINK_BANNER = getBlockType("pink_banner"); + + BlockType.Typed PINK_BED = getBlockType("pink_bed"); + + BlockType.Typed PINK_CANDLE = getBlockType("pink_candle"); + + BlockType.Typed PINK_CANDLE_CAKE = getBlockType("pink_candle_cake"); + + BlockType.Typed PINK_CARPET = getBlockType("pink_carpet"); + + BlockType.Typed PINK_CONCRETE = getBlockType("pink_concrete"); + + BlockType.Typed PINK_CONCRETE_POWDER = getBlockType("pink_concrete_powder"); + + BlockType.Typed PINK_GLAZED_TERRACOTTA = getBlockType("pink_glazed_terracotta"); + + BlockType.Typed PINK_PETALS = getBlockType("pink_petals"); + + BlockType.Typed PINK_SHULKER_BOX = getBlockType("pink_shulker_box"); + + BlockType.Typed PINK_STAINED_GLASS = getBlockType("pink_stained_glass"); + + BlockType.Typed PINK_STAINED_GLASS_PANE = getBlockType("pink_stained_glass_pane"); + + BlockType.Typed PINK_TERRACOTTA = getBlockType("pink_terracotta"); + + BlockType.Typed PINK_TULIP = getBlockType("pink_tulip"); + + BlockType.Typed PINK_WALL_BANNER = getBlockType("pink_wall_banner"); + + BlockType.Typed PINK_WOOL = getBlockType("pink_wool"); + + BlockType.Typed PISTON = getBlockType("piston"); + + BlockType.Typed PISTON_HEAD = getBlockType("piston_head"); + + BlockType.Typed PITCHER_CROP = getBlockType("pitcher_crop"); + + BlockType.Typed PITCHER_PLANT = getBlockType("pitcher_plant"); + + BlockType.Typed PLAYER_HEAD = getBlockType("player_head"); + + BlockType.Typed PLAYER_WALL_HEAD = getBlockType("player_wall_head"); + + BlockType.Typed PODZOL = getBlockType("podzol"); + + BlockType.Typed POINTED_DRIPSTONE = getBlockType("pointed_dripstone"); + + BlockType.Typed POLISHED_ANDESITE = getBlockType("polished_andesite"); + + BlockType.Typed POLISHED_ANDESITE_SLAB = getBlockType("polished_andesite_slab"); + + BlockType.Typed POLISHED_ANDESITE_STAIRS = getBlockType("polished_andesite_stairs"); + + BlockType.Typed POLISHED_BASALT = getBlockType("polished_basalt"); + + BlockType.Typed POLISHED_BLACKSTONE = getBlockType("polished_blackstone"); + + BlockType.Typed POLISHED_BLACKSTONE_BRICK_SLAB = getBlockType("polished_blackstone_brick_slab"); + + BlockType.Typed POLISHED_BLACKSTONE_BRICK_STAIRS = getBlockType("polished_blackstone_brick_stairs"); + + BlockType.Typed POLISHED_BLACKSTONE_BRICK_WALL = getBlockType("polished_blackstone_brick_wall"); + + BlockType.Typed POLISHED_BLACKSTONE_BRICKS = getBlockType("polished_blackstone_bricks"); + + BlockType.Typed POLISHED_BLACKSTONE_BUTTON = getBlockType("polished_blackstone_button"); + + BlockType.Typed POLISHED_BLACKSTONE_PRESSURE_PLATE = getBlockType("polished_blackstone_pressure_plate"); + + BlockType.Typed POLISHED_BLACKSTONE_SLAB = getBlockType("polished_blackstone_slab"); + + BlockType.Typed POLISHED_BLACKSTONE_STAIRS = getBlockType("polished_blackstone_stairs"); + + BlockType.Typed POLISHED_BLACKSTONE_WALL = getBlockType("polished_blackstone_wall"); + + BlockType.Typed POLISHED_DEEPSLATE = getBlockType("polished_deepslate"); + + BlockType.Typed POLISHED_DEEPSLATE_SLAB = getBlockType("polished_deepslate_slab"); + + BlockType.Typed POLISHED_DEEPSLATE_STAIRS = getBlockType("polished_deepslate_stairs"); + + BlockType.Typed POLISHED_DEEPSLATE_WALL = getBlockType("polished_deepslate_wall"); + + BlockType.Typed POLISHED_DIORITE = getBlockType("polished_diorite"); + + BlockType.Typed POLISHED_DIORITE_SLAB = getBlockType("polished_diorite_slab"); + + BlockType.Typed POLISHED_DIORITE_STAIRS = getBlockType("polished_diorite_stairs"); + + BlockType.Typed POLISHED_GRANITE = getBlockType("polished_granite"); + + BlockType.Typed POLISHED_GRANITE_SLAB = getBlockType("polished_granite_slab"); + + BlockType.Typed POLISHED_GRANITE_STAIRS = getBlockType("polished_granite_stairs"); + + BlockType.Typed POLISHED_TUFF = getBlockType("polished_tuff"); + + BlockType.Typed POLISHED_TUFF_SLAB = getBlockType("polished_tuff_slab"); + + BlockType.Typed POLISHED_TUFF_STAIRS = getBlockType("polished_tuff_stairs"); + + BlockType.Typed POLISHED_TUFF_WALL = getBlockType("polished_tuff_wall"); + + BlockType.Typed POPPY = getBlockType("poppy"); + + BlockType.Typed POTATOES = getBlockType("potatoes"); + + BlockType.Typed POTTED_ACACIA_SAPLING = getBlockType("potted_acacia_sapling"); + + BlockType.Typed POTTED_ALLIUM = getBlockType("potted_allium"); + + BlockType.Typed POTTED_AZALEA_BUSH = getBlockType("potted_azalea_bush"); + + BlockType.Typed POTTED_AZURE_BLUET = getBlockType("potted_azure_bluet"); + + BlockType.Typed POTTED_BAMBOO = getBlockType("potted_bamboo"); + + BlockType.Typed POTTED_BIRCH_SAPLING = getBlockType("potted_birch_sapling"); + + BlockType.Typed POTTED_BLUE_ORCHID = getBlockType("potted_blue_orchid"); + + BlockType.Typed POTTED_BROWN_MUSHROOM = getBlockType("potted_brown_mushroom"); + + BlockType.Typed POTTED_CACTUS = getBlockType("potted_cactus"); + + BlockType.Typed POTTED_CHERRY_SAPLING = getBlockType("potted_cherry_sapling"); + BlockType.Typed POTTED_CLOSED_EYEBLOSSOM = getBlockType("potted_closed_eyeblossom"); + + BlockType.Typed POTTED_CORNFLOWER = getBlockType("potted_cornflower"); + + BlockType.Typed POTTED_CRIMSON_FUNGUS = getBlockType("potted_crimson_fungus"); + + BlockType.Typed POTTED_CRIMSON_ROOTS = getBlockType("potted_crimson_roots"); + + BlockType.Typed POTTED_DANDELION = getBlockType("potted_dandelion"); + + BlockType.Typed POTTED_DARK_OAK_SAPLING = getBlockType("potted_dark_oak_sapling"); + + BlockType.Typed POTTED_DEAD_BUSH = getBlockType("potted_dead_bush"); + + BlockType.Typed POTTED_FERN = getBlockType("potted_fern"); + + BlockType.Typed POTTED_FLOWERING_AZALEA_BUSH = getBlockType("potted_flowering_azalea_bush"); + + BlockType.Typed POTTED_JUNGLE_SAPLING = getBlockType("potted_jungle_sapling"); + + BlockType.Typed POTTED_LILY_OF_THE_VALLEY = getBlockType("potted_lily_of_the_valley"); + + BlockType.Typed POTTED_MANGROVE_PROPAGULE = getBlockType("potted_mangrove_propagule"); + + BlockType.Typed POTTED_OAK_SAPLING = getBlockType("potted_oak_sapling"); + + BlockType.Typed POTTED_OPEN_EYEBLOSSOM = getBlockType("potted_open_eyeblossom"); + + BlockType.Typed POTTED_ORANGE_TULIP = getBlockType("potted_orange_tulip"); + + BlockType.Typed POTTED_OXEYE_DAISY = getBlockType("potted_oxeye_daisy"); + + BlockType.Typed POTTED_PALE_OAK_SAPLING = getBlockType("potted_pale_oak_sapling"); + + BlockType.Typed POTTED_PINK_TULIP = getBlockType("potted_pink_tulip"); + + BlockType.Typed POTTED_POPPY = getBlockType("potted_poppy"); + + BlockType.Typed POTTED_RED_MUSHROOM = getBlockType("potted_red_mushroom"); + + BlockType.Typed POTTED_RED_TULIP = getBlockType("potted_red_tulip"); + + BlockType.Typed POTTED_SPRUCE_SAPLING = getBlockType("potted_spruce_sapling"); + + BlockType.Typed POTTED_TORCHFLOWER = getBlockType("potted_torchflower"); + + BlockType.Typed POTTED_WARPED_FUNGUS = getBlockType("potted_warped_fungus"); + + BlockType.Typed POTTED_WARPED_ROOTS = getBlockType("potted_warped_roots"); + + BlockType.Typed POTTED_WHITE_TULIP = getBlockType("potted_white_tulip"); + + BlockType.Typed POTTED_WITHER_ROSE = getBlockType("potted_wither_rose"); + + BlockType.Typed POWDER_SNOW = getBlockType("powder_snow"); + + BlockType.Typed POWDER_SNOW_CAULDRON = getBlockType("powder_snow_cauldron"); + + BlockType.Typed POWERED_RAIL = getBlockType("powered_rail"); + + BlockType.Typed PRISMARINE = getBlockType("prismarine"); + + BlockType.Typed PRISMARINE_BRICK_SLAB = getBlockType("prismarine_brick_slab"); + + BlockType.Typed PRISMARINE_BRICK_STAIRS = getBlockType("prismarine_brick_stairs"); + + BlockType.Typed PRISMARINE_BRICKS = getBlockType("prismarine_bricks"); + + BlockType.Typed PRISMARINE_SLAB = getBlockType("prismarine_slab"); + + BlockType.Typed PRISMARINE_STAIRS = getBlockType("prismarine_stairs"); + + BlockType.Typed PRISMARINE_WALL = getBlockType("prismarine_wall"); + + BlockType.Typed PUMPKIN = getBlockType("pumpkin"); + + BlockType.Typed PUMPKIN_STEM = getBlockType("pumpkin_stem"); + + BlockType.Typed PURPLE_BANNER = getBlockType("purple_banner"); + + BlockType.Typed PURPLE_BED = getBlockType("purple_bed"); + + BlockType.Typed PURPLE_CANDLE = getBlockType("purple_candle"); + + BlockType.Typed PURPLE_CANDLE_CAKE = getBlockType("purple_candle_cake"); + + BlockType.Typed PURPLE_CARPET = getBlockType("purple_carpet"); + + BlockType.Typed PURPLE_CONCRETE = getBlockType("purple_concrete"); + + BlockType.Typed PURPLE_CONCRETE_POWDER = getBlockType("purple_concrete_powder"); + + BlockType.Typed PURPLE_GLAZED_TERRACOTTA = getBlockType("purple_glazed_terracotta"); + + BlockType.Typed PURPLE_SHULKER_BOX = getBlockType("purple_shulker_box"); + + BlockType.Typed PURPLE_STAINED_GLASS = getBlockType("purple_stained_glass"); + + BlockType.Typed PURPLE_STAINED_GLASS_PANE = getBlockType("purple_stained_glass_pane"); + + BlockType.Typed PURPLE_TERRACOTTA = getBlockType("purple_terracotta"); + + BlockType.Typed PURPLE_WALL_BANNER = getBlockType("purple_wall_banner"); + + BlockType.Typed PURPLE_WOOL = getBlockType("purple_wool"); + + BlockType.Typed PURPUR_BLOCK = getBlockType("purpur_block"); + + BlockType.Typed PURPUR_PILLAR = getBlockType("purpur_pillar"); + + BlockType.Typed PURPUR_SLAB = getBlockType("purpur_slab"); + + BlockType.Typed PURPUR_STAIRS = getBlockType("purpur_stairs"); + + BlockType.Typed QUARTZ_BLOCK = getBlockType("quartz_block"); + + BlockType.Typed QUARTZ_BRICKS = getBlockType("quartz_bricks"); + + BlockType.Typed QUARTZ_PILLAR = getBlockType("quartz_pillar"); + + BlockType.Typed QUARTZ_SLAB = getBlockType("quartz_slab"); + + BlockType.Typed QUARTZ_STAIRS = getBlockType("quartz_stairs"); + + BlockType.Typed RAIL = getBlockType("rail"); + + BlockType.Typed RAW_COPPER_BLOCK = getBlockType("raw_copper_block"); + + BlockType.Typed RAW_GOLD_BLOCK = getBlockType("raw_gold_block"); + + BlockType.Typed RAW_IRON_BLOCK = getBlockType("raw_iron_block"); + + BlockType.Typed RED_BANNER = getBlockType("red_banner"); + + BlockType.Typed RED_BED = getBlockType("red_bed"); + + BlockType.Typed RED_CANDLE = getBlockType("red_candle"); + + BlockType.Typed RED_CANDLE_CAKE = getBlockType("red_candle_cake"); + + BlockType.Typed RED_CARPET = getBlockType("red_carpet"); + + BlockType.Typed RED_CONCRETE = getBlockType("red_concrete"); + + BlockType.Typed RED_CONCRETE_POWDER = getBlockType("red_concrete_powder"); + + BlockType.Typed RED_GLAZED_TERRACOTTA = getBlockType("red_glazed_terracotta"); + + BlockType.Typed RED_MUSHROOM = getBlockType("red_mushroom"); + + BlockType.Typed RED_MUSHROOM_BLOCK = getBlockType("red_mushroom_block"); + + BlockType.Typed RED_NETHER_BRICK_SLAB = getBlockType("red_nether_brick_slab"); + + BlockType.Typed RED_NETHER_BRICK_STAIRS = getBlockType("red_nether_brick_stairs"); + + BlockType.Typed RED_NETHER_BRICK_WALL = getBlockType("red_nether_brick_wall"); + + BlockType.Typed RED_NETHER_BRICKS = getBlockType("red_nether_bricks"); + + BlockType.Typed RED_SAND = getBlockType("red_sand"); + + BlockType.Typed RED_SANDSTONE = getBlockType("red_sandstone"); + + BlockType.Typed RED_SANDSTONE_SLAB = getBlockType("red_sandstone_slab"); + + BlockType.Typed RED_SANDSTONE_STAIRS = getBlockType("red_sandstone_stairs"); + + BlockType.Typed RED_SANDSTONE_WALL = getBlockType("red_sandstone_wall"); + + BlockType.Typed RED_SHULKER_BOX = getBlockType("red_shulker_box"); + + BlockType.Typed RED_STAINED_GLASS = getBlockType("red_stained_glass"); + + BlockType.Typed RED_STAINED_GLASS_PANE = getBlockType("red_stained_glass_pane"); + + BlockType.Typed RED_TERRACOTTA = getBlockType("red_terracotta"); + + BlockType.Typed RED_TULIP = getBlockType("red_tulip"); + + BlockType.Typed RED_WALL_BANNER = getBlockType("red_wall_banner"); + + BlockType.Typed RED_WOOL = getBlockType("red_wool"); + + BlockType.Typed REDSTONE_BLOCK = getBlockType("redstone_block"); + + BlockType.Typed REDSTONE_LAMP = getBlockType("redstone_lamp"); + + BlockType.Typed REDSTONE_ORE = getBlockType("redstone_ore"); + + BlockType.Typed REDSTONE_TORCH = getBlockType("redstone_torch"); + + BlockType.Typed REDSTONE_WALL_TORCH = getBlockType("redstone_wall_torch"); + + BlockType.Typed REDSTONE_WIRE = getBlockType("redstone_wire"); + + BlockType.Typed REINFORCED_DEEPSLATE = getBlockType("reinforced_deepslate"); + + BlockType.Typed REPEATER = getBlockType("repeater"); + + BlockType.Typed REPEATING_COMMAND_BLOCK = getBlockType("repeating_command_block"); + + BlockType.Typed RESIN_BLOCK = getBlockType("resin_block"); + + BlockType.Typed RESIN_BRICK_SLAB = getBlockType("resin_brick_slab"); + + BlockType.Typed RESIN_BRICK_STAIRS = getBlockType("resin_brick_stairs"); + + BlockType.Typed RESIN_BRICK_WALL = getBlockType("resin_brick_wall"); + + BlockType.Typed RESIN_BRICKS = getBlockType("resin_bricks"); + + BlockType.Typed RESIN_CLUMP = getBlockType("resin_clump"); + + BlockType.Typed RESPAWN_ANCHOR = getBlockType("respawn_anchor"); + + BlockType.Typed ROOTED_DIRT = getBlockType("rooted_dirt"); + + BlockType.Typed ROSE_BUSH = getBlockType("rose_bush"); + + BlockType.Typed SAND = getBlockType("sand"); + + BlockType.Typed SANDSTONE = getBlockType("sandstone"); + + BlockType.Typed SANDSTONE_SLAB = getBlockType("sandstone_slab"); + + BlockType.Typed SANDSTONE_STAIRS = getBlockType("sandstone_stairs"); + + BlockType.Typed SANDSTONE_WALL = getBlockType("sandstone_wall"); + + BlockType.Typed SCAFFOLDING = getBlockType("scaffolding"); + + BlockType.Typed SCULK = getBlockType("sculk"); + + BlockType.Typed SCULK_CATALYST = getBlockType("sculk_catalyst"); + + BlockType.Typed SCULK_SENSOR = getBlockType("sculk_sensor"); + + BlockType.Typed SCULK_SHRIEKER = getBlockType("sculk_shrieker"); + + BlockType.Typed SCULK_VEIN = getBlockType("sculk_vein"); + + BlockType.Typed SEA_LANTERN = getBlockType("sea_lantern"); + + BlockType.Typed SEA_PICKLE = getBlockType("sea_pickle"); + + BlockType.Typed SEAGRASS = getBlockType("seagrass"); + + BlockType.Typed SHORT_DRY_GRASS = getBlockType("short_dry_grass"); + + BlockType.Typed SHORT_GRASS = getBlockType("short_grass"); + + BlockType.Typed SHROOMLIGHT = getBlockType("shroomlight"); + + BlockType.Typed SHULKER_BOX = getBlockType("shulker_box"); + + BlockType.Typed SKELETON_SKULL = getBlockType("skeleton_skull"); + + BlockType.Typed SKELETON_WALL_SKULL = getBlockType("skeleton_wall_skull"); + + BlockType.Typed SLIME_BLOCK = getBlockType("slime_block"); + + BlockType.Typed SMALL_AMETHYST_BUD = getBlockType("small_amethyst_bud"); + + BlockType.Typed SMALL_DRIPLEAF = getBlockType("small_dripleaf"); + + BlockType.Typed SMITHING_TABLE = getBlockType("smithing_table"); + + BlockType.Typed SMOKER = getBlockType("smoker"); + + BlockType.Typed SMOOTH_BASALT = getBlockType("smooth_basalt"); + + BlockType.Typed SMOOTH_QUARTZ = getBlockType("smooth_quartz"); + + BlockType.Typed SMOOTH_QUARTZ_SLAB = getBlockType("smooth_quartz_slab"); + + BlockType.Typed SMOOTH_QUARTZ_STAIRS = getBlockType("smooth_quartz_stairs"); + + BlockType.Typed SMOOTH_RED_SANDSTONE = getBlockType("smooth_red_sandstone"); + + BlockType.Typed SMOOTH_RED_SANDSTONE_SLAB = getBlockType("smooth_red_sandstone_slab"); + + BlockType.Typed SMOOTH_RED_SANDSTONE_STAIRS = getBlockType("smooth_red_sandstone_stairs"); + + BlockType.Typed SMOOTH_SANDSTONE = getBlockType("smooth_sandstone"); + + BlockType.Typed SMOOTH_SANDSTONE_SLAB = getBlockType("smooth_sandstone_slab"); + + BlockType.Typed SMOOTH_SANDSTONE_STAIRS = getBlockType("smooth_sandstone_stairs"); + + BlockType.Typed SMOOTH_STONE = getBlockType("smooth_stone"); + + BlockType.Typed SMOOTH_STONE_SLAB = getBlockType("smooth_stone_slab"); + + BlockType.Typed SNIFFER_EGG = getBlockType("sniffer_egg"); + + BlockType.Typed SNOW = getBlockType("snow"); + + BlockType.Typed SNOW_BLOCK = getBlockType("snow_block"); + + BlockType.Typed SOUL_CAMPFIRE = getBlockType("soul_campfire"); + + BlockType.Typed SOUL_FIRE = getBlockType("soul_fire"); + + BlockType.Typed SOUL_LANTERN = getBlockType("soul_lantern"); + + BlockType.Typed SOUL_SAND = getBlockType("soul_sand"); + + BlockType.Typed SOUL_SOIL = getBlockType("soul_soil"); + + BlockType.Typed SOUL_TORCH = getBlockType("soul_torch"); + + BlockType.Typed SOUL_WALL_TORCH = getBlockType("soul_wall_torch"); + + BlockType.Typed SPAWNER = getBlockType("spawner"); + + BlockType.Typed SPONGE = getBlockType("sponge"); + + BlockType.Typed SPORE_BLOSSOM = getBlockType("spore_blossom"); + + BlockType.Typed SPRUCE_BUTTON = getBlockType("spruce_button"); + + BlockType.Typed SPRUCE_DOOR = getBlockType("spruce_door"); + + BlockType.Typed SPRUCE_FENCE = getBlockType("spruce_fence"); + + BlockType.Typed SPRUCE_FENCE_GATE = getBlockType("spruce_fence_gate"); + + BlockType.Typed SPRUCE_HANGING_SIGN = getBlockType("spruce_hanging_sign"); + + BlockType.Typed SPRUCE_LEAVES = getBlockType("spruce_leaves"); + + BlockType.Typed SPRUCE_LOG = getBlockType("spruce_log"); + + BlockType.Typed SPRUCE_PLANKS = getBlockType("spruce_planks"); + + BlockType.Typed SPRUCE_PRESSURE_PLATE = getBlockType("spruce_pressure_plate"); + + BlockType.Typed SPRUCE_SAPLING = getBlockType("spruce_sapling"); + + BlockType.Typed SPRUCE_SIGN = getBlockType("spruce_sign"); + + BlockType.Typed SPRUCE_SLAB = getBlockType("spruce_slab"); + + BlockType.Typed SPRUCE_STAIRS = getBlockType("spruce_stairs"); + + BlockType.Typed SPRUCE_TRAPDOOR = getBlockType("spruce_trapdoor"); + + BlockType.Typed SPRUCE_WALL_HANGING_SIGN = getBlockType("spruce_wall_hanging_sign"); + + BlockType.Typed SPRUCE_WALL_SIGN = getBlockType("spruce_wall_sign"); + + BlockType.Typed SPRUCE_WOOD = getBlockType("spruce_wood"); + + BlockType.Typed STICKY_PISTON = getBlockType("sticky_piston"); + + BlockType.Typed STONE = getBlockType("stone"); + + BlockType.Typed STONE_BRICK_SLAB = getBlockType("stone_brick_slab"); + + BlockType.Typed STONE_BRICK_STAIRS = getBlockType("stone_brick_stairs"); + + BlockType.Typed STONE_BRICK_WALL = getBlockType("stone_brick_wall"); + + BlockType.Typed STONE_BRICKS = getBlockType("stone_bricks"); + + BlockType.Typed STONE_BUTTON = getBlockType("stone_button"); + + BlockType.Typed STONE_PRESSURE_PLATE = getBlockType("stone_pressure_plate"); + + BlockType.Typed STONE_SLAB = getBlockType("stone_slab"); + + BlockType.Typed STONE_STAIRS = getBlockType("stone_stairs"); + + BlockType.Typed STONECUTTER = getBlockType("stonecutter"); + + BlockType.Typed STRIPPED_ACACIA_LOG = getBlockType("stripped_acacia_log"); + + BlockType.Typed STRIPPED_ACACIA_WOOD = getBlockType("stripped_acacia_wood"); + + BlockType.Typed STRIPPED_BAMBOO_BLOCK = getBlockType("stripped_bamboo_block"); + + BlockType.Typed STRIPPED_BIRCH_LOG = getBlockType("stripped_birch_log"); + + BlockType.Typed STRIPPED_BIRCH_WOOD = getBlockType("stripped_birch_wood"); + + BlockType.Typed STRIPPED_CHERRY_LOG = getBlockType("stripped_cherry_log"); + + BlockType.Typed STRIPPED_CHERRY_WOOD = getBlockType("stripped_cherry_wood"); + + BlockType.Typed STRIPPED_CRIMSON_HYPHAE = getBlockType("stripped_crimson_hyphae"); + + BlockType.Typed STRIPPED_CRIMSON_STEM = getBlockType("stripped_crimson_stem"); + + BlockType.Typed STRIPPED_DARK_OAK_LOG = getBlockType("stripped_dark_oak_log"); + + BlockType.Typed STRIPPED_DARK_OAK_WOOD = getBlockType("stripped_dark_oak_wood"); + + BlockType.Typed STRIPPED_JUNGLE_LOG = getBlockType("stripped_jungle_log"); + + BlockType.Typed STRIPPED_JUNGLE_WOOD = getBlockType("stripped_jungle_wood"); + + BlockType.Typed STRIPPED_MANGROVE_LOG = getBlockType("stripped_mangrove_log"); + + BlockType.Typed STRIPPED_MANGROVE_WOOD = getBlockType("stripped_mangrove_wood"); + + BlockType.Typed STRIPPED_OAK_LOG = getBlockType("stripped_oak_log"); + + BlockType.Typed STRIPPED_OAK_WOOD = getBlockType("stripped_oak_wood"); + + BlockType.Typed STRIPPED_PALE_OAK_LOG = getBlockType("stripped_pale_oak_log"); + + BlockType.Typed STRIPPED_PALE_OAK_WOOD = getBlockType("stripped_pale_oak_wood"); + + BlockType.Typed STRIPPED_SPRUCE_LOG = getBlockType("stripped_spruce_log"); + + BlockType.Typed STRIPPED_SPRUCE_WOOD = getBlockType("stripped_spruce_wood"); + + BlockType.Typed STRIPPED_WARPED_HYPHAE = getBlockType("stripped_warped_hyphae"); + + BlockType.Typed STRIPPED_WARPED_STEM = getBlockType("stripped_warped_stem"); + + BlockType.Typed STRUCTURE_BLOCK = getBlockType("structure_block"); + + BlockType.Typed STRUCTURE_VOID = getBlockType("structure_void"); + + BlockType.Typed SUGAR_CANE = getBlockType("sugar_cane"); + + BlockType.Typed SUNFLOWER = getBlockType("sunflower"); + + BlockType.Typed SUSPICIOUS_GRAVEL = getBlockType("suspicious_gravel"); + + BlockType.Typed SUSPICIOUS_SAND = getBlockType("suspicious_sand"); + + BlockType.Typed SWEET_BERRY_BUSH = getBlockType("sweet_berry_bush"); + + BlockType.Typed TALL_DRY_GRASS = getBlockType("tall_dry_grass"); + + BlockType.Typed TALL_GRASS = getBlockType("tall_grass"); + + BlockType.Typed TALL_SEAGRASS = getBlockType("tall_seagrass"); + + BlockType.Typed TARGET = getBlockType("target"); + + BlockType.Typed TERRACOTTA = getBlockType("terracotta"); + + BlockType.Typed TEST_BLOCK = getBlockType("test_block"); + + BlockType.Typed TEST_INSTANCE_BLOCK = getBlockType("test_instance_block"); + + BlockType.Typed TINTED_GLASS = getBlockType("tinted_glass"); + + BlockType.Typed TNT = getBlockType("tnt"); + + BlockType.Typed TORCH = getBlockType("torch"); + + BlockType.Typed TORCHFLOWER = getBlockType("torchflower"); + + BlockType.Typed TORCHFLOWER_CROP = getBlockType("torchflower_crop"); + + BlockType.Typed TRAPPED_CHEST = getBlockType("trapped_chest"); + + BlockType.Typed TRIAL_SPAWNER = getBlockType("trial_spawner"); + + BlockType.Typed TRIPWIRE = getBlockType("tripwire"); + + BlockType.Typed TRIPWIRE_HOOK = getBlockType("tripwire_hook"); + + BlockType.Typed TUBE_CORAL = getBlockType("tube_coral"); + + BlockType.Typed TUBE_CORAL_BLOCK = getBlockType("tube_coral_block"); + + BlockType.Typed TUBE_CORAL_FAN = getBlockType("tube_coral_fan"); + + BlockType.Typed TUBE_CORAL_WALL_FAN = getBlockType("tube_coral_wall_fan"); + + BlockType.Typed TUFF = getBlockType("tuff"); + + BlockType.Typed TUFF_BRICK_SLAB = getBlockType("tuff_brick_slab"); + + BlockType.Typed TUFF_BRICK_STAIRS = getBlockType("tuff_brick_stairs"); + + BlockType.Typed TUFF_BRICK_WALL = getBlockType("tuff_brick_wall"); + + BlockType.Typed TUFF_BRICKS = getBlockType("tuff_bricks"); + + BlockType.Typed TUFF_SLAB = getBlockType("tuff_slab"); + + BlockType.Typed TUFF_STAIRS = getBlockType("tuff_stairs"); + + BlockType.Typed TUFF_WALL = getBlockType("tuff_wall"); + + BlockType.Typed TURTLE_EGG = getBlockType("turtle_egg"); + + BlockType.Typed TWISTING_VINES = getBlockType("twisting_vines"); + + BlockType.Typed TWISTING_VINES_PLANT = getBlockType("twisting_vines_plant"); + + BlockType.Typed VAULT = getBlockType("vault"); + + BlockType.Typed VERDANT_FROGLIGHT = getBlockType("verdant_froglight"); + + BlockType.Typed VINE = getBlockType("vine"); + + BlockType.Typed VOID_AIR = getBlockType("void_air"); + + BlockType.Typed WALL_TORCH = getBlockType("wall_torch"); + + BlockType.Typed WARPED_BUTTON = getBlockType("warped_button"); + + BlockType.Typed WARPED_DOOR = getBlockType("warped_door"); + + BlockType.Typed WARPED_FENCE = getBlockType("warped_fence"); + + BlockType.Typed WARPED_FENCE_GATE = getBlockType("warped_fence_gate"); + + BlockType.Typed WARPED_FUNGUS = getBlockType("warped_fungus"); + + BlockType.Typed WARPED_HANGING_SIGN = getBlockType("warped_hanging_sign"); + + BlockType.Typed WARPED_HYPHAE = getBlockType("warped_hyphae"); + + BlockType.Typed WARPED_NYLIUM = getBlockType("warped_nylium"); + + BlockType.Typed WARPED_PLANKS = getBlockType("warped_planks"); + + BlockType.Typed WARPED_PRESSURE_PLATE = getBlockType("warped_pressure_plate"); + + BlockType.Typed WARPED_ROOTS = getBlockType("warped_roots"); + + BlockType.Typed WARPED_SIGN = getBlockType("warped_sign"); + + BlockType.Typed WARPED_SLAB = getBlockType("warped_slab"); + + BlockType.Typed WARPED_STAIRS = getBlockType("warped_stairs"); + + BlockType.Typed WARPED_STEM = getBlockType("warped_stem"); + + BlockType.Typed WARPED_TRAPDOOR = getBlockType("warped_trapdoor"); + + BlockType.Typed WARPED_WALL_HANGING_SIGN = getBlockType("warped_wall_hanging_sign"); + + BlockType.Typed WARPED_WALL_SIGN = getBlockType("warped_wall_sign"); + + BlockType.Typed WARPED_WART_BLOCK = getBlockType("warped_wart_block"); + + BlockType.Typed WATER = getBlockType("water"); + + BlockType.Typed WATER_CAULDRON = getBlockType("water_cauldron"); + + BlockType.Typed WAXED_CHISELED_COPPER = getBlockType("waxed_chiseled_copper"); + + BlockType.Typed WAXED_COPPER_BLOCK = getBlockType("waxed_copper_block"); + + BlockType.Typed WAXED_COPPER_BULB = getBlockType("waxed_copper_bulb"); + + BlockType.Typed WAXED_COPPER_DOOR = getBlockType("waxed_copper_door"); + + BlockType.Typed WAXED_COPPER_GRATE = getBlockType("waxed_copper_grate"); + + BlockType.Typed WAXED_COPPER_TRAPDOOR = getBlockType("waxed_copper_trapdoor"); + + BlockType.Typed WAXED_CUT_COPPER = getBlockType("waxed_cut_copper"); + + BlockType.Typed WAXED_CUT_COPPER_SLAB = getBlockType("waxed_cut_copper_slab"); + + BlockType.Typed WAXED_CUT_COPPER_STAIRS = getBlockType("waxed_cut_copper_stairs"); + + BlockType.Typed WAXED_EXPOSED_CHISELED_COPPER = getBlockType("waxed_exposed_chiseled_copper"); + + BlockType.Typed WAXED_EXPOSED_COPPER = getBlockType("waxed_exposed_copper"); + + BlockType.Typed WAXED_EXPOSED_COPPER_BULB = getBlockType("waxed_exposed_copper_bulb"); + + BlockType.Typed WAXED_EXPOSED_COPPER_DOOR = getBlockType("waxed_exposed_copper_door"); + + BlockType.Typed WAXED_EXPOSED_COPPER_GRATE = getBlockType("waxed_exposed_copper_grate"); + + BlockType.Typed WAXED_EXPOSED_COPPER_TRAPDOOR = getBlockType("waxed_exposed_copper_trapdoor"); + + BlockType.Typed WAXED_EXPOSED_CUT_COPPER = getBlockType("waxed_exposed_cut_copper"); + + BlockType.Typed WAXED_EXPOSED_CUT_COPPER_SLAB = getBlockType("waxed_exposed_cut_copper_slab"); + + BlockType.Typed WAXED_EXPOSED_CUT_COPPER_STAIRS = getBlockType("waxed_exposed_cut_copper_stairs"); + + BlockType.Typed WAXED_OXIDIZED_CHISELED_COPPER = getBlockType("waxed_oxidized_chiseled_copper"); + + BlockType.Typed WAXED_OXIDIZED_COPPER = getBlockType("waxed_oxidized_copper"); + + BlockType.Typed WAXED_OXIDIZED_COPPER_BULB = getBlockType("waxed_oxidized_copper_bulb"); + + BlockType.Typed WAXED_OXIDIZED_COPPER_DOOR = getBlockType("waxed_oxidized_copper_door"); + + BlockType.Typed WAXED_OXIDIZED_COPPER_GRATE = getBlockType("waxed_oxidized_copper_grate"); + + BlockType.Typed WAXED_OXIDIZED_COPPER_TRAPDOOR = getBlockType("waxed_oxidized_copper_trapdoor"); + + BlockType.Typed WAXED_OXIDIZED_CUT_COPPER = getBlockType("waxed_oxidized_cut_copper"); + + BlockType.Typed WAXED_OXIDIZED_CUT_COPPER_SLAB = getBlockType("waxed_oxidized_cut_copper_slab"); + + BlockType.Typed WAXED_OXIDIZED_CUT_COPPER_STAIRS = getBlockType("waxed_oxidized_cut_copper_stairs"); + + BlockType.Typed WAXED_WEATHERED_CHISELED_COPPER = getBlockType("waxed_weathered_chiseled_copper"); + + BlockType.Typed WAXED_WEATHERED_COPPER = getBlockType("waxed_weathered_copper"); + + BlockType.Typed WAXED_WEATHERED_COPPER_BULB = getBlockType("waxed_weathered_copper_bulb"); + + BlockType.Typed WAXED_WEATHERED_COPPER_DOOR = getBlockType("waxed_weathered_copper_door"); + + BlockType.Typed WAXED_WEATHERED_COPPER_GRATE = getBlockType("waxed_weathered_copper_grate"); + + BlockType.Typed WAXED_WEATHERED_COPPER_TRAPDOOR = getBlockType("waxed_weathered_copper_trapdoor"); + + BlockType.Typed WAXED_WEATHERED_CUT_COPPER = getBlockType("waxed_weathered_cut_copper"); + + BlockType.Typed WAXED_WEATHERED_CUT_COPPER_SLAB = getBlockType("waxed_weathered_cut_copper_slab"); + + BlockType.Typed WAXED_WEATHERED_CUT_COPPER_STAIRS = getBlockType("waxed_weathered_cut_copper_stairs"); + + BlockType.Typed WEATHERED_CHISELED_COPPER = getBlockType("weathered_chiseled_copper"); + + BlockType.Typed WEATHERED_COPPER = getBlockType("weathered_copper"); + + BlockType.Typed WEATHERED_COPPER_BULB = getBlockType("weathered_copper_bulb"); + + BlockType.Typed WEATHERED_COPPER_DOOR = getBlockType("weathered_copper_door"); + + BlockType.Typed WEATHERED_COPPER_GRATE = getBlockType("weathered_copper_grate"); + + BlockType.Typed WEATHERED_COPPER_TRAPDOOR = getBlockType("weathered_copper_trapdoor"); + + BlockType.Typed WEATHERED_CUT_COPPER = getBlockType("weathered_cut_copper"); + + BlockType.Typed WEATHERED_CUT_COPPER_SLAB = getBlockType("weathered_cut_copper_slab"); + + BlockType.Typed WEATHERED_CUT_COPPER_STAIRS = getBlockType("weathered_cut_copper_stairs"); + + BlockType.Typed WEEPING_VINES = getBlockType("weeping_vines"); + + BlockType.Typed WEEPING_VINES_PLANT = getBlockType("weeping_vines_plant"); + + BlockType.Typed WET_SPONGE = getBlockType("wet_sponge"); + + BlockType.Typed WHEAT = getBlockType("wheat"); + + BlockType.Typed WHITE_BANNER = getBlockType("white_banner"); + + BlockType.Typed WHITE_BED = getBlockType("white_bed"); + + BlockType.Typed WHITE_CANDLE = getBlockType("white_candle"); + + BlockType.Typed WHITE_CANDLE_CAKE = getBlockType("white_candle_cake"); + + BlockType.Typed WHITE_CARPET = getBlockType("white_carpet"); + + BlockType.Typed WHITE_CONCRETE = getBlockType("white_concrete"); + + BlockType.Typed WHITE_CONCRETE_POWDER = getBlockType("white_concrete_powder"); + + BlockType.Typed WHITE_GLAZED_TERRACOTTA = getBlockType("white_glazed_terracotta"); + + BlockType.Typed WHITE_SHULKER_BOX = getBlockType("white_shulker_box"); + + BlockType.Typed WHITE_STAINED_GLASS = getBlockType("white_stained_glass"); + + BlockType.Typed WHITE_STAINED_GLASS_PANE = getBlockType("white_stained_glass_pane"); + + BlockType.Typed WHITE_TERRACOTTA = getBlockType("white_terracotta"); + + BlockType.Typed WHITE_TULIP = getBlockType("white_tulip"); + + BlockType.Typed WHITE_WALL_BANNER = getBlockType("white_wall_banner"); + + BlockType.Typed WHITE_WOOL = getBlockType("white_wool"); + + BlockType.Typed WILDFLOWERS = getBlockType("wildflowers"); + + BlockType.Typed WITHER_ROSE = getBlockType("wither_rose"); + + BlockType.Typed WITHER_SKELETON_SKULL = getBlockType("wither_skeleton_skull"); + + BlockType.Typed WITHER_SKELETON_WALL_SKULL = getBlockType("wither_skeleton_wall_skull"); + + BlockType.Typed YELLOW_BANNER = getBlockType("yellow_banner"); + + BlockType.Typed YELLOW_BED = getBlockType("yellow_bed"); + + BlockType.Typed YELLOW_CANDLE = getBlockType("yellow_candle"); + + BlockType.Typed YELLOW_CANDLE_CAKE = getBlockType("yellow_candle_cake"); + + BlockType.Typed YELLOW_CARPET = getBlockType("yellow_carpet"); + + BlockType.Typed YELLOW_CONCRETE = getBlockType("yellow_concrete"); + + BlockType.Typed YELLOW_CONCRETE_POWDER = getBlockType("yellow_concrete_powder"); + + BlockType.Typed YELLOW_GLAZED_TERRACOTTA = getBlockType("yellow_glazed_terracotta"); + + BlockType.Typed YELLOW_SHULKER_BOX = getBlockType("yellow_shulker_box"); + + BlockType.Typed YELLOW_STAINED_GLASS = getBlockType("yellow_stained_glass"); + + BlockType.Typed YELLOW_STAINED_GLASS_PANE = getBlockType("yellow_stained_glass_pane"); + + BlockType.Typed YELLOW_TERRACOTTA = getBlockType("yellow_terracotta"); + + BlockType.Typed YELLOW_WALL_BANNER = getBlockType("yellow_wall_banner"); + + BlockType.Typed YELLOW_WOOL = getBlockType("yellow_wool"); + + BlockType.Typed ZOMBIE_HEAD = getBlockType("zombie_head"); + + BlockType.Typed ZOMBIE_WALL_HEAD = getBlockType("zombie_wall_head"); + // End generate - BlockType // @NotNull diff --git a/paper-api/src/main/java/org/bukkit/block/Campfire.java b/paper-api/src/main/java/org/bukkit/block/Campfire.java index 9c3952459..c7afecea9 100644 --- a/paper-api/src/main/java/org/bukkit/block/Campfire.java +++ b/paper-api/src/main/java/org/bukkit/block/Campfire.java @@ -70,7 +70,6 @@ public interface Campfire extends TileState { */ void setCookTimeTotal(int index, int cookTimeTotal); - // Paper start /** * Disable cooking in all slots. */ @@ -104,5 +103,4 @@ public interface Campfire extends TileState { * @return {@code true} if the specified slot index cannot cook */ boolean isCookingDisabled(int index); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/block/CommandBlock.java b/paper-api/src/main/java/org/bukkit/block/CommandBlock.java index 02bf0f8c1..d455b14c8 100644 --- a/paper-api/src/main/java/org/bukkit/block/CommandBlock.java +++ b/paper-api/src/main/java/org/bukkit/block/CommandBlock.java @@ -10,7 +10,7 @@ public interface CommandBlock extends TileState, io.papermc.paper.command.Comman /** * Gets the command that this CommandBlock will run when powered. - * This will never return null. If the CommandBlock does not have a + * This will never return null. If the CommandBlock does not have a * command, an empty String will be returned instead. * * @return Command that this CommandBlock will run when powered. @@ -28,8 +28,8 @@ public interface CommandBlock extends TileState, io.papermc.paper.command.Comman public void setCommand(@Nullable String command); /** - * Gets the name of this CommandBlock. The name is used with commands - * that this CommandBlock executes. This name will never be null, and + * Gets the name of this CommandBlock. The name is used with commands + * that this CommandBlock executes. This name will never be null, and * by default is "@". * * @return Name of this CommandBlock. @@ -40,8 +40,8 @@ public interface CommandBlock extends TileState, io.papermc.paper.command.Comman public String getName(); /** - * Sets the name of this CommandBlock. The name is used with commands - * that this CommandBlock executes. Setting the name to null is the + * Sets the name of this CommandBlock. The name is used with commands + * that this CommandBlock executes. Setting the name to null is the * same as setting it to "@". * * @param name New name for this CommandBlock. @@ -50,10 +50,9 @@ public interface CommandBlock extends TileState, io.papermc.paper.command.Comman @Deprecated // Paper public void setName(@Nullable String name); - // Paper start /** - * Gets the name of this CommandBlock. The name is used with commands - * that this CommandBlock executes. This name will never be null, and + * Gets the name of this CommandBlock. The name is used with commands + * that this CommandBlock executes. This name will never be null, and * by default is a {@link net.kyori.adventure.text.TextComponent} containing {@code @}. * * @return Name of this CommandBlock. @@ -61,12 +60,11 @@ public interface CommandBlock extends TileState, io.papermc.paper.command.Comman public net.kyori.adventure.text.@NotNull Component name(); /** - * Sets the name of this CommandBlock. The name is used with commands - * that this CommandBlock executes. Setting the name to null is the + * Sets the name of this CommandBlock. The name is used with commands + * that this CommandBlock executes. Setting the name to null is the * same as setting it to a {@link net.kyori.adventure.text.TextComponent} containing {@code @}. * * @param name New name for this CommandBlock. */ public void name(net.kyori.adventure.text.@Nullable Component name); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/block/Orientation.java b/paper-api/src/main/java/org/bukkit/block/Orientation.java new file mode 100644 index 000000000..b434f5392 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/Orientation.java @@ -0,0 +1,20 @@ +package org.bukkit.block; + +/** + * Represents the face and the direction of a block + */ +public enum Orientation { + + DOWN_EAST, + DOWN_NORTH, + DOWN_SOUTH, + DOWN_WEST, + UP_EAST, + UP_NORTH, + UP_SOUTH, + UP_WEST, + WEST_UP, + EAST_UP, + NORTH_UP, + SOUTH_UP +} diff --git a/paper-api/src/main/java/org/bukkit/block/TestBlock.java b/paper-api/src/main/java/org/bukkit/block/TestBlock.java new file mode 100644 index 000000000..bbcd0c921 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/TestBlock.java @@ -0,0 +1,7 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a test block. + */ +public interface TestBlock extends TileState { +} diff --git a/paper-api/src/main/java/org/bukkit/block/TestInstanceBlock.java b/paper-api/src/main/java/org/bukkit/block/TestInstanceBlock.java new file mode 100644 index 000000000..c6da8ffe4 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/TestInstanceBlock.java @@ -0,0 +1,7 @@ +package org.bukkit.block; + +/** + * Represents a captured state of a test instance block. + */ +public interface TestInstanceBlock extends TileState { +} diff --git a/paper-api/src/main/java/org/bukkit/block/TileState.java b/paper-api/src/main/java/org/bukkit/block/TileState.java index 5c8517c5b..edbd2bf16 100644 --- a/paper-api/src/main/java/org/bukkit/block/TileState.java +++ b/paper-api/src/main/java/org/bukkit/block/TileState.java @@ -5,13 +5,13 @@ import org.bukkit.persistence.PersistentDataHolder; import org.jetbrains.annotations.NotNull; /** - * Represents a block state that also hosts a tile entity at the given location. - * + * Represents a block state that also hosts a block entity at the given location. + *
* This interface alone is merely a marker that does not provide any data. - * - * Data about the tile entities is provided by the respective interface for each - * tile entity type. - * + *

+ * Data about the block entities is provided by the respective interface for each + * block entity type. + *

* After modifying the data provided by a TileState, {@link #update()} needs to * be called to store the data. */ @@ -19,16 +19,16 @@ public interface TileState extends BlockState, PersistentDataHolder { /** * Returns a custom tag container capable of storing tags on the object. - * + *

* Note that the tags stored on this container are all stored under their * own custom namespace therefore modifying default tags using this * {@link PersistentDataHolder} is impossible. *

* This {@link PersistentDataHolder} is only linked to the snapshot instance * stored by the {@link BlockState}. - * + *

* When storing changes on the {@link PersistentDataHolder}, the updated - * content will only be applied to the actual tile entity after one of the + * content will only be applied to the actual block entity after one of the * {@link #update()} methods is called. * * @return the custom tag container @@ -40,7 +40,7 @@ public interface TileState extends BlockState, PersistentDataHolder { // Paper start /** * Checks if this TileState is a snapshot or a live - * representation of the underlying tile entity. + * representation of the underlying block entity. *

* NOTE: You may still have to call {@link BlockState#update()} on * live representations to update any visuals on the block. diff --git a/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java b/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java index 444f128e8..15415ecbb 100644 --- a/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java +++ b/paper-api/src/main/java/org/bukkit/block/banner/PatternType.java @@ -14,50 +14,96 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface PatternType extends OldEnum, Keyed { + + // Start generate - PatternType + // @GeneratedFrom 1.21.5 PatternType BASE = getType("base"); - PatternType SQUARE_BOTTOM_LEFT = getType("square_bottom_left"); - PatternType SQUARE_BOTTOM_RIGHT = getType("square_bottom_right"); - PatternType SQUARE_TOP_LEFT = getType("square_top_left"); - PatternType SQUARE_TOP_RIGHT = getType("square_top_right"); - PatternType STRIPE_BOTTOM = getType("stripe_bottom"); - PatternType STRIPE_TOP = getType("stripe_top"); - PatternType STRIPE_LEFT = getType("stripe_left"); - PatternType STRIPE_RIGHT = getType("stripe_right"); - PatternType STRIPE_CENTER = getType("stripe_center"); - PatternType STRIPE_MIDDLE = getType("stripe_middle"); - PatternType STRIPE_DOWNRIGHT = getType("stripe_downright"); - PatternType STRIPE_DOWNLEFT = getType("stripe_downleft"); - PatternType SMALL_STRIPES = getType("small_stripes"); - PatternType CROSS = getType("cross"); - PatternType STRAIGHT_CROSS = getType("straight_cross"); - PatternType TRIANGLE_BOTTOM = getType("triangle_bottom"); - PatternType TRIANGLE_TOP = getType("triangle_top"); - PatternType TRIANGLES_BOTTOM = getType("triangles_bottom"); - PatternType TRIANGLES_TOP = getType("triangles_top"); - PatternType DIAGONAL_LEFT = getType("diagonal_left"); - PatternType DIAGONAL_UP_RIGHT = getType("diagonal_up_right"); - PatternType DIAGONAL_UP_LEFT = getType("diagonal_up_left"); - PatternType DIAGONAL_RIGHT = getType("diagonal_right"); - PatternType CIRCLE = getType("circle"); - PatternType RHOMBUS = getType("rhombus"); - PatternType HALF_VERTICAL = getType("half_vertical"); - PatternType HALF_HORIZONTAL = getType("half_horizontal"); - PatternType HALF_VERTICAL_RIGHT = getType("half_vertical_right"); - PatternType HALF_HORIZONTAL_BOTTOM = getType("half_horizontal_bottom"); + PatternType BORDER = getType("border"); - PatternType CURLY_BORDER = getType("curly_border"); - PatternType CREEPER = getType("creeper"); - PatternType GRADIENT = getType("gradient"); - PatternType GRADIENT_UP = getType("gradient_up"); + PatternType BRICKS = getType("bricks"); - PatternType SKULL = getType("skull"); - PatternType FLOWER = getType("flower"); - PatternType MOJANG = getType("mojang"); - PatternType GLOBE = getType("globe"); - PatternType PIGLIN = getType("piglin"); + + PatternType CIRCLE = getType("circle"); + + PatternType CREEPER = getType("creeper"); + + PatternType CROSS = getType("cross"); + + PatternType CURLY_BORDER = getType("curly_border"); + + PatternType DIAGONAL_LEFT = getType("diagonal_left"); + + PatternType DIAGONAL_RIGHT = getType("diagonal_right"); + + PatternType DIAGONAL_UP_LEFT = getType("diagonal_up_left"); + + PatternType DIAGONAL_UP_RIGHT = getType("diagonal_up_right"); + PatternType FLOW = getType("flow"); + + PatternType FLOWER = getType("flower"); + + PatternType GLOBE = getType("globe"); + + PatternType GRADIENT = getType("gradient"); + + PatternType GRADIENT_UP = getType("gradient_up"); + PatternType GUSTER = getType("guster"); + PatternType HALF_HORIZONTAL = getType("half_horizontal"); + + PatternType HALF_HORIZONTAL_BOTTOM = getType("half_horizontal_bottom"); + + PatternType HALF_VERTICAL = getType("half_vertical"); + + PatternType HALF_VERTICAL_RIGHT = getType("half_vertical_right"); + + PatternType MOJANG = getType("mojang"); + + PatternType PIGLIN = getType("piglin"); + + PatternType RHOMBUS = getType("rhombus"); + + PatternType SKULL = getType("skull"); + + PatternType SMALL_STRIPES = getType("small_stripes"); + + PatternType SQUARE_BOTTOM_LEFT = getType("square_bottom_left"); + + PatternType SQUARE_BOTTOM_RIGHT = getType("square_bottom_right"); + + PatternType SQUARE_TOP_LEFT = getType("square_top_left"); + + PatternType SQUARE_TOP_RIGHT = getType("square_top_right"); + + PatternType STRAIGHT_CROSS = getType("straight_cross"); + + PatternType STRIPE_BOTTOM = getType("stripe_bottom"); + + PatternType STRIPE_CENTER = getType("stripe_center"); + + PatternType STRIPE_DOWNLEFT = getType("stripe_downleft"); + + PatternType STRIPE_DOWNRIGHT = getType("stripe_downright"); + + PatternType STRIPE_LEFT = getType("stripe_left"); + + PatternType STRIPE_MIDDLE = getType("stripe_middle"); + + PatternType STRIPE_RIGHT = getType("stripe_right"); + + PatternType STRIPE_TOP = getType("stripe_top"); + + PatternType TRIANGLE_BOTTOM = getType("triangle_bottom"); + + PatternType TRIANGLE_TOP = getType("triangle_top"); + + PatternType TRIANGLES_BOTTOM = getType("triangles_bottom"); + + PatternType TRIANGLES_TOP = getType("triangles_top"); + // End generate - PatternType + // Paper start - deprecate getKey /** * @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)}, diff --git a/paper-api/src/main/java/org/bukkit/block/data/Segmentable.java b/paper-api/src/main/java/org/bukkit/block/data/Segmentable.java new file mode 100644 index 000000000..c3089d24f --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/Segmentable.java @@ -0,0 +1,35 @@ +package org.bukkit.block.data; + +/** + * 'segment_amount' represents the number of segment in this block. + */ +public interface Segmentable extends BlockData { + + /** + * Gets the value of the 'segment_amount' property. + * + * @return the 'segment_amount' value + */ + int getSegmentAmount(); + + /** + * Sets the value of the 'segment_amount' property. + * + * @param segmentAmount the new 'segment_amount' value + */ + void setSegmentAmount(int segmentAmount); + + /** + * Gets the minimum allowed value of the 'segment_amount' property. + * + * @return the minimum 'segment_amount' value + */ + int getMinimumSegmentAmount(); + + /** + * Gets the maximum allowed value of the 'segment_amount' property. + * + * @return the maximum 'segment_amount' value + */ + int getMaximumSegmentAmount(); +} diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/CaveVinesPlant.java b/paper-api/src/main/java/org/bukkit/block/data/type/CaveVinesPlant.java index a7f75a98e..274bc2b1c 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/CaveVinesPlant.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/CaveVinesPlant.java @@ -11,8 +11,19 @@ public interface CaveVinesPlant extends BlockData { * Gets the value of the 'berries' property. * * @return the 'berries' value + * @deprecated bad name, use {@link #hasBerries()} */ - boolean isBerries(); + @Deprecated + default boolean isBerries() { + return this.hasBerries(); + } + + /** + * Gets the value of the 'berries' property. + * + * @return the 'berries' value + */ + boolean hasBerries(); /** * Sets the value of the 'berries' property. diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Crafter.java b/paper-api/src/main/java/org/bukkit/block/data/type/Crafter.java index c15fdf9e8..ada92c3ee 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Crafter.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Crafter.java @@ -48,18 +48,23 @@ public interface Crafter extends BlockData { * @return the 'orientation' value */ @NotNull - Orientation getOrientation(); + org.bukkit.block.Orientation getOrientation(); /** * Sets the value of the 'orientation' property. * * @param orientation the new 'orientation' value */ - void setOrientation(@NotNull Orientation orientation); + void setOrientation(@NotNull org.bukkit.block.Orientation orientation); /** * The directions the Crafter can be oriented. + * + * @deprecated this property is not specific to the Crafter, use + * {@link org.bukkit.block.Orientation} instead. All references + * to this enum will be redirected to that enum at runtime. */ + @Deprecated public enum Orientation { DOWN_EAST, diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/CreakingHeart.java b/paper-api/src/main/java/org/bukkit/block/data/type/CreakingHeart.java index 42302837f..f13f1427d 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/CreakingHeart.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/CreakingHeart.java @@ -1,9 +1,10 @@ package org.bukkit.block.data.type; import org.bukkit.block.data.Orientable; +import org.jetbrains.annotations.NotNull; /** - * 'active' is whether the block is active. + * 'creaking_heart_state' is the state of the block depending on the time and its position. *
* 'natural' is whether this is a naturally generated block. */ @@ -13,15 +14,38 @@ public interface CreakingHeart extends Orientable { * Gets the value of the 'active' property. * * @return the 'active' value + * @deprecated use {@link #getCreakingHeartState()} */ - boolean isActive(); + @Deprecated(since = "1.21.5", forRemoval = true) + default boolean isActive() { + return this.getCreakingHeartState() != State.UPROOTED; + } /** * Sets the value of the 'active' property. * * @param active the new 'active' value + * @deprecated use {@link #setCreakingHeartState(State)} */ - void setActive(boolean active); + @Deprecated(since = "1.21.5", forRemoval = true) + default void setActive(boolean active) { + this.setCreakingHeartState(active ? State.AWAKE : State.UPROOTED); + } + + /** + * Gets the value of the 'creaking_heart_state' property. + * + * @return the 'creaking_heart_state' value + */ + @NotNull + State getCreakingHeartState(); + + /** + * Sets the value of the 'creaking_heart_state' property. + * + * @param state the new 'creaking_heart_state' value + */ + void setCreakingHeartState(@NotNull State state); /** * Gets the value of the 'natural' property. @@ -36,4 +60,10 @@ public interface CreakingHeart extends Orientable { * @param natural the new 'natural' value */ void setNatural(boolean natural); + + enum State { + UPROOTED, + DORMANT, + AWAKE + } } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/DecoratedPot.java b/paper-api/src/main/java/org/bukkit/block/data/type/DecoratedPot.java index b3d290dbf..7a213b916 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/DecoratedPot.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/DecoratedPot.java @@ -4,17 +4,18 @@ import org.bukkit.block.data.Directional; import org.bukkit.block.data.Waterlogged; public interface DecoratedPot extends Directional, Waterlogged { - // Paper start - add missing block data api - /** - * @return whether the pot is cracked - */ - public boolean isCracked(); /** - * Set whether the pot is cracked. + * Gets the value of the 'cracked' property. * - * @param cracked whether the pot is cracked + * @return the 'cracked' value */ - public void setCracked(boolean cracked); - // Paper end - add missing block data api + boolean isCracked(); + + /** + * Sets the value of the 'cracked' property. + * + * @param cracked the new 'cracked' value + */ + void setCracked(boolean cracked); } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/FlowerBed.java b/paper-api/src/main/java/org/bukkit/block/data/type/FlowerBed.java new file mode 100644 index 000000000..8502070a2 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/type/FlowerBed.java @@ -0,0 +1,39 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; + +/** + * 'flower_amount' represents the number of flowers. + */ +public interface FlowerBed extends Directional { + + /** + * Gets the value of the 'flower_amount' property. + * + * @return the 'flower_amount' value + */ + int getFlowerAmount(); + + /** + * Sets the value of the 'flower_amount' property. + * + * @param flower_amount the new 'flower_amount' value + */ + void setFlowerAmount(int flower_amount); + + // Paper start + /** + * Gets the minimum allowed value of the 'flower_amount' property. + * + * @return the minimum 'flower_amount' value + */ + int getMinimumFlowerAmount(); + // Paper end + + /** + * Gets the maximum allowed value of the 'flower_amount' property. + * + * @return the maximum 'flower_amount' value + */ + int getMaximumFlowerAmount(); +} diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Jigsaw.java b/paper-api/src/main/java/org/bukkit/block/data/type/Jigsaw.java index c70c755cd..65a137a90 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Jigsaw.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Jigsaw.java @@ -14,18 +14,23 @@ public interface Jigsaw extends BlockData { * @return the 'orientation' value */ @NotNull - Orientation getOrientation(); + org.bukkit.block.Orientation getOrientation(); /** * Sets the value of the 'orientation' property. * * @param orientation the new 'orientation' value */ - void setOrientation(@NotNull Orientation orientation); + void setOrientation(@NotNull org.bukkit.block.Orientation orientation); /** * The directions the Jigsaw can be oriented. + * + * @deprecated this property is not specific to the Jigsaw, use + * {@link org.bukkit.block.Orientation} instead. All references + * to this enum will be redirected to that enum at runtime. */ + @Deprecated public enum Orientation { DOWN_EAST, diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Jukebox.java b/paper-api/src/main/java/org/bukkit/block/data/type/Jukebox.java index 5e3713620..4a59fa4fa 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Jukebox.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Jukebox.java @@ -14,4 +14,11 @@ public interface Jukebox extends BlockData { * @return the 'has_record' value */ boolean hasRecord(); + + /** + * Sets the value of the 'has_record' property. + * + * @param hasRecord the new 'has_record' value + */ + void setHasRecord(boolean hasRecord); } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/LeafLitter.java b/paper-api/src/main/java/org/bukkit/block/data/type/LeafLitter.java new file mode 100644 index 000000000..5a85bcda4 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/type/LeafLitter.java @@ -0,0 +1,6 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.Directional; +import org.bukkit.block.data.Segmentable; + +public interface LeafLitter extends Segmentable, Directional { } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Lectern.java b/paper-api/src/main/java/org/bukkit/block/data/type/Lectern.java index 11b4a173f..db714a52f 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Lectern.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Lectern.java @@ -15,4 +15,11 @@ public interface Lectern extends Directional, Powerable { * @return the 'has_book' value */ boolean hasBook(); + + /** + * Sets the value of the 'has_book' property. + * + * @param hasBook the new 'has_book' value + */ + void setHasBook(boolean hasBook); } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/MossyCarpet.java b/paper-api/src/main/java/org/bukkit/block/data/type/MossyCarpet.java index 1c904b440..65a4b2a2d 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/MossyCarpet.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/MossyCarpet.java @@ -33,7 +33,7 @@ public interface MossyCarpet extends BlockData { * @return if face is enabled */ @NotNull - Height getHeight(@NotNull BlockFace face); + Wall.Height getHeight(@NotNull BlockFace face); /** * Set the height of the specified face. @@ -41,11 +41,16 @@ public interface MossyCarpet extends BlockData { * @param face to set * @param height the height */ - void setHeight(@NotNull BlockFace face, @NotNull Height height); + void setHeight(@NotNull BlockFace face, @NotNull Wall.Height height); /** * The different heights a face may have. + * + * @deprecated this property is not specific to the MossyCarpet, use + * {@link org.bukkit.block.data.type.Wall.Height} instead. All references + * to this enum will be redirected to that enum at runtime. */ + @Deprecated public enum Height { /** * Not present. diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/PinkPetals.java b/paper-api/src/main/java/org/bukkit/block/data/type/PinkPetals.java index eae9c9cdd..db05fa9b2 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/PinkPetals.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/PinkPetals.java @@ -1,39 +1,11 @@ package org.bukkit.block.data.type; -import org.bukkit.block.data.Directional; - /** * 'flower_amount' represents the number of petals. + * + * @deprecated incorrect name as multiple types of flower collection blocks exist now. Use {@link FlowerBed} */ -public interface PinkPetals extends Directional { +@Deprecated(forRemoval = true, since = "1.21.5") +public interface PinkPetals extends FlowerBed { - /** - * Gets the value of the 'flower_amount' property. - * - * @return the 'flower_amount' value - */ - int getFlowerAmount(); - - /** - * Sets the value of the 'flower_amount' property. - * - * @param flower_amount the new 'flower_amount' value - */ - void setFlowerAmount(int flower_amount); - - // Paper start - /** - * Gets the minimum allowed value of the 'flower_amount' property. - * - * @return the minimum 'flower_amount' value - */ - int getMinimumFlowerAmount(); - // Paper end - - /** - * Gets the maximum allowed value of the 'flower_amount' property. - * - * @return the maximum 'flower_amount' value - */ - int getMaximumFlowerAmount(); } diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/SculkSensor.java b/paper-api/src/main/java/org/bukkit/block/data/type/SculkSensor.java index 1af390e2e..3e7f5f22b 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/SculkSensor.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/SculkSensor.java @@ -13,16 +13,39 @@ public interface SculkSensor extends AnaloguePowerable, Waterlogged { * Gets the value of the 'sculk_sensor_phase' property. * * @return the 'sculk_sensor_phase' value + * @deprecated bad name, use {@link #getSculkSensorPhase()} */ @NotNull - Phase getPhase(); + @Deprecated + default Phase getPhase() { + return this.getSculkSensorPhase(); + } + + /** + * Sets the value of the 'sculk_sensor_phase' property. + * + * @param phase the new 'sculk_sensor_phase' value + * @deprecated bad name, use {@link #setSculkSensorPhase(Phase)} + */ + @Deprecated + default void setPhase(@NotNull Phase phase) { + this.setSculkSensorPhase(phase); + } + + /** + * Gets the value of the 'sculk_sensor_phase' property. + * + * @return the 'sculk_sensor_phase' value + */ + @NotNull + Phase getSculkSensorPhase(); /** * Sets the value of the 'sculk_sensor_phase' property. * * @param phase the new 'sculk_sensor_phase' value */ - void setPhase(@NotNull Phase phase); + void setSculkSensorPhase(@NotNull Phase phase); /** * The Phase of the sensor. diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java b/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java index 16ced762f..793f8d4d1 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Switch.java @@ -7,6 +7,11 @@ import org.jetbrains.annotations.NotNull; public interface Switch extends Directional, FaceAttachable, Powerable { + @NotNull + AttachedFace getAttachedFace(); + + void setAttachedFace(@NotNull AttachedFace face); + /** * Gets the value of the 'face' property. * @@ -15,7 +20,9 @@ public interface Switch extends Directional, FaceAttachable, Powerable { */ @NotNull @Deprecated(since = "1.15.2") - Face getFace(); + default Face getFace() { + return Face.valueOf(this.getAttachedFace().name()); + } /** * Sets the value of the 'face' property. @@ -24,7 +31,9 @@ public interface Switch extends Directional, FaceAttachable, Powerable { * @deprecated use {@link #setAttachedFace(AttachedFace)} */ @Deprecated(since = "1.15.2") - void setFace(@NotNull Face face); + default void setFace(@NotNull Face face) { + this.setAttachedFace(AttachedFace.valueOf(face.name())); + } /** * The face to which a switch type block is stuck. diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/TestBlock.java b/paper-api/src/main/java/org/bukkit/block/data/type/TestBlock.java new file mode 100644 index 000000000..0a0f76481 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/block/data/type/TestBlock.java @@ -0,0 +1,32 @@ +package org.bukkit.block.data.type; + +import org.bukkit.block.data.BlockData; +import org.jetbrains.annotations.NotNull; + +/** + * 'mode' is the reaction of the block to a redstone pulse or its supply. + */ +public interface TestBlock extends BlockData { + + /** + * Gets the value of the 'mode' property. + * + * @return the 'mode' value + */ + @NotNull + Mode getMode(); + + /** + * Sets the value of the 'mode' property. + * + * @param mode the new 'mode' value + */ + void setMode(@NotNull Mode mode); + + enum Mode { + START, + LOG, + FAIL, + ACCEPT + } +} diff --git a/paper-api/src/main/java/org/bukkit/block/data/type/Vault.java b/paper-api/src/main/java/org/bukkit/block/data/type/Vault.java index 122f8c888..b42934612 100644 --- a/paper-api/src/main/java/org/bukkit/block/data/type/Vault.java +++ b/paper-api/src/main/java/org/bukkit/block/data/type/Vault.java @@ -26,7 +26,9 @@ public interface Vault extends Directional { */ @Deprecated(since = "1.21.3", forRemoval = true) @NotNull - State getTrialSpawnerState(); + default State getTrialSpawnerState() { + return this.getVaultState(); + } /** * Sets the value of the 'vault_state' property. @@ -42,7 +44,9 @@ public interface Vault extends Directional { * @deprecated see {@link #setVaultState(State)} */ @Deprecated(since = "1.21.3", forRemoval = true) - void setTrialSpawnerState(@NotNull State state); + default void setTrialSpawnerState(@NotNull State state) { + this.setVaultState(state); + } /** * Gets the value of the 'ominous' property. diff --git a/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java index e64bb57f7..26bc02a53 100644 --- a/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/paper-api/src/main/java/org/bukkit/command/defaults/VersionCommand.java @@ -1,6 +1,5 @@ package org.bukkit.command.defaults; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.io.Resources; @@ -11,6 +10,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.net.URL; import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -25,14 +25,12 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; import org.jetbrains.annotations.NotNull; -// Paper start - version command 2.0 import com.destroystokyo.paper.util.VersionFetcher; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.TextDecoration; import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; -// Paper end - version command 2.0 public class VersionCommand extends BukkitCommand { private VersionFetcher versionFetcher; // Paper - version command 2.0 @@ -283,8 +281,8 @@ public class VersionCommand extends BukkitCommand { private static int getDistance(@NotNull String repo, @NotNull String hash) { try { BufferedReader reader = Resources.asCharSource( - new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, "UTF-8") + "&withCounts=true"), - Charsets.UTF_8 + new URL("https://hub.spigotmc.org/stash/rest/api/1.0/projects/SPIGOT/repos/" + repo + "/commits?since=" + URLEncoder.encode(hash, StandardCharsets.UTF_8) + "&withCounts=true"), + StandardCharsets.UTF_8 ).openBufferedStream(); try { JsonObject obj = new Gson().fromJson(reader, JsonObject.class); diff --git a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java index 646223d03..6a977c1b4 100644 --- a/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java +++ b/paper-api/src/main/java/org/bukkit/configuration/file/FileConfiguration.java @@ -1,6 +1,5 @@ package org.bukkit.configuration.file; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import com.google.common.io.Files; import java.io.BufferedReader; @@ -13,6 +12,7 @@ import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.Reader; import java.io.Writer; +import java.nio.charset.StandardCharsets; import org.bukkit.configuration.Configuration; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.MemoryConfiguration; @@ -64,7 +64,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { String data = saveToString(); - Writer writer = new OutputStreamWriter(new FileOutputStream(file), Charsets.UTF_8); + Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8); try { writer.write(data); @@ -125,7 +125,7 @@ public abstract class FileConfiguration extends MemoryConfiguration { final FileInputStream stream = new FileInputStream(file); - load(new InputStreamReader(stream, Charsets.UTF_8)); + load(new InputStreamReader(stream, StandardCharsets.UTF_8)); } /** diff --git a/paper-api/src/main/java/org/bukkit/damage/DamageType.java b/paper-api/src/main/java/org/bukkit/damage/DamageType.java index b74846c77..88a430b47 100644 --- a/paper-api/src/main/java/org/bukkit/damage/DamageType.java +++ b/paper-api/src/main/java/org/bukkit/damage/DamageType.java @@ -21,55 +21,106 @@ import org.jetbrains.annotations.NotNull; @ApiStatus.Experimental public interface DamageType extends Keyed, Translatable { - public static final DamageType IN_FIRE = getDamageType("in_fire"); - public static final DamageType CAMPFIRE = getDamageType("campfire"); - public static final DamageType LIGHTNING_BOLT = getDamageType("lightning_bolt"); - public static final DamageType ON_FIRE = getDamageType("on_fire"); - public static final DamageType LAVA = getDamageType("lava"); - public static final DamageType HOT_FLOOR = getDamageType("hot_floor"); - public static final DamageType IN_WALL = getDamageType("in_wall"); - public static final DamageType CRAMMING = getDamageType("cramming"); - public static final DamageType DROWN = getDamageType("drown"); - public static final DamageType STARVE = getDamageType("starve"); - public static final DamageType CACTUS = getDamageType("cactus"); - public static final DamageType FALL = getDamageType("fall"); - public static final DamageType ENDER_PEARL = getDamageType("ender_pearl"); - public static final DamageType FLY_INTO_WALL = getDamageType("fly_into_wall"); - public static final DamageType OUT_OF_WORLD = getDamageType("out_of_world"); - public static final DamageType GENERIC = getDamageType("generic"); - public static final DamageType MAGIC = getDamageType("magic"); - public static final DamageType WITHER = getDamageType("wither"); - public static final DamageType DRAGON_BREATH = getDamageType("dragon_breath"); - public static final DamageType DRY_OUT = getDamageType("dry_out"); - public static final DamageType SWEET_BERRY_BUSH = getDamageType("sweet_berry_bush"); - public static final DamageType FREEZE = getDamageType("freeze"); - public static final DamageType STALAGMITE = getDamageType("stalagmite"); - public static final DamageType FALLING_BLOCK = getDamageType("falling_block"); - public static final DamageType FALLING_ANVIL = getDamageType("falling_anvil"); - public static final DamageType FALLING_STALACTITE = getDamageType("falling_stalactite"); - public static final DamageType STING = getDamageType("sting"); - public static final DamageType MOB_ATTACK = getDamageType("mob_attack"); - public static final DamageType MOB_ATTACK_NO_AGGRO = getDamageType("mob_attack_no_aggro"); - public static final DamageType PLAYER_ATTACK = getDamageType("player_attack"); - public static final DamageType ARROW = getDamageType("arrow"); - public static final DamageType TRIDENT = getDamageType("trident"); - public static final DamageType MOB_PROJECTILE = getDamageType("mob_projectile"); - public static final DamageType SPIT = getDamageType("spit"); - public static final DamageType FIREWORKS = getDamageType("fireworks"); - public static final DamageType FIREBALL = getDamageType("fireball"); - public static final DamageType UNATTRIBUTED_FIREBALL = getDamageType("unattributed_fireball"); - public static final DamageType WITHER_SKULL = getDamageType("wither_skull"); - public static final DamageType THROWN = getDamageType("thrown"); - public static final DamageType INDIRECT_MAGIC = getDamageType("indirect_magic"); - public static final DamageType THORNS = getDamageType("thorns"); - public static final DamageType EXPLOSION = getDamageType("explosion"); - public static final DamageType PLAYER_EXPLOSION = getDamageType("player_explosion"); - public static final DamageType SONIC_BOOM = getDamageType("sonic_boom"); - public static final DamageType BAD_RESPAWN_POINT = getDamageType("bad_respawn_point"); - public static final DamageType OUTSIDE_BORDER = getDamageType("outside_border"); - public static final DamageType GENERIC_KILL = getDamageType("generic_kill"); - public static final DamageType WIND_CHARGE = getDamageType("wind_charge"); - public static final DamageType MACE_SMASH = getDamageType("mace_smash"); + // Start generate - DamageType + // @GeneratedFrom 1.21.5 + DamageType ARROW = getDamageType("arrow"); + + DamageType BAD_RESPAWN_POINT = getDamageType("bad_respawn_point"); + + DamageType CACTUS = getDamageType("cactus"); + + DamageType CAMPFIRE = getDamageType("campfire"); + + DamageType CRAMMING = getDamageType("cramming"); + + DamageType DRAGON_BREATH = getDamageType("dragon_breath"); + + DamageType DROWN = getDamageType("drown"); + + DamageType DRY_OUT = getDamageType("dry_out"); + + DamageType ENDER_PEARL = getDamageType("ender_pearl"); + + DamageType EXPLOSION = getDamageType("explosion"); + + DamageType FALL = getDamageType("fall"); + + DamageType FALLING_ANVIL = getDamageType("falling_anvil"); + + DamageType FALLING_BLOCK = getDamageType("falling_block"); + + DamageType FALLING_STALACTITE = getDamageType("falling_stalactite"); + + DamageType FIREBALL = getDamageType("fireball"); + + DamageType FIREWORKS = getDamageType("fireworks"); + + DamageType FLY_INTO_WALL = getDamageType("fly_into_wall"); + + DamageType FREEZE = getDamageType("freeze"); + + DamageType GENERIC = getDamageType("generic"); + + DamageType GENERIC_KILL = getDamageType("generic_kill"); + + DamageType HOT_FLOOR = getDamageType("hot_floor"); + + DamageType IN_FIRE = getDamageType("in_fire"); + + DamageType IN_WALL = getDamageType("in_wall"); + + DamageType INDIRECT_MAGIC = getDamageType("indirect_magic"); + + DamageType LAVA = getDamageType("lava"); + + DamageType LIGHTNING_BOLT = getDamageType("lightning_bolt"); + + DamageType MACE_SMASH = getDamageType("mace_smash"); + + DamageType MAGIC = getDamageType("magic"); + + DamageType MOB_ATTACK = getDamageType("mob_attack"); + + DamageType MOB_ATTACK_NO_AGGRO = getDamageType("mob_attack_no_aggro"); + + DamageType MOB_PROJECTILE = getDamageType("mob_projectile"); + + DamageType ON_FIRE = getDamageType("on_fire"); + + DamageType OUT_OF_WORLD = getDamageType("out_of_world"); + + DamageType OUTSIDE_BORDER = getDamageType("outside_border"); + + DamageType PLAYER_ATTACK = getDamageType("player_attack"); + + DamageType PLAYER_EXPLOSION = getDamageType("player_explosion"); + + DamageType SONIC_BOOM = getDamageType("sonic_boom"); + + DamageType SPIT = getDamageType("spit"); + + DamageType STALAGMITE = getDamageType("stalagmite"); + + DamageType STARVE = getDamageType("starve"); + + DamageType STING = getDamageType("sting"); + + DamageType SWEET_BERRY_BUSH = getDamageType("sweet_berry_bush"); + + DamageType THORNS = getDamageType("thorns"); + + DamageType THROWN = getDamageType("thrown"); + + DamageType TRIDENT = getDamageType("trident"); + + DamageType UNATTRIBUTED_FIREBALL = getDamageType("unattributed_fireball"); + + DamageType WIND_CHARGE = getDamageType("wind_charge"); + + DamageType WITHER = getDamageType("wither"); + + DamageType WITHER_SKULL = getDamageType("wither_skull"); + // End generate - DamageType @NotNull private static DamageType getDamageType(@NotNull String key) { diff --git a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java index fc71bc086..4b66de561 100644 --- a/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java +++ b/paper-api/src/main/java/org/bukkit/enchantments/EnchantmentTarget.java @@ -6,7 +6,10 @@ import org.jetbrains.annotations.NotNull; /** * Represents the applicable target for a {@link Enchantment} + * + * @deprecated enchantment groupings are now managed by tags, not categories */ +@Deprecated(since = "1.20.5", forRemoval = true) public enum EnchantmentTarget { /** * Allows the Enchantment to be placed on all items diff --git a/paper-api/src/main/java/org/bukkit/entity/AbstractCow.java b/paper-api/src/main/java/org/bukkit/entity/AbstractCow.java new file mode 100644 index 000000000..5ca438f30 --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/entity/AbstractCow.java @@ -0,0 +1,14 @@ +package org.bukkit.entity; + +import org.jspecify.annotations.NullMarked; + +/** + * This interface defines or represents the abstract concept of cow-like + * entities on the server. The interface is hence not a direct representation + * of an entity but rather serves as a parent to interfaces/entity types like + * {@link Cow} or {@link MushroomCow}. + */ +@NullMarked +public interface AbstractCow extends Animals { + +} diff --git a/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java b/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java index e36b62012..de77a3d66 100644 --- a/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java +++ b/paper-api/src/main/java/org/bukkit/entity/AreaEffectCloud.java @@ -223,7 +223,7 @@ public interface AreaEffectCloud extends Entity { * @param type the potion effect type to check for * @return true if the potion has this effect */ - boolean hasCustomEffect(@Nullable PotionEffectType type); + boolean hasCustomEffect(@NotNull PotionEffectType type); /** * Removes all custom potion effects from this cloud. diff --git a/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java b/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java index 6303eb083..58726d628 100644 --- a/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java +++ b/paper-api/src/main/java/org/bukkit/entity/ArmorStand.java @@ -14,7 +14,7 @@ public interface ArmorStand extends LivingEntity { * * @return the held item * @see #getEquipment() - * @deprecated prefer {@link ArmorStand#getItem(EquipmentSlot)} // Paper + * @deprecated prefer {@link ArmorStand#getItem(EquipmentSlot)} */ @NotNull @Deprecated(since = "1.15.2") @@ -26,7 +26,7 @@ public interface ArmorStand extends LivingEntity { * @param item the item to hold * @see #getEquipment() * @deprecated prefer - * {@link ArmorStand#setItem(EquipmentSlot, ItemStack)} // Paper + * {@link ArmorStand#setItem(EquipmentSlot, ItemStack)} */ @Deprecated(since = "1.15.2") void setItemInHand(@Nullable ItemStack item); diff --git a/paper-api/src/main/java/org/bukkit/entity/Boat.java b/paper-api/src/main/java/org/bukkit/entity/Boat.java index 1c977e2b1..92e6bf855 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Boat.java +++ b/paper-api/src/main/java/org/bukkit/entity/Boat.java @@ -175,12 +175,15 @@ public interface Boat extends Vehicle, io.papermc.paper.entity.Leashable { // Pa */ public enum Status { - NOT_IN_WORLD, // Paper + NOT_IN_WORLD, + // Start generate - BoatStatus + // @GeneratedFrom 1.21.5 IN_WATER, UNDER_WATER, UNDER_FLOWING_WATER, ON_LAND, IN_AIR; + // End generate - BoatStatus } // Paper start diff --git a/paper-api/src/main/java/org/bukkit/entity/Cat.java b/paper-api/src/main/java/org/bukkit/entity/Cat.java index fca4671c6..95b917ae6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Cat.java +++ b/paper-api/src/main/java/org/bukkit/entity/Cat.java @@ -3,6 +3,8 @@ package org.bukkit.entity; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import java.util.Locale; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; import org.bukkit.DyeColor; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; @@ -52,21 +54,34 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC */ interface Type extends OldEnum, Keyed { - Type TABBY = getType("tabby"); - Type BLACK = getType("black"); - Type RED = getType("red"); - Type SIAMESE = getType("siamese"); - Type BRITISH_SHORTHAIR = getType("british_shorthair"); - Type CALICO = getType("calico"); - Type PERSIAN = getType("persian"); - Type RAGDOLL = getType("ragdoll"); - Type WHITE = getType("white"); - Type JELLIE = getType("jellie"); + // Start generate - CatType + // @GeneratedFrom 1.21.5 Type ALL_BLACK = getType("all_black"); + Type BLACK = getType("black"); + + Type BRITISH_SHORTHAIR = getType("british_shorthair"); + + Type CALICO = getType("calico"); + + Type JELLIE = getType("jellie"); + + Type PERSIAN = getType("persian"); + + Type RAGDOLL = getType("ragdoll"); + + Type RED = getType("red"); + + Type SIAMESE = getType("siamese"); + + Type TABBY = getType("tabby"); + + Type WHITE = getType("white"); + // End generate - CatType + @NotNull private static Type getType(@NotNull String key) { - return Registry.CAT_VARIANT.getOrThrow(NamespacedKey.minecraft(key)); + return RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); } /** @@ -77,7 +92,7 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC @NotNull @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Type valueOf(@NotNull String name) { - Type type = Registry.CAT_VARIANT.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); + Type type = RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT).get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); Preconditions.checkArgument(type != null, "No cat type found with the name %s", name); return type; } @@ -89,11 +104,10 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC @NotNull @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Type[] values() { - return Lists.newArrayList(Registry.CAT_VARIANT).toArray(new Type[0]); + return Lists.newArrayList(RegistryAccess.registryAccess().getRegistry(RegistryKey.CAT_VARIANT)).toArray(new Type[0]); } } - // Paper start - More cat api /** * Sets if the cat is lying down. * This is visual and does not affect the behaviour of the cat. @@ -123,5 +137,4 @@ public interface Cat extends Tameable, Sittable, io.papermc.paper.entity.CollarC * @return head is up */ public boolean isHeadUp(); - // Paper end - More cat api } diff --git a/paper-api/src/main/java/org/bukkit/entity/Chicken.java b/paper-api/src/main/java/org/bukkit/entity/Chicken.java index b4c1a2626..2866e19ab 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Chicken.java +++ b/paper-api/src/main/java/org/bukkit/entity/Chicken.java @@ -1,11 +1,31 @@ package org.bukkit.entity; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + /** * Represents a Chicken. */ -// Paper start +@NullMarked public interface Chicken extends Animals { + /** + * Gets the variant of this chicken. + * + * @return the chicken variant + */ + Variant getVariant(); + + /** + * Sets the variant of this chicken. + * + * @param variant the chicken variant + */ + void setVariant(Variant variant); + /** * Gets if this chicken was spawned as a chicken jockey. * @@ -33,5 +53,23 @@ public interface Chicken extends Animals { * @param eggLayTime ticks till the chicken lays an egg */ void setEggLayTime(int eggLayTime); + + /** + * Represents the variant of a chicken. + */ + interface Variant extends Keyed { + + // Start generate - ChickenVariant + // @GeneratedFrom 1.21.5 + Variant COLD = getVariant("cold"); + + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - ChickenVariant + + private static Variant getVariant(String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.CHICKEN_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } } -// Paper end diff --git a/paper-api/src/main/java/org/bukkit/entity/Cow.java b/paper-api/src/main/java/org/bukkit/entity/Cow.java index cd4ed4de0..286c58104 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Cow.java +++ b/paper-api/src/main/java/org/bukkit/entity/Cow.java @@ -1,6 +1,47 @@ package org.bukkit.entity; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + /** * Represents a Cow. */ -public interface Cow extends Animals {} +@NullMarked +public interface Cow extends AbstractCow { + + /** + * Gets the variant of this cow. + * + * @return the cow variant + */ + Variant getVariant(); + + /** + * Sets the variant of this cow. + * + * @param variant the cow variant + */ + void setVariant(Variant variant); + + /** + * Represents the variant of a cow. + */ + interface Variant extends Keyed { + + // Start generate - CowVariant + // @GeneratedFrom 1.21.5 + Variant COLD = getVariant("cold"); + + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - CowVariant + + private static Variant getVariant(String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.COW_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Damageable.java b/paper-api/src/main/java/org/bukkit/entity/Damageable.java index 4b94f1ed6..7291b6dcc 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Damageable.java +++ b/paper-api/src/main/java/org/bukkit/entity/Damageable.java @@ -53,7 +53,6 @@ public interface Damageable extends Entity { */ void setHealth(double health); - // Paper start - entity heal API /** * Heal this entity by the given amount. This will call {@link org.bukkit.event.entity.EntityRegainHealthEvent}. * @@ -70,7 +69,6 @@ public interface Damageable extends Entity { * @param reason heal reason */ void heal(double amount, @NotNull org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason reason); - // Paper end - entity heal API /** * Gets the entity's absorption amount. diff --git a/paper-api/src/main/java/org/bukkit/entity/Dolphin.java b/paper-api/src/main/java/org/bukkit/entity/Dolphin.java index d3d3f8b20..b77301c2f 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Dolphin.java +++ b/paper-api/src/main/java/org/bukkit/entity/Dolphin.java @@ -1,8 +1,9 @@ package org.bukkit.entity; import org.bukkit.Location; +import org.jetbrains.annotations.Nullable; -public interface Dolphin extends Ageable, WaterMob { // Paper start - Dolphin API +public interface Dolphin extends Ageable, WaterMob { /** * Gets the moistness level of this dolphin @@ -37,7 +38,7 @@ public interface Dolphin extends Ageable, WaterMob { // Paper start - Dolphin AP * * @return calculated closest treasure location */ - @org.jetbrains.annotations.NotNull + @Nullable Location getTreasureLocation(); /** @@ -48,5 +49,5 @@ public interface Dolphin extends Ageable, WaterMob { // Paper start - Dolphin AP * * @param location location to guide to */ - void setTreasureLocation(@org.jetbrains.annotations.NotNull Location location); -} // Paper end - Dolphin API + void setTreasureLocation(@Nullable Location location); +} diff --git a/paper-api/src/main/java/org/bukkit/entity/Entity.java b/paper-api/src/main/java/org/bukkit/entity/Entity.java index 1dac39dec..5a3a538c5 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Entity.java +++ b/paper-api/src/main/java/org/bukkit/entity/Entity.java @@ -3,10 +3,12 @@ package org.bukkit.entity; import java.util.List; import java.util.Set; import java.util.UUID; +import io.papermc.paper.datacomponent.DataComponentView; import io.papermc.paper.entity.LookAnchor; import org.bukkit.Chunk; // Paper import org.bukkit.EntityEffect; import org.bukkit.Location; +import org.bukkit.Material; import org.bukkit.Nameable; import org.bukkit.Server; import org.bukkit.Sound; @@ -33,7 +35,7 @@ import org.jetbrains.annotations.Nullable; * Not all methods are guaranteed to work/may have side effects when * {@link #isInWorld()} is false. */ -public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.sound.Sound.Emitter { // Paper +public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.sound.Sound.Emitter, DataComponentView { // Paper /** * Gets the entity's current position @@ -337,7 +339,6 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ boolean isFrozen(); - // Paper start - missing entity api /** * Sets whether the entity is invisible or not. *

@@ -347,14 +348,14 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * * @param invisible If the entity is invisible */ - void setInvisible(boolean invisible); // Paper - moved up from LivingEntity + void setInvisible(boolean invisible); /** * Gets whether the entity is invisible or not. * * @return Whether the entity is invisible */ - boolean isInvisible(); // Paper - moved up from LivingEntity + boolean isInvisible(); /** * Sets this entities no physics status. @@ -369,9 +370,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * @return true if the entity does not have physics. */ boolean hasNoPhysics(); - // Paper end - missing entity api - // Paper start - Freeze Tick Lock API /** * Gets if the entity currently has its freeze ticks locked * to a set amount. @@ -389,12 +388,11 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * @param locked prevent vanilla modification or not */ void lockFreezeTicks(boolean locked); - // Paper end - Freeze Tick Lock API /** * Mark the entity's removal. * - * @throws UnsupportedOperationException if you try to remove a {@link Player} use {@link Player#kickPlayer(String)} in this case instead + * @throws UnsupportedOperationException if you try to remove a {@link Player} use {@link Player#kick(net.kyori.adventure.text.Component)} in this case instead */ public void remove(); @@ -533,6 +531,7 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent * @param event a {@link EntityDamageEvent} * @deprecated method is for internal use only and will be removed */ + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public void setLastDamageCause(@Nullable EntityDamageEvent event); @@ -1029,23 +1028,43 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent /** * Check if entity is in bubble column + * + * @deprecated check the block at the position of the entity */ - boolean isInBubbleColumn(); + @Deprecated(since = "1.21.5") + default boolean isInBubbleColumn() { + return this.getWorld().getBlockAt(this.getLocation()).getType() == Material.BUBBLE_COLUMN; + } /** * Check if entity is in water or rain + * + * @deprecated use {@link #isInWater()}} and {@link #isInRain()} */ - boolean isInWaterOrRain(); + @Deprecated(since = "1.21.5") + default boolean isInWaterOrRain() { + return this.isInWater() || this.isInRain(); + } /** * Check if entity is in water or bubble column + * + * @deprecated use {@link #isInWater()}, bubble column is considered as water */ - boolean isInWaterOrBubbleColumn(); + @Deprecated(since = "1.21.5") + default boolean isInWaterOrBubbleColumn() { + return this.isInWater(); + } /** * Check if entity is in water or rain or bubble column + * + * @deprecated use {@link #isInWaterOrRain()}, bubble column is considered as water */ - boolean isInWaterOrRainOrBubbleColumn(); + @Deprecated(since = "1.21.5") + default boolean isInWaterOrRainOrBubbleColumn() { + return this.isInWaterOrRain(); + } /** * Check if entity is in lava diff --git a/paper-api/src/main/java/org/bukkit/entity/EntityType.java b/paper-api/src/main/java/org/bukkit/entity/EntityType.java index 73e47089d..4725b93f1 100644 --- a/paper-api/src/main/java/org/bukkit/entity/EntityType.java +++ b/paper-api/src/main/java/org/bukkit/entity/EntityType.java @@ -45,299 +45,159 @@ import org.jetbrains.annotations.Nullable; public enum EntityType implements Keyed, Translatable, net.kyori.adventure.translation.Translatable, io.papermc.paper.world.flag.FeatureDependant { // Paper - translatable - // These strings MUST match the strings in nms.EntityTypes and are case sensitive. - /** - * An item resting on the ground. - *

- * Spawn with {@link World#dropItem(Location, ItemStack)} or {@link - * World#dropItemNaturally(Location, ItemStack)} - */ - ITEM("item", Item.class, 1), - /** - * An experience orb. - */ - EXPERIENCE_ORB("experience_orb", ExperienceOrb.class, 2), - /** - * @see AreaEffectCloud - */ + // Start generate - EntityType + // @GeneratedFrom 1.21.5 + ACACIA_BOAT("acacia_boat", AcaciaBoat.class, -1), + ACACIA_CHEST_BOAT("acacia_chest_boat", AcaciaChestBoat.class, -1), + ALLAY("allay", Allay.class, -1), AREA_EFFECT_CLOUD("area_effect_cloud", AreaEffectCloud.class, 3), - /** - * @see ElderGuardian - */ - ELDER_GUARDIAN("elder_guardian", ElderGuardian.class, 4), - /** - * @see WitherSkeleton - */ - WITHER_SKELETON("wither_skeleton", WitherSkeleton.class, 5), - /** - * @see Stray - */ - STRAY("stray", Stray.class, 6), - /** - * A flying chicken egg. - */ - EGG("egg", Egg.class, 7), - /** - * A leash attached to a fencepost. - */ - LEASH_KNOT("leash_knot", LeashHitch.class, 8), - /** - * A painting on a wall. - */ - PAINTING("painting", Painting.class, 9), - /** - * An arrow projectile; may get stuck in the ground. - */ - ARROW("arrow", Arrow.class, 10), - /** - * A flying snowball. - */ - SNOWBALL("snowball", Snowball.class, 11), - /** - * A flying large fireball, as thrown by a Ghast for example. - */ - FIREBALL("fireball", LargeFireball.class, 12), - /** - * A flying small fireball, such as thrown by a Blaze or player. - */ - SMALL_FIREBALL("small_fireball", SmallFireball.class, 13), - /** - * A flying ender pearl. - */ - ENDER_PEARL("ender_pearl", EnderPearl.class, 14), - /** - * An ender eye signal. - */ - EYE_OF_ENDER("eye_of_ender", EnderSignal.class, 15), - /** - * A flying splash potion. - */ - POTION("potion", ThrownPotion.class, 16), - /** - * A flying experience bottle. - */ - EXPERIENCE_BOTTLE("experience_bottle", ThrownExpBottle.class, 17), - /** - * An item frame on a wall. - */ - ITEM_FRAME("item_frame", ItemFrame.class, 18), - /** - * A flying wither skull projectile. - */ - WITHER_SKULL("wither_skull", WitherSkull.class, 19), - /** - * Primed TNT that is about to explode. - */ - TNT("tnt", TNTPrimed.class, 20), - /** - * A block that is going to or is about to fall. - */ - FALLING_BLOCK("falling_block", FallingBlock.class, 21), - /** - * Internal representation of a Firework once it has been launched. - */ - FIREWORK_ROCKET("firework_rocket", Firework.class, 22), - /** - * @see Husk - */ - HUSK("husk", Husk.class, 23), - /** - * Like {@link #ARROW} but causes the {@link PotionEffectType#GLOWING} effect on all team members. - */ - SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24), - /** - * Bullet fired by {@link #SHULKER}. - */ - SHULKER_BULLET("shulker_bullet", ShulkerBullet.class, 25), - /** - * Like {@link #FIREBALL} but with added effects. - */ - DRAGON_FIREBALL("dragon_fireball", DragonFireball.class, 26), - /** - * @see ZombieVillager - */ - ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27), - /** - * @see SkeletonHorse - */ - SKELETON_HORSE("skeleton_horse", SkeletonHorse.class, 28), - /** - * @see ZombieHorse - */ - ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29), - /** - * Mechanical entity with an inventory for placing weapons / armor into. - */ + ARMADILLO("armadillo", Armadillo.class, -1), ARMOR_STAND("armor_stand", ArmorStand.class, 30), - /** - * @see Donkey - */ - DONKEY("donkey", Donkey.class, 31), - /** - * @see Mule - */ - MULE("mule", Mule.class, 32), - /** - * @see EvokerFangs - */ - EVOKER_FANGS("evoker_fangs", EvokerFangs.class, 33), - /** - * @see Evoker - */ - EVOKER("evoker", Evoker.class, 34), - /** - * @see Vex - */ - VEX("vex", Vex.class, 35), - /** - * @see Vindicator - */ - VINDICATOR("vindicator", Vindicator.class, 36), - /** - * @see Illusioner - */ - ILLUSIONER("illusioner", Illusioner.class, 37), - /** - * @see CommandMinecart - */ - COMMAND_BLOCK_MINECART("command_block_minecart", CommandMinecart.class, 40), - /** - * @see RideableMinecart - */ - MINECART("minecart", RideableMinecart.class, 42), - /** - * @see StorageMinecart - */ - CHEST_MINECART("chest_minecart", StorageMinecart.class, 43), - /** - * @see PoweredMinecart - */ - FURNACE_MINECART("furnace_minecart", PoweredMinecart.class, 44), - /** - * @see ExplosiveMinecart - */ - TNT_MINECART("tnt_minecart", ExplosiveMinecart.class, 45), - /** - * @see HopperMinecart - */ - HOPPER_MINECART("hopper_minecart", HopperMinecart.class, 46), - /** - * @see SpawnerMinecart - */ - SPAWNER_MINECART("spawner_minecart", SpawnerMinecart.class, 47), - CREEPER("creeper", Creeper.class, 50), - SKELETON("skeleton", Skeleton.class, 51), - SPIDER("spider", Spider.class, 52), - GIANT("giant", Giant.class, 53), - ZOMBIE("zombie", Zombie.class, 54), - SLIME("slime", Slime.class, 55), - GHAST("ghast", Ghast.class, 56), - ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57), - ENDERMAN("enderman", Enderman.class, 58), - CAVE_SPIDER("cave_spider", CaveSpider.class, 59), - SILVERFISH("silverfish", Silverfish.class, 60), - BLAZE("blaze", Blaze.class, 61), - MAGMA_CUBE("magma_cube", MagmaCube.class, 62), - ENDER_DRAGON("ender_dragon", EnderDragon.class, 63), - WITHER("wither", Wither.class, 64), - BAT("bat", Bat.class, 65), - WITCH("witch", Witch.class, 66), - ENDERMITE("endermite", Endermite.class, 67), - GUARDIAN("guardian", Guardian.class, 68), - SHULKER("shulker", Shulker.class, 69), - PIG("pig", Pig.class, 90), - SHEEP("sheep", Sheep.class, 91), - COW("cow", Cow.class, 92), - CHICKEN("chicken", Chicken.class, 93), - SQUID("squid", Squid.class, 94), - WOLF("wolf", Wolf.class, 95), - MOOSHROOM("mooshroom", MushroomCow.class, 96), - SNOW_GOLEM("snow_golem", Snowman.class, 97), - OCELOT("ocelot", Ocelot.class, 98), - IRON_GOLEM("iron_golem", IronGolem.class, 99), - HORSE("horse", Horse.class, 100), - RABBIT("rabbit", Rabbit.class, 101), - POLAR_BEAR("polar_bear", PolarBear.class, 102), - LLAMA("llama", Llama.class, 103), - LLAMA_SPIT("llama_spit", LlamaSpit.class, 104), - PARROT("parrot", Parrot.class, 105), - VILLAGER("villager", Villager.class, 120), - END_CRYSTAL("end_crystal", EnderCrystal.class, 200), - TURTLE("turtle", Turtle.class, -1), - PHANTOM("phantom", Phantom.class, -1), - TRIDENT("trident", Trident.class, -1), - COD("cod", Cod.class, -1), - SALMON("salmon", Salmon.class, -1), - PUFFERFISH("pufferfish", PufferFish.class, -1), - TROPICAL_FISH("tropical_fish", TropicalFish.class, -1), - DROWNED("drowned", Drowned.class, -1), - DOLPHIN("dolphin", Dolphin.class, -1), - CAT("cat", Cat.class, -1), - PANDA("panda", Panda.class, -1), - PILLAGER("pillager", Pillager.class, -1), - RAVAGER("ravager", Ravager.class, -1), - TRADER_LLAMA("trader_llama", TraderLlama.class, -1), - WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1), - FOX("fox", Fox.class, -1), - BEE("bee", Bee.class, -1), - HOGLIN("hoglin", Hoglin.class, -1), - PIGLIN("piglin", Piglin.class, -1), - STRIDER("strider", Strider.class, -1), - ZOGLIN("zoglin", Zoglin.class, -1), - PIGLIN_BRUTE("piglin_brute", PiglinBrute.class, -1), + ARROW("arrow", Arrow.class, 10), AXOLOTL("axolotl", Axolotl.class, -1), + BAMBOO_CHEST_RAFT("bamboo_chest_raft", BambooChestRaft.class, -1), + BAMBOO_RAFT("bamboo_raft", BambooRaft.class, -1), + BAT("bat", Bat.class, 65), + BEE("bee", Bee.class, -1), + BIRCH_BOAT("birch_boat", BirchBoat.class, -1), + BIRCH_CHEST_BOAT("birch_chest_boat", BirchChestBoat.class, -1), + BLAZE("blaze", Blaze.class, 61), + BLOCK_DISPLAY("block_display", BlockDisplay.class, -1), + BOGGED("bogged", Bogged.class, -1), + BREEZE("breeze", Breeze.class, -1), + BREEZE_WIND_CHARGE("breeze_wind_charge", BreezeWindCharge.class, -1), + CAMEL("camel", Camel.class, -1), + CAT("cat", Cat.class, -1), + CAVE_SPIDER("cave_spider", CaveSpider.class, 59), + CHERRY_BOAT("cherry_boat", CherryBoat.class, -1), + CHERRY_CHEST_BOAT("cherry_chest_boat", CherryChestBoat.class, -1), + CHEST_MINECART("chest_minecart", StorageMinecart.class, 43), + CHICKEN("chicken", Chicken.class, 93), + COD("cod", Cod.class, -1), + COMMAND_BLOCK_MINECART("command_block_minecart", CommandMinecart.class, 40), + COW("cow", Cow.class, 92), + CREAKING("creaking", Creaking.class, -1), + CREEPER("creeper", Creeper.class, 50), + DARK_OAK_BOAT("dark_oak_boat", DarkOakBoat.class, -1), + DARK_OAK_CHEST_BOAT("dark_oak_chest_boat", DarkOakChestBoat.class, -1), + DOLPHIN("dolphin", Dolphin.class, -1), + DONKEY("donkey", Donkey.class, 31), + DRAGON_FIREBALL("dragon_fireball", DragonFireball.class, 26), + DROWNED("drowned", Drowned.class, -1), + EGG("egg", Egg.class, 7), + ELDER_GUARDIAN("elder_guardian", ElderGuardian.class, 4), + END_CRYSTAL("end_crystal", EnderCrystal.class, 200), + ENDER_DRAGON("ender_dragon", EnderDragon.class, 63), + ENDER_PEARL("ender_pearl", EnderPearl.class, 14), + ENDERMAN("enderman", Enderman.class, 58), + ENDERMITE("endermite", Endermite.class, 67), + EVOKER("evoker", Evoker.class, 34), + EVOKER_FANGS("evoker_fangs", EvokerFangs.class, 33), + EXPERIENCE_BOTTLE("experience_bottle", ThrownExpBottle.class, 17), + EXPERIENCE_ORB("experience_orb", ExperienceOrb.class, 2), + EYE_OF_ENDER("eye_of_ender", EnderSignal.class, 15), + FALLING_BLOCK("falling_block", FallingBlock.class, 21), + FIREBALL("fireball", Fireball.class, 12), + FIREWORK_ROCKET("firework_rocket", Firework.class, 22), + FISHING_BOBBER("fishing_bobber", FishHook.class, -1, false), + FOX("fox", Fox.class, -1), + FROG("frog", Frog.class, -1), + FURNACE_MINECART("furnace_minecart", PoweredMinecart.class, 44), + GHAST("ghast", Ghast.class, 56), + GIANT("giant", Giant.class, 53), GLOW_ITEM_FRAME("glow_item_frame", GlowItemFrame.class, -1), GLOW_SQUID("glow_squid", GlowSquid.class, -1), GOAT("goat", Goat.class, -1), - MARKER("marker", Marker.class, -1), - ALLAY("allay", Allay.class, -1), - FROG("frog", Frog.class, -1), - TADPOLE("tadpole", Tadpole.class, -1), - WARDEN("warden", Warden.class, -1), - CAMEL("camel", Camel.class, -1), - BLOCK_DISPLAY("block_display", BlockDisplay.class, -1), + GUARDIAN("guardian", Guardian.class, 68), + HOGLIN("hoglin", Hoglin.class, -1), + HOPPER_MINECART("hopper_minecart", HopperMinecart.class, 46), + HORSE("horse", Horse.class, 100), + HUSK("husk", Husk.class, 23), + ILLUSIONER("illusioner", Illusioner.class, 37), INTERACTION("interaction", Interaction.class, -1), + IRON_GOLEM("iron_golem", IronGolem.class, 99), + ITEM("item", Item.class, 1), ITEM_DISPLAY("item_display", ItemDisplay.class, -1), - SNIFFER("sniffer", Sniffer.class, -1), - TEXT_DISPLAY("text_display", TextDisplay.class, -1), - BREEZE("breeze", Breeze.class, -1), - WIND_CHARGE("wind_charge", WindCharge.class, -1), - BREEZE_WIND_CHARGE("breeze_wind_charge", BreezeWindCharge.class, -1), - ARMADILLO("armadillo", Armadillo.class, -1), - BOGGED("bogged", Bogged.class, -1), - OMINOUS_ITEM_SPAWNER("ominous_item_spawner", OminousItemSpawner.class, -1), - ACACIA_BOAT("acacia_boat", AcaciaBoat.class, -1), - ACACIA_CHEST_BOAT("acacia_chest_boat", AcaciaChestBoat.class, -1), - BAMBOO_RAFT("bamboo_raft", BambooRaft.class, -1), - BAMBOO_CHEST_RAFT("bamboo_chest_raft", BambooChestRaft.class, -1), - BIRCH_BOAT("birch_boat", BirchBoat.class, -1), - BIRCH_CHEST_BOAT("birch_chest_boat", BirchChestBoat.class, -1), - CHERRY_BOAT("cherry_boat", CherryBoat.class, -1), - CHERRY_CHEST_BOAT("cherry_chest_boat", CherryChestBoat.class, -1), - DARK_OAK_BOAT("dark_oak_boat", DarkOakBoat.class, -1), - DARK_OAK_CHEST_BOAT("dark_oak_chest_boat", DarkOakChestBoat.class, -1), + ITEM_FRAME("item_frame", ItemFrame.class, 18), JUNGLE_BOAT("jungle_boat", JungleBoat.class, -1), JUNGLE_CHEST_BOAT("jungle_chest_boat", JungleChestBoat.class, -1), + LEASH_KNOT("leash_knot", LeashHitch.class, 8), + LIGHTNING_BOLT("lightning_bolt", LightningStrike.class, -1), + LINGERING_POTION("lingering_potion", LingeringPotion.class, -1), + LLAMA("llama", Llama.class, 103), + LLAMA_SPIT("llama_spit", LlamaSpit.class, 104), + MAGMA_CUBE("magma_cube", MagmaCube.class, 62), MANGROVE_BOAT("mangrove_boat", MangroveBoat.class, -1), MANGROVE_CHEST_BOAT("mangrove_chest_boat", MangroveChestBoat.class, -1), + MARKER("marker", Marker.class, -1), + MINECART("minecart", Minecart.class, 42), + MOOSHROOM("mooshroom", MushroomCow.class, 96), + MULE("mule", Mule.class, 32), OAK_BOAT("oak_boat", OakBoat.class, -1), OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1), + OCELOT("ocelot", Ocelot.class, 98), + OMINOUS_ITEM_SPAWNER("ominous_item_spawner", OminousItemSpawner.class, -1), + PAINTING("painting", Painting.class, 9), PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1), PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1), + PANDA("panda", Panda.class, -1), + PARROT("parrot", Parrot.class, 105), + PHANTOM("phantom", Phantom.class, -1), + PIG("pig", Pig.class, 90), + PIGLIN("piglin", Piglin.class, -1), + PIGLIN_BRUTE("piglin_brute", PiglinBrute.class, -1), + PILLAGER("pillager", Pillager.class, -1), + PLAYER("player", Player.class, -1, false), + POLAR_BEAR("polar_bear", PolarBear.class, 102), + PUFFERFISH("pufferfish", PufferFish.class, -1), + RABBIT("rabbit", Rabbit.class, 101), + RAVAGER("ravager", Ravager.class, -1), + SALMON("salmon", Salmon.class, -1), + SHEEP("sheep", Sheep.class, 91), + SHULKER("shulker", Shulker.class, 69), + SHULKER_BULLET("shulker_bullet", ShulkerBullet.class, 25), + SILVERFISH("silverfish", Silverfish.class, 60), + SKELETON("skeleton", Skeleton.class, 51), + SKELETON_HORSE("skeleton_horse", SkeletonHorse.class, 28), + SLIME("slime", Slime.class, 55), + SMALL_FIREBALL("small_fireball", SmallFireball.class, 13), + SNIFFER("sniffer", Sniffer.class, -1), + SNOW_GOLEM("snow_golem", Snowman.class, 97), + SNOWBALL("snowball", Snowball.class, 11), + SPAWNER_MINECART("spawner_minecart", SpawnerMinecart.class, 47), + SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24), + SPIDER("spider", Spider.class, 52), + SPLASH_POTION("splash_potion", SplashPotion.class, 16), SPRUCE_BOAT("spruce_boat", SpruceBoat.class, -1), SPRUCE_CHEST_BOAT("spruce_chest_boat", SpruceChestBoat.class, -1), - CREAKING("creaking", Creaking.class, -1), - /** - * A fishing line and bobber. - */ - FISHING_BOBBER("fishing_bobber", FishHook.class, -1, false), - /** - * A bolt of lightning. - *

- * Spawn with {@link World#strikeLightning(Location)}. - */ - LIGHTNING_BOLT("lightning_bolt", LightningStrike.class, -1), - PLAYER("player", Player.class, -1, false), + SQUID("squid", Squid.class, 94), + STRAY("stray", Stray.class, 6), + STRIDER("strider", Strider.class, -1), + TADPOLE("tadpole", Tadpole.class, -1), + TEXT_DISPLAY("text_display", TextDisplay.class, -1), + TNT("tnt", TNTPrimed.class, 20), + TNT_MINECART("tnt_minecart", ExplosiveMinecart.class, 45), + TRADER_LLAMA("trader_llama", TraderLlama.class, -1), + TRIDENT("trident", Trident.class, -1), + TROPICAL_FISH("tropical_fish", TropicalFish.class, -1), + TURTLE("turtle", Turtle.class, -1), + VEX("vex", Vex.class, 35), + VILLAGER("villager", Villager.class, 120), + VINDICATOR("vindicator", Vindicator.class, 36), + WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1), + WARDEN("warden", Warden.class, -1), + WIND_CHARGE("wind_charge", WindCharge.class, -1), + WITCH("witch", Witch.class, 66), + WITHER("wither", Wither.class, 64), + WITHER_SKELETON("wither_skeleton", WitherSkeleton.class, 5), + WITHER_SKULL("wither_skull", WitherSkull.class, 19), + WOLF("wolf", Wolf.class, 95), + ZOGLIN("zoglin", Zoglin.class, -1), + ZOMBIE("zombie", Zombie.class, 54), + ZOMBIE_HORSE("zombie_horse", ZombieHorse.class, 29), + ZOMBIE_VILLAGER("zombie_villager", ZombieVillager.class, 27), + ZOMBIFIED_PIGLIN("zombified_piglin", PigZombie.class, 57), + // End generate - EntityType /** * An unknown entity without an Entity Class */ diff --git a/paper-api/src/main/java/org/bukkit/entity/Evoker.java b/paper-api/src/main/java/org/bukkit/entity/Evoker.java index a0a46e6e1..0862625c8 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Evoker.java +++ b/paper-api/src/main/java/org/bukkit/entity/Evoker.java @@ -65,7 +65,6 @@ public interface Evoker extends Spellcaster { @Deprecated(since = "1.11.2") void setCurrentSpell(@Nullable Spell spell); - // Paper start /** * @return the sheep being targeted by the {@link Spell#WOLOLO wololo spell}, or {@code null} if none */ @@ -78,5 +77,4 @@ public interface Evoker extends Spellcaster { * @param sheep new wololo target */ void setWololoTarget(@Nullable Sheep sheep); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java b/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java index f4ec235b9..0f709b03b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java +++ b/paper-api/src/main/java/org/bukkit/entity/FallingBlock.java @@ -47,7 +47,7 @@ public interface FallingBlock extends Entity { org.bukkit.block.BlockState getBlockState(); /** - * Sets the {@link BlockData} and possibly present tile entity data for the falling block. + * Sets the {@link BlockData} and possibly present block entity data for the falling block. * * @param blockState the BlockState to use */ diff --git a/paper-api/src/main/java/org/bukkit/entity/Fox.java b/paper-api/src/main/java/org/bukkit/entity/Fox.java index 473a7e36a..694434588 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Fox.java +++ b/paper-api/src/main/java/org/bukkit/entity/Fox.java @@ -89,8 +89,11 @@ public interface Fox extends Animals, Sittable { * Represents the various different fox types there are. */ public enum Type { + // Start generate - FoxType + // @GeneratedFrom 1.21.5 RED, SNOW; + // End generate - FoxType } // Paper start - Add more fox behavior API diff --git a/paper-api/src/main/java/org/bukkit/entity/Frog.java b/paper-api/src/main/java/org/bukkit/entity/Frog.java index f661a6b47..7115201bd 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Frog.java +++ b/paper-api/src/main/java/org/bukkit/entity/Frog.java @@ -3,6 +3,8 @@ package org.bukkit.entity; import com.google.common.base.Preconditions; import com.google.common.collect.Lists; import java.util.Locale; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; @@ -50,22 +52,18 @@ public interface Frog extends Animals { */ interface Variant extends OldEnum, Keyed { - /** - * Temperate (brown-orange) frog. - */ - Variant TEMPERATE = getVariant("temperate"); - /** - * Warm (gray) frog. - */ - Variant WARM = getVariant("warm"); - /** - * Cold (green) frog. - */ + // Start generate - FrogVariant + // @GeneratedFrom 1.21.5 Variant COLD = getVariant("cold"); + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - FrogVariant + @NotNull private static Variant getVariant(@NotNull String key) { - return Registry.FROG_VARIANT.getOrThrow(NamespacedKey.minecraft(key)); + return RegistryAccess.registryAccess().getRegistry(RegistryKey.FROG_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); } /** @@ -76,7 +74,7 @@ public interface Frog extends Animals { @NotNull @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Variant valueOf(@NotNull String name) { - Variant variant = Registry.FROG_VARIANT.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); + Variant variant = RegistryAccess.registryAccess().getRegistry(RegistryKey.FROG_VARIANT).get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); Preconditions.checkArgument(variant != null, "No frog variant found with the name %s", name); return variant; } @@ -88,7 +86,7 @@ public interface Frog extends Animals { @NotNull @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Variant[] values() { - return Lists.newArrayList(Registry.FROG_VARIANT).toArray(new Variant[0]); + return Lists.newArrayList(RegistryAccess.registryAccess().getRegistry(RegistryKey.FROG_VARIANT)).toArray(new Variant[0]); } } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Ghast.java b/paper-api/src/main/java/org/bukkit/entity/Ghast.java index 9c618a27d..3e33ffc45 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Ghast.java +++ b/paper-api/src/main/java/org/bukkit/entity/Ghast.java @@ -19,7 +19,6 @@ public interface Ghast extends Flying, Enemy { */ void setCharging(boolean flag); - // Paper start /** * Returns the explosion power of shot fireballs. * @@ -34,5 +33,4 @@ public interface Ghast extends Flying, Enemy { * @throws IllegalArgumentException if the explosion power is less than 0 or greater than 127 */ void setExplosionPower(int explosionPower); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Goat.java b/paper-api/src/main/java/org/bukkit/entity/Goat.java index 18e48bbb0..38313098d 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Goat.java +++ b/paper-api/src/main/java/org/bukkit/entity/Goat.java @@ -53,11 +53,9 @@ public interface Goat extends Animals { */ void setScreaming(boolean screaming); - // Paper start - Goat ram API /** * Makes the goat ram at the specified entity * @param entity the entity to ram at */ void ram(@org.jetbrains.annotations.NotNull LivingEntity entity); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java index 9811e7983..8304cafc6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/HumanEntity.java @@ -299,16 +299,16 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder /** * Force-closes the currently open inventory view for this player, if any. */ - public void closeInventory(); + default void closeInventory() { + this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.PLUGIN); + } - // Paper start /** * Force-closes the currently open inventory view for this player, if any. * * @param reason why the inventory is closing */ - public void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason); - // Paper end + void closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason); /** * Returns the ItemStack currently in your hand, can be empty. @@ -382,7 +382,6 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder */ public void setCooldown(Material material, int ticks); - // Paper start /** * Sets player hurt direction * @@ -390,16 +389,13 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder */ @Override void setHurtDirection(float hurtDirection); - // Paper end - // Paper start /** * If the player has slept enough to count towards passing the night. * * @return true if the player has slept enough */ public boolean isDeeplySleeping(); - // Paper end /** * Check whether a cooldown is active on the specified item. @@ -440,7 +436,6 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder public int getSleepTicks(); - // Paper start - Potential bed api /** * Gets the Location of the player's bed, null if they have not slept * in one. This method will not attempt to validate if the current bed @@ -466,14 +461,12 @@ public interface HumanEntity extends LivingEntity, AnimalTamer, InventoryHolder */ @Nullable Location getPotentialRespawnLocation(); - // Paper end - // Paper start + /** * @return the player's fishing hook if they are fishing */ @Nullable FishHook getFishHook(); - // Paper end /** * Attempts to make the entity sleep at the given location. diff --git a/paper-api/src/main/java/org/bukkit/entity/LingeringPotion.java b/paper-api/src/main/java/org/bukkit/entity/LingeringPotion.java index ad8519ab9..c104ece12 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LingeringPotion.java +++ b/paper-api/src/main/java/org/bukkit/entity/LingeringPotion.java @@ -2,9 +2,6 @@ package org.bukkit.entity; /** * Represents a thrown lingering potion bottle - * - * @deprecated should not be used for anything, use {@link ThrownPotion} and - * set the potion via the methods there. */ -@Deprecated(since = "1.20.5", forRemoval = true) // Paper -public interface LingeringPotion extends ThrownPotion { } +public interface LingeringPotion extends ThrownPotion { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java index 5c1a36819..61794d69b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java +++ b/paper-api/src/main/java/org/bukkit/entity/LivingEntity.java @@ -663,14 +663,12 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @NotNull public Collection getActivePotionEffects(); - // Paper start - LivingEntity#clearActivePotionEffects(); /** * Removes all active potion effects for this entity. * * @return true if any were removed */ boolean clearActivePotionEffects(); - // Paper end /** * Checks whether the living entity has block line of sight to another. @@ -683,7 +681,6 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource */ public boolean hasLineOfSight(@NotNull Entity other); - // Paper start /** * Checks whether the living entity has block line of sight to the given block. *

@@ -694,7 +691,6 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return true if there is a line of sight, false if not */ public boolean hasLineOfSight(@NotNull Location location); - // Paper end /** * Returns if the living entity despawns when away from players or not. @@ -1060,23 +1056,6 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource @Deprecated(since = "1.20.5", forRemoval = true) @org.jetbrains.annotations.Contract("-> fail") // Paper public EntityCategory getCategory(); - /** - * Sets whether the entity is invisible or not. - * - * @param invisible If the entity is invisible - */ - @Override // Paper - move invisibility up to Entity - public void setInvisible(boolean invisible); - - /** - * Gets whether the entity is invisible or not. - * - * @return Whether the entity is invisible - */ - @Override // Paper - move invisibility up to Entity - public boolean isInvisible(); - - // Paper start /** * Get the number of arrows stuck in this entity * @return Number of arrows stuck @@ -1108,9 +1087,7 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @param delay Delay in ticks */ void setShieldBlockingDelay(int delay); - // Paper end - // Paper start - missing entity API /** * Retrieves the sideways movement direction of the entity. *

@@ -1167,7 +1144,6 @@ public interface LivingEntity extends Attributable, Damageable, ProjectileSource * @return Forwards movement direction, ranging from -1 (backward) to 1 (forward). */ float getForwardsMovement(); - // Paper end - missing entity API // Paper start - active item API /** diff --git a/paper-api/src/main/java/org/bukkit/entity/MushroomCow.java b/paper-api/src/main/java/org/bukkit/entity/MushroomCow.java index 3677f19ef..374bfe7b9 100644 --- a/paper-api/src/main/java/org/bukkit/entity/MushroomCow.java +++ b/paper-api/src/main/java/org/bukkit/entity/MushroomCow.java @@ -8,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Represents a mushroom {@link Cow} */ -public interface MushroomCow extends Cow, io.papermc.paper.entity.Shearable { // Paper +public interface MushroomCow extends AbstractCow, io.papermc.paper.entity.Shearable { // Paper /** * Checks for the presence of custom potion effects to be applied to the diff --git a/paper-api/src/main/java/org/bukkit/entity/Panda.java b/paper-api/src/main/java/org/bukkit/entity/Panda.java index cfe00e42f..be66608e6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Panda.java +++ b/paper-api/src/main/java/org/bukkit/entity/Panda.java @@ -185,6 +185,8 @@ public interface Panda extends Animals, Sittable { public enum Gene { + // Start generate - PandaGene + // @GeneratedFrom 1.21.5 NORMAL(false), LAZY(false), WORRIED(false), @@ -192,6 +194,7 @@ public interface Panda extends Animals, Sittable { BROWN(true), WEAK(true), AGGRESSIVE(false); + // End generate - PandaGene private final boolean recessive; diff --git a/paper-api/src/main/java/org/bukkit/entity/Phantom.java b/paper-api/src/main/java/org/bukkit/entity/Phantom.java index 2fe8e8868..ff8b73ca8 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Phantom.java +++ b/paper-api/src/main/java/org/bukkit/entity/Phantom.java @@ -1,7 +1,8 @@ package org.bukkit.entity; -import org.jetbrains.annotations.NotNull; +import org.bukkit.Location; import org.jetbrains.annotations.Nullable; +import java.util.UUID; /** * Represents a phantom. @@ -14,18 +15,17 @@ public interface Phantom extends Flying, Enemy { public int getSize(); /** - * @param sz The new size of the phantom. + * @param size The new size of the phantom. */ - public void setSize(int sz); + public void setSize(int size); - // Paper start /** * Get the UUID of the entity that caused this phantom to spawn * * @return UUID */ @Nullable - public java.util.UUID getSpawningEntity(); + public UUID getSpawningEntity(); /** * Check if this phantom will burn in the sunlight @@ -47,14 +47,13 @@ public interface Phantom extends Flying, Enemy { * * @return circling location */ - @org.jetbrains.annotations.NotNull - org.bukkit.Location getAnchorLocation(); + @Nullable + Location getAnchorLocation(); /** * Sets the location that this phantom circles around when not attacking a player * * @param location circling location (world is ignored, will always use the entity's world) */ - void setAnchorLocation(@org.jetbrains.annotations.NotNull org.bukkit.Location location); - // Paper end + void setAnchorLocation(@Nullable Location location); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Pig.java b/paper-api/src/main/java/org/bukkit/entity/Pig.java index cb0283715..9389bbc1e 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Pig.java +++ b/paper-api/src/main/java/org/bukkit/entity/Pig.java @@ -1,6 +1,47 @@ package org.bukkit.entity; +import io.papermc.paper.registry.RegistryAccess; +import io.papermc.paper.registry.RegistryKey; +import org.bukkit.Keyed; +import org.bukkit.NamespacedKey; +import org.jspecify.annotations.NullMarked; + /** * Represents a Pig. */ -public interface Pig extends Steerable, Vehicle { } +@NullMarked +public interface Pig extends Steerable, Vehicle { + + /** + * Gets the variant of this pig. + * + * @return the pig variant + */ + Variant getVariant(); + + /** + * Sets the variant of this pig. + * + * @param variant the pig variant + */ + void setVariant(Variant variant); + + /** + * Represents the variant of a pig. + */ + interface Variant extends Keyed { + + // Start generate - PigVariant + // @GeneratedFrom 1.21.5 + Variant COLD = getVariant("cold"); + + Variant TEMPERATE = getVariant("temperate"); + + Variant WARM = getVariant("warm"); + // End generate - PigVariant + + private static Variant getVariant(String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.PIG_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } +} diff --git a/paper-api/src/main/java/org/bukkit/entity/PigZombie.java b/paper-api/src/main/java/org/bukkit/entity/PigZombie.java index b2ec535bb..3e79f13ed 100644 --- a/paper-api/src/main/java/org/bukkit/entity/PigZombie.java +++ b/paper-api/src/main/java/org/bukkit/entity/PigZombie.java @@ -1,19 +1,21 @@ package org.bukkit.entity; +import org.jetbrains.annotations.Contract; + /** - * Represents a Pig Zombie. + * Represents a Zombified piglin. */ public interface PigZombie extends Zombie { /** - * Get the pig zombie's current anger level. + * Get the zombified piglin's current anger level. * * @return The anger level. */ int getAnger(); /** - * Set the pig zombie's current anger level. + * Set the zombified piglin's current anger level. * * @param level The anger level. Higher levels of anger take longer to * wear off. @@ -23,29 +25,31 @@ public interface PigZombie extends Zombie { /** * Shorthand; sets to either 0 or the default level. * - * @param angry Whether the zombie should be angry. + * @param angry Whether the piglin should be angry. */ void setAngry(boolean angry); /** - * Shorthand; gets whether the zombie is angry. + * Shorthand; gets whether the piglin is angry. * - * @return True if the zombie is angry, otherwise false. + * @return True if the piglin is angry, otherwise false. */ boolean isAngry(); /** * Not applicable to this entity * - * @return false + * @return {@code false} */ @Override + @Contract("-> false") public boolean isConverting(); /** * Not applicable to this entity */ @Override + @Contract("-> fail") public int getConversionTime(); /** @@ -54,5 +58,6 @@ public interface PigZombie extends Zombie { * @param time unused */ @Override + @Contract("_ -> fail") public void setConversionTime(int time); } diff --git a/paper-api/src/main/java/org/bukkit/entity/Piglin.java b/paper-api/src/main/java/org/bukkit/entity/Piglin.java index eb0b7c18c..01fe8fe77 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Piglin.java +++ b/paper-api/src/main/java/org/bukkit/entity/Piglin.java @@ -91,7 +91,6 @@ public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystok @NotNull public Set getBarterList(); - // Paper start /** * Causes the piglin to appear as if they are charging * a crossbow. @@ -131,6 +130,5 @@ public interface Piglin extends PiglinAbstract, InventoryHolder, com.destroystok * @return is dancing */ boolean isDancing(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Player.java b/paper-api/src/main/java/org/bukkit/entity/Player.java index 494dca2ee..7b9324d12 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Player.java +++ b/paper-api/src/main/java/org/bukkit/entity/Player.java @@ -332,18 +332,21 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Deprecated // Paper public void kickPlayer(@Nullable String message); - // Paper start /** * Kicks the player with the default kick message. + * * @see #kick(net.kyori.adventure.text.Component) */ void kick(); + /** * Kicks player with custom kick message. * * @param message kick message */ - void kick(final net.kyori.adventure.text.@Nullable Component message); + default void kick(final net.kyori.adventure.text.@Nullable Component message) { + this.kick(message, org.bukkit.event.player.PlayerKickEvent.Cause.PLUGIN); + } /** * Kicks player with custom kick message and cause. @@ -352,7 +355,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @param cause kick cause */ void kick(final net.kyori.adventure.text.@Nullable Component message, org.bukkit.event.player.PlayerKickEvent.Cause cause); - // Paper end /** * Adds this user to the {@link ProfileBanList}. If a previous ban exists, this will @@ -543,31 +545,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public boolean isSleepingIgnored(); - /** - * Gets the Location where the player will spawn at their bed, null if - * they have not slept in one or their current bed spawn is invalid. - * - * @return Bed Spawn Location if bed exists, otherwise null. - * - * @see #getRespawnLocation() - * @deprecated Misleading name. This method also returns the location of - * respawn anchors. - */ - @Nullable - @Override - @Deprecated(since = "1.20.4") - public Location getBedSpawnLocation(); - - /** - * Gets the Location where the player will spawn at, null if they - * don't have a valid respawn point. - * - * @return respawn location if exists, otherwise null. - */ - @Nullable - @Override - public Location getRespawnLocation(); - /** * Sets the Location where the player will spawn at their bed. * @@ -973,7 +950,9 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * than 1.19.4 */ @Deprecated(since = "1.20") - public void sendBlockChanges(Collection blocks, boolean suppressLightUpdates); + default void sendBlockChanges(Collection blocks, boolean suppressLightUpdates) { + this.sendBlockChanges(blocks); + } /** * Send block damage. This fakes block break progress at a certain location @@ -1294,7 +1273,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ public void sendMap(MapView map); - // Paper start /** * Shows the player the win screen that normally is only displayed after one kills the ender dragon * and exits the end for the first time. @@ -1333,9 +1311,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM * @see https://minecraft.wiki/wiki/End_Poem */ public void setHasSeenWinScreen(boolean hasSeenWinScreen); - // Paper end - // Paper start /** * Permanently Bans the Profile and IP address currently used by the player. * @@ -1346,7 +1322,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM // For reference, Bukkit defines this as nullable, while they impl isn't, we'll follow API. @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerFull(@Nullable String reason) { - return banPlayerFull(reason, null, null); + return this.banPlayerFull(reason, null, null); } /** @@ -1359,7 +1335,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerFull(@Nullable String reason, @Nullable String source) { - return banPlayerFull(reason, null, source); + return this.banPlayerFull(reason, null, source); } /** @@ -1372,7 +1348,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerFull(@Nullable String reason, java.util.@Nullable Date expires) { - return banPlayerFull(reason, expires, null); + return this.banPlayerFull(reason, expires, null); } /** @@ -1386,8 +1362,8 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerFull(@Nullable String reason, java.util.@Nullable Date expires, @Nullable String source) { - banPlayer(reason, expires, source); - return banPlayerIP(reason, expires, source, true); + this.banPlayer(reason, expires, source); + return this.banPlayerIP(reason, expires, source, true); } /** @@ -1401,7 +1377,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, boolean kickPlayer) { - return banPlayerIP(reason, null, null, kickPlayer); + return this.banPlayerIP(reason, null, null, kickPlayer); } /** @@ -1415,7 +1391,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, @Nullable String source, boolean kickPlayer) { - return banPlayerIP(reason, null, source, kickPlayer); + return this.banPlayerIP(reason, null, source, kickPlayer); } /** @@ -1429,7 +1405,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, java.util.@Nullable Date expires, boolean kickPlayer) { - return banPlayerIP(reason, expires, null, kickPlayer); + return this.banPlayerIP(reason, expires, null, kickPlayer); } /** @@ -1442,7 +1418,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason) { - return banPlayerIP(reason, null, null); + return this.banPlayerIP(reason, null, null); } /** @@ -1455,7 +1431,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, @Nullable String source) { - return banPlayerIP(reason, null, source); + return this.banPlayerIP(reason, null, source); } /** @@ -1468,7 +1444,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, java.util.@Nullable Date expires) { - return banPlayerIP(reason, expires, null); + return this.banPlayerIP(reason, expires, null); } /** @@ -1482,7 +1458,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated(since = "1.20.4") public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, java.util.@Nullable Date expires, @Nullable String source) { - return banPlayerIP(reason, expires, source, true); + return this.banPlayerIP(reason, expires, source, true); } /** @@ -1499,7 +1475,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM public default org.bukkit.@Nullable BanEntry banPlayerIP(@Nullable String reason, java.util.@Nullable Date expires, @Nullable String source, boolean kickPlayer) { org.bukkit.BanEntry banEntry = org.bukkit.Bukkit.getServer().getBanList(org.bukkit.BanList.Type.IP).addBan(getAddress().getAddress().getHostAddress(), reason, expires, source); if (kickPlayer && isOnline()) { - getPlayer().kickPlayer(reason); + this.getPlayer().kickPlayer(reason); } return banEntry; @@ -1546,7 +1522,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Override @Deprecated public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent component) { - spigot().sendMessage(component); + this.spigot().sendMessage(component); } /** @@ -1558,7 +1534,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Override @Deprecated public default void sendMessage(net.md_5.bungee.api.chat.BaseComponent... components) { - spigot().sendMessage(components); + this.spigot().sendMessage(components); } /** @@ -1570,7 +1546,7 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM */ @Deprecated public default void sendMessage(net.md_5.bungee.api.ChatMessageType position, net.md_5.bungee.api.chat.BaseComponent... components) { - spigot().sendMessage(position, components); + this.spigot().sendMessage(position, components); } /** diff --git a/paper-api/src/main/java/org/bukkit/entity/PolarBear.java b/paper-api/src/main/java/org/bukkit/entity/PolarBear.java index 4e526ba6a..2ea27cdfd 100644 --- a/paper-api/src/main/java/org/bukkit/entity/PolarBear.java +++ b/paper-api/src/main/java/org/bukkit/entity/PolarBear.java @@ -3,7 +3,6 @@ package org.bukkit.entity; /** * Represents a polar bear. */ -// Paper start public interface PolarBear extends Animals { /** @@ -21,4 +20,3 @@ public interface PolarBear extends Animals { void setStanding(boolean standing); } -// Paper end diff --git a/paper-api/src/main/java/org/bukkit/entity/Ravager.java b/paper-api/src/main/java/org/bukkit/entity/Ravager.java index 0eb721447..4b318586b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Ravager.java +++ b/paper-api/src/main/java/org/bukkit/entity/Ravager.java @@ -3,7 +3,6 @@ package org.bukkit.entity; /** * Illager beast. */ -// Paper start - Missing Entity Behavior public interface Ravager extends Raider { /** @@ -60,4 +59,3 @@ public interface Ravager extends Raider { void setRoarTicks(int ticks); } -// Paper end diff --git a/paper-api/src/main/java/org/bukkit/entity/Salmon.java b/paper-api/src/main/java/org/bukkit/entity/Salmon.java index d8a2d44fe..18e38e492 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Salmon.java +++ b/paper-api/src/main/java/org/bukkit/entity/Salmon.java @@ -27,17 +27,11 @@ public interface Salmon extends io.papermc.paper.entity.SchoolableFish { // Pape */ public enum Variant { - /** - * Small salmon. - */ + // Start generate - SalmonVariant + // @GeneratedFrom 1.21.5 SMALL, - /** - * Default salmon. - */ MEDIUM, - /** - * Large salmon. - */ LARGE; + // End generate - SalmonVariant } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java index ce04c03ba..42e1f5141 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Skeleton.java +++ b/paper-api/src/main/java/org/bukkit/entity/Skeleton.java @@ -41,7 +41,6 @@ public interface Skeleton extends AbstractSkeleton { */ void setConversionTime(int time); - // Paper start /** * Gets the time the skeleton * has been inside powdered snow. @@ -49,7 +48,6 @@ public interface Skeleton extends AbstractSkeleton { * @return time in ticks */ int inPowderedSnowTime(); - // Paper end /** * A legacy enum that defines the different variances of skeleton-like diff --git a/paper-api/src/main/java/org/bukkit/entity/SkeletonHorse.java b/paper-api/src/main/java/org/bukkit/entity/SkeletonHorse.java index 38539d5b7..69fc60b36 100644 --- a/paper-api/src/main/java/org/bukkit/entity/SkeletonHorse.java +++ b/paper-api/src/main/java/org/bukkit/entity/SkeletonHorse.java @@ -44,17 +44,19 @@ public interface SkeletonHorse extends AbstractHorse { */ void setTrapTime(int trapTime); - // Paper start /** * @deprecated use {@link #isTrapped()} */ @Deprecated - boolean isTrap(); + default boolean isTrap() { + return this.isTrapped(); + } /** * @deprecated use {@link #setTrapped(boolean)} */ @Deprecated - void setTrap(boolean trap); - // Paper end + default void setTrap(boolean trap) { + this.setTrapped(trap); + } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Slime.java b/paper-api/src/main/java/org/bukkit/entity/Slime.java index 26d09d202..d200b7e92 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Slime.java +++ b/paper-api/src/main/java/org/bukkit/entity/Slime.java @@ -25,7 +25,6 @@ public interface Slime extends Mob, Enemy { */ public void setSize(int sz); - // Paper start /** * Get whether this slime can randomly wander/jump around on its own * @@ -39,5 +38,4 @@ public interface Slime extends Mob, Enemy { * @param canWander true if can wander */ public void setWander(boolean canWander); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Sniffer.java b/paper-api/src/main/java/org/bukkit/entity/Sniffer.java index 15a0a733b..a2a06730d 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Sniffer.java +++ b/paper-api/src/main/java/org/bukkit/entity/Sniffer.java @@ -74,6 +74,8 @@ public interface Sniffer extends Animals { * Represents the current state of the Sniffer. */ public enum State { + // Start generate - SnifferState + // @GeneratedFrom 1.21.5 IDLING, FEELING_HAPPY, SCENTING, @@ -81,5 +83,6 @@ public interface Sniffer extends Animals { SEARCHING, DIGGING, RISING; + // End generate - SnifferState } } diff --git a/paper-api/src/main/java/org/bukkit/entity/SplashPotion.java b/paper-api/src/main/java/org/bukkit/entity/SplashPotion.java index c4702ce06..47aa68c52 100644 --- a/paper-api/src/main/java/org/bukkit/entity/SplashPotion.java +++ b/paper-api/src/main/java/org/bukkit/entity/SplashPotion.java @@ -2,9 +2,6 @@ package org.bukkit.entity; /** * Represents a thrown splash potion bottle - * - * @deprecated should not be used for anything, use {@link ThrownPotion} and - * set the potion via the methods there. */ -@Deprecated(since = "1.14", forRemoval = true) // Paper -public interface SplashPotion extends ThrownPotion { } +public interface SplashPotion extends ThrownPotion { +} diff --git a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java index 87e717c9e..d97674b5f 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java +++ b/paper-api/src/main/java/org/bukkit/entity/TNTPrimed.java @@ -65,7 +65,6 @@ public interface TNTPrimed extends Explosive { return this.getOrigin(); } - // Paper start /** * Sets the visual block data of this * primed tnt. @@ -85,5 +84,4 @@ public interface TNTPrimed extends Explosive { */ @org.jetbrains.annotations.NotNull org.bukkit.block.data.BlockData getBlockData(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Tadpole.java b/paper-api/src/main/java/org/bukkit/entity/Tadpole.java index 8e097ad55..a3d3a198b 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Tadpole.java +++ b/paper-api/src/main/java/org/bukkit/entity/Tadpole.java @@ -19,7 +19,6 @@ public interface Tadpole extends Fish { */ public void setAge(int age); - // Paper start - Tadpole age lock api /** * Lock the age of the animal, setting this will prevent the animal from * maturing. @@ -34,5 +33,4 @@ public interface Tadpole extends Fish { * @return the current agelock */ boolean getAgeLock(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/TextDisplay.java b/paper-api/src/main/java/org/bukkit/entity/TextDisplay.java index a8277270e..90b4d8f04 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TextDisplay.java +++ b/paper-api/src/main/java/org/bukkit/entity/TextDisplay.java @@ -28,7 +28,6 @@ public interface TextDisplay extends Display { @Deprecated // Paper void setText(@Nullable String text); - // Paper start /** * Gets the displayed text. * @@ -42,7 +41,6 @@ public interface TextDisplay extends Display { * @param text the new text */ void text(net.kyori.adventure.text.@Nullable Component text); - // Paper end /** * Gets the maximum line width before wrapping. diff --git a/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java b/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java index 84bba32e8..0cabfb192 100644 --- a/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java +++ b/paper-api/src/main/java/org/bukkit/entity/TropicalFish.java @@ -60,6 +60,8 @@ public interface TropicalFish extends io.papermc.paper.entity.SchoolableFish { / */ public static enum Pattern { + // Start generate - TropicalFishPattern + // @GeneratedFrom 1.21.5 KOB, SUNSTREAK, SNOOPER, @@ -72,5 +74,6 @@ public interface TropicalFish extends io.papermc.paper.entity.SchoolableFish { / BLOCKFISH, BETTY, CLAYFISH; + // End generate - TropicalFishPattern } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Villager.java b/paper-api/src/main/java/org/bukkit/entity/Villager.java index 1db374202..02b86d961 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Villager.java +++ b/paper-api/src/main/java/org/bukkit/entity/Villager.java @@ -171,13 +171,22 @@ public interface Villager extends AbstractVillager { */ interface Type extends OldEnum, Keyed { + // Start generate - VillagerType + // @GeneratedFrom 1.21.5 Type DESERT = getType("desert"); + Type JUNGLE = getType("jungle"); + Type PLAINS = getType("plains"); + Type SAVANNA = getType("savanna"); + Type SNOW = getType("snow"); + Type SWAMP = getType("swamp"); + Type TAIGA = getType("taiga"); + // End generate - VillagerType @NotNull private static Type getType(@NotNull String key) { @@ -214,77 +223,94 @@ public interface Villager extends AbstractVillager { */ interface Profession extends OldEnum, Keyed, net.kyori.adventure.translation.Translatable { - Profession NONE = getProfession("none"); + // Start generate - VillagerProfession + // @GeneratedFrom 1.21.5 /** * Armorer profession. Wears a black apron. Armorers primarily trade for * iron armor, chainmail armor, and sometimes diamond armor. */ Profession ARMORER = getProfession("armorer"); + /** * Butcher profession. Wears a white apron. Butchers primarily trade for * raw and cooked food. */ Profession BUTCHER = getProfession("butcher"); + /** * Cartographer profession. Wears a white robe. Cartographers primarily * trade for explorer maps and some paper. */ Profession CARTOGRAPHER = getProfession("cartographer"); + /** * Cleric profession. Wears a purple robe. Clerics primarily trade for * rotten flesh, gold ingot, redstone, lapis, ender pearl, glowstone, * and bottle o' enchanting. */ Profession CLERIC = getProfession("cleric"); + /** * Farmer profession. Wears a brown robe. Farmers primarily trade for * food-related items. */ Profession FARMER = getProfession("farmer"); + /** * Fisherman profession. Wears a brown robe. Fisherman primarily trade * for fish, as well as possibly selling string and/or coal. */ Profession FISHERMAN = getProfession("fisherman"); + /** * Fletcher profession. Wears a brown robe. Fletchers primarily trade * for string, bows, and arrows. */ Profession FLETCHER = getProfession("fletcher"); + /** * Leatherworker profession. Wears a white apron. Leatherworkers * primarily trade for leather, and leather armor, as well as saddles. */ Profession LEATHERWORKER = getProfession("leatherworker"); + /** * Librarian profession. Wears a white robe. Librarians primarily trade * for paper, books, and enchanted books. */ Profession LIBRARIAN = getProfession("librarian"); + /** * Mason profession. */ Profession MASON = getProfession("mason"); + /** * Nitwit profession. Wears a green apron, cannot trade. Nitwit * villagers do not do anything. They do not have any trades by default. */ Profession NITWIT = getProfession("nitwit"); + + Profession NONE = getProfession("none"); + /** * Shepherd profession. Wears a brown robe. Shepherds primarily trade for * wool items, and shears. */ Profession SHEPHERD = getProfession("shepherd"); + /** * Toolsmith profession. Wears a black apron. Tool smiths primarily * trade for iron and diamond tools. */ Profession TOOLSMITH = getProfession("toolsmith"); + /** * Weaponsmith profession. Wears a black apron. Weapon smiths primarily * trade for iron and diamond weapons, sometimes enchanted. */ Profession WEAPONSMITH = getProfession("weaponsmith"); + // End generate - VillagerProfession @NotNull private static Profession getProfession(@NotNull String key) { @@ -322,7 +348,6 @@ public interface Villager extends AbstractVillager { // Paper end } - // Paper start - Add villager reputation API /** * Get the {@link com.destroystokyo.paper.entity.villager.Reputation reputation} * for a specific player by {@link UUID}. @@ -366,5 +391,4 @@ public interface Villager extends AbstractVillager { * reputation regardless of its impact and the player associated. */ public void clearReputations(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/WanderingTrader.java b/paper-api/src/main/java/org/bukkit/entity/WanderingTrader.java index 9f2577465..dc7323b84 100644 --- a/paper-api/src/main/java/org/bukkit/entity/WanderingTrader.java +++ b/paper-api/src/main/java/org/bukkit/entity/WanderingTrader.java @@ -29,7 +29,6 @@ public interface WanderingTrader extends AbstractVillager { */ public void setDespawnDelay(int despawnDelay); - // Paper start - Add more WanderingTrader API /** * Set if the Wandering Trader can and will drink an invisibility potion. * @param bool whether the mob will drink @@ -74,5 +73,4 @@ public interface WanderingTrader extends AbstractVillager { * @param location location to wander towards (world is ignored, will always use the entity's world) */ void setWanderingTowards(@org.jetbrains.annotations.Nullable org.bukkit.Location location); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Warden.java b/paper-api/src/main/java/org/bukkit/entity/Warden.java index efaa45f41..94fec17b4 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Warden.java +++ b/paper-api/src/main/java/org/bukkit/entity/Warden.java @@ -30,7 +30,6 @@ public interface Warden extends Monster { */ int getAnger(@NotNull Entity entity); - // Paper start /** * Gets the highest anger level of this warden. *

@@ -40,7 +39,6 @@ public interface Warden extends Monster { * @return highest anger level */ int getHighestAnger(); - // Paper end /** * Increases the anger level of this warden. diff --git a/paper-api/src/main/java/org/bukkit/entity/Wither.java b/paper-api/src/main/java/org/bukkit/entity/Wither.java index 14543c223..11ae1b3ad 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Wither.java +++ b/paper-api/src/main/java/org/bukkit/entity/Wither.java @@ -69,7 +69,6 @@ public interface Wither extends Monster, Boss, com.destroystokyo.paper.entity.Ra RIGHT } - // Paper start /** * @return whether the wither is charged */ @@ -106,5 +105,4 @@ public interface Wither extends Monster, Boss, com.destroystokyo.paper.entity.Ra * This is called in vanilla directly after spawning the wither. */ void enterInvulnerabilityPhase(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/Wolf.java b/paper-api/src/main/java/org/bukkit/entity/Wolf.java index 346fdddd2..a1c7b6ba6 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Wolf.java +++ b/paper-api/src/main/java/org/bukkit/entity/Wolf.java @@ -90,24 +90,78 @@ public interface Wolf extends Tameable, Sittable, io.papermc.paper.entity.Collar */ void setVariant(@NotNull Variant variant); + /** + * Get the sound variant of this wolf. + * + * @return wolf sound variant + */ + @NotNull + SoundVariant getSoundVariant(); + + /** + * Set the sound variant of this wolf. + * + * @param soundVariant wolf sound variant + */ + void setSoundVariant(@NotNull SoundVariant soundVariant); + /** * Represents the variant of a wolf. */ interface Variant extends Keyed { - Variant PALE = getVariant("pale"); - Variant SPOTTED = getVariant("spotted"); - Variant SNOWY = getVariant("snowy"); - Variant BLACK = getVariant("black"); + // Start generate - WolfVariant + // @GeneratedFrom 1.21.5 Variant ASHEN = getVariant("ashen"); - Variant RUSTY = getVariant("rusty"); - Variant WOODS = getVariant("woods"); + + Variant BLACK = getVariant("black"); + Variant CHESTNUT = getVariant("chestnut"); + + Variant PALE = getVariant("pale"); + + Variant RUSTY = getVariant("rusty"); + + Variant SNOWY = getVariant("snowy"); + + Variant SPOTTED = getVariant("spotted"); + Variant STRIPED = getVariant("striped"); + Variant WOODS = getVariant("woods"); + // End generate - WolfVariant + @NotNull private static Variant getVariant(@NotNull String key) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.WOLF_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); } } + + /** + * Represents the sound variant of a wolf. + */ + interface SoundVariant extends Keyed { + + // Start generate - WolfSoundVariant + // @GeneratedFrom 1.21.5 + SoundVariant ANGRY = getSoundVariant("angry"); + + SoundVariant BIG = getSoundVariant("big"); + + SoundVariant CLASSIC = getSoundVariant("classic"); + + SoundVariant CUTE = getSoundVariant("cute"); + + SoundVariant GRUMPY = getSoundVariant("grumpy"); + + SoundVariant PUGLIN = getSoundVariant("puglin"); + + SoundVariant SAD = getSoundVariant("sad"); + // End generate - WolfSoundVariant + + @NotNull + private static SoundVariant getSoundVariant(@NotNull String key) { + return RegistryAccess.registryAccess().getRegistry(RegistryKey.WOLF_SOUND_VARIANT).getOrThrow(NamespacedKey.minecraft(key)); + } + } } diff --git a/paper-api/src/main/java/org/bukkit/entity/Zombie.java b/paper-api/src/main/java/org/bukkit/entity/Zombie.java index 65e870c75..002fd6c7c 100644 --- a/paper-api/src/main/java/org/bukkit/entity/Zombie.java +++ b/paper-api/src/main/java/org/bukkit/entity/Zombie.java @@ -110,7 +110,6 @@ public interface Zombie extends Monster, Ageable { */ void setCanBreakDoors(boolean flag); - // Paper start /** * Check if zombie is drowning * @@ -176,5 +175,4 @@ public interface Zombie extends Monster, Ageable { */ @Deprecated(since = "1.21.2", forRemoval = true) boolean supportsBreakingDoors(); - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java index d615c006c..4a4ddab67 100644 --- a/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java +++ b/paper-api/src/main/java/org/bukkit/entity/memory/MemoryKey.java @@ -44,31 +44,90 @@ public final class MemoryKey implements Keyed { return tClass; } - private static final Map MEMORY_KEYS = new HashMap<>(); - // - public static final MemoryKey HOME = new MemoryKey<>(NamespacedKey.minecraft("home"), Location.class); - public static final MemoryKey POTENTIAL_JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("potential_job_site"), Location.class); - public static final MemoryKey JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("job_site"), Location.class); - public static final MemoryKey MEETING_POINT = new MemoryKey<>(NamespacedKey.minecraft("meeting_point"), Location.class); - public static final MemoryKey GOLEM_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("golem_detected_recently"), Boolean.class); - public static final MemoryKey LAST_SLEPT = new MemoryKey<>(NamespacedKey.minecraft("last_slept"), Long.class); - public static final MemoryKey LAST_WOKEN = new MemoryKey<>(NamespacedKey.minecraft("last_woken"), Long.class); - public static final MemoryKey LAST_WORKED_AT_POI = new MemoryKey<>(NamespacedKey.minecraft("last_worked_at_poi"), Long.class); - public static final MemoryKey UNIVERSAL_ANGER = new MemoryKey<>(NamespacedKey.minecraft("universal_anger"), Boolean.class); - public static final MemoryKey ANGRY_AT = new MemoryKey<>(NamespacedKey.minecraft("angry_at"), UUID.class); - public static final MemoryKey ADMIRING_ITEM = new MemoryKey<>(NamespacedKey.minecraft("admiring_item"), Boolean.class); + private static final Map> MEMORY_KEYS = new HashMap<>(); + + // Start generate - MemoryKey + // @GeneratedFrom 1.21.5 public static final MemoryKey ADMIRING_DISABLED = new MemoryKey<>(NamespacedKey.minecraft("admiring_disabled"), Boolean.class); - public static final MemoryKey HUNTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("hunted_recently"), Boolean.class); - public static final MemoryKey PLAY_DEAD_TICKS = new MemoryKey<>(NamespacedKey.minecraft("play_dead_ticks"), Integer.class); - public static final MemoryKey TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class); - public static final MemoryKey IS_TEMPTED = new MemoryKey<>(NamespacedKey.minecraft("is_tempted"), Boolean.class); - public static final MemoryKey LONG_JUMP_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("long_jump_cooling_down"), Integer.class); + + public static final MemoryKey ADMIRING_ITEM = new MemoryKey<>(NamespacedKey.minecraft("admiring_item"), Boolean.class); + + public static final MemoryKey ANGRY_AT = new MemoryKey<>(NamespacedKey.minecraft("angry_at"), UUID.class); + + public static final MemoryKey ATE_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("ate_recently"), Boolean.class); + + public static final MemoryKey ATTACK_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("attack_cooling_down"), Boolean.class); + + public static final MemoryKey CANT_REACH_WALK_TARGET_SINCE = new MemoryKey<>(NamespacedKey.minecraft("cant_reach_walk_target_since"), Long.class); + + public static final MemoryKey DANCING = new MemoryKey<>(NamespacedKey.minecraft("dancing"), Boolean.class); + + public static final MemoryKey DANGER_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("danger_detected_recently"), Boolean.class); + + public static final MemoryKey DISABLE_WALK_TO_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("disable_walk_to_admire_item"), Boolean.class); + + public static final MemoryKey GAZE_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("gaze_cooldown_ticks"), Integer.class); + + public static final MemoryKey GOLEM_DETECTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("golem_detected_recently"), Boolean.class); + public static final MemoryKey HAS_HUNTING_COOLDOWN = new MemoryKey<>(NamespacedKey.minecraft("has_hunting_cooldown"), Boolean.class); - public static final MemoryKey RAM_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("ram_cooldown_ticks"), Integer.class); - public static final MemoryKey LIKED_PLAYER = new MemoryKey<>(NamespacedKey.minecraft("liked_player"), UUID.class); - public static final MemoryKey LIKED_NOTEBLOCK_POSITION = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock"), Location.class); - public static final MemoryKey LIKED_NOTEBLOCK_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock_cooldown_ticks"), Integer.class); + + public static final MemoryKey HEARD_BELL_TIME = new MemoryKey<>(NamespacedKey.minecraft("heard_bell_time"), Long.class); + + public static final MemoryKey HIDING_PLACE = new MemoryKey<>(NamespacedKey.minecraft("hiding_place"), Location.class); + + public static final MemoryKey HOME = new MemoryKey<>(NamespacedKey.minecraft("home"), Location.class); + + public static final MemoryKey HUNTED_RECENTLY = new MemoryKey<>(NamespacedKey.minecraft("hunted_recently"), Boolean.class); + + public static final MemoryKey IS_PANICKING = new MemoryKey<>(NamespacedKey.minecraft("is_panicking"), Boolean.class); + + public static final MemoryKey IS_TEMPTED = new MemoryKey<>(NamespacedKey.minecraft("is_tempted"), Boolean.class); + public static final MemoryKey ITEM_PICKUP_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("item_pickup_cooldown_ticks"), Integer.class); + + public static final MemoryKey JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("job_site"), Location.class); + + public static final MemoryKey LAST_SLEPT = new MemoryKey<>(NamespacedKey.minecraft("last_slept"), Long.class); + + public static final MemoryKey LAST_WOKEN = new MemoryKey<>(NamespacedKey.minecraft("last_woken"), Long.class); + + public static final MemoryKey LAST_WORKED_AT_POI = new MemoryKey<>(NamespacedKey.minecraft("last_worked_at_poi"), Long.class); + + public static final MemoryKey LIKED_NOTEBLOCK_POSITION = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock"), Location.class); + + public static final MemoryKey LIKED_NOTEBLOCK_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("liked_noteblock_cooldown_ticks"), Integer.class); + + public static final MemoryKey LIKED_PLAYER = new MemoryKey<>(NamespacedKey.minecraft("liked_player"), UUID.class); + + public static final MemoryKey LONG_JUMP_COOLING_DOWN = new MemoryKey<>(NamespacedKey.minecraft("long_jump_cooling_down"), Integer.class); + + public static final MemoryKey LONG_JUMP_MID_JUMP = new MemoryKey<>(NamespacedKey.minecraft("long_jump_mid_jump"), Boolean.class); + + public static final MemoryKey MEETING_POINT = new MemoryKey<>(NamespacedKey.minecraft("meeting_point"), Location.class); + + public static final MemoryKey PACIFIED = new MemoryKey<>(NamespacedKey.minecraft("pacified"), Boolean.class); + + public static final MemoryKey PLAY_DEAD_TICKS = new MemoryKey<>(NamespacedKey.minecraft("play_dead_ticks"), Integer.class); + + public static final MemoryKey POTENTIAL_JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("potential_job_site"), Location.class); + + public static final MemoryKey RAM_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("ram_cooldown_ticks"), Integer.class); + + public static final MemoryKey SNIFFER_DIGGING = new MemoryKey<>(NamespacedKey.minecraft("sniffer_digging"), Boolean.class); + + public static final MemoryKey SNIFFER_HAPPY = new MemoryKey<>(NamespacedKey.minecraft("sniffer_happy"), Boolean.class); + + public static final MemoryKey TEMPTATION_COOLDOWN_TICKS = new MemoryKey<>(NamespacedKey.minecraft("temptation_cooldown_ticks"), Integer.class); + + public static final MemoryKey TIME_TRYING_TO_REACH_ADMIRE_ITEM = new MemoryKey<>(NamespacedKey.minecraft("time_trying_to_reach_admire_item"), Integer.class); + + public static final MemoryKey UNIVERSAL_ANGER = new MemoryKey<>(NamespacedKey.minecraft("universal_anger"), Boolean.class); + + public static final MemoryKey VISIBLE_ADULT_HOGLIN_COUNT = new MemoryKey<>(NamespacedKey.minecraft("visible_adult_hoglin_count"), Integer.class); + + public static final MemoryKey VISIBLE_ADULT_PIGLIN_COUNT = new MemoryKey<>(NamespacedKey.minecraft("visible_adult_piglin_count"), Integer.class); + // End generate - MemoryKey /** * @deprecated this constant uses the wrong generic type, the sniffer now stores different positions * from possibly different worlds. Use the relevant methods in {@link org.bukkit.entity.Sniffer} directly @@ -86,7 +145,7 @@ public final class MemoryKey implements Keyed { * available under that key */ @Nullable - public static MemoryKey getByKey(@NotNull NamespacedKey namespacedKey) { + public static MemoryKey getByKey(@NotNull NamespacedKey namespacedKey) { return MEMORY_KEYS.get(namespacedKey); } @@ -96,7 +155,7 @@ public final class MemoryKey implements Keyed { * @return the memoryKeys */ @NotNull - public static Set values() { + public static Set> values() { return new HashSet<>(MEMORY_KEYS.values()); } } diff --git a/paper-api/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java b/paper-api/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java index a65d76770..8cfc99c7a 100644 --- a/paper-api/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java +++ b/paper-api/src/main/java/org/bukkit/entity/minecart/ExplosiveMinecart.java @@ -65,7 +65,7 @@ public interface ExplosiveMinecart extends Minecart, Explosive { /** * Immediately explode this minecart with the given power. * - * @param power the power to use. Must be positive and cannot exceed 5.0 + * @param power the power to use. Must be positive and cannot exceed 25.0 */ public void explode(double power); } diff --git a/paper-api/src/main/java/org/bukkit/event/Cancellable.java b/paper-api/src/main/java/org/bukkit/event/Cancellable.java index 9e836d308..b6656a388 100644 --- a/paper-api/src/main/java/org/bukkit/event/Cancellable.java +++ b/paper-api/src/main/java/org/bukkit/event/Cancellable.java @@ -9,15 +9,15 @@ public interface Cancellable { * Gets the cancellation state of this event. A cancelled event will not * be executed in the server, but will still pass to other plugins * - * @return true if this event is cancelled + * @return {@code true} if this event is cancelled */ - public boolean isCancelled(); + boolean isCancelled(); /** * Sets the cancellation state of this event. A cancelled event will not * be executed in the server, but will still pass to other plugins. * - * @param cancel true if you wish to cancel this event + * @param cancel {@code true} if you wish to cancel this event */ - public void setCancelled(boolean cancel); + void setCancelled(boolean cancel); } diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index 8ec56cd6b..7fd1f4b59 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -1,20 +1,22 @@ package org.bukkit.event; +import org.bukkit.Bukkit; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.jetbrains.annotations.NotNull; /** * Represents an event. - * + *
* All events require a static method named getHandlerList() which returns the same {@link HandlerList} as {@link #getHandlers()}. * * @see PluginManager#callEvent(Event) * @see PluginManager#registerEvents(Listener,Plugin) */ public abstract class Event { + private String name; - private final boolean async; + private final boolean isAsync; /** * The default constructor is defined for cleaner code. This constructor @@ -28,28 +30,26 @@ public abstract class Event { * This constructor is used to explicitly declare an event as synchronous * or asynchronous. * - * @param isAsync true indicates the event will fire asynchronously, false + * @param isAsync {@code true} indicates the event will fire asynchronously, {@code false} * by default from default constructor */ public Event(boolean isAsync) { - this.async = isAsync; + this.isAsync = isAsync; } - // Paper start /** * Calls the event and tests if cancelled. * - * @return false if event was cancelled, if cancellable. otherwise true. + * @return {@code false} if event was cancelled, if cancellable. otherwise {@code true}. */ public boolean callEvent() { - org.bukkit.Bukkit.getPluginManager().callEvent(this); + Bukkit.getPluginManager().callEvent(this); if (this instanceof Cancellable) { return !((Cancellable) this).isCancelled(); } else { return true; } } - // Paper end /** * Convenience method for providing a user-friendly identifier. By @@ -60,23 +60,23 @@ public abstract class Event { */ @NotNull public String getEventName() { - if (name == null) { - name = getClass().getSimpleName(); + if (this.name == null) { + this.name = this.getClass().getSimpleName(); } - return name; + return this.name; } @NotNull public abstract HandlerList getHandlers(); /** - * Any custom event that should not by synchronized with other events must + * Any custom event that should not be synchronized with other events must * use the specific constructor. These are the caveats of using an * asynchronous event: *

    *
  • The event is never fired from inside code triggered by a * synchronous event. Attempting to do so results in an {@link - * java.lang.IllegalStateException}. + * IllegalStateException}. *
  • However, asynchronous event handlers may fire synchronous or * asynchronous events *
  • The event may be fired multiple times simultaneously and in any @@ -89,10 +89,10 @@ public abstract class Event { *
  • Asynchronous calls are not calculated in the plugin timing system. *
* - * @return false by default, true if the event fires asynchronously + * @return {@code false} by default, {@code true} if the event fires asynchronously */ public final boolean isAsynchronous() { - return async; + return this.isAsync; } public enum Result { @@ -113,6 +113,6 @@ public abstract class Event { * take place if possible, even if the server would not normally allow * the action. Some actions may not be allowed. */ - ALLOW; + ALLOW } } diff --git a/paper-api/src/main/java/org/bukkit/event/EventException.java b/paper-api/src/main/java/org/bukkit/event/EventException.java index 84638e852..7c9c4a547 100644 --- a/paper-api/src/main/java/org/bukkit/event/EventException.java +++ b/paper-api/src/main/java/org/bukkit/event/EventException.java @@ -44,7 +44,7 @@ public class EventException extends Exception { /** * If applicable, returns the Exception that triggered this Exception * - * @return Inner exception, or null if one does not exist + * @return Inner exception, or {@code null} if one does not exist */ @Override public Throwable getCause() { diff --git a/paper-api/src/main/java/org/bukkit/event/EventHandler.java b/paper-api/src/main/java/org/bukkit/event/EventHandler.java index cc06f480b..d81ba5351 100644 --- a/paper-api/src/main/java/org/bukkit/event/EventHandler.java +++ b/paper-api/src/main/java/org/bukkit/event/EventHandler.java @@ -32,7 +32,7 @@ public @interface EventHandler { /** * Define if the handler ignores a cancelled event. *

- * If ignoreCancelled is true and the event is cancelled, the method is + * If ignoreCancelled is {@code true} and the event is cancelled, the method is * not called. Otherwise, the method is always called. * * @return whether cancelled events should be ignored diff --git a/paper-api/src/main/java/org/bukkit/event/EventPriority.java b/paper-api/src/main/java/org/bukkit/event/EventPriority.java index 376c5375d..64774948f 100644 --- a/paper-api/src/main/java/org/bukkit/event/EventPriority.java +++ b/paper-api/src/main/java/org/bukkit/event/EventPriority.java @@ -43,7 +43,7 @@ public enum EventPriority { private final int slot; - private EventPriority(int slot) { + EventPriority(int slot) { this.slot = slot; } diff --git a/paper-api/src/main/java/org/bukkit/event/HandlerList.java b/paper-api/src/main/java/org/bukkit/event/HandlerList.java index 64d8916a8..ef9d9f3dd 100644 --- a/paper-api/src/main/java/org/bukkit/event/HandlerList.java +++ b/paper-api/src/main/java/org/bukkit/event/HandlerList.java @@ -31,14 +31,12 @@ public class HandlerList { /** * List of all HandlerLists which have been created, for use in bakeAll() */ - private static ArrayList allLists = new ArrayList(); + private static final ArrayList allLists = new ArrayList<>(); - // Paper start /** * Event types which have instantiated a {@link HandlerList}. */ private static final java.util.Set EVENT_TYPES = java.util.concurrent.ConcurrentHashMap.newKeySet(); - // Paper end /** * Bake all handler lists. Best used just after all normal event @@ -101,15 +99,14 @@ public class HandlerList { * The HandlerList is then added to meta-list for use in bakeAll() */ public HandlerList() { - // Paper start java.lang.StackWalker.getInstance(java.util.EnumSet.of(java.lang.StackWalker.Option.RETAIN_CLASS_REFERENCE), 4) .walk(s -> s.filter(f -> Event.class.isAssignableFrom(f.getDeclaringClass())).findFirst()) .map(f -> f.getDeclaringClass().getName()) .ifPresent(EVENT_TYPES::add); - // Paper end - handlerslots = new EnumMap>(EventPriority.class); + + handlerslots = new EnumMap<>(EventPriority.class); for (EventPriority o : EventPriority.values()) { - handlerslots.put(o, new ArrayList()); + handlerslots.put(o, new ArrayList<>()); } synchronized (allLists) { allLists.add(this); @@ -191,7 +188,7 @@ public class HandlerList { */ public synchronized void bake() { if (handlers != null) return; // don't re-bake when still valid - List entries = new ArrayList(); + List entries = new ArrayList<>(); for (Entry> entry : handlerslots.entrySet()) { entries.addAll(entry.getValue()); } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BellResonateEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BellResonateEvent.java index df76314cd..2fc2bc648 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BellResonateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BellResonateEvent.java @@ -4,6 +4,7 @@ import java.util.List; import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,16 +13,18 @@ import org.jetbrains.annotations.NotNull; */ public class BellResonateEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List resonatedEntities; - public BellResonateEvent(@NotNull Block theBlock, @NotNull List resonatedEntities) { - super(theBlock); + @ApiStatus.Internal + public BellResonateEvent(@NotNull Block bell, @NotNull List resonatedEntities) { + super(bell); this.resonatedEntities = resonatedEntities; } /** - * Get a mutable list of all {@link LivingEntity LivingEntities} to be + * Get a mutable list of all {@link LivingEntity entities} to be * highlighted by the bell's resonating. This list can be added to or * removed from to change which entities are highlighted, and may be empty * if no entities were resonated as a result of this event. @@ -34,17 +37,17 @@ public class BellResonateEvent extends BlockEvent { */ @NotNull public List getResonatedEntities() { - return resonatedEntities; + return this.resonatedEntities; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BellRingEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BellRingEvent.java index 34a6a0382..45c7192bd 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BellRingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BellRingEvent.java @@ -5,6 +5,7 @@ import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,13 +14,16 @@ import org.jetbrains.annotations.Nullable; */ public class BellRingEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final BlockFace direction; private final Entity entity; + private boolean cancelled; - public BellRingEvent(@NotNull Block theBlock, @NotNull BlockFace direction, @Nullable Entity entity) { - super(theBlock); + @ApiStatus.Internal + public BellRingEvent(@NotNull Block block, @NotNull BlockFace direction, @Nullable Entity entity) { + super(block); this.direction = direction; this.entity = entity; } @@ -57,11 +61,11 @@ public class BellRingEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java index 691733a64..680b521b8 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -23,16 +24,19 @@ import org.jetbrains.annotations.NotNull; * to air and utilize their own methods for determining what the default drop * for the block being broken is and what to do about it, if anything. *

- * If a Block Break event is cancelled, the block will not break and + * If this event is cancelled, the block will not break and * experience will not drop. */ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { + private final Player player; private boolean dropItems; - private boolean cancel; - public BlockBreakEvent(@NotNull final Block theBlock, @NotNull final Player player) { - super(theBlock, 0); + private boolean cancelled; + + @ApiStatus.Internal + public BlockBreakEvent(@NotNull final Block block, @NotNull final Player player) { + super(block, 0); this.player = player; this.dropItems = true; // Defaults to dropping items as it normally would @@ -45,29 +49,29 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** - * Sets whether or not the block will attempt to drop items as it normally + * Sets whether the block will attempt to drop items as it normally * would. - * - * If and only if this is false then {@link BlockDropItemEvent} will not be + *

+ * If and only if this is {@code false} then {@link BlockDropItemEvent} will not be * called after this event. * - * @param dropItems Whether or not the block will attempt to drop items + * @param dropItems Whether the block will attempt to drop items */ public void setDropItems(boolean dropItems) { this.dropItems = dropItems; } /** - * Gets whether or not the block will attempt to drop items. - * - * If and only if this is false then {@link BlockDropItemEvent} will not be + * Gets whether the block will attempt to drop items. + *

+ * If and only if this is {@code false} then {@link BlockDropItemEvent} will not be * called after this event. * - * @return Whether or not the block will attempt to drop items + * @return Whether the block will attempt to drop items */ public boolean isDropItems() { return this.dropItems; @@ -75,11 +79,11 @@ public class BlockBreakEvent extends BlockExpEvent implements Cancellable { @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java index 056f6ddb3..a7c56ddec 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockBurnEvent.java @@ -10,15 +10,18 @@ import org.jetbrains.annotations.Nullable; /** * Called when a block is destroyed as a result of being burnt by fire. *

- * If a Block Burn event is cancelled, the block will not be destroyed as a + * If this event is cancelled, the block will not be destroyed as a * result of being burnt by fire. */ public class BlockBurnEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block ignitingBlock; + private boolean cancelled; @Deprecated(since = "1.11.2", forRemoval = true) + @ApiStatus.Internal public BlockBurnEvent(@NotNull final Block block) { this(block, null); } @@ -32,7 +35,7 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { /** * Gets the block which ignited this block. * - * @return The Block that ignited and burned this block, or null if no + * @return The Block that ignited and burned this block, or {@code null} if no * source block exists */ @Nullable @@ -53,11 +56,11 @@ public class BlockBurnEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java index 7969e15bb..5b488d9b3 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockCanBuildEvent.java @@ -21,26 +21,22 @@ import org.jetbrains.annotations.Nullable; * */ public class BlockCanBuildEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Player player; + private final org.bukkit.inventory.EquipmentSlot hand; + protected BlockData blockData; protected boolean buildable; - protected BlockData blockData; - private final Player player; - private final org.bukkit.inventory.EquipmentSlot hand; // Paper - expose hand - @Deprecated(since = "1.13.2", forRemoval = true) + @ApiStatus.Internal public BlockCanBuildEvent(@NotNull final Block block, @NotNull final BlockData type, final boolean canBuild) { this(block, null, type, canBuild, org.bukkit.inventory.EquipmentSlot.HAND); // Paper - expose hand } - /** - * @param block the block involved in this event - * @param player the player placing the block - * @param type the id of the block to place - * @param canBuild whether we can build - */ @Deprecated(forRemoval = true) - @io.papermc.paper.annotation.DoNotUse + @ApiStatus.Internal public BlockCanBuildEvent(@NotNull final Block block, @Nullable final Player player, @NotNull final BlockData type, final boolean canBuild) { this(block, player, type, canBuild, org.bukkit.inventory.EquipmentSlot.HAND); // Paper start - expose hand } @@ -51,40 +47,19 @@ public class BlockCanBuildEvent extends BlockEvent { this.player = player; this.buildable = canBuild; this.blockData = type; - this.hand = hand; // Paper - } - // Paper start - /** - * Gets the hand the player will use to place the block - * - * @return the EquipmentSlot representing the players hand. - */ - @NotNull - public org.bukkit.inventory.EquipmentSlot getHand() { - return hand; - } - // Paper end - - /** - * Gets whether or not the block can be built here. - *

- * By default, returns Minecraft's answer on whether the block can be - * built here or not. - * - * @return boolean whether or not the block can be built - */ - public boolean isBuildable() { - return buildable; + this.hand = hand; } /** - * Sets whether the block can be built here or not. + * Gets the player who placed the block involved in this event. + *
+ * May be {@code null} for legacy calls of the event. * - * @param cancel true if you want to allow the block to be built here - * despite Minecraft's default behaviour + * @return The Player who placed the block involved in this event */ - public void setBuildable(boolean cancel) { - this.buildable = cancel; + @Nullable + public Player getPlayer() { + return this.player; } /** @@ -94,7 +69,7 @@ public class BlockCanBuildEvent extends BlockEvent { */ @NotNull public Material getMaterial() { - return blockData.getMaterial(); + return this.blockData.getMaterial(); } /** @@ -104,29 +79,49 @@ public class BlockCanBuildEvent extends BlockEvent { */ @NotNull public BlockData getBlockData() { - return blockData.clone(); // Paper - clone because mutation isn't used + return this.blockData.clone(); } /** - * Gets the player who placed the block involved in this event. - *
- * May be null for legacy calls of the event. + * Gets the hand the player will use to place the block * - * @return The Player who placed the block involved in this event + * @return the EquipmentSlot representing the players hand. */ - @Nullable - public Player getPlayer() { - return player; + @NotNull + public org.bukkit.inventory.EquipmentSlot getHand() { + return this.hand; + } + + /** + * Gets whether the block can be built here. + *

+ * By default, returns Minecraft's answer on whether the block can be + * built here or not. + * + * @return boolean whether the block can be built + */ + public boolean isBuildable() { + return this.buildable; + } + + /** + * Sets whether the block can be built here or not. + * + * @param cancel {@code true} if you want to allow the block to be built here + * despite Minecraft's default behaviour + */ + public void setBuildable(boolean cancel) { + this.buildable = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockCookEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockCookEvent.java index 4a4bc9df2..10c5a14f7 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockCookEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockCookEvent.java @@ -3,34 +3,38 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.bukkit.inventory.CookingRecipe; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an ItemStack is successfully cooked in a block. */ public class BlockCookEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack source; private ItemStack result; + private final CookingRecipe recipe; + private boolean cancelled; - private final org.bukkit.inventory.CookingRecipe recipe; // Paper @Deprecated(forRemoval = true) + @ApiStatus.Internal public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result) { - // Paper start this(block, source, result, null); } @ApiStatus.Internal - public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result, @org.jetbrains.annotations.Nullable org.bukkit.inventory.CookingRecipe recipe) { - // Paper end + public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result, @Nullable CookingRecipe recipe) { super(block); this.source = source; this.result = result; this.cancelled = false; - this.recipe = recipe; // Paper + this.recipe = recipe; } /** @@ -40,7 +44,7 @@ public class BlockCookEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getSource() { - return source; + return this.source; } /** @@ -50,7 +54,7 @@ public class BlockCookEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getResult() { - return result; + return this.result; } /** @@ -62,9 +66,19 @@ public class BlockCookEvent extends BlockEvent implements Cancellable { this.result = result; } + /** + * Gets the cooking recipe associated with this event. + * + * @return the recipe + */ + @Nullable + public org.bukkit.inventory.CookingRecipe getRecipe() { + return this.recipe; + } + @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -72,26 +86,14 @@ public class BlockCookEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } - // Paper start - /** - * Gets the cooking recipe associated with this event. - * - * @return the recipe - */ - @org.jetbrains.annotations.Nullable - public org.bukkit.inventory.CookingRecipe getRecipe() { - return recipe; - } - // Paper end - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageAbortEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageAbortEvent.java index edc204b50..942e06644 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageAbortEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageAbortEvent.java @@ -8,11 +8,13 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player stops damaging a Block. + * * @see BlockDamageEvent */ public class BlockDamageAbortEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; private final ItemStack itemstack; @@ -29,7 +31,7 @@ public class BlockDamageAbortEvent extends BlockEvent { */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** @@ -39,17 +41,17 @@ public class BlockDamageAbortEvent extends BlockEvent { */ @NotNull public ItemStack getItemInHand() { - return itemstack; + return this.itemstack; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java index 392cde07d..01339ac87 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDamageEvent.java @@ -1,42 +1,46 @@ package org.bukkit.event.block; +import com.google.common.base.Preconditions; import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a block is damaged by a player. *

- * If a Block Damage event is cancelled, the block will not be damaged. + * If this event is cancelled, the block will not be damaged. + * * @see BlockDamageAbortEvent */ public class BlockDamageEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final BlockFace blockFace; + private final ItemStack itemInHand; private final Player player; private boolean instaBreak; - private boolean cancel; - private final ItemStack itemstack; - private final org.bukkit.block.BlockFace blockFace; // Paper - Expose BlockFace - // Paper start - expose blockface + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(forRemoval = true) - @io.papermc.paper.annotation.DoNotUse public BlockDamageEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final ItemStack itemInHand, final boolean instaBreak) { - this(player, block, null, itemInHand, instaBreak); // Some plugin do bad things... + this(player, block, null, itemInHand, instaBreak); } - @org.jetbrains.annotations.ApiStatus.Internal // Paper - public BlockDamageEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final org.bukkit.block.BlockFace blockFace, @NotNull final ItemStack itemInHand, final boolean instaBreak) { // Paper - Expose BlockFace + @ApiStatus.Internal + public BlockDamageEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace, @NotNull final ItemStack itemInHand, final boolean instaBreak) { // Paper - Expose BlockFace super(block); - this.blockFace = blockFace; - // Paper end - expose blockface this.instaBreak = instaBreak; + this.blockFace = blockFace; + this.itemInHand = itemInHand; this.player = player; - this.itemstack = itemInHand; - this.cancel = false; } /** @@ -46,27 +50,27 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** * Gets if the block is set to instantly break when damaged by the player. * - * @return true if the block should instantly break when damaged by the + * @return {@code true} if the block should instantly break when damaged by the * player */ public boolean getInstaBreak() { - return instaBreak; + return this.instaBreak; } /** * Sets if the block should instantly break when damaged by the player. * - * @param bool true if you want the block to instantly break when damaged + * @param instaBreak {@code true} if you want the block to instantly break when damaged * by the player */ - public void setInstaBreak(boolean bool) { - this.instaBreak = bool; + public void setInstaBreak(boolean instaBreak) { + this.instaBreak = instaBreak; } /** @@ -76,9 +80,9 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getItemInHand() { - return itemstack; + return this.itemInHand; } - // Paper start - Expose BlockFace + /** * Gets the BlockFace the player is interacting with. * @@ -86,31 +90,28 @@ public class BlockDamageEvent extends BlockEvent implements Cancellable { */ @NotNull public org.bukkit.block.BlockFace getBlockFace() { - if (this.blockFace == null) { - throw new IllegalStateException("BlockFace is not available for this event, most likely due to a bad constructor call by a plugin"); - } + Preconditions.checkState(this.blockFace != null, "BlockFace is not available for this event, most likely due to a bad constructor call by a plugin"); return this.blockFace; } - //Paper end @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java index 57b831979..1d1a5e039 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseArmorEvent.java @@ -4,19 +4,21 @@ import org.bukkit.block.Block; import org.bukkit.entity.LivingEntity; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when an equippable item is dispensed from a block and equipped on a * nearby entity. *

- * If a Block Dispense Armor event is cancelled, the equipment will not be + * If this event is cancelled, the equipment will not be * equipped on the target entity. */ public class BlockDispenseArmorEvent extends BlockDispenseEvent { private final LivingEntity target; + @ApiStatus.Internal public BlockDispenseArmorEvent(@NotNull Block block, @NotNull ItemStack dispensed, @NotNull LivingEntity target) { super(block, dispensed, new Vector(0, 0, 0)); this.target = target; @@ -29,6 +31,6 @@ public class BlockDispenseArmorEvent extends BlockDispenseEvent { */ @NotNull public LivingEntity getTargetEntity() { - return target; + return this.target; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java index e8ed75ba7..5aea3be60 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseEvent.java @@ -5,36 +5,41 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when an item is dispensed from a block. *

- * If a Block Dispense event is cancelled, the block will not dispense the + * If this event is cancelled, the block will not dispense the * item. */ public class BlockDispenseEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private ItemStack item; private Vector velocity; - public BlockDispenseEvent(@NotNull final Block block, @NotNull final ItemStack dispensed, @NotNull final Vector velocity) { + private boolean cancelled; + + @ApiStatus.Internal + public BlockDispenseEvent(@NotNull final Block block, @NotNull final ItemStack item, @NotNull final Vector velocity) { super(block); - this.item = dispensed; + this.item = item; this.velocity = velocity; } /** * Gets the item that is being dispensed. Modifying the returned item will * have no effect, you must use {@link - * #setItem(org.bukkit.inventory.ItemStack)} instead. + * #setItem(ItemStack)} instead. * * @return An ItemStack for the item being dispensed */ @NotNull public ItemStack getItem() { - return item.clone(); + return this.item.clone(); } /** @@ -50,42 +55,42 @@ public class BlockDispenseEvent extends BlockEvent implements Cancellable { * Gets the velocity in meters per tick. *

* Note: Modifying the returned Vector will not change the velocity, you - * must use {@link #setVelocity(org.bukkit.util.Vector)} instead. + * must use {@link #setVelocity(Vector)} instead. * * @return A Vector for the dispensed item's velocity */ @NotNull public Vector getVelocity() { - return velocity.clone(); + return this.velocity.clone(); } /** * Sets the velocity of the item being dispensed in meters per tick. * - * @param vel the velocity of the item being dispensed + * @param velocity the velocity of the item being dispensed */ - public void setVelocity(@NotNull Vector vel) { - velocity = vel.clone(); + public void setVelocity(@NotNull Vector velocity) { + this.velocity = velocity.clone(); } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseLootEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseLootEvent.java index 6dea23ddd..f0a66d428 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseLootEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDispenseLootEvent.java @@ -12,25 +12,28 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * Called when a block dispenses loot from its designated LootTable. This is not - * to be confused with events like {@link BlockDispenseEvent} which fires when a + * Called when a block dispenses loot from its designated LootTable. + *

+ * This is not to be confused with events like {@link BlockDispenseEvent} which fires when a * singular item is dispensed from its inventory container. - *

+ *
* Example: A player unlocks a trial chamber vault and the vault block dispenses * its loot. */ @ApiStatus.Experimental public class BlockDispenseLootEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; private List dispensedLoot; + private boolean cancelled; - public BlockDispenseLootEvent(@Nullable Player player, @NotNull Block theBlock, @NotNull List dispensedLoot) { - super(theBlock); + @ApiStatus.Internal + public BlockDispenseLootEvent(@Nullable Player player, @NotNull Block block, @NotNull List dispensedLoot) { + super(block); this.player = player; - this.block = theBlock; this.dispensedLoot = dispensedLoot; } @@ -41,7 +44,7 @@ public class BlockDispenseLootEvent extends BlockEvent implements Cancellable { */ @NotNull public List getDispensedLoot() { - return dispensedLoot; + return this.dispensedLoot; } /** @@ -50,7 +53,7 @@ public class BlockDispenseLootEvent extends BlockEvent implements Cancellable { * @param dispensedLoot new loot to dispense */ public void setDispensedLoot(@Nullable List dispensedLoot) { - this.dispensedLoot = (dispensedLoot == null) ? new ArrayList<>() : dispensedLoot; + this.dispensedLoot = dispensedLoot == null ? new ArrayList<>() : dispensedLoot; } /** @@ -58,18 +61,18 @@ public class BlockDispenseLootEvent extends BlockEvent implements Cancellable { *
* Warning: Some event instances like a * {@link org.bukkit.block.TrialSpawner} dispensing its reward loot may not - * have a player associated with them and will return null. + * have a player associated with them and will return {@code null}. * * @return the player who unlocked the vault */ @Nullable public Player getPlayer() { - return player; + return this.player; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -80,11 +83,11 @@ public class BlockDispenseLootEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java index 4c5ee91de..e3d13f6ca 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockDropItemEvent.java @@ -7,35 +7,40 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called after a block is broken by a player and potential drops are computed, even if said blocks loot table * does not define any drops at the point the event is constructed. - * + *

* If the block break is cancelled, this event won't be called. - * - * If isDropItems in {@link org.bukkit.event.block.BlockBreakEvent} is set to false, this event won't be + *

+ * If {@link BlockBreakEvent#isDropItems()} is set to {@code false}, this event won't be * called. - * - * If a block is broken and isDropItems is set to true, this event will be called even if the block does - * not drop any items, for example glass broken by hand. In this case, #getItems() will be empty. - * + *

+ * If a block is broken and {@link BlockBreakEvent#isDropItems()} is set to {@code true}, + * this event will be called even if the block does not drop any items, for example + * glass broken by hand. In this case, {@link #getItems()} will be empty. + *

* This event will also be called if the player breaks a multi block structure, - * for example a torch on top of a stone. Both items will be included in the #getItems() list. - * - * The Block is already broken as this event is called, so #getBlock() will be - * AIR in most cases. Use #getBlockState() for more Information about the broken + * for example a torch on top of a stone. Both items will be included in the {@link #getItems()} list. + *

+ * The Block is already broken as this event is called, so {@link #getBlock()} will be + * AIR in most cases. Use {@link #getBlockState()} for more Information about the broken * block. */ public class BlockDropItemEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; - private boolean cancel; private final BlockState blockState; private final List items; + private boolean cancelled; + + @ApiStatus.Internal public BlockDropItemEvent(@NotNull Block block, @NotNull BlockState blockState, @NotNull Player player, @NotNull List items) { super(block); this.blockState = blockState; @@ -43,16 +48,6 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { this.items = items; } - /** - * Gets the Player that is breaking the block involved in this event. - * - * @return The Player that is breaking the block involved in this event - */ - @NotNull - public Player getPlayer() { - return player; - } - /** * Gets the BlockState of the block involved in this event before it was * broken. @@ -61,40 +56,50 @@ public class BlockDropItemEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockState getBlockState() { - return blockState; + return this.blockState; + } + + /** + * Gets the Player that is breaking the block involved in this event. + * + * @return The Player that is breaking the block involved in this event + */ + @NotNull + public Player getPlayer() { + return this.player; } /** * Gets list of the Item drops caused by the block break. - * - * This list is mutable - removing an item from it will cause it to not + *

+ * This list is mutable: removing an item from it will cause it to not * drop. Adding to the list is allowed. * * @return The Item the block caused to drop */ @NotNull public List getItems() { - return items; + return this.items; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java index 62a4d1345..502abc885 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockEvent.java @@ -8,10 +8,11 @@ import org.jetbrains.annotations.NotNull; * Represents a block related event. */ public abstract class BlockEvent extends Event { + protected Block block; - public BlockEvent(@NotNull final Block theBlock) { - block = theBlock; + protected BlockEvent(@NotNull final Block block) { + this.block = block; } /** @@ -21,6 +22,6 @@ public abstract class BlockEvent extends Event { */ @NotNull public final Block getBlock() { - return block; + return this.block; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java index 21b902655..e6c745183 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExpEvent.java @@ -2,15 +2,19 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * An event that's called when a block yields experience. */ public class BlockExpEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private int exp; + @ApiStatus.Internal public BlockExpEvent(@NotNull Block block, int exp) { super(block); @@ -23,7 +27,7 @@ public class BlockExpEvent extends BlockEvent { * @return The experience to drop */ public int getExpToDrop() { - return exp; + return this.exp; } /** @@ -39,11 +43,11 @@ public class BlockExpEvent extends BlockEvent { @Override @NotNull public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java index 254d549f9..96444dac9 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockExplodeEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -19,32 +20,25 @@ import org.jetbrains.annotations.NotNull; * is disabled as no block interaction will occur. */ public class BlockExplodeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final BlockState blockState; private final List blocks; private float yield; private final ExplosionResult result; - public BlockExplodeEvent(@NotNull final Block what, @NotNull final BlockState blockState, @NotNull final List blocks, final float yield, @NotNull final ExplosionResult result) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public BlockExplodeEvent(@NotNull final Block block, @NotNull final BlockState blockState, @NotNull final List blocks, final float yield, @NotNull final ExplosionResult result) { + super(block); this.blockState = blockState; this.blocks = blocks; this.yield = yield; - this.cancel = false; this.result = result; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Returns the result of the explosion if it is not cancelled. * @@ -52,7 +46,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { */ @NotNull public ExplosionResult getExplosionResult() { - return result; + return this.result; } /** @@ -62,7 +56,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockState getExplodedBlockState() { - return blockState; + return this.blockState; } /** @@ -73,7 +67,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { */ @NotNull public List blockList() { - return blocks; + return this.blocks; } /** @@ -82,7 +76,7 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { * @return The yield. */ public float getYield() { - return yield; + return this.yield; } /** @@ -94,14 +88,24 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable { this.yield = yield; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java index f5a5ebb48..0cf3e6a52 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFadeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -18,18 +19,20 @@ import org.jetbrains.annotations.NotNull; *

  • Turtle Egg bursting when a turtle hatches
  • * *

    - * If a Block Fade event is cancelled, the block will not fade, melt or + * If this event is cancelled, the block will not fade, melt or * disappear. */ public class BlockFadeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final BlockState newState; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final BlockState newState; + private boolean cancelled; + + @ApiStatus.Internal public BlockFadeEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; - this.cancelled = false; } /** @@ -41,12 +44,12 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockState getNewState() { - return newState; + return this.newState; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -57,11 +60,11 @@ public class BlockFadeEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java index 695309b4b..9f8bd4095 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFertilizeEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.world.StructureGrowEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -17,14 +18,16 @@ import org.jetbrains.annotations.Nullable; */ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; private final List blocks; - public BlockFertilizeEvent(@NotNull Block theBlock, @Nullable Player player, @NotNull List blocks) { - super(theBlock); + private boolean cancelled; + + @ApiStatus.Internal + public BlockFertilizeEvent(@NotNull Block block, @Nullable Player player, @NotNull List blocks) { + super(block); this.player = player; this.blocks = blocks; } @@ -32,11 +35,11 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { /** * Gets the player that triggered the fertilization. * - * @return triggering player, or null if not applicable + * @return triggering player, or {@code null} if not applicable */ @Nullable public Player getPlayer() { - return player; + return this.player; } /** @@ -46,12 +49,12 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { */ @NotNull public List getBlocks() { - return blocks; + return this.blocks; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -62,11 +65,11 @@ public class BlockFertilizeEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java index 010678041..2e8962bbb 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFormEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -19,13 +20,15 @@ import org.jetbrains.annotations.NotNull; *

  • Concrete forming due to mixing of concrete powder and water. * *

    - * If a Block Form event is cancelled, the block will not be formed. + * If this event is cancelled, the block will not be formed. * * @see BlockSpreadEvent */ public class BlockFormEvent extends BlockGrowEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public BlockFormEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block, newState); } @@ -33,11 +36,11 @@ public class BlockFormEvent extends BlockGrowEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java index 1af392805..04922dbbb 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockFromToEvent.java @@ -4,32 +4,35 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Represents events with a source block and a destination block, currently * only applies to liquid (lava and water) and teleporting dragon eggs. *

    - * If a Block From To event is cancelled, the block will not move (the liquid + * If this event is cancelled, the block will not move (the liquid * will not flow). */ public class BlockFromToEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected Block to; protected BlockFace face; - protected boolean cancel; + protected boolean cancelled; + + @ApiStatus.Internal public BlockFromToEvent(@NotNull final Block block, @NotNull final BlockFace face) { super(block); this.face = face; - this.cancel = false; } + @ApiStatus.Internal public BlockFromToEvent(@NotNull final Block block, @NotNull final Block toBlock) { - super(block); + this(block, BlockFace.SELF); this.to = toBlock; - this.face = BlockFace.SELF; - this.cancel = false; } /** @@ -39,7 +42,7 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockFace getFace() { - return face; + return this.face; } /** @@ -49,30 +52,30 @@ public class BlockFromToEvent extends BlockEvent implements Cancellable { */ @NotNull public Block getToBlock() { - if (to == null) { - to = block.getRelative(face); + if (this.to == null) { + this.to = this.block.getRelative(this.face); } - return to; + return this.to; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java index 73d5375d2..c601fb975 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockGrowEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -19,13 +20,16 @@ import org.jetbrains.annotations.NotNull; *

  • Turtle Egg * *

    - * If a Block Grow event is cancelled, the block will not grow. + * If this event is cancelled, the block will not grow. */ public class BlockGrowEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final BlockState newState; - private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final BlockState newState; + private boolean cancelled; + + @ApiStatus.Internal public BlockGrowEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; @@ -38,12 +42,12 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockState getNewState() { - return newState; + return this.newState; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -54,11 +58,11 @@ public class BlockGrowEvent extends BlockEvent implements Cancellable { @Override @NotNull public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java index 6dcd9f828..f07183f8e 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockIgniteEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,39 +13,34 @@ import org.jetbrains.annotations.Nullable; * Called when a block is ignited. If you want to catch when a Player places * fire, you need to use {@link BlockPlaceEvent}. *

    - * If a Block Ignite event is cancelled, the block will not be ignited. + * If this event is cancelled, the block will not be ignited. */ public class BlockIgniteEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final IgniteCause cause; private final Entity ignitingEntity; private final Block ignitingBlock; - private boolean cancel; - public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity) { - this(theBlock, cause, ignitingEntity, null); + private boolean cancelled; + + @ApiStatus.Internal + public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity) { + this(block, cause, ignitingEntity, null); } - public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @NotNull final Block ignitingBlock) { - this(theBlock, cause, null, ignitingBlock); + @ApiStatus.Internal + public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @NotNull final Block ignitingBlock) { + this(block, cause, null, ignitingBlock); } - public BlockIgniteEvent(@NotNull final Block theBlock, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity, @Nullable final Block ignitingBlock) { - super(theBlock); + @ApiStatus.Internal + public BlockIgniteEvent(@NotNull final Block block, @NotNull final IgniteCause cause, @Nullable final Entity ignitingEntity, @Nullable final Block ignitingBlock) { + super(block); this.cause = cause; this.ignitingEntity = ignitingEntity; this.ignitingBlock = ignitingBlock; - this.cancel = false; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; } /** @@ -54,18 +50,18 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { */ @NotNull public IgniteCause getCause() { - return cause; + return this.cause; } /** * Gets the player who ignited this block * - * @return The Player that placed/ignited the fire block, or null if not ignited by a Player. + * @return The Player that placed/ignited the fire block, or {@code null} if not ignited by a Player. */ @Nullable public Player getPlayer() { - if (ignitingEntity instanceof Player) { - return (Player) ignitingEntity; + if (this.ignitingEntity instanceof Player) { + return (Player) this.ignitingEntity; } return null; @@ -74,21 +70,21 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { /** * Gets the entity who ignited this block * - * @return The Entity that placed/ignited the fire block, or null if not ignited by a Entity. + * @return The Entity that placed/ignited the fire block, or {@code null} if not ignited by a Entity. */ @Nullable public Entity getIgnitingEntity() { - return ignitingEntity; + return this.ignitingEntity; } /** * Gets the block which ignited this block * - * @return The Block that placed/ignited the fire block, or null if not ignited by a Block. + * @return The Block that placed/ignited the fire block, or {@code null} if not ignited by a Block. */ @Nullable public Block getIgnitingBlock() { - return ignitingBlock; + return this.ignitingBlock; } /** @@ -127,17 +123,27 @@ public class BlockIgniteEvent extends BlockEvent implements Cancellable { /** * Block ignition caused by a flaming arrow. */ - ARROW, + ARROW + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java index 72499d0ea..0df9dfa44 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockMultiPlaceEvent.java @@ -17,11 +17,12 @@ import org.jetbrains.annotations.NotNull; * block. */ public class BlockMultiPlaceEvent extends BlockPlaceEvent { + private final List states; + @ApiStatus.Internal @Deprecated(forRemoval = true) public BlockMultiPlaceEvent(@NotNull List states, @NotNull Block clicked, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild) { - // Paper start - add hand to BlockMultiPlaceEvent this(states, clicked, itemInHand, thePlayer, canBuild, org.bukkit.inventory.EquipmentSlot.HAND); } @@ -29,7 +30,6 @@ public class BlockMultiPlaceEvent extends BlockPlaceEvent { public BlockMultiPlaceEvent(@NotNull List states, @NotNull Block clicked, @NotNull ItemStack itemInHand, @NotNull Player thePlayer, boolean canBuild, @NotNull org.bukkit.inventory.EquipmentSlot hand) { super(states.get(0).getBlock(), states.get(0), clicked, itemInHand, thePlayer, canBuild, hand); this.states = ImmutableList.copyOf(states); - // Paper end } /** @@ -41,6 +41,6 @@ public class BlockMultiPlaceEvent extends BlockPlaceEvent { */ @NotNull public List getReplacedBlockStates() { - return states; + return this.states; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java index 0d52c6d04..d8465ceb2 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPhysicsEvent.java @@ -10,17 +10,17 @@ import org.jetbrains.annotations.NotNull; /** * Thrown when a block physics check is called. - *
    + *

    * This event is a high frequency event, it may be called thousands of times per * a second on a busy server. Plugins are advised to listen to the event with * caution and only perform lightweight checks when using it. - *
    + *

    * In addition to this, cancelling the event is liable to leave the world in an * inconsistent state. For example if you use the event to leave a block * floating in mid air when that block has a requirement to be attached to * something, there is no guarantee that the floating block will persist across * server restarts or map upgrades. - *
    + *

    * Plugins should also note that where possible this event may only called for * the "root" block of physics updates in order to limit event spam. Physics * updates that cause other blocks to change their state may not result in an @@ -28,17 +28,19 @@ import org.jetbrains.annotations.NotNull; * monitoring these changes then you should check adjacent blocks yourself. */ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final BlockData changed; private final Block sourceBlock; - private boolean cancel = false; - // Paper start - Legacy constructor, use #BlockPhysicsEvent(Block, BlockData, Block) + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(forRemoval = true) public BlockPhysicsEvent(final Block block, final BlockData changed, final int sourceX, final int sourceY, final int sourceZ) { this(block, changed, block.getWorld().getBlockAt(sourceX, sourceY, sourceZ)); } - // Paper end @ApiStatus.Internal public BlockPhysicsEvent(@NotNull final Block block, @NotNull final BlockData changed) { @@ -55,13 +57,12 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { /** * Gets the source block that triggered this event. * - * Note: This will default to block if not set. - * * @return The source block + * @apiNote This will default to block if not set. */ @NotNull public Block getSourceBlock() { - return sourceBlock; + return this.sourceBlock; } /** @@ -72,10 +73,9 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { */ @NotNull public Material getChangedType() { - return changed.getMaterial(); + return this.changed.getMaterial(); } - // Paper start - Getter for the BlockData /** * Gets the BlockData of the block that changed, causing this event. * This is the BlockData of {@link #getBlock()} at the time of the event. @@ -84,28 +84,27 @@ public class BlockPhysicsEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockData getChangedBlockData() { - return changed.clone(); + return this.changed.clone(); } - // Paper end @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java index 2cdf2919e..0794f5fde 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonEvent.java @@ -10,31 +10,22 @@ import org.jetbrains.annotations.NotNull; * Called when a piston block is triggered */ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable { - private boolean cancelled; - private final BlockFace direction; - public BlockPistonEvent(@NotNull final Block block, @NotNull final BlockFace direction) { + private final BlockFace direction; + private boolean cancelled; + + protected BlockPistonEvent(@NotNull final Block block, @NotNull final BlockFace direction) { super(block); this.direction = direction; } - @Override - public boolean isCancelled() { - return this.cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - /** - * Returns true if the Piston in the event is sticky. + * Returns {@code true} if the Piston in the event is sticky. * * @return stickiness of the piston */ public boolean isSticky() { - return block.getType() == Material.STICKY_PISTON || block.getType() == Material.MOVING_PISTON; + return this.block.getType() == Material.STICKY_PISTON || this.block.getType() == Material.MOVING_PISTON; } /** @@ -47,6 +38,16 @@ public abstract class BlockPistonEvent extends BlockEvent implements Cancellable // Both are meh! // return ((PistonBaseMaterial) block.getType().getNewData(block.getData())).getFacing(); // return ((PistonBaseMaterial) block.getState().getData()).getFacing(); - return direction; + return this.direction; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java index 202f0a556..b880a10bb 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonExtendEvent.java @@ -8,15 +8,19 @@ import org.bukkit.block.BlockFace; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; /** * Called when a piston extends */ public class BlockPistonExtendEvent extends BlockPistonEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final int length; private List blocks; + @ApiStatus.Internal @Deprecated(since = "1.8", forRemoval = true) public BlockPistonExtendEvent(@NotNull final Block block, final int length, @NotNull final BlockFace direction) { super(block, direction); @@ -51,25 +55,26 @@ public class BlockPistonExtendEvent extends BlockPistonEvent { * @return Immutable list of the moved blocks. */ @NotNull + @Unmodifiable public List getBlocks() { - if (blocks == null) { - List tmp = new ArrayList(); - for (int i = 0; i < this.getLength(); i++) { - tmp.add(block.getRelative(getDirection(), i + 1)); + if (this.blocks == null) { + List tmp = new ArrayList<>(); + for (int i = 0; i < this.length; i++) { + tmp.add(this.block.getRelative(getDirection(), i + 1)); } - blocks = Collections.unmodifiableList(tmp); + this.blocks = Collections.unmodifiableList(tmp); } - return blocks; + return this.blocks; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java index 23b3f44ab..1b773d438 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPistonRetractEvent.java @@ -5,15 +5,20 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; /** * Called when a piston retracts */ public class BlockPistonRetractEvent extends BlockPistonEvent { - private static final HandlerList handlers = new HandlerList(); - private List blocks; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final List blocks; + + @ApiStatus.Internal public BlockPistonRetractEvent(@NotNull final Block block, @NotNull final List blocks, @NotNull final BlockFace direction) { super(block, direction); @@ -29,7 +34,7 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { @Deprecated(since = "1.8") @NotNull public Location getRetractLocation() { - return getBlock().getRelative(getDirection(), 2).getLocation(); + return this.getBlock().getRelative(getDirection(), 2).getLocation(); } /** @@ -39,18 +44,19 @@ public class BlockPistonRetractEvent extends BlockPistonEvent { * @return Immutable list of the moved blocks. */ @NotNull + @Unmodifiable public List getBlocks() { - return blocks; + return this.blocks; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java index fec0191ad..81dd17b03 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockPlaceEvent.java @@ -13,18 +13,22 @@ import org.jetbrains.annotations.NotNull; /** * Called when a block is placed by a player. *

    - * If a Block Place event is cancelled, the block will not be placed. + * If this event is cancelled, the block will not be placed. */ public class BlockPlaceEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - protected boolean cancel; - protected boolean canBuild; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected Block placedAgainst; - protected BlockState replacedBlockState; protected ItemStack itemInHand; protected Player player; + protected BlockState replacedBlockState; + protected boolean canBuild; protected EquipmentSlot hand; + protected boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.9", forRemoval = true) public BlockPlaceEvent(@NotNull final Block placedBlock, @NotNull final BlockState replacedBlockState, @NotNull final Block placedAgainst, @NotNull final ItemStack itemInHand, @NotNull final Player thePlayer, final boolean canBuild) { this(placedBlock, replacedBlockState, placedAgainst, itemInHand, thePlayer, canBuild, EquipmentSlot.HAND); @@ -39,17 +43,27 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { this.replacedBlockState = replacedBlockState; this.canBuild = canBuild; this.hand = hand; - cancel = false; } - @Override - public boolean isCancelled() { - return cancel; + /** + * Gets the block that this block was placed against + * + * @return Block the block that the new block was placed against + */ + @NotNull + public Block getBlockAgainst() { + return this.placedAgainst; } - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + /** + * Gets the item in the player's hand when they placed the block. + * + * @return The ItemStack for the item in the player's hand when they + * placed the block + */ + @NotNull + public ItemStack getItemInHand() { + return this.itemInHand; } /** @@ -59,7 +73,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** @@ -70,7 +84,7 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { */ @NotNull public Block getBlockPlaced() { - return getBlock(); + return this.getBlock(); } /** @@ -84,39 +98,9 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { return this.replacedBlockState; } - /** - * Gets the block that this block was placed against - * - * @return Block the block that the new block was placed against - */ - @NotNull - public Block getBlockAgainst() { - return placedAgainst; - } - - /** - * Gets the item in the player's hand when they placed the block. - * - * @return The ItemStack for the item in the player's hand when they - * placed the block - */ - @NotNull - public ItemStack getItemInHand() { - return itemInHand; - } - - /** - * Gets the hand which placed the block - * @return Main or off-hand, depending on which hand was used to place the block - */ - @NotNull - public EquipmentSlot getHand() { - return this.hand; - } - /** * Gets the value whether the player would be allowed to build here. - * Defaults to false if the server was going to stop them (such as, the + * Defaults to {@code false} if the server was going to stop them (such as, the * player is in Spawn). Note that this is an entirely different check * than BLOCK_CANBUILD, as this refers to a player, not universe-physics * rule like cactus on dirt. @@ -128,23 +112,42 @@ public class BlockPlaceEvent extends BlockEvent implements Cancellable { } /** - * Sets the canBuild state of this event. Set to true if you want the + * Sets the canBuild state of this event. Set to {@code true} if you want the * player to be able to build. * - * @param canBuild true if you want the player to be able to build + * @param canBuild {@code true} if you want the player to be able to build */ public void setBuild(boolean canBuild) { this.canBuild = canBuild; } + /** + * Gets the hand which placed the block + * @return Main or off-hand, depending on which hand was used to place the block + */ + @NotNull + public EquipmentSlot getHand() { + return this.hand; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockReceiveGameEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockReceiveGameEvent.java index e226d1306..80c4e6eed 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockReceiveGameEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockReceiveGameEvent.java @@ -5,22 +5,26 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Called when a Sculk sensor receives a game event and hence might activate. - * + *
    * Will be called cancelled if the block's default behavior is to ignore the * event. */ public class BlockReceiveGameEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final GameEvent event; private final Entity entity; + private boolean cancelled; + @ApiStatus.Internal public BlockReceiveGameEvent(@NotNull GameEvent event, @NotNull Block block, @Nullable Entity entity) { super(block); this.event = event; @@ -34,17 +38,17 @@ public class BlockReceiveGameEvent extends BlockEvent implements Cancellable { */ @NotNull public GameEvent getEvent() { - return event; + return this.event; } /** * Get the entity which triggered this event, if present. * - * @return triggering entity or null + * @return triggering entity or {@code null} */ @Nullable public Entity getEntity() { - return entity; + return this.entity; } @Override @@ -54,17 +58,17 @@ public class BlockReceiveGameEvent extends BlockEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java index e46419b8c..bfc06ccdc 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockRedstoneEvent.java @@ -2,16 +2,20 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a redstone current changes */ public class BlockRedstoneEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final int oldCurrent; private int newCurrent; + @ApiStatus.Internal public BlockRedstoneEvent(@NotNull final Block block, final int oldCurrent, final int newCurrent) { super(block); this.oldCurrent = oldCurrent; @@ -24,7 +28,7 @@ public class BlockRedstoneEvent extends BlockEvent { * @return The previous current */ public int getOldCurrent() { - return oldCurrent; + return this.oldCurrent; } /** @@ -33,7 +37,7 @@ public class BlockRedstoneEvent extends BlockEvent { * @return The new current */ public int getNewCurrent() { - return newCurrent; + return this.newCurrent; } /** @@ -48,11 +52,11 @@ public class BlockRedstoneEvent extends BlockEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java index 610768bd3..d1846993a 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockShearEntityEvent.java @@ -5,26 +5,31 @@ import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; +import java.util.Collections; +import java.util.List; /** * Event fired when a dispenser shears a nearby sheep. */ public class BlockShearEntityEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity sheared; private final ItemStack tool; - private boolean cancelled; - private java.util.List drops; // Paper + private List drops; - @org.jetbrains.annotations.ApiStatus.Internal // Paper - public BlockShearEntityEvent(@NotNull Block dispenser, @NotNull Entity sheared, @NotNull ItemStack tool, final @NotNull java.util.List drops) { // Paper - custom shear drops + private boolean cancelled; + + @ApiStatus.Internal + public BlockShearEntityEvent(@NotNull Block dispenser, @NotNull Entity sheared, @NotNull ItemStack tool, final @NotNull List drops) { super(dispenser); this.sheared = sheared; this.tool = tool; - this.drops = drops; // Paper + this.drops = drops; } /** @@ -34,7 +39,7 @@ public class BlockShearEntityEvent extends BlockEvent implements Cancellable { */ @NotNull public Entity getEntity() { - return sheared; + return this.sheared; } /** @@ -44,12 +49,31 @@ public class BlockShearEntityEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getTool() { - return tool.clone(); + return this.tool.clone(); + } + + /** + * Get an immutable list of drops for this shearing. + * + * @return the shearing drops + * @see #setDrops(List) + */ + public @NotNull @Unmodifiable List getDrops() { + return Collections.unmodifiableList(this.drops); + } + + /** + * Sets the drops for the shearing. + * + * @param drops the shear drops + */ + public void setDrops(final @NotNull List drops) { + this.drops = List.copyOf(drops); } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -60,31 +84,11 @@ public class BlockShearEntityEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } - // Paper start - custom shear drops - /** - * Get an immutable list of drops for this shearing. - * - * @return the shearing drops - * @see #setDrops(java.util.List) - */ - public java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List getDrops() { - return java.util.Collections.unmodifiableList(this.drops); - } - - /** - * Sets the drops for the shearing. - * - * @param drops the shear drops - */ - public void setDrops(final java.util.@NotNull List drops) { - this.drops = java.util.List.copyOf(drops); - } - // Paper end - custom shear drops } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java index e9239caec..210710453 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BlockSpreadEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -17,14 +18,17 @@ import org.jetbrains.annotations.NotNull; *

  • Fire spreading. * *

    - * If a Block Spread event is cancelled, the block will not spread. + * If this event is cancelled, the block will not spread. * * @see BlockFormEvent */ public class BlockSpreadEvent extends BlockFormEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block source; + @ApiStatus.Internal public BlockSpreadEvent(@NotNull final Block block, @NotNull final Block source, @NotNull final BlockState newState) { super(block, newState); this.source = source; @@ -37,17 +41,17 @@ public class BlockSpreadEvent extends BlockFormEvent { */ @NotNull public Block getSource() { - return source; + return this.source; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/BrewingStartEvent.java b/paper-api/src/main/java/org/bukkit/event/block/BrewingStartEvent.java index f193ab698..6c020d5ea 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/BrewingStartEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/BrewingStartEvent.java @@ -1,21 +1,22 @@ package org.bukkit.event.block; +import com.google.common.base.Preconditions; import org.bukkit.block.Block; -import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Range; /** * Called when a brewing stand starts to brew. */ -@org.jetbrains.annotations.ApiStatus.Experimental // Paper +@ApiStatus.Experimental // Paper public class BrewingStartEvent extends InventoryBlockStartEvent { - // Paper - remove HandlerList private int brewingTime; - private int recipeBrewTime = 400; // Paper - Add recipeBrewTime + private int recipeBrewTime = 400; - @org.jetbrains.annotations.ApiStatus.Internal // Paper + @ApiStatus.Internal public BrewingStartEvent(@NotNull final Block furnace, @NotNull ItemStack source, int brewingTime) { super(furnace, source); this.brewingTime = brewingTime; @@ -29,7 +30,7 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { */ @Deprecated(since = "1.21", forRemoval = true) // Paper public int getTotalBrewTime() { - return brewingTime; + return this.brewingTime; } /** @@ -40,12 +41,9 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { */ @Deprecated(since = "1.21", forRemoval = true) // Paper public void setTotalBrewTime(int brewTime) { - this.setBrewingTime(brewTime); // Paper - delegate to new method + this.setBrewingTime(brewTime); } - // Paper - remove HandlerList - - // Paper start - add recipeBrewTime /** * Gets the recipe time for the brewing process which is * used to compute the progress of the brewing process with @@ -53,8 +51,8 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { * * @return recipe brew time (in ticks) */ - @org.jetbrains.annotations.ApiStatus.Experimental - public @org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int getRecipeBrewTime() { + @ApiStatus.Experimental + public @Range(from = 1, to = Integer.MAX_VALUE) int getRecipeBrewTime() { return this.recipeBrewTime; } @@ -66,9 +64,9 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { * @param recipeBrewTime recipe brew time (in ticks) * @throws IllegalArgumentException if the recipe brew time is non-positive */ - @org.jetbrains.annotations.ApiStatus.Experimental - public void setRecipeBrewTime(@org.jetbrains.annotations.Range(from = 1, to = Integer.MAX_VALUE) int recipeBrewTime) { - com.google.common.base.Preconditions.checkArgument(recipeBrewTime > 0, "recipeBrewTime must be positive"); + @ApiStatus.Experimental + public void setRecipeBrewTime(@Range(from = 1, to = Integer.MAX_VALUE) int recipeBrewTime) { + Preconditions.checkArgument(recipeBrewTime > 0, "recipeBrewTime must be positive"); this.recipeBrewTime = recipeBrewTime; } @@ -77,7 +75,7 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { * * @return The amount of ticks left for the brewing task */ - public @org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int getBrewingTime() { + public @Range(from = 0, to = Integer.MAX_VALUE) int getBrewingTime() { return this.brewingTime; } @@ -87,9 +85,8 @@ public class BrewingStartEvent extends InventoryBlockStartEvent { * @param brewTime the ticks left, which is no less than 0 * @throws IllegalArgumentException if the ticks are less than 0 */ - public void setBrewingTime(@org.jetbrains.annotations.Range(from = 0, to = Integer.MAX_VALUE) int brewTime) { - com.google.common.base.Preconditions.checkArgument(brewTime >= 0, "brewTime must be non-negative"); + public void setBrewingTime(@Range(from = 0, to = Integer.MAX_VALUE) int brewTime) { + Preconditions.checkArgument(brewTime >= 0, "brewTime must be non-negative"); this.brewingTime = brewTime; } - // Paper end - add recipeBrewTime } diff --git a/paper-api/src/main/java/org/bukkit/event/block/CampfireStartEvent.java b/paper-api/src/main/java/org/bukkit/event/block/CampfireStartEvent.java index 4b1257510..2f14d4188 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/CampfireStartEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/CampfireStartEvent.java @@ -1,21 +1,21 @@ package org.bukkit.event.block; import org.bukkit.block.Block; -import org.bukkit.event.HandlerList; import org.bukkit.inventory.CampfireRecipe; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a Campfire starts to cook. */ -@org.jetbrains.annotations.ApiStatus.Experimental // Paper +@ApiStatus.Experimental // Paper public class CampfireStartEvent extends InventoryBlockStartEvent { - // Paper - remove HandlerList + private final CampfireRecipe campfireRecipe; private int cookingTime; - private CampfireRecipe campfireRecipe; + @ApiStatus.Internal public CampfireStartEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull CampfireRecipe recipe) { super(furnace, source); this.cookingTime = recipe.getCookingTime(); @@ -29,7 +29,7 @@ public class CampfireStartEvent extends InventoryBlockStartEvent { */ @NotNull public CampfireRecipe getRecipe() { - return campfireRecipe; + return this.campfireRecipe; } /** @@ -38,7 +38,7 @@ public class CampfireStartEvent extends InventoryBlockStartEvent { * @return the total cook time */ public int getTotalCookTime() { - return cookingTime; + return this.cookingTime; } /** @@ -49,6 +49,4 @@ public class CampfireStartEvent extends InventoryBlockStartEvent { public void setTotalCookTime(int cookTime) { this.cookingTime = cookTime; } - - // Paper - remove HandlerList } diff --git a/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java index 2b7d9b1e9..4dc638d5f 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/CauldronLevelChangeEvent.java @@ -9,18 +9,21 @@ import org.bukkit.block.data.Levelled; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity entity; private final ChangeReason reason; private final BlockState newState; + private boolean cancelled; + + @ApiStatus.Internal public CauldronLevelChangeEvent(@NotNull Block block, @Nullable Entity entity, @NotNull ChangeReason reason, @NotNull BlockState newBlock) { super(block); this.entity = entity; @@ -29,18 +32,18 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable } /** - * Get entity which did this. May be null. + * Get entity which did this. May be {@code null}. * * @return acting entity */ @Nullable public Entity getEntity() { - return entity; + return this.entity; } @NotNull public ChangeReason getReason() { - return reason; + return this.reason; } /** @@ -50,7 +53,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable */ @NotNull public BlockState getNewState() { - return newState; + return this.newState; } /** @@ -62,7 +65,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable */ @Deprecated(since = "1.17") public int getOldLevel() { - BlockData oldBlock = getBlock().getBlockData(); + BlockData oldBlock = this.getBlock().getBlockData(); return (oldBlock instanceof Levelled) ? ((Levelled) oldBlock).getLevel() : ((oldBlock.getMaterial() == Material.CAULDRON) ? 0 : 3); } @@ -75,7 +78,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable */ @Deprecated(since = "1.17") public int getNewLevel() { - BlockData newBlock = newState.getBlockData(); + BlockData newBlock = this.newState.getBlockData(); return (newBlock instanceof Levelled) ? ((Levelled) newBlock).getLevel() : ((newBlock.getMaterial() == Material.CAULDRON) ? 0 : 3); } @@ -90,9 +93,9 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable public void setNewLevel(int newLevel) { Preconditions.checkArgument(0 <= newLevel && newLevel <= 3, "Cauldron level out of bounds 0 <= %s <= 3", newLevel); if (newLevel == 0) { - newState.setType(Material.CAULDRON); - } else if (newState.getBlockData() instanceof Levelled) { - ((Levelled) newState.getBlockData()).setLevel(newLevel); + this.newState.setType(Material.CAULDRON); + } else if (this.newState.getBlockData() instanceof Levelled) { + ((Levelled) this.newState.getBlockData()).setLevel(newLevel); } else { // Error, non-levellable block } @@ -100,7 +103,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -111,12 +114,12 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum ChangeReason { @@ -157,7 +160,7 @@ public class CauldronLevelChangeEvent extends BlockEvent implements Cancellable */ EVAPORATE, /** - * Filling due to natural fluid sources, eg rain or dripstone. + * Filling due to natural fluid sources, e.g. rain or dripstone. */ NATURAL_FILL, /** diff --git a/paper-api/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java b/paper-api/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java index 3d6c0ecc7..8bac7eb37 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/CrafterCraftEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.CraftingRecipe; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,14 +13,16 @@ import org.jetbrains.annotations.NotNull; */ public class CrafterCraftEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final CraftingRecipe recipe; private ItemStack result; + private boolean cancelled; - @org.jetbrains.annotations.ApiStatus.Internal // Paper - fix upstream annotation mistakes - public CrafterCraftEvent(@NotNull Block theBlock, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) { - super(theBlock); + @ApiStatus.Internal + public CrafterCraftEvent(@NotNull Block crafter, @NotNull CraftingRecipe recipe, @NotNull ItemStack result) { + super(crafter); this.result = result; this.recipe = recipe; } @@ -31,7 +34,7 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getResult() { - return result.clone(); + return this.result.clone(); } /** @@ -50,12 +53,12 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable { */ @NotNull public CraftingRecipe getRecipe() { - return recipe; + return this.recipe; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -66,11 +69,11 @@ public class CrafterCraftEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java b/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java index 3baed1c43..282a4849d 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/EntityBlockFormEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,8 +16,10 @@ import org.jetbrains.annotations.NotNull; * */ public class EntityBlockFormEvent extends BlockFormEvent { + private final Entity entity; + @ApiStatus.Internal public EntityBlockFormEvent(@NotNull final Entity entity, @NotNull final Block block, @NotNull final BlockState blockstate) { super(block, blockstate); @@ -30,6 +33,6 @@ public class EntityBlockFormEvent extends BlockFormEvent { */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java index c61f6b1bd..3fbdc4da0 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/FluidLevelChangeEvent.java @@ -5,6 +5,7 @@ import org.bukkit.block.Block; import org.bukkit.block.data.BlockData; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,13 +14,14 @@ import org.jetbrains.annotations.NotNull; */ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - // - private BlockData newData; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public FluidLevelChangeEvent(@NotNull Block theBlock, @NotNull BlockData newData) { - super(theBlock); + private BlockData newData; + private boolean cancelled; + + @ApiStatus.Internal + public FluidLevelChangeEvent(@NotNull Block fluid, @NotNull BlockData newData) { + super(fluid); this.newData = newData; } @@ -30,7 +32,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockData getNewData() { - return newData; + return this.newData; } /** @@ -48,7 +50,7 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -59,11 +61,11 @@ public class FluidLevelChangeEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/InventoryBlockStartEvent.java b/paper-api/src/main/java/org/bukkit/event/block/InventoryBlockStartEvent.java index b70450919..a96ce7ebd 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/InventoryBlockStartEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/InventoryBlockStartEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.FurnaceStartSmeltEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,9 +17,11 @@ import org.jetbrains.annotations.NotNull; */ public class InventoryBlockStartEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); - protected ItemStack source; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected ItemStack source; + + @ApiStatus.Internal public InventoryBlockStartEvent(@NotNull final Block block, @NotNull ItemStack source) { super(block); this.source = source; @@ -31,17 +34,17 @@ public class InventoryBlockStartEvent extends BlockEvent { */ @NotNull public ItemStack getSource() { - return source; + return this.source; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java index c33f9cb80..54b3d2d3d 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/LeavesDecayEvent.java @@ -3,39 +3,43 @@ package org.bukkit.event.block; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when leaves are decaying naturally. *

    - * If a Leaves Decay event is cancelled, the leaves will not decay. + * If this event is cancelled, the leaves will not decay. */ public class LeavesDecayEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private boolean cancelled; + + @ApiStatus.Internal public LeavesDecayEvent(@NotNull final Block block) { super(block); } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java index bf5de52e7..cb7c6be14 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/MoistureChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,10 +12,12 @@ import org.jetbrains.annotations.NotNull; */ public class MoistureChangeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final BlockState newState; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final BlockState newState; + private boolean cancelled; + + @ApiStatus.Internal public MoistureChangeEvent(@NotNull final Block block, @NotNull final BlockState newState) { super(block); this.newState = newState; @@ -28,12 +31,12 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable { */ @NotNull public BlockState getNewState() { - return newState; + return this.newState; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -44,11 +47,11 @@ public class MoistureChangeEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java index ea7cb75ba..d92e1db6c 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/NotePlayEvent.java @@ -1,10 +1,12 @@ package org.bukkit.event.block; +import com.google.common.base.Preconditions; import org.bukkit.Instrument; import org.bukkit.Note; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,17 +15,64 @@ import org.jetbrains.annotations.NotNull; */ public class NotePlayEvent extends BlockEvent implements Cancellable { - private static HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Instrument instrument; private Note note; - private boolean cancelled = false; + private boolean cancelled; + + @ApiStatus.Internal public NotePlayEvent(@NotNull Block block, @NotNull Instrument instrument, @NotNull Note note) { super(block); this.instrument = instrument; this.note = note; } + /** + * Gets the {@link Instrument} to be used. + * + * @return the Instrument + */ + @NotNull + public Instrument getInstrument() { + return this.instrument; + } + + /** + * Gets the {@link Note} to be played. + * + * @return the Note + */ + @NotNull + public Note getNote() { + return this.note; + } + + /** + * Overrides the {@link Instrument} to be used. + *

    + * Only works when the note block isn't under a player head. + * For this specific case the 'note_block_sound' property of the + * player head state takes the priority. + * + * @param instrument the Instrument. + */ + public void setInstrument(@NotNull Instrument instrument) { + Preconditions.checkArgument(instrument != null, "instrument cannot be null"); + this.instrument = instrument; + } + + /** + * Overrides the {@link Note} to be played. + * + * @param note the Note. + */ + public void setNote(@NotNull Note note) { + Preconditions.checkArgument(note != null, "note cannot be null"); + this.note = note; + } + @Override public boolean isCancelled() { return cancelled; @@ -34,60 +83,14 @@ public class NotePlayEvent extends BlockEvent implements Cancellable { this.cancelled = cancel; } - /** - * Gets the {@link Instrument} to be used. - * - * @return the Instrument - */ - @NotNull - public Instrument getInstrument() { - return instrument; - } - - /** - * Gets the {@link Note} to be played. - * - * @return the Note - */ - @NotNull - public Note getNote() { - return note; - } - - /** - * Overrides the {@link Instrument} to be used. - *

    - * Only works when the note block isn't under a player head. - * For this specific case the 'note_block_sound' property of the - * player head state takes the priority. - * - * @param instrument the Instrument. Has no effect if null. - */ - public void setInstrument(@NotNull Instrument instrument) { - if (instrument != null) { - this.instrument = instrument; - } - } - - /** - * Overrides the {@link Note} to be played. - * - * @param note the Note. Has no effect if null. - */ - public void setNote(@NotNull Note note) { - if (note != null) { - this.note = note; - } - } - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SculkBloomEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SculkBloomEvent.java index def800141..3f5e85e56 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SculkBloomEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SculkBloomEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.SculkCatalyst; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDeathEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -27,13 +28,14 @@ import org.jetbrains.annotations.NotNull; */ public class SculkBloomEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); private int charge; + private boolean cancelled; - public SculkBloomEvent(@NotNull Block theBlock, int charge) { - super(theBlock); + @ApiStatus.Internal + public SculkBloomEvent(@NotNull Block block, int charge) { + super(block); this.charge = charge; } @@ -43,7 +45,7 @@ public class SculkBloomEvent extends BlockEvent implements Cancellable { * @return the charge of the cursor */ public int getCharge() { - return charge; + return this.charge; } /** @@ -67,22 +69,22 @@ public class SculkBloomEvent extends BlockEvent implements Cancellable { @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java index a61537af6..f092b9c6c 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SignChangeEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.block; +import net.kyori.adventure.text.Component; import org.bukkit.block.Block; import org.bukkit.block.sign.Side; import org.bukkit.entity.Player; @@ -8,49 +9,52 @@ import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.List; /** * Called when a sign is changed by a player. *

    - * If a Sign Change event is cancelled, the sign will not be changed. + * If this event is cancelled, the sign will not be changed. */ public class SignChangeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; - private final java.util.List adventure$lines; // Paper + private final List adventure$lines; private final Side side; - // Paper start + private boolean cancelled; + @ApiStatus.Internal - public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List adventure$lines, @NotNull Side side) { - super(theBlock); + public SignChangeEvent(@NotNull final Block sign, @NotNull final Player player, @NotNull final java.util.List adventure$lines, @NotNull Side side) { + super(sign); this.player = player; this.adventure$lines = adventure$lines; this.side = side; } + @ApiStatus.Internal @Deprecated(forRemoval = true) - public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player player, @NotNull final java.util.List adventure$lines) { - this(theBlock, player, adventure$lines, Side.FRONT); + public SignChangeEvent(@NotNull final Block sign, @NotNull final Player player, @NotNull final java.util.List adventure$lines) { + this(sign, player, adventure$lines, Side.FRONT); } - // Paper end + @ApiStatus.Internal @Deprecated(since = "1.19.4", forRemoval = true) - public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines) { - this(theBlock, thePlayer, theLines, Side.FRONT); + public SignChangeEvent(@NotNull final Block sign, @NotNull final Player thePlayer, @NotNull final String[] theLines) { + this(sign, thePlayer, theLines, Side.FRONT); } + @ApiStatus.Internal @Deprecated(forRemoval = true) - public SignChangeEvent(@NotNull final Block theBlock, @NotNull final Player thePlayer, @NotNull final String[] theLines, @NotNull Side side) { - super(theBlock); + public SignChangeEvent(@NotNull final Block sign, @NotNull final Player thePlayer, @NotNull final String[] theLines, @NotNull Side side) { + super(sign); this.player = thePlayer; - // Paper start this.adventure$lines = new java.util.ArrayList<>(); for (String theLine : theLines) { this.adventure$lines.add(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(theLine)); } - // Paper end this.side = side; } @@ -61,10 +65,9 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { */ @NotNull public Player getPlayer() { - return player; + return this.player; } - // Paper start /** * Gets all of the lines of text from the sign involved in this event. * @@ -98,7 +101,6 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { public void line(int index, net.kyori.adventure.text.@Nullable Component line) throws IndexOutOfBoundsException { this.adventure$lines.set(index, line); } - // Paper end /** * Gets all of the lines of text from the sign involved in this event. @@ -109,7 +111,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { @NotNull @Deprecated // Paper public String[] getLines() { - return adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper + return this.adventure$lines.stream().map(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection()::serialize).toArray(String[]::new); // Paper } /** @@ -139,7 +141,7 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { */ @Deprecated // Paper public void setLine(int index, @Nullable String line) throws IndexOutOfBoundsException { - adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper + this.adventure$lines.set(index, line != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(line) : null); // Paper } /** @@ -149,27 +151,27 @@ public class SignChangeEvent extends BlockEvent implements Cancellable { */ @NotNull public Side getSide() { - return side; + return this.side; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java b/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java index 7029cfcd0..ae56902a8 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/SpongeAbsorbEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -19,10 +20,12 @@ import org.jetbrains.annotations.NotNull; */ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final List blocks; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List blocks; + private boolean cancelled; + + @ApiStatus.Internal public SpongeAbsorbEvent(@NotNull Block block, @NotNull List waterblocks) { super(block); this.blocks = waterblocks; @@ -38,12 +41,12 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { */ @NotNull public List getBlocks() { - return blocks; + return this.blocks; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -54,11 +57,11 @@ public class SpongeAbsorbEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/block/TNTPrimeEvent.java b/paper-api/src/main/java/org/bukkit/event/block/TNTPrimeEvent.java index 3e6a48029..89cf2d1e2 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/TNTPrimeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/TNTPrimeEvent.java @@ -4,22 +4,26 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Called when a block of TNT in the world become primed. *

    - * If a TNT Prime event is cancelled, the block of TNT will not become primed. + * If this event is cancelled, the block of TNT will not become primed. */ public class TNTPrimeEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final PrimeCause igniteCause; private final Entity primingEntity; private final Block primingBlock; + private boolean cancelled; + + @ApiStatus.Internal public TNTPrimeEvent(@NotNull final Block block, @NotNull final PrimeCause igniteCause, @Nullable final Entity primingEntity, @Nullable final Block primingBlock) { super(block); this.igniteCause = igniteCause; @@ -27,16 +31,6 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable { this.primingBlock = primingBlock; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - /** * Get the cause of the TNT becoming primed. * @@ -44,40 +38,50 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable { */ @NotNull public PrimeCause getCause() { - return igniteCause; + return this.igniteCause; } /** * Get the entity that caused the TNT to be primed. * - * @return the entity that caused the TNT to be primed, or null if it was + * @return the entity that caused the TNT to be primed, or {@code null} if it was * not caused by an entity. */ @Nullable public Entity getPrimingEntity() { - return primingEntity; + return this.primingEntity; } /** * Get the block that caused the TNT to be primed. * - * @return the block that caused the TNT to be primed, or null if it was not + * @return the block that caused the TNT to be primed, or {@code null} if it was not * caused by a block. */ @Nullable public Block getPrimingBlock() { - return primingBlock; + return this.primingBlock; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -106,7 +110,7 @@ public class TNTPrimeEvent extends BlockEvent implements Cancellable { */ PROJECTILE, /** - * When TNT with the unstable block state set to true is broken. + * When TNT with the unstable block state set to {@code true} is broken. *

    * Note: Canceling a prime event with this cause will stop the primed * TNT from spawning but will not stop the block from being broken. diff --git a/paper-api/src/main/java/org/bukkit/event/block/VaultDisplayItemEvent.java b/paper-api/src/main/java/org/bukkit/event/block/VaultDisplayItemEvent.java index cc06af61d..825f9003b 100644 --- a/paper-api/src/main/java/org/bukkit/event/block/VaultDisplayItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/block/VaultDisplayItemEvent.java @@ -14,12 +14,14 @@ import org.jetbrains.annotations.Nullable; @ApiStatus.Experimental public class VaultDisplayItemEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private ItemStack displayItem; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public VaultDisplayItemEvent(@NotNull Block theBlock, @Nullable ItemStack displayItem) { - super(theBlock); + private ItemStack displayItem; + private boolean cancelled; + + @ApiStatus.Internal + public VaultDisplayItemEvent(@NotNull Block vault, @Nullable ItemStack displayItem) { + super(vault); this.displayItem = displayItem; } @@ -30,7 +32,7 @@ public class VaultDisplayItemEvent extends BlockEvent implements Cancellable { */ @Nullable public ItemStack getDisplayItem() { - return displayItem; + return this.displayItem; } /** @@ -44,7 +46,7 @@ public class VaultDisplayItemEvent extends BlockEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -55,11 +57,11 @@ public class VaultDisplayItemEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java index e7c243038..5430e5e19 100644 --- a/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/enchantment/EnchantItemEvent.java @@ -11,6 +11,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -18,28 +19,31 @@ import org.jetbrains.annotations.NotNull; * enchantment table) */ public class EnchantItemEvent extends InventoryEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Player enchanter; private final Block table; - private ItemStack item; // Paper + private ItemStack item; private int level; - private boolean cancelled; private final Map enchants; private final Enchantment enchantmentHint; private final int levelHint; - private final Player enchanter; private final int button; - public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, @NotNull final Enchantment enchantmentHint, final int levelHint, final int i) { + private boolean cancelled; + + @ApiStatus.Internal + public EnchantItemEvent(@NotNull final Player enchanter, @NotNull final InventoryView view, @NotNull final Block table, @NotNull final ItemStack item, final int level, @NotNull final Map enchants, @NotNull final Enchantment enchantmentHint, final int levelHint, final int button) { super(view); this.enchanter = enchanter; this.table = table; this.item = item; this.level = level; - this.enchants = new HashMap(enchants); + this.enchants = new HashMap<>(enchants); this.enchantmentHint = enchantmentHint; this.levelHint = levelHint; - this.cancelled = false; - this.button = i; + this.button = button; } /** @@ -49,7 +53,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { */ @NotNull public Player getEnchanter() { - return enchanter; + return this.enchanter; } /** @@ -59,7 +63,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { */ @NotNull public Block getEnchantBlock() { - return table; + return this.table; } /** @@ -69,19 +73,15 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { */ @NotNull public ItemStack getItem() { - return item; + return this.item; } - // Paper start /** * Sets the item to be enchanted - * - * @param item item */ public void setItem(@NotNull final ItemStack item) { this.item = item; } - // Paper end /** * Gets the cost (minimum level) which is displayed as a number on the right @@ -90,14 +90,14 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * @return experience level cost */ public int getExpLevelCost() { - return level; + return this.level; } /** * Sets the cost (minimum level) which is displayed as a number on the right * hand side of the enchantment offer. * - * @param level - cost in levels + * @param level cost in levels */ public void setExpLevelCost(int level) { Preconditions.checkArgument(level > 0, "The cost must be greater than 0!"); @@ -114,7 +114,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { */ @NotNull public Map getEnchantsToAdd() { - return enchants; + return this.enchants; } /** @@ -125,7 +125,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { */ @NotNull public Enchantment getEnchantmentHint() { - return enchantmentHint; + return this.enchantmentHint; } /** @@ -135,7 +135,7 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * @return the level of the hinted enchantment */ public int getLevelHint() { - return levelHint; + return this.levelHint; } /** @@ -144,12 +144,12 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { * @return The button index (0, 1, or 2). */ public int whichButton() { - return button; + return this.button; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -160,11 +160,11 @@ public class EnchantItemEvent extends InventoryEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java b/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java index 5a56eeb4b..4627f5144 100644 --- a/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/enchantment/PrepareItemEnchantEvent.java @@ -8,21 +8,27 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.inventory.InventoryEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.view.EnchantmentView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an ItemStack is inserted in an enchantment table - can be * called multiple times */ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Player enchanter; private final Block table; private final ItemStack item; private final EnchantmentOffer[] offers; private final int bonus; - private boolean cancelled; - private final Player enchanter; + private boolean cancelled; + + @ApiStatus.Internal public PrepareItemEnchantEvent(@NotNull final Player enchanter, @NotNull EnchantmentView view, @NotNull final Block table, @NotNull final ItemStack item, @org.jetbrains.annotations.Nullable final EnchantmentOffer @NotNull [] offers, final int bonus) { // Paper - offers can contain null values super(view); this.enchanter = enchanter; @@ -32,6 +38,12 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab this.bonus = bonus; } + @NotNull + @Override + public EnchantmentView getView() { + return (EnchantmentView) super.getView(); + } + /** * Gets the player enchanting the item * @@ -39,7 +51,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab */ @NotNull public Player getEnchanter() { - return enchanter; + return this.enchanter; } /** @@ -49,7 +61,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab */ @NotNull public Block getEnchantBlock() { - return table; + return this.table; } /** @@ -59,7 +71,7 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab */ @NotNull public ItemStack getItem() { - return item; + return this.item; } /** @@ -71,9 +83,9 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab @NotNull @Deprecated(since = "1.20.5") public int[] getExpLevelCostsOffered() { - int[] levelOffers = new int[offers.length]; - for (int i = 0; i < offers.length; i++) { - levelOffers[i] = offers[i] != null ? offers[i].getCost() : 0; + int[] levelOffers = new int[this.offers.length]; + for (int i = 0; i < this.offers.length; i++) { + levelOffers[i] = this.offers[i] != null ? this.offers[i].getCost() : 0; } return levelOffers; } @@ -86,8 +98,8 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * * @return list of available enchantment offers */ - public @org.jetbrains.annotations.Nullable EnchantmentOffer @NotNull [] getOffers() { // Paper offers can contain null values - return offers; + public @Nullable EnchantmentOffer @NotNull[] getOffers() { + return this.offers; } /** @@ -96,18 +108,12 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab * @return enchantment bonus */ public int getEnchantmentBonus() { - return bonus; - } - - @NotNull - @Override - public EnchantmentView getView() { - return (EnchantmentView) super.getView(); + return this.bonus; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -118,11 +124,11 @@ public class PrepareItemEnchantEvent extends InventoryEvent implements Cancellab @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java index 9cee218b9..39fe2f55b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/AreaEffectCloudApplyEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,29 +13,23 @@ import org.jetbrains.annotations.NotNull; * once every 5 ticks */ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final List affectedEntities; - private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final List affectedEntities; + + private boolean cancelled; + + @ApiStatus.Internal public AreaEffectCloudApplyEvent(@NotNull final AreaEffectCloud entity, @NotNull final List affectedEntities) { super(entity); this.affectedEntities = affectedEntities; } - @Override - public boolean isCancelled() { - return this.cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - @Override @NotNull public AreaEffectCloud getEntity() { - return (AreaEffectCloud) entity; + return (AreaEffectCloud) this.entity; } /** @@ -49,17 +44,27 @@ public class AreaEffectCloudApplyEvent extends EntityEvent implements Cancellabl */ @NotNull public List getAffectedEntities() { - return affectedEntities; + return this.affectedEntities; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ArrowBodyCountChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ArrowBodyCountChangeEvent.java index caed284b3..76456b6d5 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ArrowBodyCountChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ArrowBodyCountChangeEvent.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,21 @@ import org.jetbrains.annotations.NotNull; */ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private boolean cancelled; - private final boolean isReset; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean reset; private final int oldAmount; private int newAmount; - public ArrowBodyCountChangeEvent(@NotNull LivingEntity entity, int oldAmount, int newAmount, boolean isReset) { + private boolean cancelled; + + @ApiStatus.Internal + public ArrowBodyCountChangeEvent(@NotNull LivingEntity entity, int oldAmount, int newAmount, boolean reset) { super(entity); this.oldAmount = oldAmount; this.newAmount = newAmount; - this.isReset = isReset; + this.reset = reset; } /** @@ -32,7 +35,7 @@ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellabl * @return was reset */ public boolean isReset() { - return isReset; + return this.reset; } /** @@ -41,7 +44,7 @@ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellabl * @return amount of arrows */ public int getOldAmount() { - return oldAmount; + return this.oldAmount; } /** @@ -50,7 +53,7 @@ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellabl * @return amount of arrows */ public int getNewAmount() { - return newAmount; + return this.newAmount; } /** @@ -66,12 +69,12 @@ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellabl @Override @NotNull public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -82,11 +85,11 @@ public class ArrowBodyCountChangeEvent extends EntityEvent implements Cancellabl @Override @NotNull public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java index 5a5615d17..b3173847a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java @@ -3,53 +3,56 @@ package org.bukkit.event.entity; import org.bukkit.entity.Bat; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a bat attempts to sleep or wake up from its slumber. *

    - * If a Bat Toggle Sleep event is cancelled, the Bat will not toggle its sleep + * If this event is cancelled, the Bat will not toggle its sleep * state. */ public class BatToggleSleepEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); - private boolean cancel = false; private final boolean awake; - public BatToggleSleepEvent(@NotNull Bat what, boolean awake) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public BatToggleSleepEvent(@NotNull Bat bat, boolean awake) { + super(bat); this.awake = awake; } /** - * Get whether or not the bat is attempting to awaken. + * Get whether the bat is attempting to awaken. * - * @return true if trying to awaken, false otherwise + * @return {@code true} if trying to awaken, {@code false} otherwise */ public boolean isAwake() { - return awake; + return this.awake; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java index 6d9c9ca81..14fdb4184 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreatureSpawnEvent.java @@ -3,16 +3,19 @@ package org.bukkit.event.entity; import org.bukkit.Chunk; import org.bukkit.entity.LivingEntity; import org.bukkit.event.world.ChunkLoadEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a creature is spawned into a world. *

    - * If a Creature Spawn event is cancelled, the creature will not spawn. + * If this event is cancelled, the creature will not spawn. */ public class CreatureSpawnEvent extends EntitySpawnEvent { + private final SpawnReason spawnReason; + @ApiStatus.Internal public CreatureSpawnEvent(@NotNull final LivingEntity spawnee, @NotNull final SpawnReason spawnReason) { super(spawnee); this.spawnReason = spawnReason; @@ -21,7 +24,7 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -32,7 +35,7 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { */ @NotNull public SpawnReason getSpawnReason() { - return spawnReason; + return this.spawnReason; } /** @@ -206,7 +209,6 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { * When a creature is spawned by an enchantment */ ENCHANTMENT, - // Paper start - Fixes and additions to the SpawnReason API /** * When an entity spawns from an ominous item spawner */ @@ -215,7 +217,6 @@ public class CreatureSpawnEvent extends EntitySpawnEvent { * When an entity spawns from a bucket */ BUCKET, - // Paper end - Fixes and additions to the SpawnReason API /** * When a creature is spawned by a potion effect, for example: * {@link org.bukkit.potion.PotionType#OOZING}, {@link org.bukkit.potion.PotionType#INFESTED} diff --git a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java index 4295baf51..55818ccb9 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/CreeperPowerEvent.java @@ -4,44 +4,40 @@ import org.bukkit.entity.Creeper; import org.bukkit.entity.LightningStrike; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Called when a Creeper is struck by lightning. *

    - * If a Creeper Power event is cancelled, the Creeper will not be powered. + * If this event is cancelled, the Creeper will not be powered. */ public class CreeperPowerEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final PowerCause cause; private LightningStrike bolt; + private boolean cancelled; + + @ApiStatus.Internal public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final LightningStrike bolt, @NotNull final PowerCause cause) { this(creeper, cause); this.bolt = bolt; } + @ApiStatus.Internal public CreeperPowerEvent(@NotNull final Creeper creeper, @NotNull final PowerCause cause) { super(creeper); this.cause = cause; } - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; - } - @NotNull @Override public Creeper getEntity() { - return (Creeper) entity; + return (Creeper) this.entity; } /** @@ -51,7 +47,7 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { */ @Nullable public LightningStrike getLightning() { - return bolt; + return this.bolt; } /** @@ -61,18 +57,28 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { */ @NotNull public PowerCause getCause() { - return cause; + return this.cause; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -83,19 +89,19 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable { /** * Power change caused by a lightning bolt *

    - * Powered state: true + * Powered state: {@code true} */ LIGHTNING, /** * Power change caused by something else (probably a plugin) *

    - * Powered state: true + * Powered state: {@code true} */ SET_ON, /** * Power change caused by something else (probably a plugin) *

    - * Powered state: false + * Powered state: {@code false} */ SET_OFF } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java index 498609bb1..4993e7309 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EnderDragonChangePhaseEvent.java @@ -4,6 +4,7 @@ import com.google.common.base.Preconditions; import org.bukkit.entity.EnderDragon; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,21 +13,24 @@ import org.jetbrains.annotations.Nullable; */ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final EnderDragon.Phase currentPhase; private EnderDragon.Phase newPhase; + private boolean cancelled; + + @ApiStatus.Internal public EnderDragonChangePhaseEvent(@NotNull EnderDragon enderDragon, @Nullable EnderDragon.Phase currentPhase, @NotNull EnderDragon.Phase newPhase) { super(enderDragon); this.currentPhase = currentPhase; - this.setNewPhase(newPhase); + this.newPhase = newPhase; } @NotNull @Override public EnderDragon getEntity() { - return (EnderDragon) entity; + return (EnderDragon) this.entity; } /** @@ -37,7 +41,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella */ @Nullable public EnderDragon.Phase getCurrentPhase() { - return currentPhase; + return this.currentPhase; } /** @@ -47,7 +51,7 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella */ @NotNull public EnderDragon.Phase getNewPhase() { - return newPhase; + return this.newPhase; } /** @@ -62,22 +66,22 @@ public class EnderDragonChangePhaseEvent extends EntityEvent implements Cancella @Override public boolean isCancelled() { - return cancel; + return cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java index cd20a4aa4..f5376caff 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityAirChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,14 +11,14 @@ import org.jetbrains.annotations.NotNull; */ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private int amount; - // private boolean cancelled; - public EntityAirChangeEvent(@NotNull Entity what, int amount) { - super(what); + @ApiStatus.Internal + public EntityAirChangeEvent(@NotNull Entity entity, int amount) { + super(entity); this.amount = amount; } @@ -27,7 +28,7 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { * @return amount of air remaining */ public int getAmount() { - return amount; + return this.amount; } /** @@ -41,7 +42,7 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -52,11 +53,11 @@ public class EntityAirChangeEvent extends EntityEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java index b7889e3b6..ba22ca30f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreakDoorEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.entity; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,13 +12,15 @@ import org.jetbrains.annotations.NotNull; * Cancelling the event will cause the event to be delayed */ public class EntityBreakDoorEvent extends EntityChangeBlockEvent { - public EntityBreakDoorEvent(@NotNull final LivingEntity entity, @NotNull final Block targetBlock, @NotNull final org.bukkit.block.data.BlockData to) { // Paper - super(entity, targetBlock, to); // Paper + + @ApiStatus.Internal + public EntityBreakDoorEvent(@NotNull final LivingEntity entity, @NotNull final Block targetBlock, @NotNull final org.bukkit.block.data.BlockData to) { + super(entity, targetBlock, to); } @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java index 486387789..af59a1d48 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityBreedEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,36 +14,31 @@ import org.jetbrains.annotations.Nullable; */ public class EntityBreedEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final LivingEntity mother; private final LivingEntity father; private final LivingEntity breeder; private final ItemStack bredWith; private int experience; - // - private boolean cancel; + private boolean cancelled; + + @ApiStatus.Internal public EntityBreedEvent(@NotNull LivingEntity child, @NotNull LivingEntity mother, @NotNull LivingEntity father, @Nullable LivingEntity breeder, @Nullable ItemStack bredWith, int experience) { super(child); - Preconditions.checkArgument(child != null, "Cannot have null child"); - Preconditions.checkArgument(mother != null, "Cannot have null mother"); - Preconditions.checkArgument(father != null, "Cannot have null father"); - - // Breeder can be null in the case of spontaneous conception this.mother = mother; this.father = father; - this.breeder = breeder; + this.breeder = breeder; // Breeder can be null in the case of spontaneous conception this.bredWith = bredWith; - - setExperience(experience); + this.experience = experience; } @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -52,7 +48,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { */ @NotNull public LivingEntity getMother() { - return mother; + return this.mother; } /** @@ -62,18 +58,18 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { */ @NotNull public LivingEntity getFather() { - return father; + return this.father; } /** - * Gets the Entity responsible for breeding. Breeder is null for spontaneous + * Gets the Entity responsible for breeding. Breeder is {@code null} for spontaneous * conception. * * @return The Entity who initiated breeding. */ @Nullable public LivingEntity getBreeder() { - return breeder; + return this.breeder; } /** @@ -83,7 +79,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { */ @Nullable public ItemStack getBredWith() { - return bredWith; + return this.bredWith; } /** @@ -92,7 +88,7 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { * @return experience amount */ public int getExperience() { - return experience; + return this.experience; } /** @@ -107,22 +103,22 @@ public class EntityBreedEvent extends EntityEvent implements Cancellable { @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java index 24e1a49e4..2e843187a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityChangeBlockEvent.java @@ -6,21 +6,25 @@ import org.bukkit.block.data.BlockData; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when any Entity changes a block and a more specific event is not available. */ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block block; - private boolean cancel; private final BlockData to; - public EntityChangeBlockEvent(@NotNull final Entity what, @NotNull final Block block, @NotNull final BlockData to) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public EntityChangeBlockEvent(@NotNull final Entity entity, @NotNull final Block block, @NotNull final BlockData to) { + super(entity); this.block = block; - this.cancel = false; this.to = to; } @@ -31,17 +35,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { */ @NotNull public Block getBlock() { - return block; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + return this.block; } /** @@ -51,7 +45,7 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { */ @NotNull public Material getTo() { - return to.getMaterial(); + return this.to.getMaterial(); } /** @@ -61,17 +55,27 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable { */ @NotNull public BlockData getBlockData() { - return to.clone(); // Paper - clone because mutation isn't used + return this.to.clone(); + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java index 6cd2d8166..0d22e366e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByBlockEvent.java @@ -10,8 +10,10 @@ import org.jetbrains.annotations.Nullable; * Called when a block causes an entity to combust. */ public class EntityCombustByBlockEvent extends EntityCombustEvent { + private final Block combuster; + @ApiStatus.Internal @Deprecated(since = "1.21", forRemoval = true) public EntityCombustByBlockEvent(@Nullable final Block combuster, @NotNull final Entity combustee, final int duration) { this(combuster, combustee, (float) duration); @@ -26,12 +28,12 @@ public class EntityCombustByBlockEvent extends EntityCombustEvent { /** * The combuster can be lava or a block that is on fire. *

    - * WARNING: block may be null. + * WARNING: block may be {@code null}. * * @return the Block that set the combustee alight. */ @Nullable public Block getCombuster() { - return combuster; + return this.combuster; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java index 8cc6e1a90..0d737db80 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustByEntityEvent.java @@ -8,8 +8,10 @@ import org.jetbrains.annotations.NotNull; * Called when an entity causes another entity to combust. */ public class EntityCombustByEntityEvent extends EntityCombustEvent { + private final Entity combuster; + @ApiStatus.Internal @Deprecated(since = "1.21", forRemoval = true) public EntityCombustByEntityEvent(@NotNull final Entity combuster, @NotNull final Entity combustee, final int duration) { this(combuster, combustee, (float) duration); @@ -28,6 +30,6 @@ public class EntityCombustByEntityEvent extends EntityCombustEvent { */ @NotNull public Entity getCombuster() { - return combuster; + return this.combuster; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java index 239756408..71bde7048 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCombustEvent.java @@ -9,13 +9,17 @@ import org.jetbrains.annotations.NotNull; /** * Called when an entity combusts. *

    - * If an Entity Combust event is cancelled, the entity will not combust. + * If this event is cancelled, the entity will not combust. */ public class EntityCombustEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private float duration; - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private float duration; + + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.21", forRemoval = true) public EntityCombustEvent(@NotNull final Entity combustee, final int duration) { this(combustee, (float) duration); @@ -25,17 +29,6 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { public EntityCombustEvent(@NotNull final Entity combustee, final float duration) { super(combustee); this.duration = duration; - this.cancel = false; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; } /** @@ -43,7 +36,7 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { * for */ public float getDuration() { - return duration; + return this.duration; } /** @@ -73,14 +66,24 @@ public class EntityCombustEvent extends EntityEvent implements Cancellable { this.duration = duration; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java index cdfecdc98..acea26560 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityCreatePortalEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.world.PortalCreateEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,13 +17,17 @@ import org.jetbrains.annotations.NotNull; */ @Deprecated(since = "1.14.1") public class EntityCreatePortalEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final List blocks; - private boolean cancelled = false; - private PortalType type = PortalType.CUSTOM; - public EntityCreatePortalEvent(@NotNull final LivingEntity what, @NotNull final List blocks, @NotNull final PortalType type) { - super(what); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final List blocks; + private final PortalType type; + + private boolean cancelled; + + @ApiStatus.Internal + public EntityCreatePortalEvent(@NotNull final LivingEntity livingEntity, @NotNull final List blocks, @NotNull final PortalType type) { + super(livingEntity); this.blocks = blocks; this.type = type; @@ -31,7 +36,7 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -41,17 +46,7 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable */ @NotNull public List getBlocks() { - return blocks; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; + return this.blocks; } /** @@ -61,17 +56,27 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable */ @NotNull public PortalType getPortalType() { - return type; + return this.type; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java index 35aa2cbc5..423630e77 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByBlockEvent.java @@ -7,6 +7,7 @@ import org.bukkit.block.BlockState; import org.bukkit.damage.DamageSource; import org.bukkit.damage.DamageType; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -18,25 +19,30 @@ import org.jetbrains.annotations.Nullable; * of the block if it has already been changed. */ public class EntityDamageByBlockEvent extends EntityDamageEvent { + private final Block damager; private final BlockState damagerState; + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { this(damager, (damager != null) ? damager.getState() : null, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), damage); } + @ApiStatus.Internal public EntityDamageByBlockEvent(@Nullable final Block damager, @Nullable final BlockState damagerState, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { super(damagee, cause, damageSource, damage); this.damager = damager; this.damagerState = damagerState; } + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageByBlockEvent(@Nullable final Block damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { this(damager, (damager != null) ? damager.getState() : null, damagee, cause, (damager != null) ? DamageSource.builder(DamageType.GENERIC).withDamageLocation(damager.getLocation()).build() : DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions); } + @ApiStatus.Internal public EntityDamageByBlockEvent(@Nullable final Block damager, @Nullable final BlockState damagerState, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee, cause, damageSource, modifiers, modifierFunctions); this.damager = damager; @@ -50,19 +56,19 @@ public class EntityDamageByBlockEvent extends EntityDamageEvent { */ @Nullable public Block getDamager() { - return damager; + return this.damager; } /** * Returns the captured BlockState of the block that damaged the player. *

    - * This block state is not placed so {@link org.bukkit.block.BlockState#isPlaced} - * will be false. + * This block state is not placed so {@link BlockState#isPlaced()} + * will be {@code false}. * * @return the block state */ @Nullable public BlockState getDamagerBlockState() { - return damagerState; + return this.damagerState; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java index 2c0103669..6e52a05fc 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageByEntityEvent.java @@ -12,31 +12,35 @@ import org.jetbrains.annotations.NotNull; * Called when an entity is damaged by an entity */ public class EntityDamageByEntityEvent extends EntityDamageEvent { - private final Entity damager; - private final boolean critical; // Paper + private final Entity damager; + private final boolean critical; + + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), damage); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { super(damagee, cause, damageSource, damage); this.damager = damager; - this.critical = false; // Paper - add critical damage API + this.critical = false; } + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { this(damager, damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee, cause, damageSource, modifiers, modifierFunctions); this.damager = damager; - // Paper start this.critical = false; } @@ -47,6 +51,16 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent { this.critical = critical; } + /** + * Returns the entity that damaged the defender. + * + * @return Entity that damaged the defender. + */ + @NotNull + public Entity getDamager() { + return this.damager; + } + /** * Shows this damage instance was critical. * The damage instance can be critical if the attacking player met the respective conditions. @@ -58,9 +72,7 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent { public boolean isCritical() { return this.critical; } - // Paper end - // Paper start /** * {@inheritDoc} *

    @@ -72,15 +84,4 @@ public class EntityDamageByEntityEvent extends EntityDamageEvent { public @NotNull DamageSource getDamageSource() { return super.getDamageSource(); } - // Paper end - - /** - * Returns the entity that damaged the defender. - * - * @return Entity that damaged the defender. - */ - @NotNull - public Entity getDamager() { - return damager; - } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java index d1a5424ff..6d5ae34b3 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDamageEvent.java @@ -15,36 +15,44 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Stores data for damage events */ public class EntityDamageEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private static final DamageModifier[] MODIFIERS = DamageModifier.values(); private static final Function ZERO = Functions.constant(-0.0); private final Map modifiers; private final Map> modifierFunctions; private final Map originals; - private boolean cancelled; private final DamageCause cause; private final DamageSource damageSource; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) { this(damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), damage); } + @ApiStatus.Internal public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, final double damage) { - this(damagee, cause, damageSource, new EnumMap(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); + this(damagee, cause, damageSource, new EnumMap<>(ImmutableMap.of(DamageModifier.BASE, damage)), new EnumMap>(ImmutableMap.of(DamageModifier.BASE, ZERO))); } + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { this(damagee, cause, DamageSource.builder(DamageType.GENERIC).build(), modifiers, modifierFunctions); } + @ApiStatus.Internal public EntityDamageEvent(@NotNull final Entity damagee, @NotNull final DamageCause cause, @NotNull final DamageSource damageSource, @NotNull final Map modifiers, @NotNull final Map> modifierFunctions) { super(damagee); Preconditions.checkArgument(modifiers.containsKey(DamageModifier.BASE), "BASE DamageModifier missing"); @@ -52,34 +60,23 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { Preconditions.checkArgument(modifiers.values().stream().allMatch(Objects::nonNull), "Cannot have null modifier values"); Preconditions.checkArgument(modifiers.keySet().equals(modifierFunctions.keySet()), "Must have a modifier function for each DamageModifier"); Preconditions.checkArgument(modifierFunctions.values().stream().allMatch(Objects::nonNull), "Cannot have null modifier function"); - this.originals = new EnumMap(modifiers); + this.originals = new EnumMap<>(modifiers); this.cause = cause; this.modifiers = modifiers; this.modifierFunctions = modifierFunctions; this.damageSource = damageSource; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - /** * Gets the original damage for the specified modifier, as defined at this * event's construction. * * @param type the modifier * @return the original damage - * @throws IllegalArgumentException if type is null */ public double getOriginalDamage(@NotNull DamageModifier type) throws IllegalArgumentException { Preconditions.checkArgument(type != null, "Cannot have null DamageModifier"); - final Double damage = originals.get(type); + final Double damage = this.originals.get(type); return (damage != null) ? damage : 0; } @@ -88,7 +85,6 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * * @param type the damage modifier * @param damage the scalar value of the damage's modifier - * @throws IllegalArgumentException if type is null * @throws UnsupportedOperationException if the caller does not support * the particular DamageModifier, or to rephrase, when {@link * #isApplicable(DamageModifier)} returns false @@ -96,10 +92,10 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ public void setDamage(@NotNull DamageModifier type, double damage) throws IllegalArgumentException, UnsupportedOperationException { Preconditions.checkArgument(type != null, "Cannot have null DamageModifier"); - if (!modifiers.containsKey(type)) { + if (!this.modifiers.containsKey(type)) { throw new UnsupportedOperationException(type + " is not applicable to " + getEntity()); } - modifiers.put(type, damage); + this.modifiers.put(type, damage); } /** @@ -107,12 +103,11 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * * @param type the damage modifier * @return The raw amount of damage caused by the event - * @throws IllegalArgumentException if type is null * @see DamageModifier#BASE */ public double getDamage(@NotNull DamageModifier type) throws IllegalArgumentException { Preconditions.checkArgument(type != null, "Cannot have null DamageModifier"); - final Double damage = modifiers.get(type); + final Double damage = this.modifiers.get(type); return damage == null ? 0 : damage; } @@ -124,12 +119,11 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * {@link DamageModifier#BASE} is always applicable. * * @param type the modifier - * @return true if the modifier is supported by the caller, false otherwise - * @throws IllegalArgumentException if type is null + * @return {@code true} if the modifier is supported by the caller, {@code false} otherwise */ public boolean isApplicable(@NotNull DamageModifier type) throws IllegalArgumentException { Preconditions.checkArgument(type != null, "Cannot have null DamageModifier"); - return modifiers.containsKey(type); + return this.modifiers.containsKey(type); } /** @@ -139,7 +133,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { * @see DamageModifier#BASE */ public double getDamage() { - return getDamage(DamageModifier.BASE); + return this.getDamage(DamageModifier.BASE); } /** @@ -151,7 +145,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { public final double getFinalDamage() { double damage = 0; for (DamageModifier modifier : MODIFIERS) { - damage += getDamage(modifier); + damage += this.getDamage(modifier); } return damage; } @@ -168,9 +162,9 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { public void setDamage(double damage) { // These have to happen in the same order as the server calculates them, keep the enum sorted double remaining = damage; - double oldRemaining = getDamage(DamageModifier.BASE); + double oldRemaining = this.getDamage(DamageModifier.BASE); for (DamageModifier modifier : MODIFIERS) { - if (!isApplicable(modifier)) { + if (!this.isApplicable(modifier)) { continue; } @@ -180,17 +174,17 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { double difference = oldVanilla - newVanilla; // Don't allow value to cross zero, assume zero values should be negative - double old = getDamage(modifier); + double old = this.getDamage(modifier); if (old > 0) { - setDamage(modifier, Math.max(0, old - difference)); + this.setDamage(modifier, Math.max(0, old - difference)); } else { - setDamage(modifier, Math.min(0, old - difference)); + this.setDamage(modifier, Math.min(0, old - difference)); } remaining += newVanilla; oldRemaining += oldVanilla; } - setDamage(DamageModifier.BASE, damage); + this.setDamage(DamageModifier.BASE, damage); } /** @@ -208,7 +202,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ @NotNull public DamageCause getCause() { - return cause; + return this.cause; } /** @@ -218,27 +212,35 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ @NotNull public DamageSource getDamageSource() { - return damageSource; + return this.damageSource; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** * An enum to specify the types of modifier * * @deprecated This API is responsible for a large number of implementation - * problems and is in general unsustainable to maintain. It is likely to be - * removed very soon in a subsequent release. Please see - * this thread for more information. + * problems and is in general unsustainable to maintain. */ @Deprecated(since = "1.12") public enum DamageModifier { @@ -295,15 +297,15 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { public enum DamageCause { /** - * Damage caused by /kill command + * Damage caused by /kill command. *

    * Damage: {@link Float#MAX_VALUE} */ KILL, /** - * Damage caused by the World Border + * Damage caused by the World Border. *

    - * Damage: {@link WorldBorder#getDamageAmount()} + * Damage: {@link WorldBorder#getDamageAmount()} */ WORLD_BORDER, /** @@ -332,45 +334,45 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ PROJECTILE, /** - * Damage caused by being put in a block + * Damage caused by being put in a block. *

    * Damage: 1 */ SUFFOCATION, /** - * Damage caused when an entity falls a distance greater than 3 blocks + * Damage caused when an entity falls a distance greater than the {@link org.bukkit.attribute.Attribute#SAFE_FALL_DISTANCE safe fall distance}. *

    - * Damage: fall height - 3.0 + * Damage: fall height - {@link org.bukkit.attribute.Attribute#SAFE_FALL_DISTANCE safe fall distance} */ FALL, /** - * Damage caused by direct exposure to fire + * Damage caused by direct exposure to fire. *

    - * Damage: 1 + * Damage: 1 or 2 (for soul fire) */ FIRE, /** - * Damage caused due to burns caused by fire + * Damage caused due to burns caused by fire. *

    * Damage: 1 */ FIRE_TICK, /** - * Damage caused due to a snowman melting + * Damage caused due to a snowman melting. *

    * Damage: 1 */ MELTING, /** - * Damage caused by direct exposure to lava + * Damage caused by direct exposure to lava. *

    * Damage: 4 */ LAVA, /** - * Damage caused by running out of air while in water + * Damage caused by running out of air while in water. *

    - * Damage: 2 + * Damage: 1 or 2 */ DROWNING, /** @@ -387,15 +389,15 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ ENTITY_EXPLOSION, /** - * Damage caused by falling into the void + * Damage caused by falling into the void. *

    - * Damage: 4 for players + * Damage: {@link org.bukkit.World#getVoidDamageAmount()} */ VOID, /** - * Damage caused by being struck by lightning + * Damage caused by being struck by lightning. *

    - * Damage: 5 + * Damage: 5 or {@link Float#MAX_VALUE} for turtle */ LIGHTNING, /** @@ -408,19 +410,19 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ SUICIDE, /** - * Damage caused by starving due to having an empty hunger bar + * Damage caused by starving due to having an empty hunger bar. *

    * Damage: 1 */ STARVATION, /** - * Damage caused due to an ongoing poison effect + * Damage caused due to an ongoing poison effect. *

    * Damage: 1 */ POISON, /** - * Damage caused by being hit by a damage potion or spell + * Damage caused by being hit by a damage potion or spell. *

    * Damage: variable */ @@ -430,7 +432,7 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ WITHER, /** - * Damage caused by being hit by a falling block which deals damage + * Damage caused by being hit by a falling block which deals damage. *

    * Note: Not every block deals damage *

    @@ -438,24 +440,22 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { */ FALLING_BLOCK, /** - * Damage caused in retaliation to another attack by the Thorns - * enchantment. + * Damage caused in retaliation to another attack by the {@link org.bukkit.enchantments.Enchantment#THORNS} + * enchantment or guardian. *

    - * Damage: 1-4 (Thorns) + * Damage: 1-5 (thorns) or 2 (guardian) */ THORNS, /** * Damage caused by a dragon breathing fire. *

    * Damage: variable + * + * @deprecated never used without help of commands or plugins, + * {@link #ENTITY_ATTACK} will be used instead */ + @Deprecated DRAGON_BREATH, - /** - * Custom damage. - *

    - * Damage: variable - */ - CUSTOM, /** * Damage caused when an entity runs into a wall. *

    @@ -471,12 +471,12 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { /** * Damage caused when an entity steps on {@link Material#CAMPFIRE} or {@link Material#SOUL_CAMPFIRE}. *

    - * Damage: 1 + * Damage: 1 or 2 (for soul fire) */ CAMPFIRE, /** * Damage caused when an entity is colliding with too many entities due - * to the maxEntityCramming game rule. + * to the {@link org.bukkit.GameRule#MAX_ENTITY_CRAMMING}. *

    * Damage: 6 */ @@ -484,20 +484,26 @@ public class EntityDamageEvent extends EntityEvent implements Cancellable { /** * Damage caused when an entity that should be in water is not. *

    - * Damage: 1 + * Damage: 1 or 2 */ DRYOUT, /** * Damage caused from freezing. *

    - * Damage: 1 or 5 + * Damage: 1 or 5 (for {@link org.bukkit.Tag#ENTITY_TYPES_FREEZE_HURTS_EXTRA_TYPES sensitive} entities) */ FREEZE, /** - * Damage caused by the Sonic Boom attack from {@link org.bukkit.entity.Warden} + * Damage caused by the Sonic Boom attack from {@link org.bukkit.entity.Warden}. *

    * Damage: 10 */ - SONIC_BOOM; + SONIC_BOOM, + /** + * Custom damage. + *

    + * Damage: variable + */ + CUSTOM; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java index 42ffb8170..76c08499b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDeathEvent.java @@ -3,35 +3,41 @@ package org.bukkit.event.entity; import java.util.List; import org.bukkit.damage.DamageSource; import org.bukkit.entity.LivingEntity; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Thrown whenever a LivingEntity dies */ -public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper - make cancellable - private static final HandlerList handlers = new HandlerList(); +public class EntityDeathEvent extends EntityEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final DamageSource damageSource; private final List drops; private int dropExp = 0; - // Paper start - make cancellable - private boolean cancelled; + private double reviveHealth = 0; private boolean shouldPlayDeathSound; @Nullable private org.bukkit.Sound deathSound; @Nullable private org.bukkit.SoundCategory deathSoundCategory; private float deathSoundVolume; private float deathSoundPitch; - // Paper end - public EntityDeathEvent(@NotNull final LivingEntity entity, @NotNull DamageSource damageSource, @NotNull final List drops) { - this(entity, damageSource, drops, 0); + private boolean cancelled; + + @ApiStatus.Internal + public EntityDeathEvent(@NotNull final LivingEntity livingEntity, @NotNull DamageSource damageSource, @NotNull final List drops) { + this(livingEntity, damageSource, drops, 0); } - public EntityDeathEvent(@NotNull final LivingEntity what, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp) { - super(what); + @ApiStatus.Internal + public EntityDeathEvent(@NotNull final LivingEntity livingEntity, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp) { + super(livingEntity); this.damageSource = damageSource; this.drops = drops; this.dropExp = droppedExp; @@ -40,7 +46,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -50,7 +56,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca */ @NotNull public DamageSource getDamageSource() { - return damageSource; + return this.damageSource; } /** @@ -62,7 +68,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @return Amount of EXP to drop. */ public int getDroppedExp() { - return dropExp; + return this.dropExp; } /** @@ -84,29 +90,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca */ @NotNull public List getDrops() { - return drops; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - - // Paper start - make cancellable - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; + return this.drops; } /** @@ -116,7 +100,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @return The amount of health */ public double getReviveHealth() { - return reviveHealth; + return this.reviveHealth; } /** @@ -127,7 +111,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @throws IllegalArgumentException Thrown if the health is {@literal <= 0 or >} max health */ public void setReviveHealth(double reviveHealth) throws IllegalArgumentException { - double maxHealth = ((LivingEntity) entity).getAttribute(org.bukkit.attribute.Attribute.MAX_HEALTH).getValue(); + double maxHealth = ((LivingEntity) this.entity).getAttribute(org.bukkit.attribute.Attribute.MAX_HEALTH).getValue(); if ((maxHealth != 0 && reviveHealth <= 0) || (reviveHealth > maxHealth)) { throw new IllegalArgumentException("Health must be between 0 (exclusive) and " + maxHealth + " (inclusive), but was " + reviveHealth); } @@ -135,16 +119,16 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca } /** - * Whether or not the death sound should play when the entity dies. If the event is cancelled it does not play! + * Whether the death sound should play when the entity dies. If the event is cancelled it does not play! * - * @return Whether or not the death sound should play. Event is called with this set to false if the entity is silent. + * @return Whether the death sound should play. Event is called with this set to {@code false} if the entity is silent. */ public boolean shouldPlayDeathSound() { - return shouldPlayDeathSound; + return this.shouldPlayDeathSound; } /** - * Set whether or not the death sound should play when the entity dies. If the event is cancelled it does not play! + * Set whether the death sound should play when the entity dies. If the event is cancelled it does not play! * * @param playDeathSound Enable or disable the death sound */ @@ -159,7 +143,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca */ @Nullable public org.bukkit.Sound getDeathSound() { - return deathSound; + return this.deathSound; } /** @@ -168,7 +152,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @param sound The sound that the entity should make when dying */ public void setDeathSound(@Nullable org.bukkit.Sound sound) { - deathSound = sound; + this.deathSound = sound; } /** @@ -178,7 +162,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca */ @Nullable public org.bukkit.SoundCategory getDeathSoundCategory() { - return deathSoundCategory; + return this.deathSoundCategory; } /** @@ -196,7 +180,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @return The volume the death sound will play at */ public float getDeathSoundVolume() { - return deathSoundVolume; + return this.deathSoundVolume; } /** @@ -214,7 +198,7 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca * @return The pitch the death sound will play with */ public float getDeathSoundPitch() { - return deathSoundPitch; + return this.deathSoundPitch; } /** @@ -225,5 +209,25 @@ public class EntityDeathEvent extends EntityEvent implements org.bukkit.event.Ca public void setDeathSoundPitch(float pitch) { this.deathSoundPitch = pitch; } - // Paper end + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java index 91188d77f..f0df91edf 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDismountEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,21 +11,23 @@ import org.jetbrains.annotations.NotNull; */ public class EntityDismountEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final Entity dismounted; - private final boolean isCancellable; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); - public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted) { - // Paper start - this(what, dismounted, true); + private final Entity dismounted; + private final boolean isCancellable; + + private boolean cancelled; + + @ApiStatus.Internal + public EntityDismountEvent(@NotNull Entity entity, @NotNull Entity dismounted) { + this(entity, dismounted, true); } - public EntityDismountEvent(@NotNull Entity what, @NotNull Entity dismounted, boolean isCancellable) { - // Paper end - super(what); + @ApiStatus.Internal + public EntityDismountEvent(@NotNull Entity entity, @NotNull Entity dismounted, boolean isCancellable) { + super(entity); this.dismounted = dismounted; - this.isCancellable = isCancellable; // Paper + this.isCancellable = isCancellable; } /** @@ -34,17 +37,16 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable { */ @NotNull public Entity getDismounted() { - return dismounted; + return this.dismounted; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - // Paper start if (cancel && !this.isCancellable) { return; } @@ -53,17 +55,16 @@ public class EntityDismountEvent extends EntityEvent implements Cancellable { public boolean isCancellable() { return this.isCancellable; - // Paper end } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java index 3ccdcc755..f3243f2fa 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityDropItemEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,10 +12,12 @@ import org.jetbrains.annotations.NotNull; */ public class EntityDropItemEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final Item drop; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Item drop; + private boolean cancelled; + + @ApiStatus.Internal public EntityDropItemEvent(@NotNull final Entity entity, @NotNull final Item drop) { super(entity); this.drop = drop; @@ -27,27 +30,27 @@ public class EntityDropItemEvent extends EntityEvent implements Cancellable { */ @NotNull public Item getItemDrop() { - return drop; + return this.drop; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java index d5bd804a5..0b1503598 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterBlockEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,10 +17,13 @@ import org.jetbrains.annotations.NotNull; */ public class EntityEnterBlockEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final Block block; - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block block; + + private boolean cancelled; + + @ApiStatus.Internal public EntityEnterBlockEvent(@NotNull final Entity entity, @NotNull final Block block) { super(entity); @@ -33,27 +37,27 @@ public class EntityEnterBlockEvent extends EntityEvent implements Cancellable { */ @NotNull public Block getBlock() { - return block; + return this.block; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java index 59aab10c2..6661154ac 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEnterLoveModeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Animals; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,11 +16,14 @@ import org.jetbrains.annotations.Nullable; */ public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final HumanEntity humanEntity; private int ticksInLove; + private boolean cancelled; + + @ApiStatus.Internal public EntityEnterLoveModeEvent(@NotNull Animals animalInLove, @Nullable HumanEntity humanEntity, int ticksInLove) { super(animalInLove); this.humanEntity = humanEntity; @@ -34,18 +38,18 @@ public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable @NotNull @Override public Animals getEntity() { - return (Animals) entity; + return (Animals) this.entity; } /** * Gets the Human Entity that caused the animal to enter love mode. * * @return The Human entity that caused the animal to enter love mode, or - * null if there wasn't one. + * {@code null} if there wasn't one. */ @Nullable public HumanEntity getHumanEntity() { - return humanEntity; + return this.humanEntity; } /** @@ -54,7 +58,7 @@ public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable * @return The amount of ticks that the animal will fall in love for */ public int getTicksInLove() { - return ticksInLove; + return this.ticksInLove; } /** @@ -69,22 +73,22 @@ public class EntityEnterLoveModeEvent extends EntityEvent implements Cancellable @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java index e3a9e3293..df67f3190 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityEvent.java @@ -9,10 +9,11 @@ import org.jetbrains.annotations.NotNull; * Represents an Entity-related event */ public abstract class EntityEvent extends Event { + protected Entity entity; - public EntityEvent(@NotNull final Entity what) { - entity = what; + protected EntityEvent(@NotNull final Entity entity) { + this.entity = entity; } /** @@ -22,7 +23,7 @@ public abstract class EntityEvent extends Event { */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } /** @@ -32,6 +33,6 @@ public abstract class EntityEvent extends Event { */ @NotNull public EntityType getEntityType() { - return entity.getType(); + return this.entity.getType(); } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java index 2ff372d73..fc59cdaac 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExhaustionEvent.java @@ -3,26 +3,36 @@ package org.bukkit.event.entity; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a human entity experiences exhaustion. - * + *
    * An exhaustion level greater than 4.0 causes a decrease in saturation by 1. */ public class EntityExhaustionEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ExhaustionReason exhaustionReason; private float exhaustion; - private boolean cancel; - public EntityExhaustionEvent(@NotNull HumanEntity who, @NotNull ExhaustionReason exhaustionReason, float exhaustion) { - super(who); + private boolean cancelled; + + @ApiStatus.Internal + public EntityExhaustionEvent(@NotNull HumanEntity human, @NotNull ExhaustionReason exhaustionReason, float exhaustion) { + super(human); this.exhaustionReason = exhaustionReason; this.exhaustion = exhaustion; } + @NotNull + @Override + public HumanEntity getEntity() { + return (HumanEntity) super.entity; + } + /** * Gets the {@link ExhaustionReason} for this event * @@ -30,7 +40,7 @@ public class EntityExhaustionEvent extends EntityEvent implements Cancellable { */ @NotNull public ExhaustionReason getExhaustionReason() { - return exhaustionReason; + return this.exhaustionReason; } /** @@ -39,12 +49,12 @@ public class EntityExhaustionEvent extends EntityEvent implements Cancellable { * @return amount of exhaustion */ public float getExhaustion() { - return exhaustion; + return this.exhaustion; } /** * Set the exhaustion to apply to the player. - * + *

    * The maximum exhaustion that a player can have is 40. No error will be * thrown if this limit is hit. This value may be negative, but there is * unknown behavior for when exhaustion is below 0. @@ -55,20 +65,14 @@ public class EntityExhaustionEvent extends EntityEvent implements Cancellable { this.exhaustion = exhaustion; } - @NotNull - @Override - public HumanEntity getEntity() { - return (HumanEntity) super.getEntity(); - } - @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } /** @@ -139,11 +143,11 @@ public class EntityExhaustionEvent extends EntityEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java index e468e55d4..9a8f5f6dc 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityExplodeEvent.java @@ -7,6 +7,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,32 +16,25 @@ import org.jetbrains.annotations.NotNull; * is disabled as no block interaction will occur. */ public class EntityExplodeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Location location; private final List blocks; private float yield; private final ExplosionResult result; - public EntityExplodeEvent(@NotNull final Entity what, @NotNull final Location location, @NotNull final List blocks, final float yield, @NotNull final ExplosionResult result) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public EntityExplodeEvent(@NotNull final Entity entity, @NotNull final Location location, @NotNull final List blocks, final float yield, @NotNull final ExplosionResult result) { + super(entity); this.location = location; this.blocks = blocks; this.yield = yield; - this.cancel = false; this.result = result; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Returns the result of the explosion if it is not cancelled. * @@ -48,7 +42,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { */ @NotNull public ExplosionResult getExplosionResult() { - return result; + return this.result; } /** @@ -59,7 +53,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { */ @NotNull public List blockList() { - return blocks; + return this.blocks; } /** @@ -72,7 +66,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { */ @NotNull public Location getLocation() { - return location.clone(); // Paper - clone to avoid changes + return this.location.clone(); } /** @@ -81,7 +75,7 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { * @return The yield. */ public float getYield() { - return yield; + return this.yield; } /** @@ -93,14 +87,24 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable { this.yield = yield; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java index e2c0cb339..1dd95cbc0 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityInteractEvent.java @@ -4,31 +4,26 @@ import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when an entity interacts with an object */ public class EntityInteractEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected Block block; + private boolean cancelled; + @ApiStatus.Internal public EntityInteractEvent(@NotNull final Entity entity, @NotNull final Block block) { super(entity); this.block = block; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - /** * Returns the involved block * @@ -36,17 +31,27 @@ public class EntityInteractEvent extends EntityEvent implements Cancellable { */ @NotNull public Block getBlock() { - return block; + return this.block; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java index bd44bc5ed..1b00318a6 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackByEntityEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,6 +16,7 @@ public class EntityKnockbackByEntityEvent extends EntityKnockbackEvent { private final Entity source; + @ApiStatus.Internal public EntityKnockbackByEntityEvent(@NotNull final LivingEntity entity, @NotNull final Entity source, @NotNull final KnockbackCause cause, final double force, @NotNull final Vector rawKnockback, @NotNull final Vector knockback) { super(entity, cause, force, rawKnockback, knockback); @@ -28,6 +30,6 @@ public class EntityKnockbackByEntityEvent extends EntityKnockbackEvent { */ @NotNull public Entity getSourceEntity() { - return source; + return this.source; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java index 6c0c2f78d..c19fe417d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityKnockbackEvent.java @@ -7,6 +7,7 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -17,13 +18,16 @@ import org.jetbrains.annotations.NotNull; @Deprecated(forRemoval = true) // Paper public class EntityKnockbackEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final KnockbackCause cause; private final double force; private final Vector rawKnockback; private Vector knockback; + private boolean cancelled; + @ApiStatus.Internal public EntityKnockbackEvent(@NotNull final LivingEntity entity, @NotNull final KnockbackCause cause, final double force, @NotNull final Vector rawKnockback, @NotNull final Vector knockback) { super(entity); @@ -36,7 +40,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -46,11 +50,12 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { */ @NotNull public KnockbackCause getCause() { - return cause; + return this.cause; } /** - * Gets the raw force of the knockback.
    + * Gets the raw force of the knockback. + *

    * This value is based on factors such as the {@link Enchantment#KNOCKBACK} * level of an attacker and the * {@link Attribute#KNOCKBACK_RESISTANCE} of the entity. @@ -58,7 +63,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { * @return the knockback force */ public double getForce() { - return force; + return this.force; } /** @@ -71,7 +76,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { */ @NotNull public Vector getKnockback() { - return rawKnockback.clone(); + return this.rawKnockback.clone(); } /** @@ -87,7 +92,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { */ @NotNull public Vector getFinalKnockback() { - return knockback.clone(); + return this.knockback.clone(); } /** @@ -104,23 +109,23 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityMountEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityMountEvent.java index c3e4f3408..607040907 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityMountEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityMountEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,12 +11,15 @@ import org.jetbrains.annotations.NotNull; */ public class EntityMountEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity mount; - public EntityMountEvent(@NotNull Entity what, @NotNull Entity mount) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public EntityMountEvent(@NotNull Entity entity, @NotNull Entity mount) { + super(entity); this.mount = mount; } @@ -26,12 +30,12 @@ public class EntityMountEvent extends EntityEvent implements Cancellable { */ @NotNull public Entity getMount() { - return mount; + return this.mount; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -42,11 +46,11 @@ public class EntityMountEvent extends EntityEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java index 94ee5a335..ee616308a 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPickupItemEvent.java @@ -4,17 +4,22 @@ import org.bukkit.entity.Item; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Thrown when an entity picks an item up from the ground */ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Item item; - private boolean cancel = false; private final int remaining; + private boolean cancelled; + + @ApiStatus.Internal public EntityPickupItemEvent(@NotNull final LivingEntity entity, @NotNull final Item item, final int remaining) { super(entity); this.item = item; @@ -24,7 +29,7 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -34,7 +39,7 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { */ @NotNull public Item getItem() { - return item; + return this.item; } /** @@ -43,27 +48,27 @@ public class EntityPickupItemEvent extends EntityEvent implements Cancellable { * @return amount remaining on the ground */ public int getRemaining() { - return remaining; + return this.remaining; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java index 479e2ba0f..236c1fa78 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPlaceEvent.java @@ -20,13 +20,15 @@ import org.jetbrains.annotations.Nullable; */ public class EntityPlaceEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; private final Block block; private final BlockFace blockFace; private final EquipmentSlot hand; + private boolean cancelled; + @ApiStatus.Internal public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace, @NotNull final EquipmentSlot hand) { super(entity); @@ -36,6 +38,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { this.hand = hand; } + @ApiStatus.Internal @Deprecated(since = "1.19.2", forRemoval = true) public EntityPlaceEvent(@NotNull final Entity entity, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace) { this(entity, player, block, blockFace, EquipmentSlot.HAND); @@ -48,7 +51,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { */ @Nullable public Player getPlayer() { - return player; + return this.player; } /** @@ -58,7 +61,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { */ @NotNull public Block getBlock() { - return block; + return this.block; } /** @@ -68,7 +71,7 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { */ @NotNull public BlockFace getBlockFace() { - return blockFace; + return this.blockFace; } /** @@ -78,12 +81,12 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -94,11 +97,11 @@ public class EntityPlaceEvent extends EntityEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java index 8b2caf665..884af49ca 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEnterEvent.java @@ -1,8 +1,11 @@ package org.bukkit.event.entity; import org.bukkit.Location; +import org.bukkit.PortalType; import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,21 +14,26 @@ import org.jetbrains.annotations.NotNull; * Cancelling this event prevents any further processing of the portal for that tick. * @see io.papermc.paper.event.entity.EntityInsideBlockEvent */ -public class EntityPortalEnterEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper - private static final HandlerList handlers = new HandlerList(); - private final Location location; +public class EntityPortalEnterEvent extends EntityEvent implements Cancellable { - @Deprecated(since = "1.21") @io.papermc.paper.annotation.DoNotUse // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Location location; + private final PortalType portalType; + + private boolean cancelled; + + @ApiStatus.Internal + @Deprecated(since = "1.21") public EntityPortalEnterEvent(@NotNull final Entity entity, @NotNull final Location location) { - // Paper start - this(entity, location, org.bukkit.PortalType.CUSTOM); + this(entity, location, PortalType.CUSTOM); } - @org.jetbrains.annotations.ApiStatus.Internal - public EntityPortalEnterEvent(@NotNull final Entity entity, @NotNull final Location location, @NotNull final org.bukkit.PortalType portalType) { - // Paper end + + @ApiStatus.Internal + public EntityPortalEnterEvent(@NotNull final Entity entity, @NotNull final Location location, @NotNull final PortalType portalType) { super(entity); this.location = location; - this.portalType = portalType; // Paper + this.portalType = portalType; } /** @@ -35,13 +43,9 @@ public class EntityPortalEnterEvent extends EntityEvent implements org.bukkit.ev */ @NotNull public Location getLocation() { - return location.clone(); // Paper - clone to avoid changes + return location.clone(); } - // Paper start - private boolean cancelled = false; - private final org.bukkit.PortalType portalType; - /** * Get the portal type. * @@ -57,19 +61,18 @@ public class EntityPortalEnterEvent extends EntityEvent implements org.bukkit.ev } @Override - public void setCancelled(final boolean cancel) { + public void setCancelled(boolean cancel) { this.cancelled = cancel; } - // Paper end @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java index 4544e7e15..3db8c3121 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import org.bukkit.Location; +import org.bukkit.PortalType; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -14,52 +15,46 @@ import org.jetbrains.annotations.Nullable; * For players see {@link org.bukkit.event.player.PlayerPortalEvent} */ public class EntityPortalEvent extends EntityTeleportEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final PortalType type; private int searchRadius = 128; private boolean canCreatePortal = true; private int creationRadius = 16; - private final org.bukkit.PortalType type; // Paper + @ApiStatus.Internal public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to) { - this(entity, from, to, 128); // Paper - } - - public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius) { - super(entity, from, to); - this.searchRadius = searchRadius; - this.type = org.bukkit.PortalType.CUSTOM; // Paper - } - - public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, boolean canCreatePortal, int creationRadius) { - // Paper start - this(entity, from, to, searchRadius, canCreatePortal, creationRadius, org.bukkit.PortalType.CUSTOM); + this(entity, from, to, 128); } @ApiStatus.Internal - public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, boolean canCreatePortal, int creationRadius, final @NotNull org.bukkit.PortalType portalType) { + public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius) { + super(entity, from, to); + this.searchRadius = searchRadius; + this.type = PortalType.CUSTOM; + } + + @ApiStatus.Internal + public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, boolean canCreatePortal, int creationRadius) { + this(entity, from, to, searchRadius, canCreatePortal, creationRadius, PortalType.CUSTOM); + } + + @ApiStatus.Internal + public EntityPortalEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to, int searchRadius, boolean canCreatePortal, int creationRadius, final @NotNull PortalType portalType) { super(entity, from, to); this.type = portalType; - // Paper end this.searchRadius = searchRadius; this.canCreatePortal = canCreatePortal; this.creationRadius = creationRadius; } - // Paper start /** - * Get the portal type relating to this event. - * - * @return the portal type - */ - public @NotNull org.bukkit.PortalType getPortalType() { - return this.type; - } - /** - * For {@link org.bukkit.PortalType#NETHER}, this is initially just the starting point + * For {@link PortalType#NETHER}, this is initially just the starting point * for the search for a portal to teleport to. It will initially just be the {@link #getFrom()} * scaled for dimension scaling and clamped to be inside the world border. *

    - * For {@link org.bukkit.PortalType#ENDER}, this will initially be the exact destination + * For {@link PortalType#ENDER}, this will initially be the exact destination * either, the world spawn for end->any world or end spawn for any world->end. * * @return starting point for search or exact destination @@ -72,13 +67,21 @@ public class EntityPortalEvent extends EntityTeleportEvent { /** * See the description of {@link #getTo()}. * @param to starting point for search or exact destination - * or null to cancel + * or {@code null} to cancel */ @Override public void setTo(@Nullable final Location to) { super.setTo(to); } - // Paper end + + /** + * Get the portal type relating to this event. + * + * @return the portal type + */ + public @NotNull PortalType getPortalType() { + return this.type; + } /** * Set the Block radius to search in for available portals. @@ -96,7 +99,7 @@ public class EntityPortalEvent extends EntityTeleportEvent { * @return the currently set search radius */ public int getSearchRadius() { - return searchRadius; + return this.searchRadius; } /** @@ -106,7 +109,7 @@ public class EntityPortalEvent extends EntityTeleportEvent { * @return whether there should create be a destination portal created */ public boolean getCanCreatePortal() { - return canCreatePortal; + return this.canCreatePortal; } /** @@ -123,10 +126,10 @@ public class EntityPortalEvent extends EntityTeleportEvent { /** * Sets the maximum radius the world is searched for a free space from the * given location. - * + *

    * If enough free space is found then the portal will be created there, if * not it will force create with air-space at the target location. - * + *

    * Does not apply to end portal target platforms which will always appear at * the target location. * @@ -140,27 +143,27 @@ public class EntityPortalEvent extends EntityTeleportEvent { /** * Gets the maximum radius the world is searched for a free space from the * given location. - * + *

    * If enough free space is found then the portal will be created there, if * not it will force create with air-space at the target location. - * + *

    * Does not apply to end portal target platforms which will always appear at * the target location. * * @return the currently set creation radius */ public int getCreationRadius() { - return creationRadius; + return this.creationRadius; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java index 0a87e2934..f34c2b3b8 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPortalExitEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,10 +17,13 @@ import org.jetbrains.annotations.NotNull; * any changes to velocity and location from taking place. */ public class EntityPortalExitEvent extends EntityTeleportEvent { - private static final HandlerList handlers = new HandlerList(); - private Vector before; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Vector before; private Vector after; + @ApiStatus.Internal public EntityPortalExitEvent(@NotNull final Entity entity, @NotNull final Location from, @NotNull final Location to, @NotNull final Vector before, @NotNull final Vector after) { super(entity, from, to); this.before = before; @@ -60,11 +64,11 @@ public class EntityPortalExitEvent extends EntityTeleportEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java index 6fb2b02ac..53b7c5f4c 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPoseChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.Pose; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,12 +13,13 @@ import org.jetbrains.annotations.NotNull; */ public class EntityPoseChangeEvent extends EntityEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Pose pose; - public EntityPoseChangeEvent(@NotNull Entity who, @NotNull Pose pose) { - super(who); + @ApiStatus.Internal + public EntityPoseChangeEvent(@NotNull Entity entity, @NotNull Pose pose) { + super(entity); this.pose = pose; } @@ -28,17 +30,17 @@ public class EntityPoseChangeEvent extends EntityEvent { */ @NotNull public Pose getPose() { - return pose; + return this.pose; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java index f6218d317..22e14ba52 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java @@ -5,7 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -16,15 +16,17 @@ import org.jetbrains.annotations.Nullable; */ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final PotionEffect oldEffect; private final PotionEffect newEffect; private final Cause cause; private final Action action; private boolean override; - @Contract("_, null, null, _, _, _ -> fail") + private boolean cancelled; + + @ApiStatus.Internal public EntityPotionEffectEvent(@NotNull LivingEntity livingEntity, @Nullable PotionEffect oldEffect, @Nullable PotionEffect newEffect, @NotNull Cause cause, @NotNull Action action, boolean override) { super(livingEntity); this.oldEffect = oldEffect; @@ -37,23 +39,23 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable /** * Gets the old potion effect of the changed type, which will be removed. * - * @return The old potion effect or null if the entity did not have the + * @return The old potion effect or {@code null} if the entity did not have the * changed effect type. */ @Nullable public PotionEffect getOldEffect() { - return oldEffect; + return this.oldEffect; } /** * Gets new potion effect of the changed type to be applied. * - * @return The new potion effect or null if the effect of the changed type + * @return The new potion effect or {@code null} if the effect of the changed type * will be removed. */ @Nullable public PotionEffect getNewEffect() { - return newEffect; + return this.newEffect; } /** @@ -63,7 +65,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable */ @NotNull public Cause getCause() { - return cause; + return this.cause; } /** @@ -73,7 +75,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable */ @NotNull public Action getAction() { - return action; + return this.action; } /** @@ -83,7 +85,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable */ @NotNull public PotionEffectType getModifiedType() { - return (oldEffect == null) ? ((newEffect == null) ? null : newEffect.getType()) : oldEffect.getType(); + return (this.oldEffect == null) ? ((this.newEffect == null) ? null : this.newEffect.getType()) : this.oldEffect.getType(); // todo not null? } /** @@ -93,7 +95,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable * @return If the new effect will override the old one. */ public boolean isOverride() { - return override; + return this.override; } /** @@ -108,23 +110,23 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java index 7ecff9fce..9ccdebc77 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRegainHealthEvent.java @@ -3,49 +3,42 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Stores data for health-regain events */ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private double amount; private final RegainReason regainReason; - private final boolean isFastRegen; // Paper + private final boolean isFastRegen; + private boolean cancelled; + + @ApiStatus.Internal public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason) { - // Paper start - Forward this(entity, amount, regainReason, false); } + @ApiStatus.Internal public EntityRegainHealthEvent(@NotNull final Entity entity, final double amount, @NotNull final RegainReason regainReason, boolean isFastRegen) { - // Paper end super(entity); this.amount = amount; this.regainReason = regainReason; - this.isFastRegen = isFastRegen; // Paper + this.isFastRegen = isFastRegen; } - // Paper start - Add getter for isFastRegen - /** - * Is this event a result of the fast regeneration mechanic - * - * @return Whether the event is the result of a fast regeneration mechanic - */ - public boolean isFastRegen() { - return isFastRegen; - } - // Paper end - /** * Gets the amount of regained health * * @return The amount of health regained */ public double getAmount() { - return amount; + return this.amount; } /** @@ -57,16 +50,6 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable this.amount = amount; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - /** * Gets the reason for why the entity is regaining health * @@ -75,18 +58,37 @@ public class EntityRegainHealthEvent extends EntityEvent implements Cancellable */ @NotNull public RegainReason getRegainReason() { - return regainReason; + return this.regainReason; + } + + /** + * Is this event a result of the fast regeneration mechanic + * + * @return Whether the event is the result of a fast regeneration mechanic + */ + public boolean isFastRegen() { + return this.isFastRegen; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java index 2a826175f..63e511d20 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityRemoveEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -17,11 +18,13 @@ import org.jetbrains.annotations.NotNull; */ public class EntityRemoveEvent extends EntityEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Cause cause; - public EntityRemoveEvent(@NotNull Entity what, @NotNull Cause cause) { - super(what); + @ApiStatus.Internal + public EntityRemoveEvent(@NotNull Entity entity, @NotNull Cause cause) { + super(entity); this.cause = cause; } @@ -32,18 +35,18 @@ public class EntityRemoveEvent extends EntityEvent { */ @NotNull public Cause getCause() { - return cause; + return this.cause; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java index 2a7426c15..fa60c0ce5 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java @@ -15,43 +15,44 @@ import org.jetbrains.annotations.Nullable; */ public class EntityResurrectEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); private final EquipmentSlot hand; + private boolean cancelled; + @ApiStatus.Internal - public EntityResurrectEvent(@NotNull LivingEntity what, @Nullable EquipmentSlot hand) { - super(what); + public EntityResurrectEvent(@NotNull LivingEntity livingEntity, @Nullable EquipmentSlot hand) { + super(livingEntity); this.hand = hand; } + @ApiStatus.Internal @Deprecated(since = "1.19.2", forRemoval = true) - public EntityResurrectEvent(@NotNull LivingEntity what) { - this(what, null); + public EntityResurrectEvent(@NotNull LivingEntity livingEntity) { + this(livingEntity, null); } @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** - * Get the hand in which the totem of undying was found, or null if the + * Get the hand in which the totem of undying was found, or {@code null} if the * entity did not have a totem of undying. * - * @return the hand, or null + * @return the hand, or {@code null} */ @Nullable public EquipmentSlot getHand() { - return hand; + return this.hand; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -62,11 +63,11 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java index 55aa26b89..ba0c583e8 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityShootBowEvent.java @@ -15,40 +15,29 @@ import org.jetbrains.annotations.Nullable; * Called when a LivingEntity shoots a bow firing an arrow */ public class EntityShootBowEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack bow; private final ItemStack consumable; private Entity projectile; private final EquipmentSlot hand; private final float force; private boolean consumeItem; + private boolean cancelled; - // Paper start - @Deprecated - public void setConsumeArrow(boolean consumeArrow) { - this.setConsumeItem(consumeArrow); - } - - @Deprecated - public boolean getConsumeArrow() { - return this.shouldConsumeItem(); - } - - @Nullable @Deprecated - public ItemStack getArrowItem() { - return this.getConsumable(); - } + @ApiStatus.Internal @Deprecated(forRemoval = true) public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) { this(shooter, bow, new ItemStack(org.bukkit.Material.AIR), projectile, force); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull ItemStack arrowItem, @NotNull final Entity projectile, final float force) { this(shooter, bow, arrowItem, projectile, EquipmentSlot.HAND, force, true); } - // Paper end @ApiStatus.Internal public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @Nullable final ItemStack consumable, @NotNull final Entity projectile, @NotNull final EquipmentSlot hand, final float force, final boolean consumeItem) { @@ -64,7 +53,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; + return (LivingEntity) this.entity; } /** @@ -74,12 +63,12 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { */ @Nullable public ItemStack getBow() { - return bow; + return this.bow; } /** * Get the ItemStack to be consumed in this event (if any). - * + *
    * For instance, bows will consume an arrow ItemStack in a player's * inventory. * @@ -87,7 +76,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { */ @Nullable public ItemStack getConsumable() { - return consumable; + return this.consumable; } /** @@ -97,7 +86,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { */ @NotNull public Entity getProjectile() { - return projectile; + return this.projectile; } /** @@ -116,7 +105,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } /** @@ -125,13 +114,13 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { * @return bow shooting force, up to 1.0 */ public float getForce() { - return force; + return this.force; } /** - * Set whether or not the consumable item should be consumed in this event. - * - * If set to false, it is recommended that a call to + * Set whether the consumable item should be consumed in this event. + *

    + * If set to {@code false}, it is recommended that a call to * {@link Player#updateInventory()} is made as the client may disagree with * the server's decision to not consume a consumable item. *

    @@ -139,7 +128,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { * (skeletons, pillagers, etc.) or with crossbows (as no item is being * consumed). * - * @param consumeItem whether or not to consume the item + * @param consumeItem whether to consume the item * @deprecated not currently functional */ @Deprecated(since = "1.20.5") @@ -148,32 +137,47 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable { } /** - * Get whether or not the consumable item should be consumed in this event. + * Get whether the consumable item should be consumed in this event. * - * @return true if consumed, false otherwise + * @return {@code true} if consumed, {@code false} otherwise */ public boolean shouldConsumeItem() { - return consumeItem; + return this.consumeItem; + } + + @Nullable @Deprecated + public ItemStack getArrowItem() { + return this.getConsumable(); + } + + @Deprecated + public void setConsumeArrow(boolean consumeArrow) { + this.setConsumeItem(consumeArrow); + } + + @Deprecated + public boolean getConsumeArrow() { + return this.shouldConsumeItem(); } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java index 961ee5113..f00d70832 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java @@ -4,32 +4,25 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when an entity is spawned into a world. *

    - * If an Entity Spawn event is cancelled, the entity will not spawn. + * If this event is cancelled, the entity will not spawn. */ public class EntitySpawnEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private boolean canceled; + @ApiStatus.Internal public EntitySpawnEvent(@NotNull final Entity spawnee) { super(spawnee); } - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; - } - /** * Gets the location at which the entity is spawning. * @@ -37,17 +30,27 @@ public class EntitySpawnEvent extends EntityEvent implements Cancellable { */ @NotNull public Location getLocation() { - return getEntity().getLocation(); + return this.getEntity().getLocation(); + } + + @Override + public boolean isCancelled() { + return this.canceled; + } + + @Override + public void setCancelled(boolean cancel) { + this.canceled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpellCastEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpellCastEvent.java index 0252ca7ae..5407f633d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntitySpellCastEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntitySpellCastEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Spellcaster; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,25 +11,27 @@ import org.jetbrains.annotations.NotNull; */ public class EntitySpellCastEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Spellcaster.Spell spell; - public EntitySpellCastEvent(@NotNull Spellcaster what, @NotNull Spellcaster.Spell spell) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public EntitySpellCastEvent(@NotNull Spellcaster spellcaster, @NotNull Spellcaster.Spell spell) { + super(spellcaster); this.spell = spell; } @Override @NotNull public Spellcaster getEntity() { - return (Spellcaster) entity; + return (Spellcaster) this.entity; } /** * Get the spell to be cast in this event. - * + *
    * This is a convenience method equivalent to * {@link Spellcaster#getSpell()}. * @@ -36,7 +39,7 @@ public class EntitySpellCastEvent extends EntityEvent implements Cancellable { */ @NotNull public Spellcaster.Spell getSpell() { - return spell; + return this.spell; } @Override @@ -46,17 +49,17 @@ public class EntitySpellCastEvent extends EntityEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @NotNull public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java index c410b48c2..3228b4dfb 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTameEvent.java @@ -4,16 +4,20 @@ import org.bukkit.entity.AnimalTamer; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Thrown when a LivingEntity is tamed */ public class EntityTameEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final AnimalTamer owner; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final AnimalTamer owner; + private boolean cancelled; + + @ApiStatus.Internal public EntityTameEvent(@NotNull final LivingEntity entity, @NotNull final AnimalTamer owner) { super(entity); this.owner = owner; @@ -22,17 +26,7 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { @NotNull @Override public LivingEntity getEntity() { - return (LivingEntity) entity; - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; + return (LivingEntity) this.entity; } /** @@ -42,17 +36,27 @@ public class EntityTameEvent extends EntityEvent implements Cancellable { */ @NotNull public AnimalTamer getOwner() { - return owner; + return this.owner; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java index e657fe224..1cb542e8c 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,27 +11,21 @@ import org.jetbrains.annotations.Nullable; * Called when a creature targets or untargets another entity */ public class EntityTargetEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Entity target; private final TargetReason reason; + private boolean cancelled; + + @ApiStatus.Internal public EntityTargetEvent(@NotNull final Entity entity, @Nullable final Entity target, @NotNull final TargetReason reason) { super(entity); this.target = target; this.reason = reason; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Returns the reason for the targeting * @@ -38,26 +33,26 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { */ @NotNull public TargetReason getReason() { - return reason; + return this.reason; } /** * Get the entity that this is targeting. *

    - * This will be null in the case that the event is called when the mob + * This will be {@code null} in the case that the event is called when the mob * forgets its target. * * @return The entity */ @Nullable public Entity getTarget() { - return target; + return this.target; } /** * Set the entity that you want the mob to target instead. *

    - * It is possible to be null, null will cause the entity to be + * It is possible to be {@code null}, {@code null} will cause the entity to be * target-less. *

    * This is different from cancelling the event. Cancelling the event will @@ -70,15 +65,25 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { this.target = target; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -162,11 +167,11 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable { /** * When the target is in a different dimension */ - TARGET_OTHER_LEVEL, // Paper + TARGET_OTHER_LEVEL, /** * When the target is in creative or spectator gamemode, or the difficulty is peaceful, or other reasons */ - TARGET_INVALID, // Paper + TARGET_INVALID, /** * A currently unknown reason for the entity changing target. */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java index e6b4d4c17..20075a52f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTargetLivingEntityEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,7 +11,9 @@ import org.jetbrains.annotations.Nullable; * LivingEntity's. */ public class EntityTargetLivingEntityEvent extends EntityTargetEvent { - public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @NotNull final TargetReason reason) { // Paper + + @ApiStatus.Internal + public EntityTargetLivingEntityEvent(@NotNull final Entity entity, @Nullable final LivingEntity target, @NotNull final TargetReason reason) { super(entity, target, reason); } @@ -23,10 +26,10 @@ public class EntityTargetLivingEntityEvent extends EntityTargetEvent { /** * Set the Entity that you want the mob to target. *

    - * It is possible to be null, null will cause the entity to be + * It is possible to be {@code null}, {@code null} will cause the entity to be * target-less. *

    - * Must be a LivingEntity, or null. + * Must be a LivingEntity, or {@code null}. * * @param target The entity to target */ diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java index bffad21c0..e27cd3a6f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTeleportEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,26 +15,19 @@ import org.jetbrains.annotations.Nullable; * (Wolf), or commands (/teleport). */ public class EntityTeleportEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Location from; private Location to; - public EntityTeleportEvent(@NotNull Entity what, @NotNull Location from, @Nullable Location to) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public EntityTeleportEvent(@NotNull Entity entity, @NotNull Location from, @Nullable Location to) { + super(entity); this.from = from; this.to = to; - this.cancel = false; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; } /** @@ -43,7 +37,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { */ @NotNull public Location getFrom() { - return from; + return this.from; } /** @@ -62,7 +56,7 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { */ @Nullable public Location getTo() { - return to; + return this.to; } /** @@ -74,14 +68,24 @@ public class EntityTeleportEvent extends EntityEvent implements Cancellable { this.to = to != null ? to.clone() : null; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java index de24f3f61..501dd9979 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleGlideEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,45 +16,47 @@ import org.jetbrains.annotations.NotNull; * This can be visually estimated by the animation in which a player turns horizontal. */ public class EntityToggleGlideEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final boolean isGliding; - public EntityToggleGlideEvent(@NotNull LivingEntity who, final boolean isGliding) { - super(who); + private boolean cancelled; + + @ApiStatus.Internal + public EntityToggleGlideEvent(@NotNull LivingEntity livingEntity, boolean isGliding) { + super(livingEntity); this.isGliding = isGliding; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } /** - * Returns true if the entity is now gliding or - * false if the entity stops gliding. + * Returns {@code true} if the entity is now gliding or + * {@code false} if the entity stops gliding. * * @return new gliding state */ public boolean isGliding() { - return isGliding; + return this.isGliding; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } - } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java index 273ae8e5d..1b3a40559 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityToggleSwimEvent.java @@ -3,25 +3,38 @@ package org.bukkit.event.entity; import org.bukkit.entity.LivingEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Sent when an entity's swimming status is toggled. */ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final boolean isSwimming; + private boolean cancelled; - public EntityToggleSwimEvent(@NotNull LivingEntity who, final boolean isSwimming) { - super(who); + @ApiStatus.Internal + public EntityToggleSwimEvent(@NotNull LivingEntity livingEntity, final boolean isSwimming) { + super(livingEntity); this.isSwimming = isSwimming; } + /** + * Returns {@code true} if the entity is now swims or + * {@code false} if the entity stops swimming. + * + * @return new swimming state + */ + public boolean isSwimming() { + return this.isSwimming; + } + @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } /** @@ -31,30 +44,20 @@ public class EntityToggleSwimEvent extends EntityEvent implements Cancellable { * swimming state you need to disable the sprinting flag for the player after * the cancel action. */ - @Deprecated // Paper + @Deprecated @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - - /** - * Returns true if the entity is now swims or - * false if the entity stops swimming. - * - * @return new swimming state - */ - public boolean isSwimming() { - return isSwimming; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java index 2220d7d6a..e2450a660 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityTransformEvent.java @@ -5,6 +5,7 @@ import java.util.List; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,12 +13,15 @@ import org.jetbrains.annotations.NotNull; */ public class EntityTransformEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final Entity converted; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List convertedList; + private final Entity converted; private final TransformReason transformReason; + private boolean cancelled; + + @ApiStatus.Internal public EntityTransformEvent(@NotNull Entity original, @NotNull List convertedList, @NotNull TransformReason transformReason) { super(original); this.convertedList = Collections.unmodifiableList(convertedList); @@ -25,19 +29,6 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { this.transformReason = transformReason; } - /** - * Gets the entity that the original entity was transformed to. - * - * This returns the first entity in the transformed entity list. - * - * @return The transformed entity. - * @see #getTransformedEntities() - */ - @NotNull - public Entity getTransformedEntity() { - return converted; - } - /** * Gets the entities that the original entity was transformed to. * @@ -45,7 +36,20 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { */ @NotNull public List getTransformedEntities() { - return convertedList; + return this.convertedList; + } + + /** + * Gets the entity that the original entity was transformed to. + *
    + * This returns the first entity in the transformed entity list. + * + * @return The transformed entity. + * @see #getTransformedEntities() + */ + @NotNull + public Entity getTransformedEntity() { + return this.converted; } /** @@ -55,28 +59,28 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable { */ @NotNull public TransformReason getTransformReason() { - return transformReason; + return this.transformReason; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum TransformReason { diff --git a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java index 98945bce6..1491c1ac4 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/EntityUnleashEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; +import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -16,13 +17,16 @@ import org.jetbrains.annotations.NotNull; * * will have no effect. */ -public class EntityUnleashEvent extends EntityEvent implements org.bukkit.event.Cancellable { // Paper - private static final HandlerList handlers = new HandlerList(); - private final UnleashReason reason; - private boolean dropLeash; // Paper - private boolean cancelled; // Paper +public class EntityUnleashEvent extends EntityEvent implements Cancellable { - // Paper start - drop leash variable + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final UnleashReason reason; + private boolean dropLeash; + + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(forRemoval = true) public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason) { this(entity, reason, false); @@ -31,9 +35,8 @@ public class EntityUnleashEvent extends EntityEvent implements org.bukkit.event. @ApiStatus.Internal public EntityUnleashEvent(@NotNull Entity entity, @NotNull UnleashReason reason, boolean dropLeash) { super(entity); - // Paper end this.reason = reason; - this.dropLeash = dropLeash; // Paper + this.dropLeash = dropLeash; } /** @@ -43,17 +46,16 @@ public class EntityUnleashEvent extends EntityEvent implements org.bukkit.event. */ @NotNull public UnleashReason getReason() { - return reason; + return this.reason; } - // Paper start /** * Returns whether a leash item will be dropped. * * @return Whether the leash item will be dropped */ public boolean isDropLeash() { - return dropLeash; + return this.dropLeash; } /** @@ -67,24 +69,23 @@ public class EntityUnleashEvent extends EntityEvent implements org.bukkit.event. @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } - // Paper end @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum UnleashReason { diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java index 03202de02..b25c62f75 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java @@ -13,10 +13,13 @@ import org.jetbrains.annotations.Nullable; * Called when a ThrownExpBottle hits and releases experience. */ public class ExpBottleEvent extends ProjectileHitEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private int exp; private boolean showEffect = true; + @ApiStatus.Internal @Deprecated(since = "1.20.2", forRemoval = true) public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) { this(bottle, null, null, null, exp); @@ -31,13 +34,13 @@ public class ExpBottleEvent extends ProjectileHitEvent { @NotNull @Override public ThrownExpBottle getEntity() { - return (ThrownExpBottle) entity; + return (ThrownExpBottle) this.entity; } /** * This method indicates if the particle effect should be shown. * - * @return true if the effect will be shown, false otherwise + * @return {@code true} if the effect will be shown, {@code false} otherwise */ public boolean getShowEffect() { return this.showEffect; @@ -48,7 +51,7 @@ public class ExpBottleEvent extends ProjectileHitEvent { *

    * This does not change the experience created. * - * @param showEffect true indicates the effect will be shown, false + * @param showEffect {@code true} indicates the effect will be shown, false * indicates no effect will be shown */ public void setShowEffect(final boolean showEffect) { @@ -63,7 +66,7 @@ public class ExpBottleEvent extends ProjectileHitEvent { * @return the total amount of experience to be created */ public int getExperience() { - return exp; + return this.exp; } /** @@ -80,11 +83,11 @@ public class ExpBottleEvent extends ProjectileHitEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java index 6db5dad71..f7444a734 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ExplosionPrimeEvent.java @@ -4,45 +4,40 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Explosive; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when an entity has made a decision to explode. */ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private float radius; private boolean fire; - public ExplosionPrimeEvent(@NotNull final Entity what, final float radius, final boolean fire) { - super(what); - this.cancel = false; + private boolean cancelled; + + @ApiStatus.Internal + public ExplosionPrimeEvent(@NotNull final Entity entity, final float radius, final boolean fire) { + super(entity); this.radius = radius; this.fire = fire; } + @ApiStatus.Internal public ExplosionPrimeEvent(@NotNull final Explosive explosive) { this(explosive, explosive.getYield(), explosive.isIncendiary()); } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Gets the radius of the explosion * * @return returns the radius of the explosion */ public float getRadius() { - return radius; + return this.radius; } /** @@ -57,29 +52,39 @@ public class ExplosionPrimeEvent extends EntityEvent implements Cancellable { /** * Gets whether this explosion will create fire or not * - * @return true if this explosion will create fire + * @return {@code true} if this explosion will create fire */ public boolean getFire() { - return fire; + return this.fire; } /** * Sets whether this explosion will create fire or not * - * @param fire true if you want this explosion to create fire + * @param fire {@code true} if you want this explosion to create fire */ public void setFire(boolean fire) { this.fire = fire; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java index 51ad0e6bf..ed00d785f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FireworkExplodeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Firework; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,28 +11,13 @@ import org.jetbrains.annotations.NotNull; */ public class FireworkExplodeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public FireworkExplodeEvent(@NotNull final Firework what) { - super(what); - } + private boolean cancelled; - @Override - public boolean isCancelled() { - return cancel; - } - - /** - * Set the cancelled state of this event. If the firework explosion is - * cancelled, the firework will still be removed, but no particles will be - * displayed. - * - * @param cancel whether to cancel or not. - */ - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + @ApiStatus.Internal + public FireworkExplodeEvent(@NotNull final Firework firework) { + super(firework); } @NotNull @@ -40,14 +26,32 @@ public class FireworkExplodeEvent extends EntityEvent implements Cancellable { return (Firework) super.getEntity(); } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + /** + * {@inheritDoc} + *

    + * If the firework explosion is cancelled, the firework will + * still be removed, but no particles will be displayed. + * + * @param cancel whether to cancel or not. + */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java index 7f4c5ea86..11112a9f8 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/FoodLevelChangeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -11,17 +12,23 @@ import org.jetbrains.annotations.Nullable; * Called when a human entity's food level changes */ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private int level; private final ItemStack item; - public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level) { - this(what, level, null); + private boolean cancelled; + + @ApiStatus.Internal + @Deprecated(since = "1.21.5", forRemoval = true) + public FoodLevelChangeEvent(@NotNull final HumanEntity human, final int level) { + this(human, level, null); } - public FoodLevelChangeEvent(@NotNull final HumanEntity what, final int level, @Nullable final ItemStack item) { - super(what); + @ApiStatus.Internal + public FoodLevelChangeEvent(@NotNull final HumanEntity human, final int level, @Nullable final ItemStack item) { + super(human); this.level = level; this.item = item; } @@ -29,7 +36,7 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { @NotNull @Override public HumanEntity getEntity() { - return (HumanEntity) entity; + return (HumanEntity) this.entity; } /** @@ -39,7 +46,7 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { */ @Nullable public ItemStack getItem() { - return (item == null) ? null : item.clone(); + return this.item == null ? null : this.item.clone(); } /** @@ -51,7 +58,7 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { * @return The resultant food level */ public int getFoodLevel() { - return level; + return this.level; } /** @@ -69,22 +76,22 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable { @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java index e8b060d1a..b676c2907 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/HorseJumpEvent.java @@ -3,39 +3,30 @@ package org.bukkit.event.entity; import org.bukkit.entity.AbstractHorse; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a horse jumps. */ public class HorseJumpEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private float power; + private boolean cancelled; + + @ApiStatus.Internal public HorseJumpEvent(@NotNull final AbstractHorse horse, final float power) { super(horse); this.power = power; } - @Override - public boolean isCancelled() { - return cancelled; - } - - /** - * @deprecated horse jumping was moved client side. - */ - @Override - @Deprecated(since = "1.9") - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - @NotNull @Override public AbstractHorse getEntity() { - return (AbstractHorse) entity; + return (AbstractHorse) this.entity; } /** @@ -56,7 +47,7 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { * @return jump strength */ public float getPower() { - return power; + return this.power; } /** @@ -77,14 +68,28 @@ public class HorseJumpEvent extends EntityEvent implements Cancellable { this.power = power; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + /** + * @deprecated horse jumping was moved client side. + */ + @Override + @Deprecated(since = "1.9") + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java index 2bb29fa44..1c931fc29 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemDespawnEvent.java @@ -4,6 +4,7 @@ import org.bukkit.Location; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,29 +15,23 @@ import org.jetbrains.annotations.NotNull; * minutes. This behavior is not guaranteed and may change in future versions. */ public class ItemDespawnEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Location location; - public ItemDespawnEvent(@NotNull final Item despawnee, @NotNull final Location loc) { + private boolean cancelled; + + @ApiStatus.Internal + public ItemDespawnEvent(@NotNull final Item despawnee, @NotNull final Location location) { super(despawnee); - location = loc; - } - - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; + this.location = location; } @NotNull @Override public Item getEntity() { - return (Item) entity; + return (Item) this.entity; } /** @@ -46,17 +41,27 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable { */ @NotNull public Location getLocation() { - return location.clone(); // Paper - clone to avoid changes + return this.location.clone(); + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java index e378cc29b..1a2a3977b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemMergeEvent.java @@ -3,33 +3,27 @@ package org.bukkit.event.entity; import org.bukkit.entity.Item; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; public class ItemMergeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Item target; + private boolean cancelled; + + @ApiStatus.Internal public ItemMergeEvent(@NotNull Item item, @NotNull Item target) { super(item); this.target = target; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancelled) { - this.cancelled = cancelled; - } - @NotNull @Override public Item getEntity() { - return (Item) entity; + return (Item) this.entity; } /** @@ -39,17 +33,27 @@ public class ItemMergeEvent extends EntityEvent implements Cancellable { */ @NotNull public Item getTarget() { - return target; + return this.target; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancelled) { + this.cancelled = cancelled; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java index 61a50f95f..9e8056e0b 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ItemSpawnEvent.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull; */ public class ItemSpawnEvent extends EntitySpawnEvent { + @ApiStatus.Internal @Deprecated(since = "1.13.2", forRemoval = true) public ItemSpawnEvent(@NotNull final Item spawnee, final Location loc) { this(spawnee); @@ -23,6 +24,6 @@ public class ItemSpawnEvent extends EntitySpawnEvent { @NotNull @Override public Item getEntity() { - return (Item) entity; + return (Item) this.entity; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java index da213dc84..de0dbee7d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java @@ -15,11 +15,15 @@ import org.jetbrains.annotations.Nullable; * Called when a splash potion hits an area */ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final AreaEffectCloud entity; - private boolean allowEmptyAreaEffectCreation; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final AreaEffectCloud entity; + private boolean allowEmptyAreaEffectCreation; + + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.20.2", forRemoval = true) public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) { this(potion, null, null, null, entity); @@ -34,7 +38,7 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca @NotNull @Override public ThrownPotion getEntity() { - return (ThrownPotion) super.getEntity(); + return (ThrownPotion) this.entity; } /** @@ -80,11 +84,11 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java index 7119dc013..d09523630 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZapEvent.java @@ -1,43 +1,34 @@ package org.bukkit.event.entity; -import java.util.Collections; -import org.bukkit.entity.Entity; +import com.destroystokyo.paper.event.entity.EntityZapEvent; import org.bukkit.entity.LightningStrike; import org.bukkit.entity.Pig; import org.bukkit.entity.PigZombie; import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Stores data for pigs being zapped */ -public class PigZapEvent extends com.destroystokyo.paper.event.entity.EntityZapEvent implements Cancellable { // Paper - // private static final HandlerList handlers = new HandlerList(); // Paper - moved in the super class - private boolean canceled; - private final PigZombie pigzombie; +public class PigZapEvent extends EntityZapEvent implements Cancellable { + + private final PigZombie zombifiedPiglin; private final LightningStrike bolt; - public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie pigzombie) { - super(pig, bolt, pigzombie); // Paper + private boolean cancelled; + + @ApiStatus.Internal + public PigZapEvent(@NotNull final Pig pig, @NotNull final LightningStrike bolt, @NotNull final PigZombie zombifiedPiglin) { + super(pig, bolt, zombifiedPiglin); this.bolt = bolt; - this.pigzombie = pigzombie; - } - - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; + this.zombifiedPiglin = zombifiedPiglin; } @NotNull @Override public Pig getEntity() { - return (Pig) entity; + return (Pig) this.entity; } /** @@ -47,11 +38,11 @@ public class PigZapEvent extends com.destroystokyo.paper.event.entity.EntityZapE */ @NotNull public LightningStrike getLightning() { - return bolt; + return this.bolt; } /** - * Gets the zombie pig that will replace the pig, provided the event is + * Gets the zombified piglin that will replace the pig, provided the event is * not cancelled first. * * @return resulting entity @@ -60,21 +51,16 @@ public class PigZapEvent extends com.destroystokyo.paper.event.entity.EntityZapE @NotNull @Deprecated(since = "1.13.2") public PigZombie getPigZombie() { - return pigzombie; + return this.zombifiedPiglin; } - // Paper start - /* - @NotNull @Override - public HandlerList getHandlers() { - return handlers; + public boolean isCancelled() { + return this.cancelled; } - @NotNull - public static HandlerList getHandlerList() { - return handlers; + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } - */ - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java index bb4f13bbb..a7bc404c1 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PigZombieAngerEvent.java @@ -4,23 +4,27 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.PigZombie; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * Called when a Pig Zombie is angered by another entity. + * Called when a Zombified piglin is angered by another entity. *

    - * If the event is cancelled, the pig zombie will not be angered. + * If the event is cancelled, the zombified piglin will not be angered. */ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity target; private int newAnger; - public PigZombieAngerEvent(@NotNull final PigZombie pigZombie, @Nullable final Entity target, final int newAnger) { - super(pigZombie); + private boolean cancelled; + + @ApiStatus.Internal + public PigZombieAngerEvent(@NotNull final PigZombie zombifiedPiglin, @Nullable final Entity target, final int newAnger) { + super(zombifiedPiglin); this.target = target; this.newAnger = newAnger; } @@ -28,11 +32,11 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { /** * Gets the entity (if any) which triggered this anger update. * - * @return triggering entity, or null + * @return triggering entity, or {@code null} */ @Nullable public Entity getTarget() { - return target; + return this.target; } /** @@ -42,7 +46,7 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { * @see PigZombie#getAnger() */ public int getNewAnger() { - return newAnger; + return this.newAnger; } /** @@ -58,27 +62,27 @@ public class PigZombieAngerEvent extends EntityEvent implements Cancellable { @NotNull @Override public PigZombie getEntity() { - return (PigZombie) entity; + return (PigZombie) this.entity; } @Override public boolean isCancelled() { - return canceled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - canceled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PiglinBarterEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PiglinBarterEvent.java index bd67b7cba..ffad58a1f 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PiglinBarterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PiglinBarterEvent.java @@ -5,22 +5,26 @@ import org.bukkit.entity.Piglin; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Stores all data related to the bartering interaction with a piglin. - * + *
    * Called when a piglin completes a barter. */ public class PiglinBarterEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List outcome; private final ItemStack input; - public PiglinBarterEvent(@NotNull Piglin what, @NotNull ItemStack input, @NotNull List outcome) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public PiglinBarterEvent(@NotNull Piglin piglin, @NotNull ItemStack input, @NotNull List outcome) { + super(piglin); this.input = input; this.outcome = outcome; @@ -29,7 +33,7 @@ public class PiglinBarterEvent extends EntityEvent implements Cancellable { @NotNull @Override public Piglin getEntity() { - return (Piglin) super.getEntity(); + return (Piglin) this.entity; } /** @@ -39,7 +43,7 @@ public class PiglinBarterEvent extends EntityEvent implements Cancellable { */ @NotNull public ItemStack getInput() { - return input.clone(); + return this.input.clone(); } /** @@ -49,27 +53,27 @@ public class PiglinBarterEvent extends EntityEvent implements Cancellable { */ @NotNull public List getOutcome() { - return outcome; + return this.outcome; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java index ab7584873..deb1e59ef 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -1,9 +1,13 @@ package org.bukkit.event.entity; +import java.util.ArrayList; import java.util.List; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.damage.DamageSource; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -11,76 +15,253 @@ import org.jetbrains.annotations.Nullable; * Thrown whenever a {@link Player} dies */ public class PlayerDeathEvent extends EntityDeathEvent { + private int newExp = 0; - private net.kyori.adventure.text.Component deathMessage; // Paper - adventure private int newLevel = 0; private int newTotalExp = 0; + private Component deathMessage; + private boolean doExpDrop; private boolean keepLevel = false; private boolean keepInventory = false; - private boolean doExpDrop; // Paper - shouldDropExperience API - // Paper start - adventure - @org.jetbrains.annotations.ApiStatus.Internal - public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final @Nullable net.kyori.adventure.text.Component deathMessage) { + @Deprecated + private final List itemsToKeep = new ArrayList<>(); + + @ApiStatus.Internal + public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final @Nullable Component deathMessage) { this(player, damageSource, drops, droppedExp, 0, deathMessage); } - @org.jetbrains.annotations.ApiStatus.Internal - public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final @Nullable net.kyori.adventure.text.Component deathMessage) { + @ApiStatus.Internal + public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final @Nullable Component deathMessage) { this(player, damageSource, drops, droppedExp, newExp, 0, 0, deathMessage); } - @org.jetbrains.annotations.ApiStatus.Internal - public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable net.kyori.adventure.text.Component deathMessage) { - // Paper start - shouldDropExperience API + @ApiStatus.Internal + public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable Component deathMessage) { this(player, damageSource, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true); } - @org.jetbrains.annotations.ApiStatus.Internal - public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable net.kyori.adventure.text.Component deathMessage, final boolean doExpDrop) { - // Paper end - shouldDropExperience API + @ApiStatus.Internal + public PlayerDeathEvent(final @NotNull Player player, final @NotNull DamageSource damageSource, final @NotNull List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, final @Nullable Component deathMessage, final boolean doExpDrop) { super(player, damageSource, drops, droppedExp); this.newExp = newExp; this.newTotalExp = newTotalExp; this.newLevel = newLevel; this.deathMessage = deathMessage; - this.doExpDrop = doExpDrop; // Paper - shouldDropExperience API + this.doExpDrop = doExpDrop; } - // Paper end - adventure + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, @Nullable final String deathMessage) { this(player, damageSource, drops, droppedExp, 0, deathMessage); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int newExp, @Nullable final String deathMessage) { this(player, damageSource, drops, droppedExp, newExp, 0, 0, deathMessage); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerDeathEvent(@NotNull final Player player, @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage) { - // Paper start - shouldDropExperience API this(player, damageSource, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage, true); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerDeathEvent(@NotNull final Player player, final @NotNull DamageSource damageSource, @NotNull final List drops, final int droppedExp, final int newExp, final int newTotalExp, final int newLevel, @Nullable final String deathMessage, boolean doExpDrop) { - // Paper end - shouldDropExperience API super(player, damageSource, drops, droppedExp); this.newExp = newExp; this.newTotalExp = newTotalExp; this.newLevel = newLevel; - this.deathMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(deathMessage); // Paper - this.doExpDrop = doExpDrop; // Paper - shouldDropExperience API + this.deathMessage = LegacyComponentSerializer.legacySection().deserializeOrNull(deathMessage); + this.doExpDrop = doExpDrop; } - @Deprecated // Paper - // Paper start - private List itemsToKeep = new java.util.ArrayList<>(); + @NotNull + @Override + public Player getEntity() { + return (Player) this.entity; + } + + /** + * Clarity method for getting the player. Not really needed except + * for reasons of clarity. + * + * @return Player who is involved in this event + */ + public @NotNull Player getPlayer() { + return this.getEntity(); + } + + /** + * Gets how much EXP the Player should have at respawn. + *

    + * This does not indicate how much EXP should be dropped, please see + * {@link #getDroppedExp()} for that. + * + * @return New EXP of the respawned player + */ + public int getNewExp() { + return this.newExp; + } + + /** + * Sets how much EXP the Player should have at respawn. + *

    + * This does not indicate how much EXP should be dropped, please see + * {@link #setDroppedExp(int)} for that. + * + * @param exp New EXP of the respawned player + */ + public void setNewExp(int exp) { + this.newExp = exp; + } + + /** + * Gets the Level the Player should have at respawn. + * + * @return New Level of the respawned player + */ + public int getNewLevel() { + return this.newLevel; + } + + /** + * Sets the Level the Player should have at respawn. + * + * @param level New Level of the respawned player + */ + public void setNewLevel(int level) { + this.newLevel = level; + } + + /** + * Gets the Total EXP the Player should have at respawn. + * + * @return New Total EXP of the respawned player + */ + public int getNewTotalExp() { + return this.newTotalExp; + } + + /** + * Sets the Total EXP the Player should have at respawn. + * + * @param totalExp New Total EXP of the respawned player + */ + public void setNewTotalExp(int totalExp) { + this.newTotalExp = totalExp; + } + + /** + * Set the death message that will appear to everyone on the server. + * + * @param deathMessage Component message to appear to other players on the server. + */ + public void deathMessage(final @Nullable Component deathMessage) { + this.deathMessage = deathMessage; + } + + /** + * Get the death message that will appear to everyone on the server. + * + * @return Component message to appear to other players on the server. + */ + public @Nullable Component deathMessage() { + return this.deathMessage; + } + + /** + * Set the death message that will appear to everyone on the server. + * + * @param deathMessage Message to appear to other players on the server. + * @deprecated in favour of {@link #deathMessage(Component)} + */ + @Deprecated + public void setDeathMessage(@Nullable String deathMessage) { + this.deathMessage = LegacyComponentSerializer.legacySection().deserializeOrNull(deathMessage); + } + + /** + * Get the death message that will appear to everyone on the server. + * + * @return Message to appear to other players on the server. + * @deprecated in favour of {@link #deathMessage()} + */ + @Nullable + @Deprecated + public String getDeathMessage() { + return LegacyComponentSerializer.legacySection().serializeOrNull(this.deathMessage); + } + + /** + * @return should experience be dropped from this death + */ + public boolean shouldDropExperience() { + return this.doExpDrop; + } + + /** + * @param doExpDrop sets if experience should be dropped from this death + */ + public void setShouldDropExperience(boolean doExpDrop) { + this.doExpDrop = doExpDrop; + } + + /** + * Gets if the Player should keep all EXP at respawn. + *

    + * This flag overrides other EXP settings + * + * @return {@code true} if Player should keep all pre-death exp + */ + public boolean getKeepLevel() { + return this.keepLevel; + } + + /** + * Sets if the Player should keep all EXP at respawn. + *

    + * This overrides all other EXP settings + *

    + * This doesn't prevent the EXP from dropping. + * {@link #setDroppedExp(int)} should be used stop the + * EXP from dropping. + * + * @param keepLevel {@code true} to keep all current value levels + */ + public void setKeepLevel(boolean keepLevel) { + this.keepLevel = keepLevel; + } + + /** + * Sets if the Player keeps inventory on death. + *

    + * This doesn't prevent the items from dropping. + * {@code getDrops().clear()} should be used stop the + * items from dropping. + * + * @param keepInventory {@code true} to keep the inventory + */ + public void setKeepInventory(boolean keepInventory) { + this.keepInventory = keepInventory; + } + + /** + * Gets if the Player keeps inventory on death. + * + * @return {@code true} if the player keeps inventory on death + */ + public boolean getKeepInventory() { + return this.keepInventory; + } /** * A mutable collection to add items that the player should retain in their inventory on death (Similar to KeepInventory game rule) - * + *
    * You MUST remove the item from the .getDrops() collection too or it will duplicate! *

    {@code
          *    {@literal @EventHandler(ignoreCancelled = true)}
    @@ -97,7 +278,7 @@ public class PlayerDeathEvent extends EntityDeathEvent {
          *         }
          *     }
          * }
    - * + *

    * Adding an item to this list that the player did not previously have will give them the item on death. * An example case could be a "Note" that "You died at X/Y/Z coordinates" * @@ -105,193 +286,6 @@ public class PlayerDeathEvent extends EntityDeathEvent { */ @NotNull public List getItemsToKeep() { - return itemsToKeep; - } - // Paper end - - // Paper start - shouldDropExperience API - /** - * @return should experience be dropped from this death - */ - public boolean shouldDropExperience() { - return doExpDrop; - } - - /** - * @param doExpDrop sets if experience should be dropped from this death - */ - public void setShouldDropExperience(boolean doExpDrop) { - this.doExpDrop = doExpDrop; - } - // Paper end - shouldDropExperience API - - @NotNull - @Override - public Player getEntity() { - return (Player) entity; - } - - // Paper start - improve death events - /** - * Clarity method for getting the player. Not really needed except - * for reasons of clarity. - * - * @return Player who is involved in this event - */ - public @NotNull Player getPlayer() { - return this.getEntity(); - } - - // Paper end - improve death events - - // Paper start - adventure - /** - * Set the death message that will appear to everyone on the server. - * - * @param deathMessage Component message to appear to other players on the server. - */ - public void deathMessage(final net.kyori.adventure.text.@Nullable Component deathMessage) { - this.deathMessage = deathMessage; - } - - /** - * Get the death message that will appear to everyone on the server. - * - * @return Component message to appear to other players on the server. - */ - public net.kyori.adventure.text.@Nullable Component deathMessage() { - return this.deathMessage; - } - // Paper end - adventure - - /** - * Set the death message that will appear to everyone on the server. - * - * @param deathMessage Message to appear to other players on the server. - * @deprecated in favour of {@link #deathMessage(net.kyori.adventure.text.Component)} - */ - @Deprecated // Paper - public void setDeathMessage(@Nullable String deathMessage) { - this.deathMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserializeOrNull(deathMessage); // Paper - } - - /** - * Get the death message that will appear to everyone on the server. - * - * @return Message to appear to other players on the server. - * @deprecated in favour of {@link #deathMessage()} - */ - @Nullable - @Deprecated // Paper - public String getDeathMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serializeOrNull(this.deathMessage); // Paper - } - // Paper end - /** - * Gets how much EXP the Player should have at respawn. - *

    - * This does not indicate how much EXP should be dropped, please see - * {@link #getDroppedExp()} for that. - * - * @return New EXP of the respawned player - */ - public int getNewExp() { - return newExp; - } - - /** - * Sets how much EXP the Player should have at respawn. - *

    - * This does not indicate how much EXP should be dropped, please see - * {@link #setDroppedExp(int)} for that. - * - * @param exp New EXP of the respawned player - */ - public void setNewExp(int exp) { - newExp = exp; - } - - /** - * Gets the Level the Player should have at respawn. - * - * @return New Level of the respawned player - */ - public int getNewLevel() { - return newLevel; - } - - /** - * Sets the Level the Player should have at respawn. - * - * @param level New Level of the respawned player - */ - public void setNewLevel(int level) { - newLevel = level; - } - - /** - * Gets the Total EXP the Player should have at respawn. - * - * @return New Total EXP of the respawned player - */ - public int getNewTotalExp() { - return newTotalExp; - } - - /** - * Sets the Total EXP the Player should have at respawn. - * - * @param totalExp New Total EXP of the respawned player - */ - public void setNewTotalExp(int totalExp) { - newTotalExp = totalExp; - } - - /** - * Gets if the Player should keep all EXP at respawn. - *

    - * This flag overrides other EXP settings - * - * @return True if Player should keep all pre-death exp - */ - public boolean getKeepLevel() { - return keepLevel; - } - - /** - * Sets if the Player should keep all EXP at respawn. - *

    - * This overrides all other EXP settings - *

    - * This doesn't prevent the EXP from dropping. - * {@link #setDroppedExp(int)} should be used stop the - * EXP from dropping. - * - * @param keepLevel True to keep all current value levels - */ - public void setKeepLevel(boolean keepLevel) { - this.keepLevel = keepLevel; - } - - /** - * Sets if the Player keeps inventory on death. - *

    - * This doesn't prevent the items from dropping. - * {@code getDrops().clear()} should be used stop the - * items from dropping. - * - * @param keepInventory True to keep the inventory - */ - public void setKeepInventory(boolean keepInventory) { - this.keepInventory = keepInventory; - } - - /** - * Gets if the Player keeps inventory on death. - * - * @return True if the player keeps inventory on death - */ - public boolean getKeepInventory() { - return keepInventory; + return this.itemsToKeep; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java index e58e0b1d6..f0e4ade7d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PlayerLeashEntityEvent.java @@ -13,24 +13,28 @@ import org.jetbrains.annotations.NotNull; * Called immediately prior to a creature being leashed by a player. */ public class PlayerLeashEntityEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity leashHolder; private final Entity entity; - private boolean cancelled = false; private final Player player; private final EquipmentSlot hand; + private boolean cancelled; + @ApiStatus.Internal - public PlayerLeashEntityEvent(@NotNull Entity what, @NotNull Entity leashHolder, @NotNull Player leasher, @NotNull EquipmentSlot hand) { + public PlayerLeashEntityEvent(@NotNull Entity entity, @NotNull Entity leashHolder, @NotNull Player leasher, @NotNull EquipmentSlot hand) { this.leashHolder = leashHolder; - this.entity = what; + this.entity = entity; this.player = leasher; this.hand = hand; } + @ApiStatus.Internal @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerLeashEntityEvent(@NotNull Entity what, @NotNull Entity leashHolder, @NotNull Player leasher) { - this(what, leashHolder, leasher, EquipmentSlot.HAND); + public PlayerLeashEntityEvent(@NotNull Entity entity, @NotNull Entity leashHolder, @NotNull Player leasher) { + this(entity, leashHolder, leasher, EquipmentSlot.HAND); } /** @@ -40,7 +44,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { */ @NotNull public Entity getLeashHolder() { - return leashHolder; + return this.leashHolder; } /** @@ -50,7 +54,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } /** @@ -60,7 +64,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { */ @NotNull public final Player getPlayer() { - return player; + return this.player; } /** @@ -70,18 +74,7 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { */ @NotNull public EquipmentSlot getHand() { - return hand; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; + return this.hand; } @Override @@ -93,4 +86,15 @@ public class PlayerLeashEntityEvent extends Event implements Cancellable { public void setCancelled(boolean cancel) { this.cancelled = cancel; } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java index 82ee49da5..f085ebdef 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java @@ -19,10 +19,13 @@ import org.jetbrains.annotations.Nullable; * Called when a splash potion hits an area */ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - protected final Map affectedEntities; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + protected final Map affectedEntities; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.20.2", forRemoval = true) public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map affectedEntities) { this(potion, null, null, null, affectedEntities); @@ -37,7 +40,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable @NotNull @Override public ThrownPotion getEntity() { - return (ThrownPotion) entity; + return (ThrownPotion) this.entity; } /** @@ -47,7 +50,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable */ @NotNull public ThrownPotion getPotion() { - return (ThrownPotion) getEntity(); + return this.getEntity(); } /** @@ -57,7 +60,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable */ @NotNull public Collection getAffectedEntities() { - return new ArrayList(affectedEntities.keySet()); + return new ArrayList<>(this.affectedEntities.keySet()); } /** @@ -69,7 +72,7 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable * fully hit by potion effects */ public double getIntensity(@NotNull LivingEntity entity) { - Double intensity = affectedEntities.get(entity); + Double intensity = this.affectedEntities.get(entity); return intensity != null ? intensity : 0.0; } @@ -82,30 +85,30 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable public void setIntensity(@NotNull LivingEntity entity, double intensity) { Preconditions.checkArgument(entity != null, "You must specify a valid entity."); if (intensity <= 0.0) { - affectedEntities.remove(entity); + this.affectedEntities.remove(entity); } else { - affectedEntities.put(entity, Math.min(intensity, 1.0)); + this.affectedEntities.put(entity, Math.min(intensity, 1.0)); } } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java index b64b41e6b..76121957d 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileHitEvent.java @@ -14,28 +14,35 @@ import org.jetbrains.annotations.Nullable; * Called when a projectile hits an object */ public class ProjectileHitEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity hitEntity; private final Block hitBlock; private final BlockFace hitFace; - private boolean cancel = false; - @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Paper + private boolean cancelled; + + @ApiStatus.Internal + @Deprecated(forRemoval = true) public ProjectileHitEvent(@NotNull final Projectile projectile) { - this(projectile, null, null, null); // Paper + this(projectile, null, null, null); } - @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Paper + @ApiStatus.Internal + @Deprecated(forRemoval = true) public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity) { - this(projectile, hitEntity, null, null); // Paper + this(projectile, hitEntity, null, null); } - @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Paper + @ApiStatus.Internal + @Deprecated(forRemoval = true) public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Block hitBlock) { - this(projectile, null, hitBlock, null); // Paper + this(projectile, null, hitBlock, null); } - @Deprecated(forRemoval = true) @io.papermc.paper.annotation.DoNotUse // Paper + @ApiStatus.Internal + @Deprecated(forRemoval = true) public ProjectileHitEvent(@NotNull final Projectile projectile, @Nullable Entity hitEntity, @Nullable Block hitBlock) { this(projectile, hitEntity, hitBlock, null); } @@ -51,72 +58,70 @@ public class ProjectileHitEvent extends EntityEvent implements Cancellable { @NotNull @Override public Projectile getEntity() { - return (Projectile) entity; + return (Projectile) this.entity; + } + + /** + * Gets the entity that was hit, if it was an entity that was hit. + * + * @return hit entity or else {@code null} + */ + @Nullable + public Entity getHitEntity() { + return this.hitEntity; } /** * Gets the block that was hit, if it was a block that was hit. * - * @return hit block or else null + * @return hit block or else {@code null} */ @Nullable public Block getHitBlock() { - return hitBlock; + return this.hitBlock; } /** * Gets the block face that was hit, if it was a block that was hit and the * face was provided in the event. * - * @return hit face or else null + * @return hit face or else {@code null} */ @Nullable public BlockFace getHitBlockFace() { - return hitFace; - } - - /** - * Gets the entity that was hit, if it was an entity that was hit. - * - * @return hit entity or else null - */ - @Nullable - public Entity getHitEntity() { - return hitEntity; + return this.hitFace; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } /** * Whether to cancel the action that occurs when the projectile hits. - * + *

    * In the case of an entity, it will not collide (unless it's a firework, * then use {@link FireworkExplodeEvent}). *
    - * In the case of a block, some blocks (eg target block, bell) will not + * In the case of a block, some blocks (e.g. target block, bell) will not * perform the action associated. - *
    + *

    * This does NOT prevent block collisions, and explosions will still occur * unless their respective events are cancelled. - * - * @param cancel true if you wish to cancel this event */ @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java index c5fc3c558..3c8b56e56 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/ProjectileLaunchEvent.java @@ -3,31 +3,34 @@ package org.bukkit.event.entity; import org.bukkit.entity.Entity; import org.bukkit.entity.Projectile; import org.bukkit.event.Cancellable; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a projectile is launched. */ public class ProjectileLaunchEvent extends EntitySpawnEvent implements Cancellable { + private boolean cancelled; - public ProjectileLaunchEvent(@NotNull Entity what) { - super(what); - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; + @ApiStatus.Internal + public ProjectileLaunchEvent(@NotNull Entity entity) { + super(entity); } @NotNull @Override public Projectile getEntity() { - return (Projectile) entity; + return (Projectile) this.entity; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java index f3afd40c8..c791dec81 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SheepDyeWoolEvent.java @@ -1,10 +1,9 @@ package org.bukkit.event.entity; +import io.papermc.paper.event.entity.EntityDyeEvent; import org.bukkit.DyeColor; import org.bukkit.entity.Player; import org.bukkit.entity.Sheep; -import org.bukkit.event.Cancellable; -import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,9 +11,9 @@ import org.jetbrains.annotations.Nullable; /** * Called when a sheep's wool is dyed */ -public class SheepDyeWoolEvent extends io.papermc.paper.event.entity.EntityDyeEvent implements Cancellable { - // Paper - move everything to superclass +public class SheepDyeWoolEvent extends EntityDyeEvent { + @ApiStatus.Internal @Deprecated(since = "1.17.1", forRemoval = true) public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color) { this(sheep, color, null); @@ -22,12 +21,12 @@ public class SheepDyeWoolEvent extends io.papermc.paper.event.entity.EntityDyeEv @ApiStatus.Internal public SheepDyeWoolEvent(@NotNull final Sheep sheep, @NotNull final DyeColor color, @Nullable Player player) { - super(sheep, color, player); // Paper + super(sheep, color, player); } @NotNull @Override public Sheep getEntity() { - return (Sheep) entity; + return (Sheep) this.entity; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java index 05264b31a..74743cb94 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SheepRegrowWoolEvent.java @@ -3,45 +3,47 @@ package org.bukkit.event.entity; import org.bukkit.entity.Sheep; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a sheep regrows its wool */ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private boolean cancelled; + + @ApiStatus.Internal public SheepRegrowWoolEvent(@NotNull final Sheep sheep) { super(sheep); - this.cancel = false; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; } @NotNull @Override public Sheep getEntity() { - return (Sheep) entity; + return (Sheep) this.entity; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } - } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java index 02b659847..f71e62c8e 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SlimeSplitEvent.java @@ -3,35 +3,29 @@ package org.bukkit.event.entity; import org.bukkit.entity.Slime; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a Slime splits into smaller Slimes upon death */ public class SlimeSplitEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - private int count; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private int count; + private boolean cancelled; + + @ApiStatus.Internal public SlimeSplitEvent(@NotNull final Slime slime, final int count) { super(slime); this.count = count; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - @NotNull @Override public Slime getEntity() { - return (Slime) entity; + return (Slime) this.entity; } /** @@ -40,7 +34,7 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { * @return the amount of slimes to spawn */ public int getCount() { - return count; + return this.count; } /** @@ -52,14 +46,24 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable { this.count = count; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java index f3ec8f673..bc08511b3 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java @@ -2,17 +2,21 @@ package org.bukkit.event.entity; import org.bukkit.block.CreatureSpawner; import org.bukkit.entity.Entity; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when an entity is spawned into a world by a spawner. *

    - * If a Spawner Spawn event is cancelled, the entity will not spawn. + * If this event is cancelled, the entity will not spawn. */ public class SpawnerSpawnEvent extends EntitySpawnEvent { + private final CreatureSpawner spawner; - public SpawnerSpawnEvent(@NotNull final Entity spawnee, @org.jetbrains.annotations.Nullable final CreatureSpawner spawner) { // Paper + @ApiStatus.Internal + public SpawnerSpawnEvent(@NotNull final Entity spawnee, @Nullable final CreatureSpawner spawner) { // Paper super(spawnee); this.spawner = spawner; } @@ -24,8 +28,8 @@ public class SpawnerSpawnEvent extends EntitySpawnEvent { * * @return the spawner tile state */ - @org.jetbrains.annotations.Nullable // Paper + @Nullable public CreatureSpawner getSpawner() { - return spawner; + return this.spawner; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/StriderTemperatureChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/StriderTemperatureChangeEvent.java index 26a4f88a3..572f69df6 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/StriderTemperatureChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/StriderTemperatureChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.entity; import org.bukkit.entity.Strider; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,19 +12,21 @@ import org.jetbrains.annotations.NotNull; */ public class StriderTemperatureChangeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final boolean shivering; private boolean cancelled; - public StriderTemperatureChangeEvent(@NotNull Strider what, boolean shivering) { - super(what); + @ApiStatus.Internal + public StriderTemperatureChangeEvent(@NotNull Strider strider, boolean shivering) { + super(strider); this.shivering = shivering; } @NotNull @Override public Strider getEntity() { - return (Strider) entity; + return (Strider) this.entity; } /** @@ -32,12 +35,12 @@ public class StriderTemperatureChangeEvent extends EntityEvent implements Cancel * @return the new shivering state */ public boolean isShivering() { - return shivering; + return this.shivering; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -48,11 +51,11 @@ public class StriderTemperatureChangeEvent extends EntityEvent implements Cancel @Override @NotNull public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/TrialSpawnerSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/TrialSpawnerSpawnEvent.java index 589b06ce0..bdbb5c193 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/TrialSpawnerSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/TrialSpawnerSpawnEvent.java @@ -8,12 +8,14 @@ import org.jetbrains.annotations.NotNull; /** * Called when an entity is spawned into a world by a trial spawner. *

    - * If a Trial Spawner Spawn event is cancelled, the entity will not spawn. + * If this event is cancelled, the entity will not spawn. */ @ApiStatus.Experimental public class TrialSpawnerSpawnEvent extends EntitySpawnEvent { + private final TrialSpawner spawner; + @ApiStatus.Internal public TrialSpawnerSpawnEvent(@NotNull final Entity spawnee, @NotNull final TrialSpawner spawner) { super(spawnee); this.spawner = spawner; @@ -21,6 +23,6 @@ public class TrialSpawnerSpawnEvent extends EntitySpawnEvent { @NotNull public TrialSpawner getTrialSpawner() { - return spawner; + return this.spawner; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java index 58155105d..e515790ff 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerAcquireTradeEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.AbstractVillager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,16 +12,23 @@ import org.jetbrains.annotations.NotNull; */ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - // - private MerchantRecipe recipe; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public VillagerAcquireTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) { - super(what); + private MerchantRecipe recipe; + private boolean cancelled; + + @ApiStatus.Internal + public VillagerAcquireTradeEvent(@NotNull AbstractVillager villager, @NotNull MerchantRecipe recipe) { + super(villager); this.recipe = recipe; } + @NotNull + @Override + public AbstractVillager getEntity() { + return (AbstractVillager) this.entity; + } + /** * Get the recipe to be acquired. * @@ -28,7 +36,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl */ @NotNull public MerchantRecipe getRecipe() { - return recipe; + return this.recipe; } /** @@ -42,7 +50,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -50,20 +58,14 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl this.cancelled = cancel; } - @NotNull - @Override - public AbstractVillager getEntity() { - return (AbstractVillager) super.getEntity(); - } - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java index 346899bc0..c441c2cd0 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerCareerChangeEvent.java @@ -4,17 +4,21 @@ import org.bukkit.entity.Villager; import org.bukkit.entity.Villager.Profession; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; public class VillagerCareerChangeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Profession profession; private final ChangeReason reason; - public VillagerCareerChangeEvent(@NotNull Villager what, @NotNull Profession profession, @NotNull ChangeReason reason) { - super(what); + private boolean cancelled; + + @ApiStatus.Internal + public VillagerCareerChangeEvent(@NotNull Villager villager, @NotNull Profession profession, @NotNull ChangeReason reason) { + super(villager); this.profession = profession; this.reason = reason; } @@ -22,7 +26,7 @@ public class VillagerCareerChangeEvent extends EntityEvent implements Cancellabl @NotNull @Override public Villager getEntity() { - return (Villager) super.getEntity(); + return (Villager) this.entity; } /** @@ -32,7 +36,7 @@ public class VillagerCareerChangeEvent extends EntityEvent implements Cancellabl */ @NotNull public Profession getProfession() { - return profession; + return this.profession; } /** @@ -51,28 +55,28 @@ public class VillagerCareerChangeEvent extends EntityEvent implements Cancellabl */ @NotNull public ChangeReason getReason() { - return reason; + return this.reason; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java index f1dc767eb..37a228376 100644 --- a/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/entity/VillagerReplenishTradeEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Villager; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.MerchantRecipe; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,16 +17,23 @@ import org.jetbrains.annotations.NotNull; */ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - // - private MerchantRecipe recipe; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) { - super(what); + private MerchantRecipe recipe; + private boolean cancelled; + + @ApiStatus.Internal + public VillagerReplenishTradeEvent(@NotNull AbstractVillager villager, @NotNull MerchantRecipe recipe) { + super(villager); this.recipe = recipe; } + @NotNull + @Override + public AbstractVillager getEntity() { + return (AbstractVillager) super.getEntity(); + } + /** * Get the recipe to replenish. * @@ -33,7 +41,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella */ @NotNull public MerchantRecipe getRecipe() { - return recipe; + return this.recipe; } /** @@ -54,7 +62,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella */ @Deprecated(since = "1.18.1") public int getBonus() { - return recipe.getUses(); + return this.recipe.getUses(); } /** @@ -70,7 +78,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -78,20 +86,14 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella this.cancelled = cancel; } - @NotNull - @Override - public AbstractVillager getEntity() { - return (AbstractVillager) super.getEntity(); - } - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java index 454885e47..d9e935274 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakByEntityEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Entity; import org.bukkit.entity.Hanging; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -9,13 +10,16 @@ import org.jetbrains.annotations.Nullable; * Triggered when a hanging entity is removed by an entity */ public class HangingBreakByEntityEvent extends HangingBreakEvent { + private final Entity remover; - public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover) { // Paper + @ApiStatus.Internal + public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover) { this(hanging, remover, HangingBreakEvent.RemoveCause.ENTITY); } - public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) { // Paper + @ApiStatus.Internal + public HangingBreakByEntityEvent(@NotNull final Hanging hanging, @NotNull final Entity remover, @NotNull final HangingBreakEvent.RemoveCause cause) { super(hanging, cause); this.remover = remover; } @@ -25,8 +29,8 @@ public class HangingBreakByEntityEvent extends HangingBreakEvent { * * @return the entity that removed the hanging entity */ - @NotNull // Paper + @NotNull public Entity getRemover() { - return remover; + return this.remover; } } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java index 16d8196e1..8e2ee7cc2 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingBreakEvent.java @@ -3,16 +3,20 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Hanging; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Triggered when a hanging entity is removed */ public class HangingBreakEvent extends HangingEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final HangingBreakEvent.RemoveCause cause; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final HangingBreakEvent.RemoveCause cause; + private boolean cancelled; + + @ApiStatus.Internal public HangingBreakEvent(@NotNull final Hanging hanging, @NotNull final HangingBreakEvent.RemoveCause cause) { super(hanging); this.cause = cause; @@ -25,12 +29,12 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { */ @NotNull public HangingBreakEvent.RemoveCause getCause() { - return cause; + return this.cause; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -38,6 +42,17 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { this.cancelled = cancel; } + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + /** * An enum to specify the cause of the removal */ @@ -63,15 +78,4 @@ public class HangingBreakEvent extends HangingEvent implements Cancellable { */ DEFAULT, } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java index f01a1a0f0..2a61941f1 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingEvent.java @@ -2,12 +2,14 @@ package org.bukkit.event.hanging; import org.bukkit.entity.Hanging; import org.bukkit.event.Event; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Represents a hanging entity-related event. */ public abstract class HangingEvent extends Event { + protected Hanging hanging; protected HangingEvent(@NotNull final Hanging painting) { @@ -21,6 +23,6 @@ public abstract class HangingEvent extends Event { */ @NotNull public Hanging getEntity() { - return hanging; + return this.hanging; } } diff --git a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java index 08ff883d9..223d4f0cc 100644 --- a/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/hanging/HangingPlaceEvent.java @@ -16,14 +16,18 @@ import org.jetbrains.annotations.Nullable; * Triggered when a hanging entity is created in the world */ public class HangingPlaceEvent extends HangingEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; private final Block block; private final BlockFace blockFace; private final EquipmentSlot hand; private final ItemStack itemStack; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.17.1") public HangingPlaceEvent(@NotNull final Hanging hanging, @Nullable final Player player, @NotNull final Block block, @NotNull final BlockFace blockFace, @Nullable final EquipmentSlot hand) { this(hanging, player, block, blockFace, hand, null); @@ -46,7 +50,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { */ @Nullable public Player getPlayer() { - return player; + return this.player; } /** @@ -56,7 +60,7 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { */ @NotNull public Block getBlock() { - return block; + return this.block; } /** @@ -66,18 +70,18 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { */ @NotNull public BlockFace getBlockFace() { - return blockFace; + return this.blockFace; } /** - * Returns the hand that was used to place the hanging entity, or null + * Returns the hand that was used to place the hanging entity, or {@code null} * if a player did not place the hanging entity. * * @return the hand */ @Nullable public EquipmentSlot getHand() { - return hand; + return this.hand; } /** @@ -87,12 +91,12 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { */ @Nullable public ItemStack getItemStack() { - return itemStack; + return this.itemStack; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -103,11 +107,11 @@ public class HangingPlaceEvent extends HangingEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java index f37cc5dee..e67c074c6 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/BrewEvent.java @@ -7,6 +7,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.BrewerInventory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,12 +15,16 @@ import org.jetbrains.annotations.NotNull; * complete. */ public class BrewEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private BrewerInventory contents; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final BrewerInventory contents; private final List results; - private int fuelLevel; + private final int fuelLevel; + private boolean cancelled; + @ApiStatus.Internal public BrewEvent(@NotNull Block brewer, @NotNull BrewerInventory contents, @NotNull List results, int fuelLevel) { super(brewer); this.contents = contents; @@ -30,28 +35,18 @@ public class BrewEvent extends BlockEvent implements Cancellable { /** * Gets the contents of the Brewing Stand. * - * Note: The brewer inventory still holds the items found prior to - * the finalization of the brewing process, e.g. the plain water bottles. - * * @return the contents + * @apiNote The brewer inventory still holds the items found prior to + * the finalization of the brewing process, e.g. the plain water bottles. */ @NotNull public BrewerInventory getContents() { - return contents; - } - - /** - * Gets the remaining fuel level. - * - * @return the remaining fuel - */ - public int getFuelLevel() { - return fuelLevel; + return this.contents; } /** * Gets the resulting items in the Brewing Stand. - * + *

    * The returned list, in case of a server-created event instance, is * mutable. Any changes in the returned list will reflect in the brewing * result if the event is not cancelled. If the size of the list is reduced, @@ -61,27 +56,36 @@ public class BrewEvent extends BlockEvent implements Cancellable { */ @NotNull public List getResults() { - return results; + return this.results; + } + + /** + * Gets the remaining fuel level. + * + * @return the remaining fuel + */ + public int getFuelLevel() { + return this.fuelLevel; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java index 633ec5187..c70457fce 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/BrewingStandFuelEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,12 +14,15 @@ import org.jetbrains.annotations.NotNull; */ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack fuel; private int fuelPower; - private boolean cancelled; private boolean consuming = true; + private boolean cancelled; + + @ApiStatus.Internal public BrewingStandFuelEvent(@NotNull Block brewingStand, @NotNull ItemStack fuel, int fuelPower) { super(brewingStand); this.fuel = fuel; @@ -32,7 +36,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getFuel() { - return fuel; + return this.fuel; } /** @@ -42,7 +46,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { * @return the fuel power for this fuel */ public int getFuelPower() { - return fuelPower; + return this.fuelPower; } /** @@ -61,7 +65,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { * @return whether the fuel will be reduced or not */ public boolean isConsuming() { - return consuming; + return this.consuming; } /** @@ -75,7 +79,7 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -86,11 +90,11 @@ public class BrewingStandFuelEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/ClickType.java b/paper-api/src/main/java/org/bukkit/event/inventory/ClickType.java index fa96e8c27..f771e70eb 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/ClickType.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/ClickType.java @@ -72,7 +72,7 @@ public enum ClickType { * Gets whether this ClickType represents the pressing of a key on a * keyboard. * - * @return true if this ClickType represents the pressing of a key + * @return {@code true} if this ClickType represents the pressing of a key */ public boolean isKeyboardClick() { return (this == ClickType.NUMBER_KEY) || (this == ClickType.DROP) || (this == ClickType.CONTROL_DROP) || (this == ClickType.SWAP_OFFHAND); @@ -81,7 +81,7 @@ public enum ClickType { /** * Gets whether this ClickType represents the pressing of a mouse button * - * @return true if this ClickType represents the pressing of a mouse button + * @return {@code true} if this ClickType represents the pressing of a mouse button */ public boolean isMouseClick() { return (this == ClickType.DOUBLE_CLICK) || (this == ClickType.LEFT) || (this == ClickType.RIGHT) || (this == ClickType.MIDDLE) @@ -92,7 +92,7 @@ public enum ClickType { * Gets whether this ClickType represents an action that can only be * performed by a Player in creative mode. * - * @return true if this action requires Creative mode + * @return {@code true} if this action requires Creative mode */ public boolean isCreativeAction() { // Why use middle click? @@ -102,7 +102,7 @@ public enum ClickType { /** * Gets whether this ClickType represents a right click. * - * @return true if this ClickType represents a right click + * @return {@code true} if this ClickType represents a right click */ public boolean isRightClick() { return (this == ClickType.RIGHT) || (this == ClickType.SHIFT_RIGHT); @@ -111,7 +111,7 @@ public enum ClickType { /** * Gets whether this ClickType represents a left click. * - * @return true if this ClickType represents a left click + * @return {@code true} if this ClickType represents a left click */ public boolean isLeftClick() { return (this == ClickType.LEFT) || (this == ClickType.SHIFT_LEFT) || (this == ClickType.DOUBLE_CLICK) || (this == ClickType.CREATIVE); @@ -121,7 +121,7 @@ public enum ClickType { * Gets whether this ClickType indicates that the shift key was pressed * down when the click was made. * - * @return true if the action uses Shift. + * @return {@code true} if the action uses Shift. */ public boolean isShiftClick() { return (this == ClickType.SHIFT_LEFT) || (this == ClickType.SHIFT_RIGHT); diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java index cab13877f..4df7b317f 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/CraftItemEvent.java @@ -4,35 +4,39 @@ import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when the recipe of an Item is completed inside a crafting matrix. */ public class CraftItemEvent extends InventoryClickEvent { - private Recipe recipe; - public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { - super(what, type, slot, click, action); + private final Recipe recipe; + + @ApiStatus.Internal + public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { + super(view, type, slot, click, action); this.recipe = recipe; } - public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { - super(what, type, slot, click, action, key); + @ApiStatus.Internal + public CraftItemEvent(@NotNull Recipe recipe, @NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { + super(view, type, slot, click, action, key); this.recipe = recipe; } - /** - * @return A copy of the current recipe on the crafting matrix. - */ - @NotNull - public Recipe getRecipe() { - return recipe; - } - @NotNull @Override public CraftingInventory getInventory() { return (CraftingInventory) super.getInventory(); } + + /** + * @return A copy of the current recipe on the crafting matrix. + */ + @NotNull + public Recipe getRecipe() { + return this.recipe; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java index 2f80910dd..aacb6ed25 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceBurnEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,19 +14,21 @@ import org.jetbrains.annotations.NotNull; * {@link org.bukkit.block.BlastFurnace}. */ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack fuel; private int burnTime; - private boolean cancelled; - private boolean burning; - private boolean consumeFuel = true; // Paper + private boolean burning = true; + private boolean consumeFuel = true; + private boolean cancelled; + + @ApiStatus.Internal public FurnaceBurnEvent(@NotNull final Block furnace, @NotNull final ItemStack fuel, final int burnTime) { super(furnace); this.fuel = fuel; this.burnTime = burnTime; - this.cancelled = false; - this.burning = true; } /** @@ -35,7 +38,7 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { */ @NotNull public ItemStack getFuel() { - return fuel; + return this.fuel; } /** @@ -44,7 +47,7 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { * @return the burn time for this fuel */ public int getBurnTime() { - return burnTime; + return this.burnTime; } /** @@ -52,8 +55,8 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { * * @param burnTime the burn time for this fuel */ - public void setBurnTime(@org.jetbrains.annotations.Range(from = Short.MIN_VALUE, to = Short.MAX_VALUE) int burnTime) { // Paper - this.burnTime = Math.max(Short.MIN_VALUE, Math.min(Short.MAX_VALUE, burnTime)); // Paper + public void setBurnTime(@org.jetbrains.annotations.Range(from = Short.MIN_VALUE, to = Short.MAX_VALUE) int burnTime) { + this.burnTime = Math.clamp(burnTime, Short.MIN_VALUE, Short.MAX_VALUE); } /** @@ -68,34 +71,33 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { /** * Sets whether the furnace's fuel is burning or not. * - * @param burning true if the furnace's fuel is burning + * @param burning {@code true} if the furnace's fuel is burning */ public void setBurning(boolean burning) { this.burning = burning; } - // Paper start + /** * Gets whether the furnace's fuel will be consumed or not. * * @return whether the furnace's fuel will be consumed */ public boolean willConsumeFuel() { - return consumeFuel; + return this.consumeFuel; } /** * Sets whether the furnace's fuel will be consumed or not. * - * @param consumeFuel true to consume the fuel + * @param consumeFuel {@code true} to consume the fuel */ public void setConsumeFuel(boolean consumeFuel) { this.consumeFuel = consumeFuel; } - // Paper end @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -106,11 +108,11 @@ public class FurnaceBurnEvent extends BlockEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java index 5ffd28fd2..8429635bd 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceExtractEvent.java @@ -6,6 +6,7 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockExpEvent; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,10 +15,12 @@ import org.jetbrains.annotations.NotNull; * {@link org.bukkit.block.BlastFurnace}. */ public class FurnaceExtractEvent extends BlockExpEvent { + private final Player player; private final Material itemType; private final int itemAmount; + @ApiStatus.Internal public FurnaceExtractEvent(@NotNull Player player, @NotNull Block block, @NotNull Material itemType, int itemAmount, int exp) { super(block, exp); this.player = player; @@ -35,7 +38,7 @@ public class FurnaceExtractEvent extends BlockExpEvent { */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** @@ -45,7 +48,7 @@ public class FurnaceExtractEvent extends BlockExpEvent { */ @NotNull public Material getItemType() { - return itemType; + return this.itemType; } /** @@ -54,6 +57,6 @@ public class FurnaceExtractEvent extends BlockExpEvent { * @return the amount of the item */ public int getItemAmount() { - return itemAmount; + return this.itemAmount; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java index 714d9d75a..b220ccfd0 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceSmeltEvent.java @@ -13,6 +13,7 @@ import org.jetbrains.annotations.NotNull; */ public class FurnaceSmeltEvent extends BlockCookEvent { + @ApiStatus.Internal @Deprecated(forRemoval = true) public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) { super(furnace, source, result); diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java index 6226beaa3..18ce250bc 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/FurnaceStartSmeltEvent.java @@ -15,22 +15,21 @@ import org.jetbrains.annotations.NotNull; * {@link org.bukkit.block.Smoker}, and {@link org.bukkit.block.BlastFurnace}. */ public class FurnaceStartSmeltEvent extends InventoryBlockStartEvent { - // Paper - remove HandlerList + private final CookingRecipe recipe; private int totalCookTime; + @ApiStatus.Internal @Deprecated(forRemoval = true) public FurnaceStartSmeltEvent(@NotNull final Block furnace, @NotNull ItemStack source, @NotNull final CookingRecipe recipe) { - // Paper start this(furnace, source, recipe, recipe.getCookingTime()); } @ApiStatus.Internal public FurnaceStartSmeltEvent(final @NotNull Block furnace, final @NotNull ItemStack source, final @NotNull CookingRecipe recipe, final int cookingTime) { - // Paper end super(furnace, source); this.recipe = recipe; - this.totalCookTime = cookingTime; // Paper - furnace cook speed multiplier + this.totalCookTime = cookingTime; } /** @@ -40,7 +39,7 @@ public class FurnaceStartSmeltEvent extends InventoryBlockStartEvent { */ @NotNull public CookingRecipe getRecipe() { - return recipe; + return this.recipe; } /** @@ -49,7 +48,7 @@ public class FurnaceStartSmeltEvent extends InventoryBlockStartEvent { * @return the total cook time */ public int getTotalCookTime() { - return totalCookTime; + return this.totalCookTime; } /** @@ -60,6 +59,4 @@ public class FurnaceStartSmeltEvent extends InventoryBlockStartEvent { public void setTotalCookTime(int cookTime) { this.totalCookTime = cookTime; } - - // Paper - remove HandlerList } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java index 18bb808e7..93225536c 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/HopperInventorySearchEvent.java @@ -4,6 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.event.HandlerList; import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,7 +14,8 @@ import org.jetbrains.annotations.Nullable; */ public class HopperInventorySearchEvent extends BlockEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Inventory inventory; private final ContainerType containerType; private final Block searchBlock; @@ -34,6 +36,7 @@ public class HopperInventorySearchEvent extends BlockEvent { DESTINATION; } + @ApiStatus.Internal public HopperInventorySearchEvent(@Nullable Inventory inventory, @NotNull ContainerType containerType, @NotNull Block hopper, @NotNull Block searchBlock) { // Paper super(hopper); this.inventory = inventory; @@ -59,7 +62,7 @@ public class HopperInventorySearchEvent extends BlockEvent { */ @Nullable public Inventory getInventory() { - return inventory; + return this.inventory; } /** @@ -69,7 +72,7 @@ public class HopperInventorySearchEvent extends BlockEvent { */ @NotNull public ContainerType getContainerType() { - return containerType; + return this.containerType; } /** @@ -79,17 +82,17 @@ public class HopperInventorySearchEvent extends BlockEvent { */ @NotNull public Block getSearchBlock() { - return searchBlock; + return this.searchBlock; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java index ff2d64550..7ef5fbd88 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryClickEvent.java @@ -10,6 +10,7 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -29,8 +30,6 @@ import org.jetbrains.annotations.Nullable; *

      *
    • {@link HumanEntity#closeInventory()} *
    • {@link HumanEntity#openInventory(Inventory)} - *
    • {@link HumanEntity#openWorkbench(Location, boolean)} - *
    • {@link HumanEntity#openEnchanting(Location, boolean)} *
    • {@link InventoryView#close()} *
    * To invoke one of these methods, schedule a task using @@ -50,24 +49,28 @@ import org.jetbrains.annotations.Nullable; * work as well. */ public class InventoryClickEvent extends InventoryInteractEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ClickType click; private final InventoryAction action; - private SlotType slot_type; - private int whichSlot; - private int rawSlot; + private final SlotType slotType; + private final int whichSlot; + private final int rawSlot; private ItemStack current = null; private int hotbarKey = -1; + @ApiStatus.Internal public InventoryClickEvent(@NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { super(view); - this.slot_type = type; + this.slotType = type; this.rawSlot = slot; this.whichSlot = view.convertSlot(slot); this.click = click; this.action = action; } + @ApiStatus.Internal public InventoryClickEvent(@NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { this(view, type, slot, click, action); this.hotbarKey = key; @@ -80,7 +83,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { */ @NotNull public SlotType getSlotType() { - return slot_type; + return this.slotType; } /** @@ -88,9 +91,9 @@ public class InventoryClickEvent extends InventoryInteractEvent { * * @return the cursor ItemStack */ - @NotNull // Paper - fix nullability + @NotNull public ItemStack getCursor() { - return getView().getCursor(); + return this.getView().getCursor(); } /** @@ -100,43 +103,43 @@ public class InventoryClickEvent extends InventoryInteractEvent { */ @Nullable public ItemStack getCurrentItem() { - if (slot_type == SlotType.OUTSIDE) { - return current; + if (this.slotType == SlotType.OUTSIDE) { + return this.current; } - return getView().getItem(rawSlot); + return this.getView().getItem(this.rawSlot); } /** - * Gets whether or not the ClickType for this event represents a right + * Gets whether the ClickType for this event represents a right * click. * - * @return true if the ClickType uses the right mouse button. + * @return {@code true} if the ClickType uses the right mouse button. * @see ClickType#isRightClick() */ public boolean isRightClick() { - return click.isRightClick(); + return this.click.isRightClick(); } /** - * Gets whether or not the ClickType for this event represents a left + * Gets whether the ClickType for this event represents a left * click. * - * @return true if the ClickType uses the left mouse button. + * @return {@code true} if the ClickType uses the left mouse button. * @see ClickType#isLeftClick() */ public boolean isLeftClick() { - return click.isLeftClick(); + return this.click.isLeftClick(); } /** * Gets whether the ClickType for this event indicates that the key was * pressed down when the click was made. * - * @return true if the ClickType uses Shift or Ctrl. + * @return {@code true} if the ClickType uses Shift or Ctrl. * @see ClickType#isShiftClick() */ public boolean isShiftClick() { - return click.isShiftClick(); + return this.click.isShiftClick(); } /** @@ -150,7 +153,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { */ @Deprecated(since = "1.5.2") public void setCursor(@Nullable ItemStack stack) { - getView().setCursor(stack); + this.getView().setCursor(stack); } /** @@ -159,22 +162,22 @@ public class InventoryClickEvent extends InventoryInteractEvent { * @param stack the item to be placed in the current slot */ public void setCurrentItem(@Nullable ItemStack stack) { - if (slot_type == SlotType.OUTSIDE) { - current = stack; + if (this.slotType == SlotType.OUTSIDE) { + this.current = stack; } else { - getView().setItem(rawSlot, stack); + getView().setItem(this.rawSlot, stack); } } /** * Gets the inventory corresponding to the clicked slot. * - * @return inventory, or null if clicked outside + * @return inventory, or {@code null} if clicked outside * @see InventoryView#getInventory(int) */ @Nullable public Inventory getClickedInventory() { - return getView().getInventory(rawSlot); + return this.getView().getInventory(rawSlot); } /** @@ -182,10 +185,10 @@ public class InventoryClickEvent extends InventoryInteractEvent { * {@link Inventory#getItem(int)}. Note that there may be two slots with * the same slot number, since a view links two different inventories. * - * @return The slot number. + * @return the slot number */ public int getSlot() { - return whichSlot; + return this.whichSlot; } /** @@ -195,7 +198,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * @return the slot number */ public int getRawSlot() { - return rawSlot; + return this.rawSlot; } /** @@ -206,7 +209,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { * a NUMBER_KEY action */ public int getHotbarButton() { - return hotbarKey; + return this.hotbarKey; } /** @@ -220,7 +223,7 @@ public class InventoryClickEvent extends InventoryInteractEvent { */ @NotNull public InventoryAction getAction() { - return action; + return this.action; } /** @@ -232,17 +235,17 @@ public class InventoryClickEvent extends InventoryInteractEvent { */ @NotNull public ClickType getClick() { - return click; + return this.click; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java index 4db0a07db..e23e58ea3 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCloseEvent.java @@ -4,6 +4,7 @@ package org.bukkit.event.inventory; import org.bukkit.entity.HumanEntity; import org.bukkit.event.HandlerList; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -19,8 +20,6 @@ import org.jetbrains.annotations.NotNull; *
      *
    • {@link HumanEntity#closeInventory()} *
    • {@link HumanEntity#openInventory(org.bukkit.inventory.Inventory)} - *
    • {@link HumanEntity#openWorkbench(org.bukkit.Location, boolean)} - *
    • {@link HumanEntity#openEnchanting(org.bukkit.Location, boolean)} *
    • {@link InventoryView#close()} *
    * To invoke one of these methods, schedule a task using @@ -29,12 +28,46 @@ import org.jetbrains.annotations.NotNull; * other methods could potentially create issues as well. */ public class InventoryCloseEvent extends InventoryEvent { - private static final HandlerList handlers = new HandlerList(); - // Paper start + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Reason reason; + + @ApiStatus.Internal + public InventoryCloseEvent(@NotNull InventoryView transaction) { + this(transaction, Reason.UNKNOWN); + } + + @ApiStatus.Internal + public InventoryCloseEvent(@NotNull InventoryView transaction, @NotNull Reason reason) { + super(transaction); + this.reason = reason; + } + + /** + * Returns the player involved in this event + * + * @return Player who is involved in this event + */ + @NotNull + public final HumanEntity getPlayer() { + return this.transaction.getPlayer(); + } + @NotNull public Reason getReason() { - return reason; + return this.reason; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; } public enum Reason { @@ -75,35 +108,4 @@ public class InventoryCloseEvent extends InventoryEvent { */ PLUGIN, } - - public InventoryCloseEvent(@NotNull InventoryView transaction) { - this(transaction, Reason.UNKNOWN); - } - - public InventoryCloseEvent(@NotNull InventoryView transaction, @NotNull Reason reason) { - super(transaction); - this.reason = reason; - // Paper end - } - - /** - * Returns the player involved in this event - * - * @return Player who is involved in this event - */ - @NotNull - public final HumanEntity getPlayer() { - return transaction.getPlayer(); - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java index 9c6db8be4..1979cf9eb 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryCreativeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.event.inventory.InventoryType.SlotType; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,17 +12,19 @@ import org.jetbrains.annotations.NotNull; * Inventory while in creative mode. */ public class InventoryCreativeEvent extends InventoryClickEvent { + private ItemStack item; - public InventoryCreativeEvent(@NotNull InventoryView what, @NotNull SlotType type, int slot, @NotNull ItemStack newItem) { - super(what, type, slot, ClickType.CREATIVE, InventoryAction.PLACE_ALL); + @ApiStatus.Internal + public InventoryCreativeEvent(@NotNull InventoryView view, @NotNull SlotType type, int slot, @NotNull ItemStack newItem) { + super(view, type, slot, ClickType.CREATIVE, InventoryAction.PLACE_ALL); this.item = newItem; } @Override @NotNull public ItemStack getCursor() { - return item; + return this.item; } @Override diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java index da37e0ddf..a10d5da13 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryDragEvent.java @@ -1,6 +1,5 @@ package org.bukkit.event.inventory; -import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableSet; import java.util.Collections; import java.util.Map; @@ -14,6 +13,7 @@ import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -35,8 +35,6 @@ import org.jetbrains.annotations.Nullable; *
      *
    • {@link HumanEntity#closeInventory()} *
    • {@link HumanEntity#openInventory(Inventory)} - *
    • {@link HumanEntity#openWorkbench(Location, boolean)} - *
    • {@link HumanEntity#openEnchanting(Location, boolean)} *
    • {@link InventoryView#close()} *
    * To invoke one of these methods, schedule a task using @@ -55,59 +53,42 @@ import org.jetbrains.annotations.Nullable; * execute the task on the next tick, would work as well. */ public class InventoryDragEvent extends InventoryInteractEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final DragType type; private final Map addedItems; private final Set containerSlots; private final ItemStack oldCursor; private ItemStack newCursor; - public InventoryDragEvent(@NotNull InventoryView what, @Nullable ItemStack newCursor, @NotNull ItemStack oldCursor, boolean right, @NotNull Map slots) { - super(what); + @ApiStatus.Internal + public InventoryDragEvent(@NotNull InventoryView view, @Nullable ItemStack newCursor, @NotNull ItemStack oldCursor, boolean right, @NotNull Map slots) { + super(view); - Preconditions.checkArgument(oldCursor != null); - Preconditions.checkArgument(slots != null); - - type = right ? DragType.SINGLE : DragType.EVEN; + this.type = right ? DragType.SINGLE : DragType.EVEN; this.newCursor = newCursor; this.oldCursor = oldCursor; this.addedItems = slots; ImmutableSet.Builder b = ImmutableSet.builder(); for (Integer slot : slots.keySet()) { - b.add(what.convertSlot(slot)); + b.add(view.convertSlot(slot)); } this.containerSlots = b.build(); } /** - * Gets all items to be added to the inventory in this drag. + * Gets the DragType that describes the behavior of ItemStacks placed + * after this InventoryDragEvent. + *

    + * The ItemStacks and the raw slots that they're being applied to can be + * found using {@link #getNewItems()}. * - * @return map from raw slot id to new ItemStack + * @return the DragType of this InventoryDragEvent */ @NotNull - public Map getNewItems() { - return Collections.unmodifiableMap(addedItems); - } - - /** - * Gets the raw slot ids to be changed in this drag. - * - * @return list of raw slot ids, suitable for getView().getItem(int) - */ - @NotNull - public Set getRawSlots() { - return addedItems.keySet(); - } - - /** - * Gets the slots to be changed in this drag. - * - * @return list of converted slot ids, suitable for {@link - * org.bukkit.inventory.Inventory#getItem(int)}. - */ - @NotNull - public Set getInventorySlots() { - return containerSlots; + public DragType getType() { + return this.type; } /** @@ -118,7 +99,7 @@ public class InventoryDragEvent extends InventoryInteractEvent { */ @Nullable public ItemStack getCursor() { - return newCursor; + return this.newCursor; } /** @@ -142,31 +123,48 @@ public class InventoryDragEvent extends InventoryInteractEvent { */ @NotNull public ItemStack getOldCursor() { - return oldCursor.clone(); + return this.oldCursor.clone(); } /** - * Gets the DragType that describes the behavior of ItemStacks placed - * after this InventoryDragEvent. - *

    - * The ItemStacks and the raw slots that they're being applied to can be - * found using {@link #getNewItems()}. + * Gets all items to be added to the inventory in this drag. * - * @return the DragType of this InventoryDragEvent + * @return map from raw slot id to new ItemStack */ @NotNull - public DragType getType() { - return type; + public Map getNewItems() { + return Collections.unmodifiableMap(this.addedItems); + } + + /** + * Gets the raw slot ids to be changed in this drag. + * + * @return list of raw slot ids, suitable for getView().getItem(int) + */ + @NotNull + public Set getRawSlots() { + return this.addedItems.keySet(); + } + + /** + * Gets the slots to be changed in this drag. + * + * @return list of converted slot ids, suitable for {@link + * org.bukkit.inventory.Inventory#getItem(int)}. + */ + @NotNull + public Set getInventorySlots() { + return this.containerSlots; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java index 5d3fe64ab..5ee8871a1 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryEvent.java @@ -7,15 +7,19 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Represents a player related inventory event */ public class InventoryEvent extends Event { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected InventoryView transaction; + @ApiStatus.Internal public InventoryEvent(@NotNull InventoryView transaction) { this.transaction = transaction; } @@ -27,7 +31,7 @@ public class InventoryEvent extends Event { */ @NotNull public Inventory getInventory() { - return transaction.getTopInventory(); + return this.transaction.getTopInventory(); } /** @@ -38,7 +42,7 @@ public class InventoryEvent extends Event { */ @NotNull public List getViewers() { - return transaction.getTopInventory().getViewers(); + return this.transaction.getTopInventory().getViewers(); } /** @@ -48,17 +52,17 @@ public class InventoryEvent extends Event { */ @NotNull public InventoryView getView() { - return transaction; + return this.transaction; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java index 14f821ca1..946972968 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryInteractEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.inventory; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,8 +11,10 @@ import org.jetbrains.annotations.NotNull; * HumanEntity and the contents of an Inventory. */ public abstract class InventoryInteractEvent extends InventoryEvent implements Cancellable { + private Result result = Result.DEFAULT; + @ApiStatus.Internal public InventoryInteractEvent(@NotNull InventoryView transaction) { super(transaction); } @@ -23,18 +26,18 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C */ @NotNull public HumanEntity getWhoClicked() { - return getView().getPlayer(); + return this.getView().getPlayer(); } /** - * Sets the result of this event. This will change whether or not this + * Sets the result of this event. This will change whether this * event is considered cancelled. * * @param newResult the new {@link org.bukkit.event.Event.Result} for this event * @see #isCancelled() */ public void setResult(@NotNull Result newResult) { - result = newResult; + this.result = newResult; } /** @@ -46,14 +49,14 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C */ @NotNull public Result getResult() { - return result; + return this.result; } /** - * Gets whether or not this event is cancelled. This is based off of the - * Result value returned by {@link #getResult()}. Result.ALLOW and - * Result.DEFAULT will result in a returned value of false, but - * Result.DENY will result in a returned value of true. + * Gets whether this event is cancelled. This is based off of the + * Result value returned by {@link #getResult()}. {@link Result#ALLOW} and + * {@link Result#DEFAULT} will result in a returned value of false, but + * {@link Result#DENY} will result in a returned value of {@code true}. *

    * {@inheritDoc} * @@ -61,21 +64,20 @@ public abstract class InventoryInteractEvent extends InventoryEvent implements C */ @Override public boolean isCancelled() { - return getResult() == Result.DENY; + return this.getResult() == Result.DENY; } /** * Proxy method to {@link #setResult(org.bukkit.event.Event.Result)} for the Cancellable * interface. {@link #setResult(org.bukkit.event.Event.Result)} is preferred, as it allows - * you to specify the Result beyond Result.DENY and Result.ALLOW. + * you to specify the Result beyond {@link Result#DENY} and {@link Result#ALLOW}. *

    * {@inheritDoc} * - * @param toCancel result becomes DENY if true, ALLOW if false + * @param cancel result becomes {@link Result#DENY} if {@code true}, {@link Result#ALLOW} if {@code false} */ @Override - public void setCancelled(boolean toCancel) { - setResult(toCancel ? Result.DENY : Result.ALLOW); + public void setCancelled(boolean cancel) { + this.setResult(cancel ? Result.DENY : Result.ALLOW); } - } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java index 0161b8a94..e75630496 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryMoveItemEvent.java @@ -6,6 +6,7 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -25,13 +26,17 @@ import org.jetbrains.annotations.NotNull; * former state. Otherwise any additional items will be discarded. */ public class InventoryMoveItemEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Inventory sourceInventory; private final Inventory destinationInventory; private ItemStack itemStack; private final boolean didSourceInitiate; + private boolean cancelled; + + @ApiStatus.Internal public InventoryMoveItemEvent(@NotNull final Inventory sourceInventory, @NotNull final ItemStack itemStack, @NotNull final Inventory destinationInventory, final boolean didSourceInitiate) { Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null"); this.sourceInventory = sourceInventory; @@ -47,7 +52,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { */ @NotNull public Inventory getSource() { - return sourceInventory; + return this.sourceInventory; } /** @@ -58,7 +63,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { */ @NotNull public ItemStack getItem() { - return itemStack; // Paper - Removed clone, handled better in Server + return this.itemStack; } /** @@ -69,7 +74,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { * @param itemStack The ItemStack */ public void setItem(@NotNull ItemStack itemStack) { - Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred."); + Preconditions.checkArgument(itemStack != null, "ItemStack cannot be null. Cancel the event if you want nothing to be transferred."); this.itemStack = itemStack.clone(); } @@ -80,7 +85,7 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { */ @NotNull public Inventory getDestination() { - return destinationInventory; + return this.destinationInventory; } /** @@ -91,12 +96,12 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { */ @NotNull public Inventory getInitiator() { - return didSourceInitiate ? sourceInventory : destinationInventory; + return this.didSourceInitiate ? this.sourceInventory : this.destinationInventory; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -107,11 +112,11 @@ public class InventoryMoveItemEvent extends Event implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java index 8e2afeab4..7641225bf 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryOpenEvent.java @@ -1,22 +1,27 @@ package org.bukkit.event.inventory; +import net.kyori.adventure.text.Component; import org.bukkit.entity.HumanEntity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.InventoryView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a player opens an inventory */ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private net.kyori.adventure.text.Component titleOverride; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private Component titleOverride; + private boolean cancelled; + + @ApiStatus.Internal public InventoryOpenEvent(@NotNull InventoryView transaction) { super(transaction); - this.cancelled = false; } /** @@ -26,45 +31,16 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { */ @NotNull public final HumanEntity getPlayer() { - return transaction.getPlayer(); + return this.transaction.getPlayer(); } /** - * Gets the cancellation state of this event. A cancelled event will not - * be executed in the server, but will still pass to other plugins. - *

    - * If an inventory open event is cancelled, the inventory screen will not - * show. - * - * @return true if this event is cancelled - */ - @Override - public boolean isCancelled() { - return cancelled; - } - - /** - * Sets the cancellation state of this event. A cancelled event will not - * be executed in the server, but will still pass to other plugins. - *

    - * If an inventory open event is cancelled, the inventory screen will not - * show. - * - * @param cancel true if you wish to cancel this event - */ - @Override - public void setCancelled(boolean cancel) { - cancelled = cancel; - } - - // Paper start - /** - * Gets the title override set by another event or null + * Gets the title override set by another event or {@code null} * if not set. * - * @return the title override or null + * @return the title override or {@code null} */ - public net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component titleOverride() { + public @Nullable Component titleOverride() { return this.titleOverride; } @@ -77,21 +53,42 @@ public class InventoryOpenEvent extends InventoryEvent implements Cancellable { * NOTE: Horse inventories are a special case where setting this will * have no effect. Horse inventory titles are set by the horse display name. * - * @param titleOverride the title override or null + * @param titleOverride the title override or {@code null} */ - public void titleOverride(net.kyori.adventure.text.@org.jetbrains.annotations.Nullable Component titleOverride) { + public void titleOverride(@Nullable Component titleOverride) { this.titleOverride = titleOverride; } - // Paper end + + /** + * {@inheritDoc} + *

    + * If this event is cancelled, the inventory screen will not + * show. + */ + @Override + public boolean isCancelled() { + return cancelled; + } + + /** + * {@inheritDoc} + *

    + * If this event is cancelled, the inventory screen will not + * show. + */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java index 1ffac4d58..9f738a7f0 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/InventoryPickupItemEvent.java @@ -5,46 +5,46 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.Inventory; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a hopper or hopper minecart picks up a dropped item. */ public class InventoryPickupItemEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Inventory inventory; private final Item item; + private boolean cancelled; + + @ApiStatus.Internal public InventoryPickupItemEvent(@NotNull final Inventory inventory, @NotNull final Item item) { - super(); this.inventory = inventory; this.item = item; } /** * Gets the Inventory that picked up the item - * - * @return Inventory */ @NotNull public Inventory getInventory() { - return inventory; + return this.inventory; } /** * Gets the Item entity that was picked up - * - * @return Item */ @NotNull public Item getItem() { - return item; + return this.item; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -55,11 +55,11 @@ public class InventoryPickupItemEvent extends Event implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java index d2b4b2e93..52679ffde 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareAnvilEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.inventory; -import org.bukkit.event.HandlerList; import org.bukkit.inventory.AnvilInventory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.view.AnvilView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,8 +12,7 @@ import org.jetbrains.annotations.Nullable; */ public class PrepareAnvilEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent { - // Paper - move HandlerList to PrepareInventoryResultEvent - + @ApiStatus.Internal public PrepareAnvilEvent(@NotNull AnvilView inventory, @Nullable ItemStack result) { super(inventory, result); } @@ -26,13 +25,10 @@ public class PrepareAnvilEvent extends com.destroystokyo.paper.event.inventory.P /** * {@inheritDoc} - * *

    * Note: by default custom recipes in anvil are disabled * you should define a repair cost on the anvil inventory * greater or equals to zero in order to allow that. - * - * @param result result item */ public void setResult(@Nullable ItemStack result) { super.setResult(result); @@ -43,6 +39,4 @@ public class PrepareAnvilEvent extends com.destroystokyo.paper.event.inventory.P public AnvilView getView() { return (AnvilView) super.getView(); } - - // Paper - move HandlerList to PrepareInventoryResultEvent } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java index a7e036000..77d74f822 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareGrindstoneEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.inventory; -import org.bukkit.event.HandlerList; import org.bukkit.inventory.GrindstoneInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,8 +12,7 @@ import org.jetbrains.annotations.Nullable; */ public class PrepareGrindstoneEvent extends com.destroystokyo.paper.event.inventory.PrepareGrindstoneEvent { // Paper - // Paper - move HandlerList to PrepareInventoryResultEvent - + @ApiStatus.Internal public PrepareGrindstoneEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { super(inventory, result); } @@ -21,8 +20,6 @@ public class PrepareGrindstoneEvent extends com.destroystokyo.paper.event.invent @NotNull @Override public GrindstoneInventory getInventory() { - return (GrindstoneInventory) super.getInventory(); + return super.getInventory(); } - - // Paper - move HandlerList to PrepareInventoryResultEvent } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java index 0b58ffff3..e521ac218 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareInventoryResultEvent.java @@ -1,38 +1,43 @@ package org.bukkit.event.inventory; +import org.bukkit.Warning; import org.bukkit.event.HandlerList; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Called when an item is put in a slot and the result is calculated. + * * @deprecated use {@link com.destroystokyo.paper.event.inventory.PrepareResultEvent} */ -@Deprecated @org.bukkit.Warning(false) // Paper +@Deprecated @Warning public class PrepareInventoryResultEvent extends InventoryEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private ItemStack result; + @ApiStatus.Internal public PrepareInventoryResultEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { super(inventory); this.result = result; } /** - * Get result item, may be null. + * Get result item, may be {@code null}. * * @return result item */ @Nullable public ItemStack getResult() { - return result; + return this.result; } /** - * Set result item, may be null. + * Set result item, may be {@code null}. * * @param result result item */ @@ -43,11 +48,11 @@ public class PrepareInventoryResultEvent extends InventoryEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java index efd29d198..26de96c6d 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareItemCraftEvent.java @@ -4,17 +4,21 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class PrepareItemCraftEvent extends InventoryEvent { - private static final HandlerList handlers = new HandlerList(); - private boolean repair; - private CraftingInventory matrix; - public PrepareItemCraftEvent(@NotNull CraftingInventory what, @NotNull InventoryView view, boolean isRepair) { + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean repair; + private final CraftingInventory matrix; + + @ApiStatus.Internal + public PrepareItemCraftEvent(@NotNull CraftingInventory matrix, @NotNull InventoryView view, boolean isRepair) { super(view); - this.matrix = what; + this.matrix = matrix; this.repair = isRepair; } @@ -27,7 +31,7 @@ public class PrepareItemCraftEvent extends InventoryEvent { */ @Nullable public Recipe getRecipe() { - return matrix.getRecipe(); + return this.matrix.getRecipe(); } /** @@ -36,27 +40,27 @@ public class PrepareItemCraftEvent extends InventoryEvent { @NotNull @Override public CraftingInventory getInventory() { - return matrix; + return this.matrix; } /** * Check if this event was triggered by a tool repair operation rather * than a crafting recipe. * - * @return True if this is a repair. + * @return {@code true} if this is a repair. */ public boolean isRepair() { - return repair; + return this.repair; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java index 8d7924fa8..f0701401b 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/PrepareSmithingEvent.java @@ -1,9 +1,9 @@ package org.bukkit.event.inventory; -import org.bukkit.event.HandlerList; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.SmithingInventory; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,8 +12,7 @@ import org.jetbrains.annotations.Nullable; */ public class PrepareSmithingEvent extends com.destroystokyo.paper.event.inventory.PrepareResultEvent { - // Paper - move HandlerList ot PrepareInventoryResultEvent - + @ApiStatus.Internal public PrepareSmithingEvent(@NotNull InventoryView inventory, @Nullable ItemStack result) { super(inventory, result); } @@ -23,6 +22,4 @@ public class PrepareSmithingEvent extends com.destroystokyo.paper.event.inventor public SmithingInventory getInventory() { return (SmithingInventory) super.getInventory(); } - - // Paper - move HandlerList to PrepareInventoryResultEvent } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java index f8e45134c..960f0be30 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/SmithItemEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.inventory; import org.bukkit.inventory.InventoryView; import org.bukkit.inventory.SmithingInventory; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -9,10 +10,12 @@ import org.jetbrains.annotations.NotNull; */ public class SmithItemEvent extends InventoryClickEvent { + @ApiStatus.Internal public SmithItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action) { super(view, type, slot, click, action); } + @ApiStatus.Internal public SmithItemEvent(@NotNull InventoryView view, @NotNull InventoryType.SlotType type, int slot, @NotNull ClickType click, @NotNull InventoryAction action, int key) { super(view, type, slot, click, action, key); } diff --git a/paper-api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java b/paper-api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java index 60ed27fbd..70627b864 100644 --- a/paper-api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/inventory/TradeSelectEvent.java @@ -4,6 +4,7 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.Merchant; import org.bukkit.inventory.MerchantInventory; import org.bukkit.inventory.view.MerchantView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,24 +16,16 @@ import org.jetbrains.annotations.NotNull; */ public class TradeSelectEvent extends InventoryInteractEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final int index; + @ApiStatus.Internal public TradeSelectEvent(@NotNull MerchantView transaction, int newIndex) { super(transaction); this.index = newIndex; } - /** - * Used to get the index of the trade the player clicked on. - * - * @return The index of the trade clicked by the player - */ - public int getIndex() { - return index; - } - @NotNull @Override public MerchantInventory getInventory() { @@ -46,7 +39,7 @@ public class TradeSelectEvent extends InventoryInteractEvent { */ @NotNull public Merchant getMerchant() { - return getInventory().getMerchant(); + return this.getInventory().getMerchant(); } @NotNull @@ -55,14 +48,23 @@ public class TradeSelectEvent extends InventoryInteractEvent { return (MerchantView) super.getView(); } + /** + * Used to get the index of the trade the player clicked on. + * + * @return The index of the trade clicked by the player + */ + public int getIndex() { + return this.index; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java index 399afcd19..c80372377 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatEvent.java @@ -2,9 +2,12 @@ package org.bukkit.event.player; import java.util.IllegalFormatException; import java.util.Set; +import com.google.common.base.Preconditions; +import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -25,26 +28,23 @@ import org.jetbrains.annotations.NotNull; * * @deprecated use {@link io.papermc.paper.event.player.AsyncChatEvent} instead */ -@Deprecated // Paper -@org.bukkit.Warning(value = false, reason = "Don't nag on old event yet") // Paper +@Deprecated +@Warning(reason = "Don't nag on old event yet") // Paper public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private String message; private String format = "<%1$s> %2$s"; private final Set recipients; - /** - * @param async This changes the event to a synchronous state. - * @param who the chat sender - * @param message the message sent - * @param players the players to receive the message. This may be a lazy - * or unmodifiable collection. - */ - public AsyncPlayerChatEvent(final boolean async, @NotNull final Player who, @NotNull final String message, @NotNull final Set players) { - super(who, async); + private boolean cancelled; + + @ApiStatus.Internal + public AsyncPlayerChatEvent(final boolean async, @NotNull final Player player, @NotNull final String message, @NotNull final Set players) { + super(player, async); this.message = message; - recipients = players; + this.recipients = players; } /** @@ -55,7 +55,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public String getMessage() { - return message; + return this.message; } /** @@ -80,7 +80,7 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public String getFormat() { - return format; + return this.format; } /** @@ -94,13 +94,13 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { * format string * @throws IllegalFormatException if the underlying API throws the * exception - * @throws NullPointerException if format is null * @see String#format(String, Object...) */ public void setFormat(@NotNull final String format) throws IllegalFormatException, NullPointerException { + Preconditions.checkArgument(format != null, "format cannot be null"); // Oh for a better way to do this! try { - String.format(format, player, message); + String.format(format, this.player, this.message); } catch (RuntimeException ex) { ex.fillInStackTrace(); throw ex; @@ -124,27 +124,27 @@ public class AsyncPlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public Set getRecipients() { - return recipients; + return this.recipients; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatPreviewEvent.java b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatPreviewEvent.java index ee7a99a0c..43e1b1ebd 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatPreviewEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerChatPreviewEvent.java @@ -4,6 +4,7 @@ import java.util.Set; import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,23 +15,24 @@ import org.jetbrains.annotations.NotNull; * @deprecated chat previews have been removed */ @Deprecated(since = "1.19.1") -@Warning(false) +@Warning public class AsyncPlayerChatPreviewEvent extends AsyncPlayerChatEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); - public AsyncPlayerChatPreviewEvent(final boolean async, @NotNull final Player who, @NotNull final String message, @NotNull final Set players) { - super(async, who, message, players); + @ApiStatus.Internal + public AsyncPlayerChatPreviewEvent(final boolean async, @NotNull final Player player, @NotNull final String message, @NotNull final Set players) { + super(async, player, message, players); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java index c8479838e..cf7593ce0 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/AsyncPlayerPreLoginEvent.java @@ -2,6 +2,9 @@ package org.bukkit.event.player; import java.net.InetAddress; import java.util.UUID; +import com.destroystokyo.paper.profile.PlayerProfile; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -20,20 +23,24 @@ import org.jetbrains.annotations.NotNull; * if the client's language is known. */ public class AsyncPlayerPreLoginEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private Result result; - private net.kyori.adventure.text.Component message; // Paper - private final InetAddress ipAddress; - private com.destroystokyo.paper.profile.PlayerProfile profile; // Paper - private final InetAddress rawAddress; // Paper - private final String hostname; // Paper - private final boolean transferred; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final InetAddress ipAddress; + private final InetAddress rawAddress; + private final String hostname; + private final boolean transferred; + private Result result; + private Component message; + private PlayerProfile profile; + + @ApiStatus.Internal @Deprecated(since = "1.7.5", forRemoval = true) public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) { this(name, ipAddress, null); } + @ApiStatus.Internal @Deprecated(since = "1.20.5", forRemoval = true) public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { this(name, ipAddress, uniqueId, false); @@ -41,15 +48,16 @@ public class AsyncPlayerPreLoginEvent extends Event { @ApiStatus.Internal public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId, boolean transferred) { - // Paper start this(name, ipAddress, uniqueId, transferred, org.bukkit.Bukkit.createProfile(uniqueId, name)); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile) { this(name, ipAddress, ipAddress, uniqueId, transferred, profile); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile) { this(name, ipAddress, rawAddress, uniqueId, transferred, profile, ""); @@ -57,14 +65,13 @@ public class AsyncPlayerPreLoginEvent extends Event { @ApiStatus.Internal public AsyncPlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final InetAddress rawAddress, @NotNull final UUID uniqueId, boolean transferred, @NotNull com.destroystokyo.paper.profile.PlayerProfile profile, @NotNull String hostname) { - // Paper end super(true); this.result = Result.ALLOWED; - this.message = net.kyori.adventure.text.Component.empty(); // Paper + this.message = Component.empty(); this.profile = profile; this.ipAddress = ipAddress; - this.rawAddress = rawAddress; // Paper - this.hostname = hostname; // Paper + this.rawAddress = rawAddress; + this.hostname = hostname; this.transferred = transferred; } @@ -75,7 +82,7 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public Result getLoginResult() { - return result; + return this.result; } /** @@ -89,7 +96,7 @@ public class AsyncPlayerPreLoginEvent extends Event { @Deprecated(since = "1.3.2") @NotNull public PlayerPreLoginEvent.Result getResult() { - return result == null ? null : result.old(); + return this.result == null ? null : this.result.old(); // todo a lot of nullability issues in this class + player profile } /** @@ -114,24 +121,22 @@ public class AsyncPlayerPreLoginEvent extends Event { this.result = result == null ? null : Result.valueOf(result.name()); } - // Paper start /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the current kick message that will be used when the outcome is not allowed * * @return Current kick message */ @NotNull - public net.kyori.adventure.text.Component kickMessage() { - return message; + public Component kickMessage() { + return this.message; } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Sets the kick message to display when the outcome is not allowed * * @param message New kick message */ - public void kickMessage(@NotNull final net.kyori.adventure.text.Component message) { + public void kickMessage(@NotNull final Component message) { this.message = message; } @@ -141,7 +146,7 @@ public class AsyncPlayerPreLoginEvent extends Event { * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { + public void disallow(@NotNull final Result result, @NotNull final Component message) { this.result = result; this.message = message; } @@ -160,37 +165,36 @@ public class AsyncPlayerPreLoginEvent extends Event { this.result = result == null ? null : Result.valueOf(result.name()); this.message = message; } - // Paper end + /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the current kick message that will be used when the outcome is not allowed * * @return Current kick message * @deprecated in favour of {@link #kickMessage()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getKickMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.message); } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Sets the kick message to display when the outcome is not allowed * * @param message New kick message - * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #kickMessage(Component)} */ - @Deprecated // Paper + @Deprecated public void setKickMessage(@NotNull final String message) { - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** * Allows the player to log in */ public void allow() { - result = Result.ALLOWED; - message = net.kyori.adventure.text.Component.empty(); // Paper + this.result = Result.ALLOWED; + this.message = Component.empty(); } /** @@ -198,12 +202,12 @@ public class AsyncPlayerPreLoginEvent extends Event { * * @param result New result for disallowing the player * @param message Kick message to display to the user - * @deprecated in favour of {@link #disallow(org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #disallow(org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result, Component)} */ - @Deprecated // Paper + @Deprecated public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** @@ -218,7 +222,7 @@ public class AsyncPlayerPreLoginEvent extends Event { @Deprecated(since = "1.3.2") public void disallow(@NotNull final PlayerPreLoginEvent.Result result, @NotNull final String message) { this.result = result == null ? null : Result.valueOf(result.name()); - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** @@ -228,7 +232,7 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public String getName() { - return profile.getName(); // Paper + return this.profile.getName(); } /** @@ -238,7 +242,7 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public InetAddress getAddress() { - return ipAddress; + return this.ipAddress; } /** @@ -248,17 +252,16 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public UUID getUniqueId() { - return profile.getId(); // Paper + return this.profile.getId(); } - // Paper start /** * Gets the PlayerProfile of the player logging in * @return The Profile */ @NotNull public com.destroystokyo.paper.profile.PlayerProfile getPlayerProfile() { - return profile; + return this.profile; } /** @@ -275,7 +278,7 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public InetAddress getRawAddress() { - return rawAddress; + return this.rawAddress; } /** @@ -286,28 +289,27 @@ public class AsyncPlayerPreLoginEvent extends Event { */ @NotNull public String getHostname() { - return hostname; + return this.hostname; } - // Paper end /** * Gets if this connection has been transferred from another server. * - * @return true if the connection has been transferred + * @return {@code true} if the connection has been transferred */ public boolean isTransferred() { - return transferred; + return this.transferred; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java index 6f618bb14..c430b19ae 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAdvancementDoneEvent.java @@ -3,31 +3,32 @@ package org.bukkit.event.player; import org.bukkit.advancement.Advancement; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -// Paper start import org.jetbrains.annotations.Nullable; import net.kyori.adventure.text.Component; -// Paper end /** * Called when a player has completed all criteria in an advancement. */ public class PlayerAdvancementDoneEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - // - private final Advancement advancement; - private Component message; // Paper - Add Adventure message + private static final HandlerList HANDLER_LIST = new HandlerList(); - public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement) { - // Paper start - Add Adventure message - this(who, advancement, null); + private final Advancement advancement; + private Component message; + + @ApiStatus.Internal + @Deprecated(since = "1.21.5", forRemoval = true) + public PlayerAdvancementDoneEvent(@NotNull Player player, @NotNull Advancement advancement) { + this(player, advancement, null); } - public PlayerAdvancementDoneEvent(@NotNull Player who, @NotNull Advancement advancement, @Nullable Component message) { - // Paper end - super(who); + + @ApiStatus.Internal + public PlayerAdvancementDoneEvent(@NotNull Player player, @NotNull Advancement advancement, @Nullable Component message) { + super(player); this.advancement = advancement; - this.message = message; // Paper - Add Adventure message + this.message = message; } /** @@ -37,17 +38,16 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { */ @NotNull public Advancement getAdvancement() { - return advancement; + return this.advancement; } - // Paper start - Add Adventure message /** * Gets the message to send to all online players. *

    - * Will be null if the advancement does not announce to chat, for example if + * Will be {@code null} if the advancement does not announce to chat, for example if * it is a recipe unlock or a root advancement. * - * @return The announcement message, or null + * @return The announcement message, or {@code null} */ @Nullable public Component message() { @@ -57,22 +57,22 @@ public class PlayerAdvancementDoneEvent extends PlayerEvent { /** * Sets the message to send to all online players. *

    - * If set to null the message will not be sent. + * If set to {@code null} the message will not be sent. * * @param message The new message */ public void message(@Nullable Component message) { this.message = message; } - // Paper end + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java index 9eb6141a1..d685e7e15 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAnimationEvent.java @@ -11,25 +11,22 @@ import org.jetbrains.annotations.NotNull; *
    Use {@link io.papermc.paper.event.player.PlayerArmSwingEvent} for determining which arm was swung. */ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final PlayerAnimationType animationType; - private boolean isCancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final PlayerAnimationType animationType; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.19", forRemoval = true) public PlayerAnimationEvent(@NotNull final Player player) { this(player, PlayerAnimationType.ARM_SWING); } - /** - * Construct a new PlayerAnimation event - * - * @param player The player instance - * @param playerAnimationType The animation type - */ @ApiStatus.Internal public PlayerAnimationEvent(@NotNull final Player player, @NotNull final PlayerAnimationType playerAnimationType) { super(player); - animationType = playerAnimationType; + this.animationType = playerAnimationType; } /** @@ -39,27 +36,27 @@ public class PlayerAnimationEvent extends PlayerEvent implements Cancellable { */ @NotNull public PlayerAnimationType getAnimationType() { - return animationType; + return this.animationType; } @Override public boolean isCancelled() { - return this.isCancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.isCancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java index 04dbcb41b..a0471a025 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerArmorStandManipulateEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,22 +14,23 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); private final ItemStack playerItem; private final ItemStack armorStandItem; private final EquipmentSlot slot; - public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot, @NotNull EquipmentSlot hand) { - super(who, clickedEntity, hand); + @ApiStatus.Internal + public PlayerArmorStandManipulateEvent(@NotNull final Player player, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot, @NotNull EquipmentSlot hand) { + super(player, clickedEntity, hand); this.playerItem = playerItem; this.armorStandItem = armorStandItem; this.slot = slot; } @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerArmorStandManipulateEvent(@NotNull final Player who, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) { - this(who, clickedEntity, playerItem, armorStandItem, slot, EquipmentSlot.HAND); + public PlayerArmorStandManipulateEvent(@NotNull final Player player, @NotNull final ArmorStand clickedEntity, @NotNull final ItemStack playerItem, @NotNull final ItemStack armorStandItem, @NotNull final EquipmentSlot slot) { + this(player, clickedEntity, playerItem, armorStandItem, slot, EquipmentSlot.HAND); } /** @@ -96,11 +98,11 @@ public class PlayerArmorStandManipulateEvent extends PlayerInteractEntityEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java index 812712494..a50a70b46 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerAttemptPickupItemEvent.java @@ -21,8 +21,8 @@ public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancell private boolean cancelled; - @Deprecated(forRemoval = true) // Remove in 1.13 // Remove in 1.14? // Remove before the heat death of the universe? @ApiStatus.Internal + @Deprecated(forRemoval = true) public PlayerAttemptPickupItemEvent(final Player player, final Item item) { this(player, item, 0); } @@ -54,7 +54,7 @@ public class PlayerAttemptPickupItemEvent extends PlayerEvent implements Cancell /** * Set if the item will fly at the player - *

    Cancelling the event will set this value to false.

    + *

    Cancelling the event will set this value to {@code false}.

    * * @param flyAtPlayer {@code true} for item to fly at player */ diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java index 96c9b7fe0..628a1bbfa 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedEnterEvent.java @@ -13,6 +13,117 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Block bed; + private final BedEnterResult bedEnterResult; + private Result useBed = Result.DEFAULT; + + @ApiStatus.Internal + public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) { + super(player); + this.bed = bed; + this.bedEnterResult = bedEnterResult; + } + + @ApiStatus.Internal + @Deprecated(since = "1.13.2", forRemoval = true) + public PlayerBedEnterEvent(@NotNull Player player, @NotNull Block bed) { + this(player, bed, BedEnterResult.OK); + } + + /** + * Returns the bed block involved in this event. + * + * @return the bed block involved in this event + */ + @NotNull + public Block getBed() { + return this.bed; + } + + /** + * This describes the default outcome of this event. + * + * @return the bed enter result representing the default outcome of this event + */ + @NotNull + public BedEnterResult getBedEnterResult() { + return this.bedEnterResult; + } + + /** + * This controls the action to take with the bed that was clicked on. + *

    + * In case of {@link Result#DEFAULT}, the default outcome is described by + * {@link #getBedEnterResult()}. + * + * @return the action to take with the interacted bed + * @see #setUseBed(Result) + */ + @NotNull + public Result useBed() { + return this.useBed; + } + + /** + * Sets the action to take with the interacted bed. + *

    + * {@link Result#ALLOW} will result in the player sleeping, regardless of + * the default outcome described by {@link #getBedEnterResult()}. + *
    + * {@link Result#DENY} will prevent the player from sleeping. This has the + * same effect as canceling the event via {@link #setCancelled(boolean)}. + *
    + * {@link Result#DEFAULT} will result in the outcome described by + * {@link #getBedEnterResult()}. + * + * @param useBed the action to take with the interacted bed + * @see #useBed() + */ + public void setUseBed(@NotNull Result useBed) { + this.useBed = useBed; + } + + /** + * Gets the cancellation state of this event. Set to {@code true} if you want to + * prevent the player from sleeping. + *

    + * Canceling the event has the same effect as setting {@link #useBed()} to + * {@link Result#DENY}. + *

    + * For backwards compatibility reasons this also returns {@code true} if + * {@link #useBed()} is {@link Result#DEFAULT} and the + * {@link #getBedEnterResult() default action} is to prevent bed entering. + * + * @return boolean cancellation state + */ + @Override + public boolean isCancelled() { + return this.useBed == Result.DENY || this.useBed == Result.DEFAULT && this.bedEnterResult != BedEnterResult.OK; + } + + /** + * {@inheritDoc} + *

    + * Canceling this event will prevent use of the bed. + */ + @Override + public void setCancelled(boolean cancel) { + this.setUseBed(cancel ? Result.DENY : useBed() == Result.DENY ? Result.DEFAULT : useBed()); + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + /** * Represents the default possible outcomes of this event. */ @@ -25,9 +136,9 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * The world doesn't allow sleeping or saving the spawn point (eg, * Nether, The End or Custom Worlds). This is based on * {@link World#isBedWorks()} and {@link World#isNatural()}. - * + *

    * Entering the bed is prevented and if {@link World#isBedWorks()} is - * false then the bed explodes. + * {@code false} then the bed explodes. */ NOT_POSSIBLE_HERE, /** @@ -43,12 +154,10 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { * Entering the bed is prevented due to the player being too far away. */ TOO_FAR_AWAY, - // Paper start /** * Bed was obstructed. */ OBSTRUCTED, - // Paper end /** * Entering the bed is prevented due to there being monsters nearby. */ @@ -58,116 +167,4 @@ public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable { */ OTHER_PROBLEM; } - - private static final HandlerList handlers = new HandlerList(); - private final Block bed; - private final BedEnterResult bedEnterResult; - private Result useBed = Result.DEFAULT; - - @ApiStatus.Internal - public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed, @NotNull BedEnterResult bedEnterResult) { - super(who); - this.bed = bed; - this.bedEnterResult = bedEnterResult; - } - - @Deprecated(since = "1.13.2", forRemoval = true) - public PlayerBedEnterEvent(@NotNull Player who, @NotNull Block bed) { - this(who, bed, BedEnterResult.OK); - } - - /** - * This describes the default outcome of this event. - * - * @return the bed enter result representing the default outcome of this event - */ - @NotNull - public BedEnterResult getBedEnterResult() { - return bedEnterResult; - } - - /** - * This controls the action to take with the bed that was clicked on. - *

    - * In case of {@link org.bukkit.event.Event.Result#DEFAULT}, the default outcome is described by - * {@link #getBedEnterResult()}. - * - * @return the action to take with the interacted bed - * @see #setUseBed(org.bukkit.event.Event.Result) - */ - @NotNull - public Result useBed() { - return useBed; - } - - /** - * Sets the action to take with the interacted bed. - *

    - * {@link org.bukkit.event.Event.Result#ALLOW} will result in the player sleeping, regardless of - * the default outcome described by {@link #getBedEnterResult()}. - *
    - * {@link org.bukkit.event.Event.Result#DENY} will prevent the player from sleeping. This has the - * same effect as canceling the event via {@link #setCancelled(boolean)}. - *
    - * {@link org.bukkit.event.Event.Result#DEFAULT} will result in the outcome described by - * {@link #getBedEnterResult()}. - * - * @param useBed the action to take with the interacted bed - * @see #useBed() - */ - public void setUseBed(@NotNull Result useBed) { - this.useBed = useBed; - } - - /** - * Gets the cancellation state of this event. Set to true if you want to - * prevent the player from sleeping. - *

    - * Canceling the event has the same effect as setting {@link #useBed()} to - * {@link org.bukkit.event.Event.Result#DENY}. - *

    - * For backwards compatibility reasons this also returns true if - * {@link #useBed()} is {@link org.bukkit.event.Event.Result#DEFAULT} and the - * {@link #getBedEnterResult() default action} is to prevent bed entering. - * - * @return boolean cancellation state - */ - @Override - public boolean isCancelled() { - return (useBed == Result.DENY || useBed == Result.DEFAULT && bedEnterResult != BedEnterResult.OK); - } - - /** - * Sets the cancellation state of this event. A canceled event will not be - * executed in the server, but will still pass to other plugins. - *

    - * Canceling this event will prevent use of the bed. - * - * @param cancel true if you wish to cancel this event - */ - @Override - public void setCancelled(boolean cancel) { - setUseBed(cancel ? Result.DENY : useBed() == Result.DENY ? Result.DEFAULT : useBed()); - } - - /** - * Returns the bed block involved in this event. - * - * @return the bed block involved in this event - */ - @NotNull - public Block getBed() { - return bed; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java index f09b37850..74bdeb8e8 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java @@ -5,19 +5,23 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * This event is fired when the player is leaving a bed. */ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block bed; private boolean setBedSpawn; private boolean cancelled; - public PlayerBedLeaveEvent(@NotNull final Player who, @NotNull final Block bed, boolean setBedSpawn) { - super(who); + @ApiStatus.Internal + public PlayerBedLeaveEvent(@NotNull final Player player, @NotNull final Block bed, boolean setBedSpawn) { + super(player); this.bed = bed; this.setBedSpawn = setBedSpawn; } @@ -29,7 +33,7 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { */ @NotNull public Block getBed() { - return bed; + return this.bed; } /** @@ -42,13 +46,13 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { * To change a {@link Player}'s spawn location, use * {@link Player#setBedSpawnLocation(Location)}. * - * @return true if the spawn location will be changed + * @return {@code true} if the spawn location will be changed * @deprecated the respawn point is now set when the player enter the bed and * this option doesn't work since MC 1.15. */ - @Deprecated(forRemoval = true) // Paper - Unused + @Deprecated(forRemoval = true) public boolean shouldSetSpawnLocation() { - return setBedSpawn; + return this.setBedSpawn; } /** @@ -61,11 +65,11 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { * To change a {@link Player}'s spawn location, use * {@link Player#setBedSpawnLocation(Location)}. * - * @param setBedSpawn true to change the new spawn location + * @param setBedSpawn {@code true} to change the new spawn location * @deprecated the respawn point is now set when the player enter the bed and * this option doesn't work since MC 1.15. */ - @Deprecated(forRemoval = true) // Paper - Unused + @Deprecated(forRemoval = true) public void setSpawnLocation(boolean setBedSpawn) { this.setBedSpawn = setBedSpawn; } @@ -83,11 +87,11 @@ public class PlayerBedLeaveEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java index 36e02c71d..a20f55d37 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEmptyEvent.java @@ -14,31 +14,34 @@ import org.jetbrains.annotations.NotNull; * Called when a player empties a bucket */ public class PlayerBucketEmptyEvent extends PlayerBucketEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal @Deprecated(since = "1.14.4", forRemoval = true) - public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - super(who, blockClicked, blockFace, bucket, itemInHand); - } - - @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - super(who, block, blockClicked, blockFace, bucket, itemInHand); + public PlayerBucketEmptyEvent(@NotNull final Player player, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(player, blockClicked, blockFace, bucket, itemInHand); } @ApiStatus.Internal - public PlayerBucketEmptyEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { - super(who, block, blockClicked, blockFace, bucket, itemInHand, hand); + @Deprecated(since = "1.19.2", forRemoval = true) + public PlayerBucketEmptyEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(player, block, blockClicked, blockFace, bucket, itemInHand); + } + + @ApiStatus.Internal + public PlayerBucketEmptyEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { + super(player, block, blockClicked, blockFace, bucket, itemInHand, hand); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEntityEvent.java index 7b9c91b3f..34d958978 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEntityEvent.java @@ -7,6 +7,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,13 +15,16 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final Entity entity; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + protected final Entity entity; private final ItemStack originalBucket; private final ItemStack entityBucket; private final EquipmentSlot hand; + private boolean cancelled; + + @ApiStatus.Internal public PlayerBucketEntityEvent(@NotNull Player player, @NotNull Entity entity, @NotNull ItemStack originalBucket, @NotNull ItemStack entityBucket, @NotNull EquipmentSlot hand) { super(player); this.entity = entity; @@ -36,24 +40,24 @@ public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } /** * Gets the bucket used to capture the {@link Entity}. - * + *
    * This refers to the bucket clicked with, eg {@link Material#WATER_BUCKET}. * * @return The used bucket */ @NotNull public ItemStack getOriginalBucket() { - return originalBucket; + return this.originalBucket; } /** * Gets the bucket that the {@link Entity} will be put into. - * + *
    * This refers to the bucket with the entity, eg * {@link Material#PUFFERFISH_BUCKET}. * @@ -61,7 +65,7 @@ public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable */ @NotNull public ItemStack getEntityBucket() { - return entityBucket; + return this.entityBucket; } /** @@ -71,12 +75,12 @@ public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -87,11 +91,11 @@ public class PlayerBucketEntityEvent extends PlayerEvent implements Cancellable @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java index 0e07667be..777d25beb 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketEvent.java @@ -17,27 +17,31 @@ import org.jetbrains.annotations.Nullable; * Called when a player interacts with a Bucket */ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable { - private ItemStack itemStack; - private boolean cancelled = false; + private final Block block; private final Block blockClicked; private final BlockFace blockFace; private final Material bucket; private final EquipmentSlot hand; + private ItemStack itemStack; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.14.4", forRemoval = true) - public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - this(who, null, blockClicked.getRelative(blockFace), blockFace, bucket, itemInHand, EquipmentSlot.HAND); - } - - @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - this(who, block, blockClicked, blockFace, bucket, itemInHand, EquipmentSlot.HAND); + public PlayerBucketEvent(@NotNull final Player player, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + this(player, null, blockClicked.getRelative(blockFace), blockFace, bucket, itemInHand, EquipmentSlot.HAND); } @ApiStatus.Internal - public PlayerBucketEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { - super(who); + @Deprecated(since = "1.19.2", forRemoval = true) + public PlayerBucketEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + this(player, block, blockClicked, blockFace, bucket, itemInHand, EquipmentSlot.HAND); + } + + @ApiStatus.Internal + public PlayerBucketEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { + super(player); this.block = block; this.blockClicked = blockClicked; this.blockFace = blockFace; @@ -50,6 +54,36 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab this.hand = hand; } + /** + * Gets the block involved in this event. + * + * @return The Block which block is involved in this event + */ + @NotNull + public final Block getBlock() { + return this.block; + } + + /** + * Return the block clicked + * + * @return the clicked block + */ + @NotNull + public Block getBlockClicked() { + return this.blockClicked; + } + + /** + * Get the face on the clicked block + * + * @return the clicked face + */ + @NotNull + public BlockFace getBlockFace() { + return this.blockFace; + } + /** * Returns the bucket used in this event * @@ -57,7 +91,17 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab */ @NotNull public Material getBucket() { - return bucket; + return this.bucket; + } + + /** + * Get the hand that was used in this event. + * + * @return the hand + */ + @NotNull + public EquipmentSlot getHand() { + return this.hand; } /** @@ -67,7 +111,7 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab */ @Nullable public ItemStack getItemStack() { - return itemStack; + return this.itemStack; } /** @@ -79,49 +123,9 @@ public abstract class PlayerBucketEvent extends PlayerEvent implements Cancellab this.itemStack = itemStack; } - /** - * Gets the block involved in this event. - * - * @return The Block which block is involved in this event - */ - @NotNull - public final Block getBlock() { - return block; - } - - /** - * Return the block clicked - * - * @return the clicked block - */ - @NotNull - public Block getBlockClicked() { - return blockClicked; - } - - /** - * Get the face on the clicked block - * - * @return the clicked face - */ - @NotNull - public BlockFace getBlockFace() { - return blockFace; - } - - /** - * Get the hand that was used in this event. - * - * @return the hand - */ - @NotNull - public EquipmentSlot getHand() { - return hand; - } - @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java index c74c33e7d..f439df0d0 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFillEvent.java @@ -14,31 +14,34 @@ import org.jetbrains.annotations.NotNull; * Called when a player fills a bucket */ public class PlayerBucketFillEvent extends PlayerBucketEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal @Deprecated(since = "1.14.4", forRemoval = true) - public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - super(who, blockClicked, blockFace, bucket, itemInHand); - } - - @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { - super(who, block, blockClicked, blockFace, bucket, itemInHand); + public PlayerBucketFillEvent(@NotNull final Player player, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(player, blockClicked, blockFace, bucket, itemInHand); } @ApiStatus.Internal - public PlayerBucketFillEvent(@NotNull final Player who, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { - super(who, block, blockClicked, blockFace, bucket, itemInHand, hand); + @Deprecated(since = "1.19.2", forRemoval = true) + public PlayerBucketFillEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand) { + super(player, block, blockClicked, blockFace, bucket, itemInHand); + } + + @ApiStatus.Internal + public PlayerBucketFillEvent(@NotNull final Player player, @NotNull final Block block, @NotNull final Block blockClicked, @NotNull final BlockFace blockFace, @NotNull final Material bucket, @NotNull final ItemStack itemInHand, @NotNull final EquipmentSlot hand) { + super(player, block, blockClicked, blockFace, bucket, itemInHand, hand); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFishEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFishEvent.java index 2821347fc..2cfd0bbc3 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFishEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerBucketFishEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Fish; import org.bukkit.entity.Player; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -14,9 +15,10 @@ import org.jetbrains.annotations.NotNull; * @deprecated Use the more generic {@link PlayerBucketEntityEvent} */ @Deprecated(since = "1.16.5") -@Warning(false) +@Warning public class PlayerBucketFishEvent extends PlayerBucketEntityEvent { + @ApiStatus.Internal public PlayerBucketFishEvent(@NotNull Player player, @NotNull Fish fish, @NotNull ItemStack waterBucket, @NotNull ItemStack fishBucket, @NotNull EquipmentSlot hand) { super(player, fish, waterBucket, fishBucket, hand); } @@ -29,12 +31,12 @@ public class PlayerBucketFishEvent extends PlayerBucketEntityEvent { @NotNull @Override public Fish getEntity() { - return (Fish) super.getEntity(); + return (Fish) this.entity; } /** * Gets the bucket used. - * + *
    * This refers to the bucket clicked with, ie {@link Material#WATER_BUCKET}. * * @return The used bucket @@ -43,12 +45,12 @@ public class PlayerBucketFishEvent extends PlayerBucketEntityEvent { @NotNull @Deprecated(since = "1.16.5") public ItemStack getWaterBucket() { - return getOriginalBucket(); + return this.getOriginalBucket(); } /** * Gets the bucket that the fish will be put into. - * + *
    * This refers to the bucket with the fish, ie * {@link Material#PUFFERFISH_BUCKET}. * @@ -58,6 +60,6 @@ public class PlayerBucketFishEvent extends PlayerBucketEntityEvent { @NotNull @Deprecated(since = "1.16.5") public ItemStack getFishBucket() { - return getEntityBucket(); + return this.getEntityBucket(); } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java index 4cd9b6e40..4a73d7f3f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedMainHandEvent.java @@ -9,17 +9,19 @@ import org.jetbrains.annotations.NotNull; /** * Called when a player changes their main hand in the client settings. + * * @apiNote Obsolete and replaced by {@link PlayerClientOptionsChangeEvent}. */ @ApiStatus.Obsolete public class PlayerChangedMainHandEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final MainHand newMainHand; - public PlayerChangedMainHandEvent(@NotNull Player who, @NotNull MainHand newMainHand) { - super(who); + @ApiStatus.Internal + public PlayerChangedMainHandEvent(@NotNull Player player, @NotNull MainHand newMainHand) { + super(player); this.newMainHand = newMainHand; } @@ -35,7 +37,7 @@ public class PlayerChangedMainHandEvent extends PlayerEvent { @NotNull @Deprecated(since = "1.21.4", forRemoval = true) public MainHand getMainHand() { - return newMainHand == MainHand.LEFT ? MainHand.RIGHT : MainHand.LEFT; + return this.newMainHand == MainHand.LEFT ? MainHand.RIGHT : MainHand.LEFT; } /** @@ -45,17 +47,17 @@ public class PlayerChangedMainHandEvent extends PlayerEvent { */ @NotNull public MainHand getNewMainHand() { - return newMainHand; + return this.newMainHand; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java index f1d1d1e9b..4bd5e4122 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChangedWorldEvent.java @@ -3,15 +3,19 @@ package org.bukkit.event.player; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player switches to another world. */ public class PlayerChangedWorldEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final World from; + @ApiStatus.Internal public PlayerChangedWorldEvent(@NotNull final Player player, @NotNull final World from) { super(player); this.from = from; @@ -20,21 +24,21 @@ public class PlayerChangedWorldEvent extends PlayerEvent { /** * Gets the world the player is switching from. * - * @return player's previous world + * @return player's previous world */ @NotNull public World getFrom() { - return from; + return this.from; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java index 9316a525f..d79edfb11 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChannelEvent.java @@ -9,27 +9,29 @@ import org.jetbrains.annotations.NotNull; * channel. */ public abstract class PlayerChannelEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final String channel; - public PlayerChannelEvent(@NotNull final Player player, @NotNull final String channel) { + protected PlayerChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player); this.channel = channel; } @NotNull public final String getChannel() { - return channel; + return this.channel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java index 373162d96..5c5849dbc 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatEvent.java @@ -7,6 +7,7 @@ import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -17,19 +18,24 @@ import org.jetbrains.annotations.NotNull; @Deprecated(since = "1.3.1") @Warning(reason = "Listening to this event forces chat to wait for the main thread, delaying chat messages.") public class PlayerChatEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Set recipients; private String message; private String format; - private final Set recipients; + private boolean cancelled; + + @ApiStatus.Internal public PlayerChatEvent(@NotNull final Player player, @NotNull final String message) { super(player); this.message = message; this.format = "<%1$s> %2$s"; - this.recipients = new HashSet(player.getServer().getOnlinePlayers()); + this.recipients = new HashSet<>(player.getServer().getOnlinePlayers()); } + @ApiStatus.Internal public PlayerChatEvent(@NotNull final Player player, @NotNull final String message, @NotNull final String format, @NotNull final Set recipients) { super(player); this.message = message; @@ -37,16 +43,6 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { this.recipients = recipients; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Gets the message that the player is attempting to send * @@ -54,7 +50,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public String getMessage() { - return message; + return this.message; } /** @@ -84,7 +80,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public String getFormat() { - return format; + return this.format; } /** @@ -95,7 +91,7 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { public void setFormat(@NotNull final String format) { // Oh for a better way to do this! try { - String.format(format, player, message); + String.format(format, this.player, this.message); } catch (RuntimeException ex) { ex.fillInStackTrace(); throw ex; @@ -111,17 +107,27 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable { */ @NotNull public Set getRecipients() { - return recipients; + return this.recipients; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java index b13394e42..39181a5ac 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerChatTabCompleteEvent.java @@ -5,6 +5,7 @@ import java.util.Collection; import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -15,13 +16,16 @@ import org.jetbrains.annotations.NotNull; @Deprecated(since = "1.13") @Warning(reason = "This event is no longer fired due to client changes") public class PlayerChatTabCompleteEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final String message; private final String lastToken; private final Collection completions; - public PlayerChatTabCompleteEvent(@NotNull final Player who, @NotNull final String message, @NotNull final Collection completions) { - super(who); + @ApiStatus.Internal + public PlayerChatTabCompleteEvent(@NotNull final Player player, @NotNull final String message, @NotNull final Collection completions) { + super(player); Preconditions.checkArgument(message != null, "Message cannot be null"); Preconditions.checkArgument(completions != null, "Completions cannot be null"); this.message = message; @@ -41,7 +45,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { */ @NotNull public String getChatMessage() { - return message; + return this.message; } /** @@ -54,7 +58,7 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { */ @NotNull public String getLastToken() { - return lastToken; + return this.lastToken; } /** @@ -64,17 +68,17 @@ public class PlayerChatTabCompleteEvent extends PlayerEvent { */ @NotNull public Collection getTabCompletions() { - return completions; + return this.completions; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java index 9eb2c2a1f..d9a6ebfb6 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandPreprocessEvent.java @@ -6,6 +6,7 @@ import java.util.Set; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -41,38 +42,33 @@ import org.jetbrains.annotations.NotNull; *

    * If the event is cancelled, processing of the command will halt. *

    - * The state of whether or not there is a slash (/) at the + * The state of whether there is a slash (/) at the * beginning of the message should be preserved. If a slash is added or * removed, unexpected behavior may result. */ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private String message; private final Set recipients; + private boolean cancelled; + + @ApiStatus.Internal public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message) { super(player); - this.recipients = new HashSet(player.getServer().getOnlinePlayers()); + this.recipients = new HashSet<>(player.getServer().getOnlinePlayers()); this.message = message; } + @ApiStatus.Internal public PlayerCommandPreprocessEvent(@NotNull final Player player, @NotNull final String message, @NotNull final Set recipients) { super(player); this.recipients = recipients; this.message = message; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Gets the command that the player is attempting to send. *

    @@ -83,7 +79,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell */ @NotNull public String getMessage() { - return message; + return this.message; } /** @@ -93,7 +89,7 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell * consider the first character when executing the content. * * @param command New message that the player will send - * @throws IllegalArgumentException if command is null or empty + * @throws IllegalArgumentException if command is {@code null} or empty */ public void setMessage(@NotNull String command) throws IllegalArgumentException { Preconditions.checkArgument(command != null, "Command cannot be null"); @@ -101,19 +97,6 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell this.message = command; } - /** - * Sets the player that this command will be executed as. - * - * @param player New player which this event will execute as - * @throws IllegalArgumentException if the player provided is null - * @deprecated Only works for sign commands; use {@link Player#performCommand(String)}, including those cases - */ - @Deprecated(forRemoval = true) - public void setPlayer(@NotNull final Player player) throws IllegalArgumentException { - Preconditions.checkArgument(player != null, "Player cannot be null"); - this.player = player; - } - /** * Gets a set of recipients that this chat message will be displayed to. *

    @@ -130,17 +113,40 @@ public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancell @NotNull @Deprecated(since = "1.3.1", forRemoval = true) public Set getRecipients() { - return recipients; + return this.recipients; + } + + /** + * Sets the player that this command will be executed as. + * + * @param player New player which this event will execute as + * @throws IllegalArgumentException if the player provided is null + * @deprecated Only works for sign commands; use {@link Player#performCommand(String)}, including those cases + */ + @Deprecated(forRemoval = true) + public void setPlayer(@NotNull final Player player) throws IllegalArgumentException { + Preconditions.checkArgument(player != null, "Player cannot be null"); + this.player = player; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java index 762825997..f768a9fa7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import java.util.Collection; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -16,9 +17,11 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerCommandSendEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Collection commands; + @ApiStatus.Internal public PlayerCommandSendEvent(@NotNull final Player player, @NotNull final Collection commands) { super(player); this.commands = commands; @@ -34,17 +37,17 @@ public class PlayerCommandSendEvent extends PlayerEvent { */ @NotNull public Collection getCommands() { - return commands; + return this.commands; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java index aca500f32..02fa5fca4 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerDropItemEvent.java @@ -4,16 +4,20 @@ import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Thrown when a player drops an item from their inventory */ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final Item drop; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Item drop; + private boolean cancelled; + + @ApiStatus.Internal public PlayerDropItemEvent(@NotNull final Player player, @NotNull final Item drop) { super(player); this.drop = drop; @@ -26,27 +30,27 @@ public class PlayerDropItemEvent extends PlayerEvent implements Cancellable { */ @NotNull public Item getItemDrop() { - return drop; + return this.drop; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java index 77dff6319..cdf9ce8a5 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEditBookEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.meta.BookMeta; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,28 +14,24 @@ import org.jetbrains.annotations.NotNull; * cancelled, no changes are made to the BookMeta */ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); private final BookMeta previousBookMeta; private final int slot; private BookMeta newBookMeta; private boolean isSigning; - private boolean cancel; - public PlayerEditBookEvent(@NotNull Player who, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) { - super(who); + private boolean cancelled; - Preconditions.checkArgument(slot >= -1 && slot <= 8, "Slot must be in range (-1)-8 inclusive"); - Preconditions.checkArgument(previousBookMeta != null, "Previous book meta must not be null"); - Preconditions.checkArgument(newBookMeta != null, "New book meta must not be null"); - - Bukkit.getItemFactory().equals(previousBookMeta, newBookMeta); + @ApiStatus.Internal + public PlayerEditBookEvent(@NotNull Player player, int slot, @NotNull BookMeta previousBookMeta, @NotNull BookMeta newBookMeta, boolean isSigning) { + super(player); this.previousBookMeta = previousBookMeta; this.newBookMeta = newBookMeta; this.slot = slot; this.isSigning = isSigning; - this.cancel = false; } /** @@ -47,7 +44,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { */ @NotNull public BookMeta getPreviousBookMeta() { - return previousBookMeta.clone(); + return this.previousBookMeta.clone(); } /** @@ -61,7 +58,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { */ @NotNull public BookMeta getNewBookMeta() { - return newBookMeta.clone(); + return this.newBookMeta.clone(); } /** @@ -76,7 +73,7 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { */ @Deprecated(since = "1.13.1", forRemoval = true) public int getSlot() { - return slot; + return this.slot; } /** @@ -92,43 +89,43 @@ public class PlayerEditBookEvent extends PlayerEvent implements Cancellable { } /** - * Gets whether or not the book is being signed. If a book is signed the + * Gets whether the book is being signed. If a book is signed the * Material changes from BOOK_AND_QUILL to WRITTEN_BOOK. * - * @return true if the book is being signed + * @return {@code true} if the book is being signed */ public boolean isSigning() { - return isSigning; + return this.isSigning; } /** - * Sets whether or not the book is being signed. If a book is signed the + * Sets whether the book is being signed. If a book is signed the * Material changes from BOOK_AND_QUILL to WRITTEN_BOOK. * - * @param signing whether or not the book is being signed. + * @param signing whether the book is being signed. */ public void setSigning(boolean signing) { - isSigning = signing; + this.isSigning = signing; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java index 917338044..63181a864 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEggThrowEvent.java @@ -4,18 +4,22 @@ import org.bukkit.entity.Egg; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player throws an egg and it might hatch */ public class PlayerEggThrowEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Egg egg; private boolean hatching; private EntityType hatchType; private byte numHatches; + @ApiStatus.Internal public PlayerEggThrowEvent(@NotNull final Player player, @NotNull final Egg egg, final boolean hatching, final byte numHatches, @NotNull final EntityType hatchingType) { super(player); this.egg = egg; @@ -31,7 +35,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { */ @NotNull public Egg getEgg() { - return egg; + return this.egg; } /** @@ -41,13 +45,13 @@ public class PlayerEggThrowEvent extends PlayerEvent { * @return boolean Whether the egg is going to hatch or not */ public boolean isHatching() { - return hatching; + return this.hatching; } /** * Sets whether the egg will hatch or not. * - * @param hatching true if you want the egg to hatch, false if you want it + * @param hatching {@code true} if you want the egg to hatch, {@code false} if you want it * not to */ public void setHatching(boolean hatching) { @@ -61,7 +65,7 @@ public class PlayerEggThrowEvent extends PlayerEvent { */ @NotNull public EntityType getHatchingType() { - return hatchType; + return this.hatchType; } /** @@ -86,13 +90,13 @@ public class PlayerEggThrowEvent extends PlayerEvent { * @return The number of mobs going to be hatched by the egg */ public byte getNumHatches() { - return numHatches; + return this.numHatches; } /** * Change the number of mobs coming out of the hatched egg *

    - * The boolean hatching will override this number. Ie. If hatching = + * The boolean hatching will override this number. I.e. If hatching = * false, this number will not matter * * @param numHatches The number of mobs coming out of the egg @@ -104,11 +108,11 @@ public class PlayerEggThrowEvent extends PlayerEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java index f6d3b817d..5d1b52216 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerEvent.java @@ -8,16 +8,16 @@ import org.jetbrains.annotations.NotNull; * Represents a player related event */ public abstract class PlayerEvent extends Event { + protected Player player; - public PlayerEvent(@NotNull final Player who) { - player = who; + protected PlayerEvent(@NotNull final Player player) { + this.player = player; } - public PlayerEvent(@NotNull final Player who, boolean async) { // Paper - public + protected PlayerEvent(@NotNull final Player player, boolean async) { super(async); - player = who; - + this.player = player; } /** @@ -27,6 +27,6 @@ public abstract class PlayerEvent extends Event { */ @NotNull public final Player getPlayer() { - return player; + return this.player; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java index 7c340f539..a2b666d05 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpChangeEvent.java @@ -1,30 +1,34 @@ package org.bukkit.event.player; -import org.bukkit.entity.Entity; // Paper +import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; // Paper +import org.jetbrains.annotations.Nullable; /** * Called when a players experience changes naturally */ public class PlayerExpChangeEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - // Paper start + + private static final HandlerList HANDLER_LIST = new HandlerList(); + @Nullable private final Entity source; private int exp; + @ApiStatus.Internal public PlayerExpChangeEvent(@NotNull final Player player, final int expAmount) { this(player, null, expAmount); } + @ApiStatus.Internal public PlayerExpChangeEvent(@NotNull final Player player, @Nullable final Entity sourceEntity, final int expAmount) { super(player); - source = sourceEntity; - exp = expAmount; + this.source = sourceEntity; + this.exp = expAmount; } /** @@ -34,9 +38,8 @@ public class PlayerExpChangeEvent extends PlayerEvent { */ @Nullable public Entity getSource() { - return source; + return this.source; } - // Paper end /** * Get the amount of experience the player will receive @@ -44,7 +47,7 @@ public class PlayerExpChangeEvent extends PlayerEvent { * @return The amount of experience */ public int getAmount() { - return exp; + return this.exp; } /** @@ -53,17 +56,17 @@ public class PlayerExpChangeEvent extends PlayerEvent { * @param amount The amount of experience to set */ public void setAmount(int amount) { - exp = amount; + this.exp = amount; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpCooldownChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpCooldownChangeEvent.java index 6d19fb52d..96b352906 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerExpCooldownChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerExpCooldownChangeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -9,13 +10,15 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerExpCooldownChangeEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private int newCooldown; - private final ChangeReason reason; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public PlayerExpCooldownChangeEvent(@NotNull final Player player, int newcooldown, @NotNull ChangeReason reason) { + private final ChangeReason reason; + private int newCooldown; + + @ApiStatus.Internal + public PlayerExpCooldownChangeEvent(@NotNull final Player player, int newCooldown, @NotNull ChangeReason reason) { super(player); - this.newCooldown = newcooldown; + this.newCooldown = newCooldown; this.reason = reason; } @@ -26,7 +29,7 @@ public class PlayerExpCooldownChangeEvent extends PlayerEvent { */ @NotNull public ChangeReason getReason() { - return reason; + return this.reason; } /** @@ -36,7 +39,7 @@ public class PlayerExpCooldownChangeEvent extends PlayerEvent { * @see Player#getExpCooldown() */ public int getNewCooldown() { - return newCooldown; + return this.newCooldown; } /** @@ -52,12 +55,12 @@ public class PlayerExpCooldownChangeEvent extends PlayerEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum ChangeReason { diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java index 8b4ad4217..691037dec 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerFishEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,14 +14,18 @@ import org.jetbrains.annotations.Nullable; * Thrown when a player is fishing */ public class PlayerFishEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity entity; - private boolean cancel = false; - private int exp; - private final State state; private final FishHook hookEntity; private final EquipmentSlot hand; + private final State state; + private int exp; + private boolean cancelled; + + @ApiStatus.Internal public PlayerFishEvent(@NotNull final Player player, @Nullable final Entity entity, @NotNull final FishHook hookEntity, @Nullable EquipmentSlot hand, @NotNull final State state) { super(player); this.entity = entity; @@ -29,6 +34,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { this.state = state; } + @ApiStatus.Internal public PlayerFishEvent(@NotNull final Player player, @Nullable final Entity entity, @NotNull final FishHook hookEntity, @NotNull final State state) { this(player, entity, hookEntity, null, state); } @@ -39,12 +45,12 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * If player has fished successfully, the result may be cast to {@link * org.bukkit.entity.Item}. * - * @return Entity caught by the player, Entity if fishing, and null if + * @return Entity caught by the player, Entity if fishing, and {@code null} if * bobber has gotten stuck in the ground or nothing has been caught */ @Nullable public Entity getCaught() { - return entity; + return this.entity; } /** @@ -54,17 +60,31 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { */ @NotNull public FishHook getHook() { - return hookEntity; + return this.hookEntity; } - @Override - public boolean isCancelled() { - return cancel; + /** + * Get the hand that was used in this event. + *

    + * The hand used is only present for player interactions. + * This means it will be {@code null} if state is set + * to {@link State#BITE} or {@link State#FAILED_ATTEMPT}. + * + * @return the hand + */ + @Nullable + public EquipmentSlot getHand() { + return this.hand; } - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + /** + * Gets the state of the fishing + * + * @return A State detailing the state of the fishing + */ + @NotNull + public State getState() { + return this.state; } /** @@ -76,7 +96,7 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * @return the amount of experience to drop */ public int getExpToDrop() { - return exp; + return this.exp; } /** @@ -88,42 +108,28 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * @param amount the amount of experience to drop */ public void setExpToDrop(int amount) { - exp = amount; + this.exp = amount; } - /** - * Get the hand that was used in this event. - *

    - * The hand used is only present for player interactions. - * This means it will be null if state is set - * to {@link State#BITE} or {@link State#FAILED_ATTEMPT}. - * - * @return the hand - */ - @Nullable - public EquipmentSlot getHand() { - return hand; + @Override + public boolean isCancelled() { + return this.cancelled; } - /** - * Gets the state of the fishing - * - * @return A State detailing the state of the fishing - */ - @NotNull - public State getState() { - return state; + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -164,14 +170,11 @@ public class PlayerFishEvent extends PlayerEvent implements Cancellable { * Called when there is a bite on the hook and it is ready to be reeled * in. */ - BITE - // Paper start - Add missing fishing event state - , + BITE, /** * Called when a bobber was lured, and is now waiting to be hooked * (when a "fish" starts to swim toward the bobber to bite it). */ LURED, - // Paper end - Add missing fishing event state } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java index 996f58fb7..63c494a03 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerGameModeChangeEvent.java @@ -1,11 +1,13 @@ package org.bukkit.event.player; +import net.kyori.adventure.text.Component; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when the GameMode of the player is changed. @@ -16,36 +18,27 @@ import org.jetbrains.annotations.NotNull; * to check before changing player state. */ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final GameMode newGameMode; - // Paper start - private final Cause cause; - private net.kyori.adventure.text.Component cancelMessage; - @Deprecated(forRemoval = true) // Paper end + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final GameMode newGameMode; + private final Cause cause; + private Component cancelMessage; + + private boolean cancelled; + + @ApiStatus.Internal + @Deprecated(forRemoval = true) public PlayerGameModeChangeEvent(@NotNull final Player player, @NotNull final GameMode newGameMode) { - // Paper start this(player, newGameMode, Cause.UNKNOWN, null); } @ApiStatus.Internal public PlayerGameModeChangeEvent(@NotNull final Player player, @NotNull final GameMode newGameMode, @NotNull Cause cause, @org.jetbrains.annotations.Nullable net.kyori.adventure.text.Component cancelMessage) { - // Paper end super(player); this.newGameMode = newGameMode; - this.cause = cause; // Paper - this.cancelMessage = cancelMessage; // Paper - } - - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; + this.cause = cause; + this.cancelMessage = cancelMessage; } /** @@ -55,20 +48,9 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl */ @NotNull public GameMode getNewGameMode() { - return newGameMode; + return this.newGameMode; } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - // Paper start /** * Gets the cause of this gamemode change. * @@ -76,7 +58,7 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl */ @NotNull public Cause getCause() { - return cause; + return this.cause; } /** @@ -86,13 +68,13 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl *

    * This returns {@code null} if the gamemode change was due to a plugin, or a * player joining the game with a gamemode not equal to the server default gamemode - * and {@code force-gamemode} is set to true. + * and {@code force-gamemode} is set to {@code true}. * - * @return the error message shown to the command user, null if not directly caused by a command + * @return the error message shown to the command user, {@code null} if not directly caused by a command */ - @org.jetbrains.annotations.Nullable - public net.kyori.adventure.text.Component cancelMessage() { - return cancelMessage; + @Nullable + public Component cancelMessage() { + return this.cancelMessage; } /** @@ -100,12 +82,33 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl * The message is only shown to cancelled events that are directly called by a command * not by a plugin or a player joining with the wrong gamemode. * - * @param message the error message shown to the command user, null to show no message. + * @param message the error message shown to the command user, {@code null} to show no message. */ - public void cancelMessage(@org.jetbrains.annotations.Nullable net.kyori.adventure.text.Component message) { + public void cancelMessage(@Nullable Component message) { this.cancelMessage = message; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + public enum Cause { /** @@ -113,32 +116,27 @@ public class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellabl * {@link Player#setGameMode(GameMode)}. */ PLUGIN, - /** * The {@code /gamemode} command was used. */ COMMAND, - /** * A player had their gamemode changed as a result of * the {@code /defaultgamemode} command, or they joined * with a gamemode that was not the default gamemode and - * {@code force-gamemode} in {@code server.properties} is set to true. + * {@code force-gamemode} in {@code server.properties} is set to {@code true}. */ DEFAULT_GAMEMODE, - /** * When the player dies in a hardcore world and has their gamemode * changed to {@link GameMode#SPECTATOR}. */ HARDCORE_DEATH, - /** * This cause is only used if a plugin fired their own * {@link PlayerGameModeChangeEvent} and did not include a * cause. Can usually be ignored. */ - UNKNOWN, + UNKNOWN } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerHarvestBlockEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerHarvestBlockEvent.java index f18ee5a8d..a7b580033 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerHarvestBlockEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerHarvestBlockEvent.java @@ -22,12 +22,14 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerHarvestBlockEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Block harvestedBlock; private final EquipmentSlot hand; private final List itemsHarvested; + private boolean cancelled; + @ApiStatus.Internal public PlayerHarvestBlockEvent(@NotNull Player player, @NotNull Block harvestedBlock, @NotNull EquipmentSlot hand, @NotNull List itemsHarvested) { super(player); @@ -36,6 +38,7 @@ public class PlayerHarvestBlockEvent extends PlayerEvent implements Cancellable this.itemsHarvested = itemsHarvested; } + @ApiStatus.Internal @Deprecated(since = "1.19.2", forRemoval = true) public PlayerHarvestBlockEvent(@NotNull Player player, @NotNull Block harvestedBlock, @NotNull List itemsHarvested) { this(player, harvestedBlock, EquipmentSlot.HAND, itemsHarvested); @@ -48,7 +51,7 @@ public class PlayerHarvestBlockEvent extends PlayerEvent implements Cancellable */ @NotNull public Block getHarvestedBlock() { - return harvestedBlock; + return this.harvestedBlock; } /** @@ -58,7 +61,7 @@ public class PlayerHarvestBlockEvent extends PlayerEvent implements Cancellable */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } /** @@ -68,27 +71,27 @@ public class PlayerHarvestBlockEvent extends PlayerEvent implements Cancellable */ @NotNull public List getItemsHarvested() { - return itemsHarvested; + return this.itemsHarvested; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java index 549a9a1b5..60389332f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerHideEntityEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -17,11 +18,13 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerHideEntityEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity entity; - public PlayerHideEntityEvent(@NotNull Player who, @NotNull Entity entity) { - super(who); + @ApiStatus.Internal + public PlayerHideEntityEvent(@NotNull Player player, @NotNull Entity entity) { + super(player); this.entity = entity; } @@ -32,17 +35,17 @@ public class PlayerHideEntityEvent extends PlayerEvent { */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInputEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInputEvent.java index 27faff149..202c06ad6 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInputEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInputEvent.java @@ -14,9 +14,11 @@ import org.jetbrains.annotations.NotNull; @ApiStatus.Experimental public class PlayerInputEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Input input; + @ApiStatus.Internal public PlayerInputEvent(@NotNull final Player player, @NotNull final Input input) { super(player); this.input = input; @@ -29,17 +31,17 @@ public class PlayerInputEvent extends PlayerEvent { */ @NotNull public Input getInput() { - return input; + return this.input; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java index 3f24d302e..e790cb487 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractAtEntityEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -18,31 +19,35 @@ import org.jetbrains.annotations.NotNull; * to listen to this event for that scenario. */ public class PlayerInteractAtEntityEvent extends PlayerInteractEntityEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Vector position; - public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position) { - this(who, clickedEntity, position, EquipmentSlot.HAND); + @ApiStatus.Internal + public PlayerInteractAtEntityEvent(@NotNull Player player, @NotNull Entity clickedEntity, @NotNull Vector position) { + this(player, clickedEntity, position, EquipmentSlot.HAND); } - public PlayerInteractAtEntityEvent(@NotNull Player who, @NotNull Entity clickedEntity, @NotNull Vector position, @NotNull EquipmentSlot hand) { - super(who, clickedEntity, hand); + @ApiStatus.Internal + public PlayerInteractAtEntityEvent(@NotNull Player player, @NotNull Entity clickedEntity, @NotNull Vector position, @NotNull EquipmentSlot hand) { + super(player, clickedEntity, hand); this.position = position; } @NotNull public Vector getClickedPosition() { - return position.clone(); + return this.position.clone(); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java index 1d3d62969..6dac09f9c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEntityEvent.java @@ -5,37 +5,33 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.EquipmentSlot; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Represents an event that is called when a player right clicks an entity. */ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - protected Entity clickedEntity; - boolean cancelled = false; - private EquipmentSlot hand; - public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity) { - this(who, clickedEntity, EquipmentSlot.HAND); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + protected Entity clickedEntity; + private final EquipmentSlot hand; + + private boolean cancelled; + + @ApiStatus.Internal + public PlayerInteractEntityEvent(@NotNull final Player player, @NotNull final Entity clickedEntity) { + this(player, clickedEntity, EquipmentSlot.HAND); } - public PlayerInteractEntityEvent(@NotNull final Player who, @NotNull final Entity clickedEntity, @NotNull final EquipmentSlot hand) { - super(who); + @ApiStatus.Internal + public PlayerInteractEntityEvent(@NotNull final Player player, @NotNull final Entity clickedEntity, @NotNull final EquipmentSlot hand) { + super(player); this.clickedEntity = clickedEntity; this.hand = hand; } - @Override - public boolean isCancelled() { - return cancelled; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancelled = cancel; - } - /** * Gets the entity that was right-clicked by the player. * @@ -53,17 +49,27 @@ public class PlayerInteractEntityEvent extends PlayerEvent implements Cancellabl */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java index 759aaa935..b3c8ba52e 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java @@ -12,6 +12,7 @@ import org.bukkit.event.block.BlockCanBuildEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -21,42 +22,47 @@ import org.jetbrains.annotations.Nullable; * {@link #getHand()}. *

    * This event will fire as cancelled if the vanilla behavior is to do nothing - * (e.g interacting with air). For the purpose of avoiding doubt, this means + * (e.g. interacting with air). For the purpose of avoiding doubt, this means * that the event will only be in the cancelled state if it is fired as a result * of some prediction made by the server where no subsequent code will run, * rather than when the subsequent interaction activity (e.g. placing a block in - * an illegal position ({@link BlockCanBuildEvent}) will fail. + * an illegal position ({@link BlockCanBuildEvent}) will fail). */ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - protected ItemStack item; - protected Action action; - protected Block blockClicked; - protected BlockFace blockFace; - private Result useClickedBlock; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Action action; + private final ItemStack item; + private final Block blockClicked; + private final BlockFace blockFace; + private final EquipmentSlot hand; + private final Vector clickedPosition; private Result useItemInHand; - private EquipmentSlot hand; - private Vector clickedPosistion; + private Result useClickedBlock; - public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) { - this(who, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND); + @ApiStatus.Internal + public PlayerInteractEvent(@NotNull final Player player, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) { + this(player, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND); } - public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) { - this(who, action, item, clickedBlock, clickedFace, hand, null); + @ApiStatus.Internal + public PlayerInteractEvent(@NotNull final Player player, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) { + this(player, action, item, clickedBlock, clickedFace, hand, null); } - public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand, @Nullable final Vector clickedPosition) { - super(who); + @ApiStatus.Internal + public PlayerInteractEvent(@NotNull final Player player, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand, @Nullable final Vector clickedPosition) { + super(player); this.action = action; this.item = item; this.blockClicked = clickedBlock; this.blockFace = clickedFace; this.hand = hand; - this.clickedPosistion = clickedPosition; + this.clickedPosition = clickedPosition; - useItemInHand = Result.DEFAULT; - useClickedBlock = clickedBlock == null ? Result.DENY : Result.ALLOW; + this.useItemInHand = Result.DEFAULT; + this.useClickedBlock = clickedBlock == null ? Result.DENY : Result.ALLOW; } /** @@ -66,40 +72,37 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @NotNull public Action getAction() { - return action; + return this.action; } /** - * Gets the cancellation state of this event. Set to true if you want to + * Gets the cancellation state of this event. Set to {@code true} if you want to * prevent buckets from placing water and so forth * * @return boolean cancellation state * @deprecated This event has two possible cancellation states, one for * {@link #useInteractedBlock()} and one for {@link #useItemInHand()}. It is - * possible a call might have the former false, but the latter true, eg in + * possible a call might have the former false, but the latter {@code true}, e.g. in * the case of using a firework whilst gliding. Callers should check the * relevant methods individually. */ @Deprecated(since = "1.14") @Override public boolean isCancelled() { - return useInteractedBlock() == Result.DENY; + return this.useInteractedBlock() == Result.DENY; } /** - * Sets the cancellation state of this event. A canceled event will not be - * executed in the server, but will still pass to other plugins + * {@inheritDoc} *

    * Canceling this event will prevent use of food (player won't lose the * food item), prevent bows/snowballs/eggs from firing, etc. (player won't * lose the ammo) - * - * @param cancel true if you wish to cancel this event */ @Override public void setCancelled(boolean cancel) { - setUseInteractedBlock(cancel ? Result.DENY : useInteractedBlock() == Result.DENY ? Result.DEFAULT : useInteractedBlock()); - setUseItemInHand(cancel ? Result.DENY : useItemInHand() == Result.DENY ? Result.DEFAULT : useItemInHand()); + this.setUseInteractedBlock(cancel ? Result.DENY : this.useInteractedBlock() == Result.DENY ? Result.DEFAULT : this.useInteractedBlock()); + this.setUseItemInHand(cancel ? Result.DENY : this.useItemInHand() == Result.DENY ? Result.DEFAULT : this.useItemInHand()); } /** @@ -120,17 +123,17 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @NotNull public Material getMaterial() { - if (!hasItem()) { + if (!this.hasItem()) { return Material.AIR; } - return item.getType(); + return this.item.getType(); } /** * Check if this event involved a block * - * @return boolean true if it did + * @return boolean {@code true} if it did */ public boolean hasBlock() { return this.blockClicked != null; @@ -139,7 +142,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { /** * Check if this event involved an item * - * @return boolean true if it did + * @return boolean {@code true} if it did */ public boolean hasItem() { return this.item != null; @@ -149,14 +152,14 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { * Convenience method to inform the user whether this was a block * placement event. * - * @return boolean true if the item in hand was a block + * @return boolean {@code true} if the item in hand was a block */ public boolean isBlockInHand() { - if (!hasItem()) { + if (!this.hasItem()) { return false; } - return item.getType().isBlock(); + return this.item.getType().isBlock(); } /** @@ -166,7 +169,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @Nullable public Block getClickedBlock() { - return blockClicked; + return this.blockClicked; } /** @@ -176,7 +179,49 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @NotNull public BlockFace getBlockFace() { - return blockFace; + return this.blockFace; + } + + /** + * The hand used to perform this interaction. May be {@code null} in the case of + * {@link Action#PHYSICAL}. + * + * @return the hand used to interact. May be {@code null}. + */ + @Nullable + public EquipmentSlot getHand() { + return this.hand; + } + + /** + * Gets the exact position on the block the player interacted with, this will + * be {@code null} outside of {@link Action#RIGHT_CLICK_BLOCK}. + *

    + * All vector components are between 0.0 and 1.0 inclusive. + * + * @deprecated misleading, use {@link #getInteractionPoint()} + * @return the clicked position. May be {@code null}. + */ + @Nullable + @Deprecated + public Vector getClickedPosition() { + if (this.clickedPosition == null) { + return null; + } + return this.clickedPosition.clone(); + } + + /** + * The exact point at which the interaction occurred. May be {@code null}. + * + * @return the exact interaction point. May be {@code null}. + */ + @Nullable + public Location getInteractionPoint() { + if (this.blockClicked == null || this.clickedPosition == null) { + return null; + } + return this.blockClicked.getLocation().add(this.clickedPosition); } /** @@ -188,7 +233,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @NotNull public Result useInteractedBlock() { - return useClickedBlock; + return this.useClickedBlock; } /** @@ -208,7 +253,7 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { */ @NotNull public Result useItemInHand() { - return useItemInHand; + return this.useItemInHand; } /** @@ -218,58 +263,14 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { this.useItemInHand = useItemInHand; } - /** - * The hand used to perform this interaction. May be null in the case of - * {@link Action#PHYSICAL}. - * - * @return the hand used to interact. May be null. - */ - @Nullable - public EquipmentSlot getHand() { - return hand; - } - - /** - * Gets the exact position on the block the player interacted with, this will - * be null outside of {@link Action#RIGHT_CLICK_BLOCK}. - *

    - * All vector components are between 0.0 and 1.0 inclusive. - * - * @deprecated misleading, use {@link #getInteractionPoint()} - * @return the clicked position. May be null. - */ - @Nullable - @Deprecated // Paper - public Vector getClickedPosition() { - if (this.clickedPosistion == null) { - return null; - } - return clickedPosistion.clone(); - } - - // Paper start - /** - * The exact point at which the interaction occurred. May be null. - * - * @return the exact interaction point. May be null. - */ - @Nullable - public Location getInteractionPoint() { - if (this.blockClicked == null || this.clickedPosistion == null) { - return null; - } - return this.blockClicked.getLocation().add(this.clickedPosistion); - } - // Paper end - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java index 35c373c87..eae7374e9 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemBreakEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,9 +13,12 @@ import org.jetbrains.annotations.NotNull; * and its durability will be reset to 0. */ public class PlayerItemBreakEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack brokenItem; + @ApiStatus.Internal public PlayerItemBreakEvent(@NotNull final Player player, @NotNull final ItemStack brokenItem) { super(player); this.brokenItem = brokenItem; @@ -27,17 +31,17 @@ public class PlayerItemBreakEvent extends PlayerEvent { */ @NotNull public ItemStack getBrokenItem() { - return brokenItem; + return this.brokenItem; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java index 4cd915b0c..0e0a9ceeb 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java @@ -21,17 +21,15 @@ import org.jetbrains.annotations.Nullable; * not be removed from the player's inventory. */ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean isCancelled = false; - private ItemStack item; - private final EquipmentSlot hand; - @Nullable private ItemStack replacement; // Paper - /** - * @param player the player consuming - * @param item the ItemStack being consumed - * @param hand the hand that was used - */ + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final EquipmentSlot hand; + private ItemStack item; + @Nullable private ItemStack replacement; + + private boolean cancelled; + @ApiStatus.Internal public PlayerItemConsumeEvent(@NotNull final Player player, @NotNull final ItemStack item, @NotNull final EquipmentSlot hand) { super(player); @@ -40,11 +38,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { this.hand = hand; } - /** - * @param player the player consuming - * @param item the ItemStack being consumed - * @deprecated use {@link #PlayerItemConsumeEvent(Player, ItemStack, EquipmentSlot)} - */ + @ApiStatus.Internal @Deprecated(since = "1.19.2", forRemoval = true) public PlayerItemConsumeEvent(@NotNull final Player player, @NotNull final ItemStack item) { this(player, item, EquipmentSlot.HAND); @@ -59,7 +53,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { */ @NotNull public ItemStack getItem() { - return item.clone(); + return this.item.clone(); } /** @@ -82,15 +76,14 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } - // Paper start /** - * Return the custom item stack that will replace the consumed item, or null if no + * Return the custom item stack that will replace the consumed item, or {@code null} if no * custom replacement has been set (which means the default replacement will be used). * - * @return The custom item stack that will replace the consumed item or null + * @return The custom item stack that will replace the consumed item or {@code null} */ @Nullable public ItemStack getReplacement() { @@ -98,34 +91,33 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable { } /** - * Set a custom item stack to replace the consumed item. Pass null to clear any custom + * Set a custom item stack to replace the consumed item. Pass {@code null} to clear any custom * stack that has been set and use the default replacement. * - * @param replacement Replacement item to set, null to clear any custom stack and use default + * @param replacement Replacement item to set, {@code null} to clear any custom stack and use default */ public void setReplacement(@Nullable ItemStack replacement) { this.replacement = replacement; } - // Paper end @Override public boolean isCancelled() { - return this.isCancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.isCancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java index c55f1b971..938cfe239 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemDamageEvent.java @@ -13,25 +13,26 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack item; private final int originalDamage; private int damage; - private boolean cancelled = false; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(forRemoval = true) - public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack what, int damage) { - // Paper start - Add pre-reduction damage - this(player, what, damage, damage); + public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack item, int damage) { + this(player, item, damage, damage); } @ApiStatus.Internal - public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack what, int damage, int originalDamage) { + public PlayerItemDamageEvent(@NotNull Player player, @NotNull ItemStack item, int damage, int originalDamage) { super(player); - this.item = what; + this.item = item; this.damage = damage; this.originalDamage = originalDamage; - // Paper end } /** @@ -41,7 +42,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { */ @NotNull public ItemStack getItem() { - return item; + return this.item; } /** @@ -50,10 +51,13 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { * @return durability change */ public int getDamage() { - return damage; + return this.damage; + } + + public void setDamage(int damage) { + this.damage = damage; } - // Paper start - Add pre-reduction damage /** * Gets the amount of durability damage this item would have taken before * the Unbreaking reduction. If the item has no Unbreaking level then @@ -62,12 +66,7 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { * @return pre-reduction damage amount */ public int getOriginalDamage() { - return originalDamage; - } - // Paper end - - public void setDamage(int damage) { - this.damage = damage; + return this.originalDamage; } @Override @@ -83,11 +82,11 @@ public class PlayerItemDamageEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java index 39048573a..5059fa900 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemHeldEvent.java @@ -3,17 +3,22 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Fired when a player changes their currently held item */ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final int previous; private final int current; + private boolean cancelled; + + @ApiStatus.Internal public PlayerItemHeldEvent(@NotNull final Player player, final int previous, final int current) { super(player); this.previous = previous; @@ -26,7 +31,7 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { * @return Previous slot index */ public int getPreviousSlot() { - return previous; + return this.previous; } /** @@ -35,27 +40,27 @@ public class PlayerItemHeldEvent extends PlayerEvent implements Cancellable { * @return New slot index */ public int getNewSlot() { - return current; + return this.current; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java index 7471cb755..a751b2ab7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerItemMendEvent.java @@ -18,33 +18,104 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack item; private final EquipmentSlot slot; private final ExperienceOrb experienceOrb; + private final int consumedExperience; private int repairAmount; - private boolean cancelled; - private final int consumedExperience; // Paper - @Deprecated(forRemoval = true) // Paper - public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount) { - // Paper start - this(who, item, slot, experienceOrb, repairAmount, repairAmount / 2); + private boolean cancelled; + + @ApiStatus.Internal + @Deprecated(forRemoval = true) + public PlayerItemMendEvent(@NotNull Player player, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount) { + this(player, item, slot, experienceOrb, repairAmount, repairAmount / 2); } @ApiStatus.Internal - public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount, int consumedExperience) { - // Paper end - super(who); + public PlayerItemMendEvent(@NotNull Player player, @NotNull ItemStack item, @NotNull EquipmentSlot slot, @NotNull ExperienceOrb experienceOrb, int repairAmount, int consumedExperience) { + super(player); this.item = item; this.slot = slot; this.experienceOrb = experienceOrb; this.repairAmount = repairAmount; - // Paper start this.consumedExperience = consumedExperience; } + @Deprecated(since = "1.19.2", forRemoval = true) + public PlayerItemMendEvent(@NotNull Player player, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount) { + this(player, item, null, experienceOrb, repairAmount); + } + + /** + * Get the {@link ItemStack} to be repaired. + *
    + * This is not necessarily the item the player is holding. + * + * @return the item to be repaired + */ + @NotNull + public ItemStack getItem() { + return this.item; + } + + /** + * Get the {@link EquipmentSlot} in which the repaired {@link ItemStack} + * may be found. + * + * @return the repaired slot + */ + @NotNull + public EquipmentSlot getSlot() { + return this.slot; + } + + /** + * Get the experience orb triggering the event. + * + * @return the experience orb + */ + @NotNull + public ExperienceOrb getExperienceOrb() { + return this.experienceOrb; + } + + /** + * Get the amount the item is to be repaired. + *

    + * The default value is twice the value of the consumed experience orb + * or the remaining damage left on the item, whichever is smaller. + * + * @return how much damage will be repaired by the experience orb + */ + public int getRepairAmount() { + return this.repairAmount; + } + + /** + * Set the amount the item will be repaired. + *
    + * Half of this value will be subtracted from the experience orb which initiated this event. + * + * @param amount how much damage will be repaired on the item + */ + public void setRepairAmount(int amount) { + this.repairAmount = amount; + } + + /** + * Helper method to get the amount of experience that will be consumed. + * This method just returns the result of inputting {@link #getRepairAmount()} + * into the function {@link #getDurabilityToXpOperation()}. + * + * @return the amount of xp that will be consumed + */ + public int getConsumedExperience() { + return this.consumedExperience; + } + /** * Get the operation used to calculate xp used based on * the set repair amount. Used to calculate how much of @@ -75,82 +146,9 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { throw new UnsupportedOperationException("Enchantments use effects to compute xp to durability since 1.21."); } - /** - * Helper method to get the amount of experience that will be consumed. - * This method just returns the result of inputting {@link #getRepairAmount()} - * into the function {@link #getDurabilityToXpOperation()}. - * - * @return the amount of xp that will be consumed - */ - public int getConsumedExperience() { - return this.consumedExperience; - } - // Paper end - - @Deprecated(since = "1.19.2", forRemoval = true) - public PlayerItemMendEvent(@NotNull Player who, @NotNull ItemStack item, @NotNull ExperienceOrb experienceOrb, int repairAmount) { - this(who, item, null, experienceOrb, repairAmount); - } - - /** - * Get the {@link ItemStack} to be repaired. - * - * This is not necessarily the item the player is holding. - * - * @return the item to be repaired - */ - @NotNull - public ItemStack getItem() { - return item; - } - - /** - * Get the {@link EquipmentSlot} in which the repaired {@link ItemStack} - * may be found. - * - * @return the repaired slot - */ - @NotNull - public EquipmentSlot getSlot() { - return slot; - } - - /** - * Get the experience orb triggering the event. - * - * @return the experience orb - */ - @NotNull - public ExperienceOrb getExperienceOrb() { - return experienceOrb; - } - - /** - * Get the amount the item is to be repaired. - * - * The default value is twice the value of the consumed experience orb - * or the remaining damage left on the item, whichever is smaller. - * - * @return how much damage will be repaired by the experience orb - */ - public int getRepairAmount() { - return repairAmount; - } - - /** - * Set the amount the item will be repaired. - * - * Half of this value will be subtracted from the experience orb which initiated this event. - * - * @param amount how much damage will be repaired on the item - */ - public void setRepairAmount(int amount) { - this.repairAmount = amount; - } - @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -161,11 +159,11 @@ public class PlayerItemMendEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java index 027e3d2c4..eaa42e82c 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerJoinEvent.java @@ -1,5 +1,7 @@ package org.bukkit.event.player; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -10,73 +12,73 @@ import org.jetbrains.annotations.Nullable; * Called when a player joins a server */ public class PlayerJoinEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - // Paper start - private net.kyori.adventure.text.Component joinMessage; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private Component joinMessage; @ApiStatus.Internal - public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final net.kyori.adventure.text.Component joinMessage) { + public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final Component joinMessage) { super(playerJoined); this.joinMessage = joinMessage; } - @Deprecated(forRemoval = true) // Paper end + @ApiStatus.Internal + @Deprecated(forRemoval = true) public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) { super(playerJoined); - this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper end + this.joinMessage = joinMessage != null ? LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; } - // Paper start /** * Gets the join message to send to all online players * - * @return string join message. Can be null + * @return string join message. Can be {@code null} */ - public net.kyori.adventure.text.@Nullable Component joinMessage() { + public @Nullable Component joinMessage() { return this.joinMessage; } /** * Sets the join message to send to all online players * - * @param joinMessage join message. If null, no message will be sent + * @param joinMessage join message. If {@code null}, no message will be sent */ - public void joinMessage(net.kyori.adventure.text.@Nullable Component joinMessage) { + public void joinMessage(@Nullable Component joinMessage) { this.joinMessage = joinMessage; } - // Paper end /** * Gets the join message to send to all online players * - * @return string join message. Can be null + * @return string join message. Can be {@code null} * @deprecated in favour of {@link #joinMessage()} */ @Nullable - @Deprecated // Paper + @Deprecated public String getJoinMessage() { - return this.joinMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.joinMessage); // Paper + return this.joinMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.joinMessage); } /** * Sets the join message to send to all online players * - * @param joinMessage join message. If null, no message will be sent - * @deprecated in favour of {@link #joinMessage(net.kyori.adventure.text.Component)} + * @param joinMessage join message. If {@code null}, no message will be sent + * @deprecated in favour of {@link #joinMessage(Component)} */ - @Deprecated // Paper + @Deprecated public void setJoinMessage(@Nullable String joinMessage) { - this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper + this.joinMessage = joinMessage != null ? LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java index 09ea15c3d..61f278a97 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerKickEvent.java @@ -1,5 +1,7 @@ package org.bukkit.event.player; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; @@ -10,63 +12,47 @@ import org.jetbrains.annotations.NotNull; * Called when a player gets kicked from the server */ public class PlayerKickEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private net.kyori.adventure.text.Component leaveMessage; // Paper - private net.kyori.adventure.text.Component kickReason; // Paper - private final Cause cause; // Paper - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private Component kickReason; + private Component leaveMessage; + private final Cause cause; + + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final String kickReason, @NotNull final String leaveMessage) { super(playerKicked); - this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper - this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper - this.cause = Cause.UNKNOWN; // Paper - this.cancel = false; + this.kickReason = LegacyComponentSerializer.legacySection().deserialize(kickReason); + this.leaveMessage = LegacyComponentSerializer.legacySection().deserialize(leaveMessage); + this.cause = Cause.UNKNOWN; } - // Paper start + + @ApiStatus.Internal @Deprecated(forRemoval = true) - public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final net.kyori.adventure.text.Component kickReason, @NotNull final net.kyori.adventure.text.Component leaveMessage) { + public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final Component kickReason, @NotNull final Component leaveMessage) { super(playerKicked); this.kickReason = kickReason; this.leaveMessage = leaveMessage; - this.cancel = false; this.cause = Cause.UNKNOWN; } @ApiStatus.Internal - public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final net.kyori.adventure.text.Component kickReason, @NotNull final net.kyori.adventure.text.Component leaveMessage, @NotNull final Cause cause) { + public PlayerKickEvent(@NotNull final Player playerKicked, @NotNull final Component kickReason, @NotNull final Component leaveMessage, @NotNull final Cause cause) { super(playerKicked); this.kickReason = kickReason; this.leaveMessage = leaveMessage; - this.cancel = false; this.cause = cause; } - /** - * Gets the leave message send to all online players - * - * @return string kick reason - */ - public net.kyori.adventure.text.@NotNull Component leaveMessage() { - return this.leaveMessage; - } - - /** - * Sets the leave message send to all online players - * - * @param leaveMessage leave message - */ - public void leaveMessage(net.kyori.adventure.text.@NotNull Component leaveMessage) { - this.leaveMessage = leaveMessage; - } - /** * Gets the reason why the player is getting kicked * * @return string kick reason */ - public net.kyori.adventure.text.@NotNull Component reason() { + public @NotNull Component reason() { return this.kickReason; } @@ -75,10 +61,9 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * * @param kickReason kick reason */ - public void reason(net.kyori.adventure.text.@NotNull Component kickReason) { + public void reason(@NotNull Component kickReason) { this.kickReason = kickReason; } - // Paper end /** * Gets the reason why the player is getting kicked @@ -87,9 +72,38 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * @deprecated in favour of {@link #reason()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getReason() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.kickReason); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.kickReason); + } + + /** + * Sets the reason why the player is getting kicked + * + * @param kickReason kick reason + * @deprecated in favour of {@link #reason(net.kyori.adventure.text.Component)} + */ + @Deprecated + public void setReason(@NotNull String kickReason) { + this.kickReason = LegacyComponentSerializer.legacySection().deserialize(kickReason); + } + + /** + * Gets the leave message send to all online players + * + * @return string kick reason + */ + public @NotNull Component leaveMessage() { + return this.leaveMessage; + } + + /** + * Sets the leave message send to all online players + * + * @param leaveMessage leave message + */ + public void leaveMessage(@NotNull Component leaveMessage) { + this.leaveMessage = leaveMessage; } /** @@ -99,30 +113,9 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * @deprecated in favour of {@link #leaveMessage()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getLeaveMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); // Paper - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - - /** - * Sets the reason why the player is getting kicked - * - * @param kickReason kick reason - * @deprecated in favour of {@link #reason(net.kyori.adventure.text.Component)} - */ - @Deprecated // Paper - public void setReason(@NotNull String kickReason) { - this.kickReason = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(kickReason); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.leaveMessage); } /** @@ -131,86 +124,68 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { * @param leaveMessage leave message * @deprecated in favour of {@link #leaveMessage(net.kyori.adventure.text.Component)} */ - @Deprecated // Paper + @Deprecated public void setLeaveMessage(@NotNull String leaveMessage) { - this.leaveMessage = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(leaveMessage); // Paper + this.leaveMessage = LegacyComponentSerializer.legacySection().deserialize(leaveMessage); + } + + /** + * Gets the cause of this kick + */ + @NotNull + public org.bukkit.event.player.PlayerKickEvent.Cause getCause() { + return this.cause; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; - } - // Paper start - /** - * Gets the cause of this kick - * - * @return - */ - @NotNull - public org.bukkit.event.player.PlayerKickEvent.Cause getCause() { - return cause; + return HANDLER_LIST; } public enum Cause { PLUGIN, - WHITELIST, - BANNED, - IP_BANNED, - KICK_COMMAND, - FLYING_PLAYER, - FLYING_VEHICLE, - TIMEOUT, - IDLING, - INVALID_VEHICLE_MOVEMENT, - INVALID_PLAYER_MOVEMENT, - INVALID_ENTITY_ATTACKED, - INVALID_PAYLOAD, - INVALID_COOKIE, - SPAM, - ILLEGAL_ACTION, - ILLEGAL_CHARACTERS, - OUT_OF_ORDER_CHAT, - UNSIGNED_CHAT, - CHAT_VALIDATION_FAILED, - EXPIRED_PROFILE_PUBLIC_KEY, - INVALID_PUBLIC_KEY_SIGNATURE, - TOO_MANY_PENDING_CHATS, - SELF_INTERACTION, - DUPLICATE_LOGIN, - RESOURCE_PACK_REJECTION, - /** * Spigot's restart command */ @@ -220,5 +195,4 @@ public class PlayerKickEvent extends PlayerEvent implements Cancellable { */ UNKNOWN, } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java index 00481d733..e8d0cf104 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLevelChangeEvent.java @@ -2,16 +2,20 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a players level changes */ public class PlayerLevelChangeEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final int oldLevel; private final int newLevel; + @ApiStatus.Internal public PlayerLevelChangeEvent(@NotNull final Player player, final int oldLevel, final int newLevel) { super(player); this.oldLevel = oldLevel; @@ -24,7 +28,7 @@ public class PlayerLevelChangeEvent extends PlayerEvent { * @return The old level of the player */ public int getOldLevel() { - return oldLevel; + return this.oldLevel; } /** @@ -33,17 +37,17 @@ public class PlayerLevelChangeEvent extends PlayerEvent { * @return The new (current) level of the player */ public int getNewLevel() { - return newLevel; + return this.newLevel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLinksSendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLinksSendEvent.java index 01700bff1..6fc2aa25d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLinksSendEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLinksSendEvent.java @@ -12,9 +12,11 @@ import org.jetbrains.annotations.NotNull; @ApiStatus.Experimental public class PlayerLinksSendEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ServerLinks links; + @ApiStatus.Internal public PlayerLinksSendEvent(@NotNull final Player player, @NotNull final ServerLinks links) { super(player); this.links = links; @@ -27,17 +29,17 @@ public class PlayerLinksSendEvent extends PlayerEvent { */ @NotNull public ServerLinks getLinks() { - return links; + return this.links; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java index dc6b41950..736d51113 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLocaleChangeEvent.java @@ -1,33 +1,28 @@ package org.bukkit.event.player; +import net.kyori.adventure.translation.Translator; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import java.util.Locale; +import java.util.Objects; /** * Called when a player changes their locale in the client settings. */ public class PlayerLocaleChangeEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - // - private final String locale; - // Paper start - private final java.util.Locale adventure$locale; - /** - * @see Player#locale() - * - * @return the player's new locale - */ - public @NotNull java.util.Locale locale() { - return this.adventure$locale; - } - // Paper end + private static final HandlerList HANDLER_LIST = new HandlerList(); - public PlayerLocaleChangeEvent(@NotNull Player who, @NotNull String locale) { - super(who); + private final String locale; + private final Locale adventure$locale; + + @ApiStatus.Internal + public PlayerLocaleChangeEvent(@NotNull Player player, @NotNull String locale) { + super(player); this.locale = locale; - this.adventure$locale = java.util.Objects.requireNonNullElse(net.kyori.adventure.translation.Translator.parseLocale(locale), java.util.Locale.US); // Paper start + this.adventure$locale = Objects.requireNonNullElse(Translator.parseLocale(locale), Locale.US); } /** @@ -36,19 +31,27 @@ public class PlayerLocaleChangeEvent extends PlayerEvent { * @deprecated in favour of {@link #locale()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getLocale() { - return locale; + return this.locale; + } + + /** + * @see Player#locale() + * @return the player's new locale + */ + public @NotNull Locale locale() { + return this.adventure$locale; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java index 8d67cd1f7..996fffc84 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerLoginEvent.java @@ -1,6 +1,8 @@ package org.bukkit.event.player; import java.net.InetAddress; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -14,23 +16,15 @@ import org.jetbrains.annotations.NotNull; * entity be postponed to the {@link PlayerJoinEvent} instead. */ public class PlayerLoginEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final String hostname; private final InetAddress address; private final InetAddress realAddress; - private final String hostname; private Result result = Result.ALLOWED; - private net.kyori.adventure.text.Component message = net.kyori.adventure.text.Component.empty(); + private Component message = Component.empty(); - /** - * This constructor defaults message to an empty string, and result to - * ALLOWED - * - * @param player The {@link Player} for this event - * @param hostname The hostname that was used to connect to the server - * @param address The address the player used to connect, provided for - * timing issues - * @param realAddress the actual, unspoofed connecting address - */ @ApiStatus.Internal public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address, final @NotNull InetAddress realAddress) { super(player); @@ -39,77 +33,61 @@ public class PlayerLoginEvent extends PlayerEvent { this.realAddress = realAddress; } - /** - * This constructor defaults message to an empty string, and result to - * ALLOWED - * - * @param player The {@link Player} for this event - * @param hostname The hostname that was used to connect to the server - * @param address The address the player used to connect, provided for - * timing issues - */ @ApiStatus.Internal public PlayerLoginEvent(@NotNull final Player player, @NotNull final String hostname, @NotNull final InetAddress address) { this(player, hostname, address, address); } - /** - * This constructor pre-configures the event with a result and message - * - * @param player The {@link Player} for this event - * @param hostname The hostname that was used to connect to the server - * @param address The address the player used to connect, provided for - * timing issues - * @param result The result status for this event - * @param message The message to be displayed if result denies login - * @param realAddress the actual, unspoofed connecting address - * @deprecated in favour of {@link #PlayerLoginEvent(Player, String, InetAddress, Result, net.kyori.adventure.text.Component, InetAddress)} - */ + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final String message, @NotNull final InetAddress realAddress) { this(player, hostname, address, realAddress); this.result = result; - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } - // Paper start - /** - * This constructor pre-configures the event with a result and message - * - * @param player The {@link Player} for this event - * @param hostname The hostname that was used to connect to the server - * @param address The address the player used to connect, provided for - * timing issues - * @param result The result status for this event - * @param message The message to be displayed if result denies login - * @param realAddress the actual, unspoofed connecting address - */ @ApiStatus.Internal public PlayerLoginEvent(@NotNull final Player player, @NotNull String hostname, @NotNull final InetAddress address, @NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message, @NotNull final InetAddress realAddress) { - this(player, hostname, address, realAddress); // Spigot + this(player, hostname, address, realAddress); this.result = result; this.message = message; } /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the hostname that the player used to connect to the server, or + * blank if unknown * - * @return Current kick message + * @return The hostname */ - public net.kyori.adventure.text.@NotNull Component kickMessage() { - return this.message; + @NotNull + public String getHostname() { + return this.hostname; } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Gets the {@link InetAddress} for the Player associated with this event. + * This method is provided as a workaround for player.getAddress() + * returning {@code null} during PlayerLoginEvent. * - * @param message New kick message + * @return The address for this player. For legacy compatibility, this may + * be {@code null}. */ - public void kickMessage(net.kyori.adventure.text.@NotNull Component message) { - this.message = message; + @NotNull + public InetAddress getAddress() { + return this.address; + } + + /** + * Gets the connection address of this player, regardless of whether it has + * been spoofed or not. + * + * @return the player's connection address + * @see #getAddress() + */ + @NotNull + public InetAddress getRealAddress() { + return this.realAddress; } - // Paper end /** * Gets the current result of the login, as an enum @@ -118,7 +96,7 @@ public class PlayerLoginEvent extends PlayerEvent { */ @NotNull public Result getResult() { - return result; + return this.result; } /** @@ -131,8 +109,25 @@ public class PlayerLoginEvent extends PlayerEvent { } /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the current kick message that will be used when the outcome is not allowed + * + * @return Current kick message + */ + public @NotNull Component kickMessage() { + return this.message; + } + + /** + * Sets the kick message to display when the outcome is not allowed + * + * @param message New kick message + */ + public void kickMessage(@NotNull Component message) { + this.message = message; + } + + /** + * Gets the current kick message that will be used when the outcome is not allowed * * @return Current kick message * @deprecated in favour of {@link #kickMessage()} @@ -140,37 +135,26 @@ public class PlayerLoginEvent extends PlayerEvent { @NotNull @Deprecated // Paper public String getKickMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.message); } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Sets the kick message to display when the outcome is not allowed * * @param message New kick message - * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #kickMessage(Component)} */ - @Deprecated // Paper + @Deprecated public void setKickMessage(@NotNull final String message) { - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper - } - - /** - * Gets the hostname that the player used to connect to the server, or - * blank if unknown - * - * @return The hostname - */ - @NotNull - public String getHostname() { - return hostname; + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** * Allows the player to log in */ public void allow() { - result = Result.ALLOWED; - message = net.kyori.adventure.text.Component.empty(); // Paper + this.result = Result.ALLOWED; + this.message = Component.empty(); } /** @@ -178,59 +162,34 @@ public class PlayerLoginEvent extends PlayerEvent { * * @param result New result for disallowing the player * @param message Kick message to display to the user - * @deprecated in favour of {@link #disallow(Result, net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #disallow(Result, Component)} */ - @Deprecated // Paper start + @Deprecated public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } + /** * Disallows the player from logging in, with the given reason * * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { - // Paper end + public void disallow(@NotNull final Result result, @NotNull final Component message) { this.result = result; this.message = message; } - /** - * Gets the {@link InetAddress} for the Player associated with this event. - * This method is provided as a workaround for player.getAddress() - * returning null during PlayerLoginEvent. - * - * @return The address for this player. For legacy compatibility, this may - * be null. - */ - @NotNull - public InetAddress getAddress() { - return address; - } - - /** - * Gets the connection address of this player, regardless of whether it has - * been spoofed or not. - * - * @return the player's connection address - * @see #getAddress() - */ - @NotNull - public InetAddress getRealAddress() { - return realAddress; - } - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java index 237d65477..5a086cb5f 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerMoveEvent.java @@ -5,6 +5,7 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -12,47 +13,21 @@ import org.jetbrains.annotations.Nullable; * Holds information for player movement events */ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private Location from; private Location to; + private boolean cancelled; + + @ApiStatus.Internal public PlayerMoveEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player); this.from = from; this.to = to; } - /** - * Gets the cancellation state of this event. A cancelled event will not - * be executed in the server, but will still pass to other plugins - *

    - * If a move or teleport event is cancelled, the player will be moved or - * teleported back to the Location as defined by getFrom(). This will not - * fire an event - * - * @return true if this event is cancelled - */ - @Override - public boolean isCancelled() { - return cancel; - } - - /** - * Sets the cancellation state of this event. A cancelled event will not - * be executed in the server, but will still pass to other plugins - *

    - * If a move or teleport event is cancelled, the player will be moved or - * teleported back to the Location as defined by getFrom(). This will not - * fire an event - * - * @param cancel true if you wish to cancel this event - */ - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Gets the location this player moved from * @@ -60,7 +35,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { */ @NotNull public Location getFrom() { - return from; + return this.from; } /** @@ -69,7 +44,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @param from New location to mark as the players previous location */ public void setFrom(@NotNull Location from) { - validateLocation(from); + this.validateLocation(from); this.from = from.clone(); } @@ -89,18 +64,17 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @param to New Location this player will move to */ public void setTo(@NotNull Location to) { - validateLocation(to); + this.validateLocation(to); this.to = to.clone(); } - // Paper start - PlayerMoveEvent improvements /** * Check if the player has changed position (even within the same block) in the event * * @return whether the player has changed position or not */ public boolean hasChangedPosition() { - return hasExplicitlyChangedPosition() || !from.getWorld().equals(to.getWorld()); + return this.hasExplicitlyChangedPosition() || !this.from.getWorld().equals(this.to.getWorld()); } /** @@ -109,7 +83,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @return whether the player has changed position or not */ public boolean hasExplicitlyChangedPosition() { - return from.getX() != to.getX() || from.getY() != to.getY() || from.getZ() != to.getZ(); + return this.from.getX() != this.to.getX() || this.from.getY() != this.to.getY() || this.from.getZ() != this.to.getZ(); } /** @@ -118,7 +92,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @return whether the player has moved to a new block or not */ public boolean hasChangedBlock() { - return hasExplicitlyChangedBlock() || !from.getWorld().equals(to.getWorld()); + return this.hasExplicitlyChangedBlock() || !this.from.getWorld().equals(this.to.getWorld()); } /** @@ -127,7 +101,7 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @return whether the player has moved to a new block or not */ public boolean hasExplicitlyChangedBlock() { - return from.getBlockX() != to.getBlockX() || from.getBlockY() != to.getBlockY() || from.getBlockZ() != to.getBlockZ(); + return this.from.getBlockX() != this.to.getBlockX() || this.from.getBlockY() != this.to.getBlockY() || this.from.getBlockZ() != this.to.getBlockZ(); } /** @@ -136,9 +110,32 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { * @return whether the player has changed orientation or not */ public boolean hasChangedOrientation() { - return from.getPitch() != to.getPitch() || from.getYaw() != to.getYaw(); + return this.from.getPitch() != this.to.getPitch() || this.from.getYaw() != this.to.getYaw(); + } + + /** + * {@inheritDoc} + *

    + * If a move or teleport event is cancelled, the player will be moved or + * teleported back to the Location as defined by getFrom(). This will not + * fire an event + */ + @Override + public boolean isCancelled() { + return this.cancelled; + } + + /** + * {@inheritDoc} + *

    + * If a move or teleport event is cancelled, the player will be moved or + * teleported back to the Location as defined by getFrom(). This will not + * fire an event + */ + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } - // Paper end private void validateLocation(@NotNull Location loc) { Preconditions.checkArgument(loc != null, "Cannot use null location!"); @@ -148,11 +145,11 @@ public class PlayerMoveEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java index c9a866394..7464052c1 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupArrowEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.AbstractArrow; import org.bukkit.entity.Item; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,6 +13,7 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { private final AbstractArrow arrow; + @ApiStatus.Internal public PlayerPickupArrowEvent(@NotNull final Player player, @NotNull final Item item, @NotNull final AbstractArrow arrow) { super(player, item, 0); this.arrow = arrow; @@ -24,6 +26,6 @@ public class PlayerPickupArrowEvent extends PlayerPickupItemEvent { */ @NotNull public AbstractArrow getArrow() { - return arrow; + return this.arrow; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java index f5166bbf9..873af6bc4 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPickupItemEvent.java @@ -6,6 +6,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityPickupItemEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,14 +14,18 @@ import org.jetbrains.annotations.NotNull; * @deprecated {@link EntityPickupItemEvent} */ @Deprecated(since = "1.12") -@Warning(false) +@Warning public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final Item item; - private boolean flyAtPlayer = true; // Paper - private boolean cancel = false; - private final int remaining; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Item item; + private final int remaining; + private boolean flyAtPlayer = true; + + private boolean cancelled; + + @ApiStatus.Internal public PlayerPickupItemEvent(@NotNull final Player player, @NotNull final Item item, final int remaining) { super(player); this.item = item; @@ -34,7 +39,7 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { */ @NotNull public Item getItem() { - return item; + return this.item; } /** @@ -43,16 +48,15 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { * @return amount remaining on the ground */ public int getRemaining() { - return remaining; + return this.remaining; } - // Paper start /** * Set if the item will fly at the player *

    - * Cancelling the event will set this value to false. + * Cancelling the event will set this value to {@code false}. * - * @param flyAtPlayer true for item to fly at player + * @param flyAtPlayer {@code true} for item to fly at player */ public void setFlyAtPlayer(boolean flyAtPlayer) { this.flyAtPlayer = flyAtPlayer; @@ -61,32 +65,31 @@ public class PlayerPickupItemEvent extends PlayerEvent implements Cancellable { /** * Gets if the item will fly at the player * - * @return true if the item will fly at the player + * @return {@code true} if the item will fly at the player */ public boolean getFlyAtPlayer() { - return flyAtPlayer; + return this.flyAtPlayer; } - // Paper end @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; - this.flyAtPlayer = !cancel; // Paper + this.cancelled = cancel; + this.flyAtPlayer = !cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java index a6fa22e4f..75b397792 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPortalEvent.java @@ -1,10 +1,13 @@ package org.bukkit.event.player; +import io.papermc.paper.entity.TeleportFlag; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import java.util.Set; /** * Called when a player is about to teleport because it is in contact with a @@ -13,26 +16,31 @@ import org.jetbrains.annotations.Nullable; * For other entities see {@link org.bukkit.event.entity.EntityPortalEvent} */ public class PlayerPortalEvent extends PlayerTeleportEvent { - private static final HandlerList handlers = new HandlerList(); - private int getSearchRadius = 128; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private int searchRadius = 128; private boolean canCreatePortal = true; private int creationRadius = 16; + @ApiStatus.Internal public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player, from, to); } + @ApiStatus.Internal public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause) { super(player, from, to, cause); } - public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause, int getSearchRadius, boolean canCreatePortal, int creationRadius) { + @ApiStatus.Internal + public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause, int searchRadius, boolean canCreatePortal, int creationRadius) { super(player, from, to, cause); - this.getSearchRadius = getSearchRadius; + this.searchRadius = searchRadius; this.canCreatePortal = canCreatePortal; this.creationRadius = creationRadius; } - // Paper start + /** * For {@link TeleportCause#NETHER_PORTAL}, this is initially just the starting point * for the search for a portal to teleport to. It will initially just be the {@link #getFrom()} @@ -50,6 +58,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { /** * See the description of {@link #getTo()}. + * * @param to starting point for search or exact destination */ @Override @@ -57,29 +66,6 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { super.setTo(to); } - /** - * No effect - * @return no effect - * @deprecated No effect - */ - @Deprecated(forRemoval = true) - @Override - public boolean willDismountPlayer() { - return super.willDismountPlayer(); - } - - /** - * No effect - * @return no effect - * @deprecated No effect - */ - @Deprecated(forRemoval = true) - @Override - public @NotNull java.util.Set getRelativeTeleportationFlags() { - return super.getRelativeTeleportationFlags(); - } - // Paper end - /** * Set the Block radius to search in for available portals. * @@ -87,7 +73,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { * location */ public void setSearchRadius(int searchRadius) { - this.getSearchRadius = searchRadius; + this.searchRadius = searchRadius; } /** @@ -96,7 +82,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { * @return the currently set search radius */ public int getSearchRadius() { - return getSearchRadius; + return this.searchRadius; } /** @@ -106,7 +92,7 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { * @return whether there should create be a destination portal created */ public boolean getCanCreatePortal() { - return canCreatePortal; + return this.canCreatePortal; } /** @@ -123,10 +109,10 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { /** * Sets the maximum radius the world is searched for a free space from the * given location. - * + *

    * If enough free space is found then the portal will be created there, if * not it will force create with air-space at the target location. - * + *

    * Does not apply to end portal target platforms which will always appear at * the target location. * @@ -140,27 +126,51 @@ public class PlayerPortalEvent extends PlayerTeleportEvent { /** * Gets the maximum radius the world is searched for a free space from the * given location. - * + *

    * If enough free space is found then the portal will be created there, if * not it will force create with air-space at the target location. - * + *

    * Does not apply to end portal target platforms which will always appear at * the target location. * * @return the currently set creation radius */ public int getCreationRadius() { - return creationRadius; + return this.creationRadius; + } + + /** + * No effect + * + * @return no effect + * @deprecated No effect + */ + @Deprecated(forRemoval = true) + @Override + public boolean willDismountPlayer() { + return super.willDismountPlayer(); + } + + /** + * No effect + * + * @return no effect + * @deprecated No effect + */ + @Deprecated(forRemoval = true) + @Override + public @NotNull Set getRelativeTeleportationFlags() { + return super.getRelativeTeleportationFlags(); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java index b2b1c04b0..ff7dae468 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerPreLoginEvent.java @@ -2,6 +2,8 @@ package org.bukkit.event.player; import java.net.InetAddress; import java.util.UUID; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.Warning; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -25,13 +27,16 @@ import org.jetbrains.annotations.NotNull; @Deprecated(since = "1.3.2") @Warning(reason = "This event causes a login thread to synchronize with the main thread") public class PlayerPreLoginEvent extends Event { - private static final HandlerList handlers = new HandlerList(); - private Result result; - private net.kyori.adventure.text.Component message; // Paper + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final String name; private final InetAddress ipAddress; private final UUID uniqueId; + private Result result; + private Component message; + @ApiStatus.Internal @Deprecated(since = "1.7.5", forRemoval = true) public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress) { this(name, ipAddress, null); @@ -40,7 +45,7 @@ public class PlayerPreLoginEvent extends Event { @ApiStatus.Internal public PlayerPreLoginEvent(@NotNull final String name, @NotNull final InetAddress ipAddress, @NotNull final UUID uniqueId) { this.result = Result.ALLOWED; - this.message = net.kyori.adventure.text.Component.empty(); // Paper + this.message = Component.empty(); this.name = name; this.ipAddress = ipAddress; this.uniqueId = uniqueId; @@ -53,7 +58,7 @@ public class PlayerPreLoginEvent extends Event { */ @NotNull public Result getResult() { - return result; + return this.result; } /** @@ -65,24 +70,22 @@ public class PlayerPreLoginEvent extends Event { this.result = result; } - // Paper start /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the current kick message that will be used when the outcome is not allowed * * @return Current kick message */ @NotNull - public net.kyori.adventure.text.Component kickMessage() { - return message; + public Component kickMessage() { + return this.message; } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Sets the kick message to display when the outcome is not allowed * * @param message New kick message */ - public void kickMessage(@NotNull final net.kyori.adventure.text.Component message) { + public void kickMessage(@NotNull final Component message) { this.message = message; } @@ -92,14 +95,13 @@ public class PlayerPreLoginEvent extends Event { * @param result New result for disallowing the player * @param message Kick message to display to the user */ - public void disallow(@NotNull final Result result, @NotNull final net.kyori.adventure.text.Component message) { + public void disallow(@NotNull final Result result, @NotNull final Component message) { this.result = result; this.message = message; } - // Paper end + /** - * Gets the current kick message that will be used if getResult() != - * Result.ALLOWED + * Gets the current kick message that will be used when the outcome is not allowed * * @return Current kick message * @deprecated in favour of {@link #kickMessage()} @@ -107,26 +109,26 @@ public class PlayerPreLoginEvent extends Event { @Deprecated // Paper @NotNull public String getKickMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.message); } /** - * Sets the kick message to display if getResult() != Result.ALLOWED + * Sets the kick message to display when the outcome is not allowed * * @param message New kick message - * @deprecated in favour of {@link #kickMessage(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #kickMessage(Component)} */ - @Deprecated // Paper + @Deprecated public void setKickMessage(@NotNull final String message) { - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** * Allows the player to log in */ public void allow() { - result = Result.ALLOWED; - message = net.kyori.adventure.text.Component.empty(); // Paper + this.result = Result.ALLOWED; + this.message = Component.empty(); } /** @@ -134,12 +136,12 @@ public class PlayerPreLoginEvent extends Event { * * @param result New result for disallowing the player * @param message Kick message to display to the user - * @deprecated in favour of {@link #disallow(org.bukkit.event.player.PlayerPreLoginEvent.Result, net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #disallow(org.bukkit.event.player.PlayerPreLoginEvent.Result, Component)} */ @Deprecated // Paper public void disallow(@NotNull final Result result, @NotNull final String message) { this.result = result; - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** @@ -149,7 +151,7 @@ public class PlayerPreLoginEvent extends Event { */ @NotNull public String getName() { - return name; + return this.name; } /** @@ -159,13 +161,7 @@ public class PlayerPreLoginEvent extends Event { */ @NotNull public InetAddress getAddress() { - return ipAddress; - } - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; + return this.ipAddress; } /** @@ -175,12 +171,18 @@ public class PlayerPreLoginEvent extends Event { */ @NotNull public UUID getUniqueId() { - return uniqueId; + return this.uniqueId; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java index 891d72500..079088d0d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerQuitEvent.java @@ -1,5 +1,7 @@ package org.bukkit.event.player; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; @@ -10,30 +12,35 @@ import org.jetbrains.annotations.Nullable; * Called when a player leaves a server */ public class PlayerQuitEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private net.kyori.adventure.text.Component quitMessage; // Paper - private final QuitReason reason; // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final QuitReason reason; + private Component quitMessage; + + @ApiStatus.Internal @Deprecated(forRemoval = true) - public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { - // Paper start - this(who, quitMessage, null); - } - @Deprecated(forRemoval = true) - public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) { - super(who); - this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper - this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; - } - // Paper start - @Deprecated(forRemoval = true) - public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) { - this(who, quitMessage, null); + public PlayerQuitEvent(@NotNull final Player player, @Nullable final String quitMessage) { + this(player, quitMessage, null); } @ApiStatus.Internal - public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage, @Nullable QuitReason quitReason) { - super(who); + @Deprecated(forRemoval = true) + public PlayerQuitEvent(@NotNull final Player player, @Nullable final String quitMessage, @Nullable QuitReason quitReason) { + super(player); + this.quitMessage = quitMessage != null ? LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; + this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; + } + + @ApiStatus.Internal + @Deprecated(forRemoval = true) + public PlayerQuitEvent(@NotNull final Player player, @Nullable final Component quitMessage) { + this(player, quitMessage, null); + } + + @ApiStatus.Internal + public PlayerQuitEvent(@NotNull final Player player, @Nullable final Component quitMessage, @Nullable QuitReason quitReason) { + super(player); this.quitMessage = quitMessage; this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; } @@ -43,8 +50,8 @@ public class PlayerQuitEvent extends PlayerEvent { * * @return string quit message */ - public net.kyori.adventure.text.@Nullable Component quitMessage() { - return quitMessage; + public @Nullable Component quitMessage() { + return this.quitMessage; } /** @@ -52,10 +59,9 @@ public class PlayerQuitEvent extends PlayerEvent { * * @param quitMessage quit message */ - public void quitMessage(net.kyori.adventure.text.@Nullable Component quitMessage) { + public void quitMessage(@Nullable Component quitMessage) { this.quitMessage = quitMessage; } - // Paper end /** * Gets the quit message to send to all online players @@ -64,40 +70,40 @@ public class PlayerQuitEvent extends PlayerEvent { * @deprecated in favour of {@link #quitMessage()} */ @Nullable - @Deprecated // Paper + @Deprecated public String getQuitMessage() { - return this.quitMessage == null ? null : net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.quitMessage); // Paper + return this.quitMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.quitMessage); } /** * Sets the quit message to send to all online players * * @param quitMessage quit message - * @deprecated in favour of {@link #quitMessage(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #quitMessage(Component)} */ - @Deprecated // Paper + @Deprecated public void setQuitMessage(@Nullable String quitMessage) { - this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper + this.quitMessage = quitMessage != null ? LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - - // Paper start @NotNull public QuitReason getReason() { return this.reason; } + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + public enum QuitReason { + /** * The player left on their own behalf. *

    @@ -105,24 +111,20 @@ public class PlayerQuitEvent extends PlayerEvent { * connection themselves. This may occur if no keep-alive packet is received on their side, among other things. */ DISCONNECTED, - /** * The player was kicked from the server. */ KICKED, - /** * The player has timed out. */ TIMED_OUT, - /** * The player's connection has entered an erroneous state. *

    * Reasons for this may include invalid packets, invalid data, and uncaught exceptions in the packet handler, * among others. */ - ERRONEOUS_STATE, + ERRONEOUS_STATE } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java index a843f7347..01d2e76a7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookClickEvent.java @@ -1,25 +1,30 @@ package org.bukkit.event.player; import com.google.common.base.Preconditions; +import org.bukkit.Warning; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.inventory.CraftingRecipe; import org.bukkit.inventory.Recipe; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player clicks a recipe in the recipe book. + * * @deprecated use {@link com.destroystokyo.paper.event.player.PlayerRecipeBookClickEvent} */ -@Deprecated(forRemoval = true) // Paper -@org.bukkit.Warning(false) // Paper +@Deprecated(forRemoval = true) +@Warning public class PlayerRecipeBookClickEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Recipe originalRecipe; private Recipe recipe; private boolean shiftClick; + @ApiStatus.Internal public PlayerRecipeBookClickEvent(@NotNull final Player player, @NotNull final Recipe recipe, boolean shiftClick) { super(player); this.originalRecipe = recipe; @@ -28,8 +33,9 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent { } /** - * Gets the original recipe the player was trying to craft.
    - * This will not reflect any changes made with {@link setRecipe}. + * Gets the original recipe the player was trying to craft. + *
    + * This will not reflect any changes made with {@link #setRecipe(Recipe)}. * * @return the original recipe */ @@ -39,8 +45,9 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent { } /** - * Gets the recipe the player is trying to craft.
    - * This will reflect changes made with {@link setRecipe}. + * Gets the recipe the player is trying to craft. + *
    + * This will reflect changes made with {@link #setRecipe(Recipe)}. * * @return the recipe */ @@ -71,7 +78,7 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent { } /** - * If true the game will attempt to move the ingredients for as many copies + * If {@code true} the game will attempt to move the ingredients for as many copies * of this recipe as possible into the appropriate slots, otherwise only 1 * copy will be moved. * @@ -94,11 +101,11 @@ public class PlayerRecipeBookClickEvent extends PlayerEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java index 249f670f7..c8d6e3eba 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -9,11 +10,13 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerRecipeBookSettingsChangeEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final RecipeBookType recipeBookType; private final boolean open; private final boolean filtering; + @ApiStatus.Internal public PlayerRecipeBookSettingsChangeEvent(@NotNull final Player player, @NotNull final RecipeBookType recipeBookType, final boolean open, final boolean filtering) { super(player); this.recipeBookType = recipeBookType; @@ -28,36 +31,36 @@ public class PlayerRecipeBookSettingsChangeEvent extends PlayerEvent { */ @NotNull public RecipeBookType getRecipeBookType() { - return recipeBookType; + return this.recipeBookType; } /** * Checks if the recipe book is being opened or closed. * - * @return true if opening + * @return {@code true} if opening */ public boolean isOpen() { - return open; + return this.open; } /** * Checks if the recipe book filter is being enabled or disabled. * - * @return true if enabling + * @return {@code true} if enabling */ public boolean isFiltering() { - return filtering; + return this.filtering; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java index f41c29e98..f8023d975 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRecipeDiscoverEvent.java @@ -4,6 +4,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,13 +12,14 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); - private boolean cancel = false; private final NamespacedKey recipe; + private boolean cancelled; - public PlayerRecipeDiscoverEvent(@NotNull Player who, @NotNull NamespacedKey recipe) { - super(who); + @ApiStatus.Internal + public PlayerRecipeDiscoverEvent(@NotNull Player player, @NotNull NamespacedKey recipe) { + super(player); this.recipe = recipe; } @@ -28,27 +30,27 @@ public class PlayerRecipeDiscoverEvent extends PlayerEvent implements Cancellabl */ @NotNull public NamespacedKey getRecipe() { - return recipe; + return this.recipe; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java index 97ae244fa..aeb0c8365 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRegisterChannelEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -8,6 +9,7 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerRegisterChannelEvent extends PlayerChannelEvent { + @ApiStatus.Internal public PlayerRegisterChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player, channel); } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java index e58fecf0f..78219b8c3 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java @@ -3,35 +3,30 @@ package org.bukkit.event.player; import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; /** * Called when a player takes action on a resource pack request. + * * @see Player#setResourcePack(String, String) * @see Player#setResourcePack(String, String, boolean) */ public class PlayerResourcePackStatusEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final UUID id; private final Status status; - public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull UUID id, @NotNull Status resourcePackStatus) { - super(who); + @ApiStatus.Internal + public PlayerResourcePackStatusEvent(@NotNull final Player player, @NotNull UUID id, @NotNull Status resourcePackStatus) { + super(player); this.id = id; this.status = resourcePackStatus; } - // Paper start - add hash (not used anymore) - /** - * @deprecated Hash does not seem to ever be set - */ - @Deprecated(forRemoval = true) - public String getHash() { - return null; - } - // Paper end - /** * Gets the unique ID of this pack. * @@ -39,7 +34,7 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { */ @NotNull public UUID getID() { - return id; + return this.id; } /** @@ -49,18 +44,27 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { */ @NotNull public Status getStatus() { - return status; + return this.status; + } + + /** + * @deprecated This is no longer sent from the client and will always be null + */ + @Deprecated(forRemoval = true) + @Contract("-> null") + public String getHash() { + return null; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -100,6 +104,6 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { /** * The pack was discarded by the client. */ - DISCARDED; + DISCARDED } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java index 450a3cc54..07b1b4a15 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRespawnEvent.java @@ -6,6 +6,8 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; +import java.util.Set; /** * Called when a player respawns. @@ -14,42 +16,43 @@ import org.jetbrains.annotations.NotNull; * because the player is "reset" between this event and that event and some changes won't persist. */ public class PlayerRespawnEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); - private Location respawnLocation; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final boolean isBedSpawn; private final boolean isAnchorSpawn; private final RespawnReason respawnReason; - private final java.util.Set respawnFlags; // Paper + private final Set respawnFlags; + private Location respawnLocation; + @ApiStatus.Internal @Deprecated(since = "1.16.1", forRemoval = true) public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn) { this(respawnPlayer, respawnLocation, isBedSpawn, false); } + @ApiStatus.Internal @Deprecated(since = "1.19.4", forRemoval = true) public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn) { - this(respawnPlayer, respawnLocation, isBedSpawn, false, RespawnReason.PLUGIN); + this(respawnPlayer, respawnLocation, isBedSpawn, isAnchorSpawn, RespawnReason.PLUGIN); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, @NotNull final RespawnReason respawnReason) { - // Paper start this(respawnPlayer, respawnLocation, isBedSpawn, isAnchorSpawn, respawnReason, com.google.common.collect.ImmutableSet.builder()); } @ApiStatus.Internal public PlayerRespawnEvent(@NotNull final Player respawnPlayer, @NotNull final Location respawnLocation, final boolean isBedSpawn, final boolean isAnchorSpawn, @NotNull final RespawnReason respawnReason, @NotNull final com.google.common.collect.ImmutableSet.Builder respawnFlags) { - // Paper end super(respawnPlayer); this.respawnLocation = respawnLocation; this.isBedSpawn = isBedSpawn; this.isAnchorSpawn = isAnchorSpawn; this.respawnReason = respawnReason; - // Paper start if (this.isBedSpawn) { respawnFlags.add(RespawnFlag.BED_SPAWN); } if (this.isAnchorSpawn) { respawnFlags.add(RespawnFlag.ANCHOR_SPAWN); } this.respawnFlags = respawnFlags.build(); - // Paper end } /** @@ -77,7 +80,7 @@ public class PlayerRespawnEvent extends PlayerEvent { /** * Gets whether the respawn location is the player's bed. * - * @return true if the respawn location is the player's bed. + * @return {@code true} if the respawn location is the player's bed. */ public boolean isBedSpawn() { return this.isBedSpawn; @@ -86,10 +89,10 @@ public class PlayerRespawnEvent extends PlayerEvent { /** * Gets whether the respawn location is the player's respawn anchor. * - * @return true if the respawn location is the player's respawn anchor. + * @return {@code true} if the respawn location is the player's respawn anchor. */ public boolean isAnchorSpawn() { - return isAnchorSpawn; + return this.isAnchorSpawn; } /** @@ -99,18 +102,28 @@ public class PlayerRespawnEvent extends PlayerEvent { */ @NotNull public RespawnReason getRespawnReason() { - return respawnReason; + return this.respawnReason; + } + + /** + * Get the set of flags that apply to this respawn. + * + * @return an immutable set of the flags that apply to this respawn + */ + @NotNull + public @Unmodifiable Set getRespawnFlags() { + return this.respawnFlags; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** @@ -129,18 +142,7 @@ public class PlayerRespawnEvent extends PlayerEvent { /** * When a plugin respawns the player. */ - PLUGIN; - } - - // Paper start - /** - * Get the set of flags that apply to this respawn. - * - * @return an immutable set of the flags that apply to this respawn - */ - @NotNull - public java.util.Set getRespawnFlags() { - return respawnFlags; + PLUGIN } public enum RespawnFlag { @@ -155,7 +157,6 @@ public class PlayerRespawnEvent extends PlayerEvent { /** * Is caused by going to the end portal in the end. */ - END_PORTAL, + END_PORTAL } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java index e0fd25b59..97f8e1098 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerRiptideEvent.java @@ -16,20 +16,22 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerRiptideEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final ItemStack item; private final Vector velocity; @ApiStatus.Internal - public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item, @NotNull Vector velocity) { - super(who); + public PlayerRiptideEvent(@NotNull final Player player, @NotNull final ItemStack item, @NotNull Vector velocity) { + super(player); this.item = item; this.velocity = velocity; } + @ApiStatus.Internal @Deprecated(since = "1.20.4", forRemoval = true) - public PlayerRiptideEvent(@NotNull final Player who, @NotNull final ItemStack item) { - this(who, item, new Vector()); + public PlayerRiptideEvent(@NotNull final Player player, @NotNull final ItemStack item) { + this(player, item, new Vector(0, 0, 0)); } /** @@ -39,7 +41,7 @@ public class PlayerRiptideEvent extends PlayerEvent { */ @NotNull public ItemStack getItem() { - return item; + return this.item; } /** @@ -49,17 +51,17 @@ public class PlayerRiptideEvent extends PlayerEvent { */ @NotNull public Vector getVelocity() { - return velocity.clone(); + return this.velocity.clone(); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java index a252c74f3..29179b6b3 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerShearEntityEvent.java @@ -9,40 +9,36 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; +import java.util.List; /** * Called when a player shears an entity */ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel; - private final Entity what; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Entity entity; private final ItemStack item; private final EquipmentSlot hand; - private java.util.List drops; // Paper - custom shear drops + private List drops; + + private boolean cancelled; @ApiStatus.Internal - public PlayerShearEntityEvent(@NotNull Player who, @NotNull Entity what, @NotNull ItemStack item, @NotNull EquipmentSlot hand, final java.util.@NotNull List drops) { // Paper - custom shear drops - super(who); - this.what = what; + public PlayerShearEntityEvent(@NotNull Player player, @NotNull Entity entity, @NotNull ItemStack item, @NotNull EquipmentSlot hand, final @NotNull List drops) { + super(player); + this.entity = entity; this.item = item; this.hand = hand; - this.drops = drops; // Paper - custom shear drops + this.drops = drops; } + @ApiStatus.Internal @Deprecated(since = "1.15.2", forRemoval = true) - public PlayerShearEntityEvent(@NotNull final Player who, @NotNull final Entity what) { - this(who, what, new ItemStack(Material.SHEARS), EquipmentSlot.HAND, java.util.Collections.emptyList()); // Paper - custom shear drops - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + public PlayerShearEntityEvent(@NotNull final Player player, @NotNull final Entity entity) { + this(player, entity, new ItemStack(Material.SHEARS), EquipmentSlot.HAND, java.util.Collections.emptyList()); } /** @@ -52,7 +48,7 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { */ @NotNull public Entity getEntity() { - return what; + return this.entity; } /** @@ -62,7 +58,7 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { */ @NotNull public ItemStack getItem() { - return item.clone(); + return this.item.clone(); } /** @@ -72,28 +68,16 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - - // Paper start - custom shear drops /** * Get an immutable list of drops for this shearing. * * @return the shearing drops * @see #setDrops(java.util.List) */ - public java.util.@NotNull @org.jetbrains.annotations.Unmodifiable List getDrops() { + public @NotNull @Unmodifiable List getDrops() { return this.drops; } @@ -102,8 +86,28 @@ public class PlayerShearEntityEvent extends PlayerEvent implements Cancellable { * * @param drops the shear drops */ - public void setDrops(final java.util.@NotNull List drops) { - this.drops = java.util.List.copyOf(drops); + public void setDrops(final @NotNull List drops) { + this.drops = List.copyOf(drops); + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; } - // Paper end - custom shear drops } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java index fb28eda44..d0ce86e71 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerShowEntityEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -18,11 +19,13 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerShowEntityEvent extends PlayerEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity entity; - public PlayerShowEntityEvent(@NotNull Player who, @NotNull Entity entity) { - super(who); + @ApiStatus.Internal + public PlayerShowEntityEvent(@NotNull Player player, @NotNull Entity entity) { + super(player); this.entity = entity; } @@ -33,17 +36,17 @@ public class PlayerShowEntityEvent extends PlayerEvent { */ @NotNull public Entity getEntity() { - return entity; + return this.entity; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerSignOpenEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerSignOpenEvent.java index 72fe69c38..bcc5659e3 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerSignOpenEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerSignOpenEvent.java @@ -1,26 +1,32 @@ package org.bukkit.event.player; +import org.bukkit.Warning; import org.bukkit.block.Sign; import org.bukkit.block.sign.Side; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * This event is fired when a sign is opened by the player. + * * @deprecated use {@link io.papermc.paper.event.player.PlayerOpenSignEvent} */ -@Deprecated(forRemoval = true) // Paper -@org.bukkit.Warning(false) // Paper +@Deprecated(forRemoval = true) +@Warning public class PlayerSignOpenEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Sign sign; private final Side side; private final Cause cause; + private boolean cancelled; + @ApiStatus.Internal public PlayerSignOpenEvent(@NotNull final Player player, @NotNull final Sign sign, @NotNull final Side side, @NotNull final Cause cause) { super(player); this.sign = sign; @@ -71,12 +77,12 @@ public class PlayerSignOpenEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum Cause { @@ -96,6 +102,6 @@ public class PlayerSignOpenEvent extends PlayerEvent implements Cancellable { /** * Indicate the sign was opened for an unknown reason. */ - UNKNOWN; + UNKNOWN } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerSpawnChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerSpawnChangeEvent.java index a57aaf09a..66ea3e999 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerSpawnChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerSpawnChangeEvent.java @@ -5,22 +5,27 @@ import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * This event is fired when the spawn point of the player is changed. + * * @deprecated use {@link com.destroystokyo.paper.event.player.PlayerSetSpawnEvent} */ -@Deprecated(forRemoval = true) // Paper +@Deprecated(forRemoval = true) public class PlayerSpawnChangeEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Cause cause; private Location newSpawn; private boolean forced; + private boolean cancelled; + @ApiStatus.Internal public PlayerSpawnChangeEvent(@NotNull final Player player, @Nullable Location newSpawn, boolean forced, @NotNull final Cause cause) { super(player); this.newSpawn = newSpawn; @@ -28,36 +33,6 @@ public class PlayerSpawnChangeEvent extends PlayerEvent implements Cancellable { this.forced = forced; } - /** - * Gets the cause of spawn change. - * - * @return change cause - */ - @NotNull - public Cause getCause() { - return this.cause; - } - - /** - * Gets if the spawn position will be used regardless of bed obstruction - * rules. - * - * @return true if is forced - */ - public boolean isForced() { - return this.forced; - } - - /** - * Sets if the spawn position will be used regardless of bed obstruction - * rules. - * - * @param forced true if forced - */ - public void setForced(boolean forced) { - this.forced = forced; - } - /** * Gets the new spawn to be set. * @@ -82,6 +57,36 @@ public class PlayerSpawnChangeEvent extends PlayerEvent implements Cancellable { } } + /** + * Gets the cause of spawn change. + * + * @return change cause + */ + @NotNull + public Cause getCause() { + return this.cause; + } + + /** + * Gets if the spawn position will be used regardless of bed obstruction + * rules. + * + * @return {@code true} if is forced + */ + public boolean isForced() { + return this.forced; + } + + /** + * Sets if the spawn position will be used regardless of bed obstruction + * rules. + * + * @param forced {@code true} if forced + */ + public void setForced(boolean forced) { + this.forced = forced; + } + @Override public boolean isCancelled() { return this.cancelled; @@ -95,12 +100,12 @@ public class PlayerSpawnChangeEvent extends PlayerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum Cause { @@ -130,6 +135,6 @@ public class PlayerSpawnChangeEvent extends PlayerEvent implements Cancellable { /** * Indicate the spawn was caused by an unknown reason. */ - UNKNOWN; + UNKNOWN } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java index 3fbcb0ecd..5100c8dff 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerStatisticIncrementEvent.java @@ -8,6 +8,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.material.MaterialData; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -16,17 +17,20 @@ import org.jetbrains.annotations.Nullable; *

    * This event is not called for some high frequency statistics, e.g. movement * based statistics. - * */ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + protected final Statistic statistic; private final int initialValue; private final int newValue; - private boolean isCancelled = false; private final EntityType entityType; private final Material material; + private boolean cancelled; + + @ApiStatus.Internal public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue) { super(player); this.statistic = statistic; @@ -36,6 +40,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel this.material = null; } + @ApiStatus.Internal public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull EntityType entityType) { super(player); this.statistic = statistic; @@ -45,6 +50,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel this.material = null; } + @ApiStatus.Internal public PlayerStatisticIncrementEvent(@NotNull Player player, @NotNull Statistic statistic, int initialValue, int newValue, @NotNull Material material) { super(player); this.statistic = statistic; @@ -71,7 +77,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel */ @NotNull public Statistic getStatistic() { - return statistic; + return this.statistic; } /** @@ -80,7 +86,7 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel * @return the previous value of the statistic */ public int getPreviousValue() { - return initialValue; + return this.initialValue; } /** @@ -89,49 +95,49 @@ public class PlayerStatisticIncrementEvent extends PlayerEvent implements Cancel * @return the new value of the statistic */ public int getNewValue() { - return newValue; + return this.newValue; } /** - * Gets the EntityType if {@link #getStatistic() getStatistic()} is an - * entity statistic otherwise returns null. + * Gets the EntityType if {@link #getStatistic()} is an + * entity statistic otherwise returns {@code null}. * * @return the EntityType of the statistic */ @Nullable public EntityType getEntityType() { - return entityType; + return this.entityType; } /** - * Gets the Material if {@link #getStatistic() getStatistic()} is a block - * or item statistic otherwise returns null. + * Gets the Material if {@link #getStatistic()} is a block + * or item statistic otherwise returns {@code null}. * * @return the Material of the statistic */ @Nullable public Material getMaterial() { - return material; + return this.material; } @Override public boolean isCancelled() { - return isCancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.isCancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java index 39dd08de7..b2db137fa 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerSwapHandItemsEvent.java @@ -4,21 +4,24 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** - * Called when a player swap items between main hand and off hand using the + * Called when a player swap items between main hand and off-hand using the * hotkey. */ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private ItemStack mainHandItem; private ItemStack offHandItem; + private boolean cancelled; + @ApiStatus.Internal public PlayerSwapHandItemsEvent(@NotNull Player player, @NotNull ItemStack mainHandItem, @NotNull ItemStack offHandItem) { super(player); @@ -31,9 +34,9 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * * @return item in the main hand */ - @NotNull // Paper + @NotNull public ItemStack getMainHandItem() { - return mainHandItem; + return this.mainHandItem; } /** @@ -42,31 +45,31 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable * @param mainHandItem new item in the main hand */ public void setMainHandItem(@Nullable ItemStack mainHandItem) { - this.mainHandItem = mainHandItem == null ? ItemStack.empty() : mainHandItem; // Paper + this.mainHandItem = mainHandItem == null ? ItemStack.empty() : mainHandItem; } /** - * Gets the item switched to the off hand. + * Gets the item switched to the off-hand. * - * @return item in the off hand + * @return item in the off-hand */ @NotNull // Paper public ItemStack getOffHandItem() { - return offHandItem; + return this.offHandItem; } /** - * Sets the item in the off hand. + * Sets the item in the off-hand. * - * @param offHandItem new item in the off hand + * @param offHandItem new item in the off-hand */ public void setOffHandItem(@Nullable ItemStack offHandItem) { - this.offHandItem = offHandItem == null ? ItemStack.empty() : offHandItem; // Paper + this.offHandItem = offHandItem == null ? ItemStack.empty() : offHandItem; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -77,11 +80,11 @@ public class PlayerSwapHandItemsEvent extends PlayerEvent implements Cancellable @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java index 5ef664a65..495e51647 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerTakeLecternBookEvent.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,13 +15,14 @@ import org.jetbrains.annotations.Nullable; */ public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private boolean cancelled; - private final Lectern lectern; + private static final HandlerList HANDLER_LIST = new HandlerList(); - public PlayerTakeLecternBookEvent(@NotNull Player who, @NotNull Lectern lectern) { - super(who); + private final Lectern lectern; + private boolean cancelled; + + @ApiStatus.Internal + public PlayerTakeLecternBookEvent(@NotNull Player player, @NotNull Lectern lectern) { + super(player); this.lectern = lectern; } @@ -31,7 +33,7 @@ public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellab */ @NotNull public Lectern getLectern() { - return lectern; + return this.lectern; } /** @@ -41,12 +43,12 @@ public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellab */ @Nullable public ItemStack getBook() { - return lectern.getInventory().getItem(0); + return this.lectern.getInventory().getItem(0); } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -57,11 +59,11 @@ public class PlayerTakeLecternBookEvent extends PlayerEvent implements Cancellab @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java index ccfb08af8..07e98ba82 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerTeleportEvent.java @@ -1,42 +1,45 @@ package org.bukkit.event.player; +import io.papermc.paper.entity.TeleportFlag; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; +import java.util.Collections; +import java.util.Set; /** * Holds information for player teleport events */ public class PlayerTeleportEvent extends PlayerMoveEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Set teleportFlags; private TeleportCause cause = TeleportCause.UNKNOWN; - // Paper start - Teleport API - private boolean dismounted = true; - private final java.util.Set teleportFlagSet; - // Paper end - + @ApiStatus.Internal public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) { super(player, from, to); - teleportFlagSet = java.util.Collections.emptySet(); // Paper - Teleport API + this.teleportFlags = Collections.emptySet(); } + @ApiStatus.Internal public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause) { this(player, from, to); - this.cause = cause; } - // Paper start - Teleport API - @org.jetbrains.annotations.ApiStatus.Internal - public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause, @NotNull java.util.Set teleportFlagSet) { + @ApiStatus.Internal + public PlayerTeleportEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TeleportCause cause, @NotNull Set teleportFlags) { super(player, from, to); - this.teleportFlagSet = teleportFlagSet; this.cause = cause; + this.teleportFlags = teleportFlags; } - // Paper end /** * Gets the cause of this teleportation event @@ -45,7 +48,41 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { */ @NotNull public TeleportCause getCause() { - return cause; + return this.cause; + } + + /** + * Returns the relative teleportation flags used in this teleportation. + * This determines which axis the player will not lose their velocity in. + * + * @return an immutable set of relative teleportation flags + */ + @NotNull + public @Unmodifiable Set getRelativeTeleportationFlags() { + return this.teleportFlags; + } + + /** + * Gets if the player will be dismounted in this teleportation. + * + * @return dismounted or not + * @deprecated dismounting on tp is no longer controlled by the server + */ + @Deprecated(forRemoval = true) + @Contract("-> true") + public boolean willDismountPlayer() { + return true; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; } public enum TeleportCause { @@ -100,41 +137,6 @@ public class PlayerTeleportEvent extends PlayerMoveEvent { * Indicates the teleportation was caused by an event not covered by * this enum */ - UNKNOWN; - } - - // Paper start - Teleport API - /** - * Gets if the player will be dismounted in this teleportation. - * - * @return dismounted or not - * @deprecated dismounting on tp is no longer controlled by the server - */ - @Deprecated(forRemoval = true) - public boolean willDismountPlayer() { - return this.dismounted; - } - - /** - * Returns the relative teleportation flags used in this teleportation. - * This determines which axis the player will not lose their velocity in. - * - * @return an immutable set of relative teleportation flags - */ - @NotNull - public java.util.Set getRelativeTeleportationFlags() { - return this.teleportFlagSet; - } - // Paper end - - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; + UNKNOWN } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java index 9c200f8ac..5f8b468d7 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleFlightEvent.java @@ -3,16 +3,20 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their flying state */ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final boolean isFlying; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean isFlying; + private boolean cancelled; + + @ApiStatus.Internal public PlayerToggleFlightEvent(@NotNull final Player player, final boolean isFlying) { super(player); this.isFlying = isFlying; @@ -24,27 +28,27 @@ public class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable * @return flying state */ public boolean isFlying() { - return isFlying; + return this.isFlying; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java index 348e5b5e5..959f60321 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSneakEvent.java @@ -3,16 +3,20 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their sneaking state */ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final boolean isSneaking; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean isSneaking; + private boolean cancelled; + + @ApiStatus.Internal public PlayerToggleSneakEvent(@NotNull final Player player, final boolean isSneaking) { super(player); this.isSneaking = isSneaking; @@ -24,27 +28,27 @@ public class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable { * @return sneaking state */ public boolean isSneaking() { - return isSneaking; + return this.isSneaking; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java index dc8cf2197..9930dcfeb 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerToggleSprintEvent.java @@ -3,16 +3,20 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a player toggles their sprinting state */ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private final boolean isSprinting; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean isSprinting; + private boolean cancelled; + + @ApiStatus.Internal public PlayerToggleSprintEvent(@NotNull final Player player, final boolean isSprinting) { super(player); this.isSprinting = isSprinting; @@ -24,27 +28,27 @@ public class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable * @return sprinting state */ public boolean isSprinting() { - return isSprinting; + return this.isSprinting; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java index 0b02a75f0..40d53499a 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnleashEntityEvent.java @@ -13,25 +13,25 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Cancellable { - private boolean cancelled = false; - private final Player player; private final EquipmentSlot hand; - // Paper start - drop leash variable + private boolean cancelled; + + @ApiStatus.Internal + public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand, boolean dropLeash) { + super(entity, UnleashReason.PLAYER_UNLEASH, dropLeash); + this.player = player; + this.hand = hand; + } + + @ApiStatus.Internal @Deprecated(forRemoval = true) public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand) { this(entity, player, hand, false); } @ApiStatus.Internal - public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player, @NotNull EquipmentSlot hand, boolean dropLeash) { - super(entity, UnleashReason.PLAYER_UNLEASH, dropLeash); - // Paper end - this.player = player; - this.hand = hand; - } - @Deprecated(since = "1.19.2", forRemoval = true) public PlayerUnleashEntityEvent(@NotNull Entity entity, @NotNull Player player) { this(entity, player, EquipmentSlot.HAND); @@ -44,7 +44,7 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc */ @NotNull public Player getPlayer() { - return player; + return this.player; } /** @@ -54,12 +54,12 @@ public class PlayerUnleashEntityEvent extends EntityUnleashEvent implements Canc */ @NotNull public EquipmentSlot getHand() { - return hand; + return this.hand; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java index b22bc21f5..fa424d5cf 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerUnregisterChannelEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.player; import org.bukkit.entity.Player; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -8,6 +9,7 @@ import org.jetbrains.annotations.NotNull; */ public class PlayerUnregisterChannelEvent extends PlayerChannelEvent { + @ApiStatus.Internal public PlayerUnregisterChannelEvent(@NotNull final Player player, @NotNull final String channel) { super(player, channel); } diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java index 87b15dcab..1f06ed0e4 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerVelocityEvent.java @@ -4,31 +4,25 @@ import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.util.Vector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when the velocity of a player changes. */ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; - private Vector velocity; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private Vector velocity; + private boolean cancelled; + + @ApiStatus.Internal public PlayerVelocityEvent(@NotNull final Player player, @NotNull final Vector velocity) { super(player); this.velocity = velocity; } - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; - } - /** * Gets the velocity vector that will be sent to the player * @@ -36,7 +30,7 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { */ @NotNull public Vector getVelocity() { - return velocity; + return this.velocity; } /** @@ -48,14 +42,24 @@ public class PlayerVelocityEvent extends PlayerEvent implements Cancellable { this.velocity = velocity.clone(); } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/raid/RaidEvent.java b/paper-api/src/main/java/org/bukkit/event/raid/RaidEvent.java index b2ff4bc33..37e075a94 100644 --- a/paper-api/src/main/java/org/bukkit/event/raid/RaidEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/raid/RaidEvent.java @@ -20,10 +20,10 @@ public abstract class RaidEvent extends WorldEvent { /** * Returns the raid involved with this event. * - * @return Raid + * @return the raid */ @NotNull public Raid getRaid() { - return raid; + return this.raid; } } diff --git a/paper-api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java b/paper-api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java index f0d280b8c..915ccbac8 100644 --- a/paper-api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/raid/RaidFinishEvent.java @@ -6,17 +6,20 @@ import org.bukkit.Raid; import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; /** * This event is called when a {@link Raid} was complete with a clear result. */ public class RaidFinishEvent extends RaidEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List winners; + @ApiStatus.Internal public RaidFinishEvent(@NotNull Raid raid, @NotNull World world, @NotNull List winners) { super(raid, world); this.winners = winners; @@ -28,21 +31,21 @@ public class RaidFinishEvent extends RaidEvent { * Note: Players who are considered as heroes but were not online at the * end would not be included in this list. * - * @return winners + * @return the winners */ @NotNull - public List getWinners() { - return Collections.unmodifiableList(winners); + public @Unmodifiable List getWinners() { + return Collections.unmodifiableList(this.winners); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java b/paper-api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java index 1b8bb5241..581bf07cb 100644 --- a/paper-api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/raid/RaidSpawnWaveEvent.java @@ -6,53 +6,55 @@ import org.bukkit.Raid; import org.bukkit.World; import org.bukkit.entity.Raider; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; /** * Called when a raid wave spawns. */ public class RaidSpawnWaveEvent extends RaidEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List raiders; private final Raider leader; - public RaidSpawnWaveEvent(@NotNull Raid raid, @NotNull World world, @NotNull Raider leader, @NotNull List raiders) { // Paper + @ApiStatus.Internal + public RaidSpawnWaveEvent(@NotNull Raid raid, @NotNull World world, @NotNull Raider leader, @NotNull List raiders) { super(raid, world); this.raiders = raiders; this.leader = leader; } - /** - * Returns the patrol leader. - * - * @return {@link Raider} - */ - @NotNull // Paper - public Raider getPatrolLeader() { - return leader; - } - /** * Returns all {@link Raider} that spawned in this wave. * * @return an immutable list of raiders */ @NotNull - public List getRaiders() { - return Collections.unmodifiableList(raiders); + public @Unmodifiable List getRaiders() { + return Collections.unmodifiableList(this.raiders); + } + + /** + * Returns the patrol leader. + * + * @return {@link Raider} + */ + @NotNull + public Raider getPatrolLeader() { + return this.leader; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java b/paper-api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java index 9e852ac97..60891959f 100644 --- a/paper-api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/raid/RaidStopEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.raid; import org.bukkit.Raid; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,10 +11,11 @@ import org.jetbrains.annotations.NotNull; */ public class RaidStopEvent extends RaidEvent { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Reason reason; + @ApiStatus.Internal public RaidStopEvent(@NotNull Raid raid, @NotNull World world, @NotNull Reason reason) { super(raid, world); this.reason = reason; @@ -26,18 +28,18 @@ public class RaidStopEvent extends RaidEvent { */ @NotNull public Reason getReason() { - return reason; + return this.reason; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum Reason { diff --git a/paper-api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java b/paper-api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java index 128e43cf1..40c1dcd4b 100644 --- a/paper-api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/raid/RaidTriggerEvent.java @@ -5,6 +5,7 @@ import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -13,11 +14,12 @@ import org.jetbrains.annotations.NotNull; */ public class RaidTriggerEvent extends RaidEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private final Player player; - private boolean cancel; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Player player; + private boolean cancelled; + + @ApiStatus.Internal public RaidTriggerEvent(@NotNull Raid raid, @NotNull World world, @NotNull Player player) { super(raid, world); this.player = player; @@ -30,27 +32,27 @@ public class RaidTriggerEvent extends RaidEvent implements Cancellable { */ @NotNull public Player getPlayer() { - return player; + return this.player; } @Override public boolean isCancelled() { - return cancel; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.cancel = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java index eb27cbe13..fbd9affdc 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/BroadcastMessageEvent.java @@ -1,60 +1,64 @@ package org.bukkit.event.server; import java.util.Set; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; -import org.bukkit.event.player.AsyncPlayerChatEvent; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Event triggered for server broadcast messages such as from - * {@link org.bukkit.Server#broadcast(net.kyori.adventure.text.Component)} (String, String)}. - * - * This event behaves similarly to {@link io.papermc.paper.event.player.AsyncChatEvent} in that it + * {@link org.bukkit.Server#broadcast(Component)} (String, String)}. + *

    + * This event behaves similarly to {@link io.papermc.paper.event.player.AsyncChatEvent} in that it * should be async if fired from an async thread. Please see that event for - * further information. + * further information. */ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private net.kyori.adventure.text.Component message; // Paper - private final Set recipients; - private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Set recipients; + private Component message; + + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.14", forRemoval = true) public BroadcastMessageEvent(@NotNull String message, @NotNull Set recipients) { this(false, message, recipients); } + @ApiStatus.Internal @Deprecated(forRemoval = true) public BroadcastMessageEvent(boolean isAsync, @NotNull String message, @NotNull Set recipients) { - // Paper start super(isAsync); - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); + this.message = LegacyComponentSerializer.legacySection().deserialize(message); this.recipients = recipients; } + @ApiStatus.Internal @Deprecated(forRemoval = true) - public BroadcastMessageEvent(net.kyori.adventure.text.@NotNull Component message, @NotNull Set recipients) { + public BroadcastMessageEvent(@NotNull Component message, @NotNull Set recipients) { this(false, message, recipients); } @ApiStatus.Internal - public BroadcastMessageEvent(boolean isAsync, net.kyori.adventure.text.@NotNull Component message, @NotNull Set recipients) { - // Paper end + public BroadcastMessageEvent(boolean isAsync, @NotNull Component message, @NotNull Set recipients) { super(isAsync); this.message = message; this.recipients = recipients; } - // Paper start + /** * Get the broadcast message. * * @return Message to broadcast */ - public net.kyori.adventure.text.@NotNull Component message() { + public @NotNull Component message() { return this.message; } @@ -63,10 +67,9 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { * * @param message New message to broadcast */ - public void message(net.kyori.adventure.text.@NotNull Component message) { + public void message(@NotNull Component message) { this.message = message; } - // Paper end /** * Get the message to broadcast. @@ -75,20 +78,20 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { * @deprecated in favour of {@link #message()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getMessage() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.message); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.message); } /** * Set the message to broadcast. * * @param message New message to broadcast - * @deprecated in favour of {@link #message(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #message(Component)} */ @Deprecated // Paper public void setMessage(@NotNull String message) { - this.message = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(message); // Paper + this.message = LegacyComponentSerializer.legacySection().deserialize(message); } /** @@ -106,12 +109,12 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { */ @NotNull public Set getRecipients() { - return recipients; + return this.recipients; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -122,11 +125,11 @@ public class BroadcastMessageEvent extends ServerEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java index dc7440d2e..d6eccfe3f 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/MapInitializeEvent.java @@ -2,15 +2,19 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.map.MapView; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a map is initialized. */ public class MapInitializeEvent extends ServerEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final MapView mapView; + @ApiStatus.Internal public MapInitializeEvent(@NotNull final MapView mapView) { this.mapView = mapView; } @@ -22,17 +26,17 @@ public class MapInitializeEvent extends ServerEvent { */ @NotNull public MapView getMap() { - return mapView; + return this.mapView; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java index a4fe2d7b8..c0945f706 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginDisableEvent.java @@ -2,14 +2,17 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a plugin is disabled. */ public class PluginDisableEvent extends PluginEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public PluginDisableEvent(@NotNull final Plugin plugin) { super(plugin); } @@ -17,11 +20,11 @@ public class PluginDisableEvent extends PluginEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java index fe78757d6..432af27f8 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEnableEvent.java @@ -2,14 +2,17 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.Plugin; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a plugin is enabled. */ public class PluginEnableEvent extends PluginEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public PluginEnableEvent(@NotNull final Plugin plugin) { super(plugin); } @@ -17,11 +20,11 @@ public class PluginEnableEvent extends PluginEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java index 89487b359..ad0e3f567 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/PluginEvent.java @@ -7,9 +7,10 @@ import org.jetbrains.annotations.NotNull; * Used for plugin enable and disable events */ public abstract class PluginEvent extends ServerEvent { + private final Plugin plugin; - public PluginEvent(@NotNull final Plugin plugin) { + protected PluginEvent(@NotNull final Plugin plugin) { this.plugin = plugin; } @@ -20,6 +21,6 @@ public abstract class PluginEvent extends ServerEvent { */ @NotNull public Plugin getPlugin() { - return plugin; + return this.plugin; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java b/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java index 2dac594c5..81988414d 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/RemoteServerCommandEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -9,8 +10,10 @@ import org.jetbrains.annotations.NotNull; * of {@link ServerCommandEvent} for more information. */ public class RemoteServerCommandEvent extends ServerCommandEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public RemoteServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) { super(sender, command); } @@ -18,11 +21,11 @@ public class RemoteServerCommandEvent extends ServerCommandEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java index 617459afa..341a51e16 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerCommandEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.server; import org.bukkit.command.CommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -35,19 +36,33 @@ import org.jetbrains.annotations.NotNull; *

    * If the event is cancelled, processing of the command will halt. *

    - * The state of whether or not there is a slash (/) at the + * The state of whether there is a slash (/) at the * beginning of the message should be preserved. If a slash is added or * removed, unexpected behavior may result. */ public class ServerCommandEvent extends ServerEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private String command; - private final CommandSender sender; - private boolean cancel = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final CommandSender sender; + private String command; + + private boolean cancelled; + + @ApiStatus.Internal public ServerCommandEvent(@NotNull final CommandSender sender, @NotNull final String command) { - this.command = command; this.sender = sender; + this.command = command; + } + + /** + * Get the command sender. + * + * @return The sender + */ + @NotNull + public CommandSender getSender() { + return this.sender; } /** @@ -58,7 +73,7 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { */ @NotNull public String getCommand() { - return command; + return this.command; } /** @@ -70,34 +85,24 @@ public class ServerCommandEvent extends ServerEvent implements Cancellable { this.command = message; } - /** - * Get the command sender. - * - * @return The sender - */ - @NotNull - public CommandSender getSender() { - return sender; + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java index 8a04bdd74..fdc397243 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerListPingEvent.java @@ -3,12 +3,15 @@ package org.bukkit.event.server; import com.google.common.base.Preconditions; import java.net.InetAddress; import java.util.Iterator; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; import org.bukkit.Bukkit; import org.bukkit.UndefinedNullability; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.util.CachedServerIcon; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; /** @@ -16,117 +19,78 @@ import org.jetbrains.annotations.NotNull; * checked and removed by {@link #iterator() iterating} over this event. *
    * Note: The players in {@link #iterator()} will not be shown in the - * server info if {@link Bukkit#getHideOnlinePlayers()} is true. + * server info if {@link Bukkit#getHideOnlinePlayers()} is {@code true}. */ public class ServerListPingEvent extends ServerEvent implements Iterable { + private static final int MAGIC_PLAYER_COUNT = Integer.MIN_VALUE; - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final String hostname; private final InetAddress address; - private net.kyori.adventure.text.Component motd; // Paper private final int numPlayers; + private Component motd; private int maxPlayers; - @Deprecated(forRemoval = true) @ApiStatus.Internal + @Deprecated(forRemoval = true) public ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) { super(true); Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online", numPlayers); this.hostname = hostname; this.address = address; - this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + this.motd = LegacyComponentSerializer.legacySection().deserialize(motd); this.numPlayers = numPlayers; this.maxPlayers = maxPlayers; } - /** - * This constructor is intended for implementations that provide the - * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} - * count. - * - * @param hostname The hostname that was used to connect to the server - * @param address the address of the pinger - * @param motd the message of the day - * @param maxPlayers the max number of players - * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, int)} - */ - @Deprecated(forRemoval = true) @ApiStatus.Internal + @Deprecated(forRemoval = true) protected ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) { super(true); this.numPlayers = MAGIC_PLAYER_COUNT; this.hostname = hostname; this.address = address; - this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + this.motd = LegacyComponentSerializer.legacySection().deserialize(motd); this.maxPlayers = maxPlayers; } - @Deprecated(forRemoval = true) @ApiStatus.Internal - public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int numPlayers, final int maxPlayers) { + @Deprecated(forRemoval = true) + public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final Component motd, final int numPlayers, final int maxPlayers) { this("", address, motd, numPlayers, maxPlayers); } @ApiStatus.Internal - public ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int numPlayers, final int maxPlayers) { + public ServerListPingEvent(@NotNull final String hostname, @NotNull final InetAddress address, @NotNull final Component motd, final int numPlayers, final int maxPlayers) { super(true); - Preconditions.checkArgument(numPlayers >= 0, "Cannot have negative number of players online (%s)", numPlayers); this.hostname = hostname; this.address = address; this.motd = motd; this.numPlayers = numPlayers; this.maxPlayers = maxPlayers; } - /** - * This constructor is intended for implementations that provide the - * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} - * count. - * - * @param address the address of the pinger - * @param motd the message of the day - * @param maxPlayers the max number of players - * @deprecated in favour of {@link #ServerListPingEvent(String, java.net.InetAddress, net.kyori.adventure.text.Component, int)} - */ - @Deprecated(forRemoval = true) + @ApiStatus.Internal - protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final net.kyori.adventure.text.Component motd, final int maxPlayers) { + @Deprecated(forRemoval = true) + protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final Component motd, final int maxPlayers) { this("", address, motd, maxPlayers); } - /** + /* * This constructor is intended for implementations that provide the * {@link #iterator()} method, thus provided the {@link #getNumPlayers()} * count. - * - * @param hostname The hostname that was used to connect to the server - * @param address the address of the pinger - * @param motd the message of the day - * @param maxPlayers the max number of players */ @ApiStatus.Internal - protected ServerListPingEvent(final @NotNull String hostname, final @NotNull InetAddress address, final net.kyori.adventure.text.@NotNull Component motd, final int maxPlayers) { + protected ServerListPingEvent(final @NotNull String hostname, final @NotNull InetAddress address, final @NotNull Component motd, final int maxPlayers) { this.numPlayers = MAGIC_PLAYER_COUNT; this.hostname = hostname; this.address = address; this.motd = motd; this.maxPlayers = maxPlayers; } - /** - * Get the message of the day message. - * - * @return the message of the day - */ - public net.kyori.adventure.text.@NotNull Component motd() { - return motd; - } - /** - * Change the message of the day message. - * - * @param motd the message of the day - */ - public void motd(net.kyori.adventure.text.@NotNull Component motd) { - this.motd = motd; - } /** * Gets the hostname that the player used to connect to the server, or @@ -136,7 +100,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable */ @NotNull public String getHostname() { - return hostname; + return this.hostname; } /** @@ -146,7 +110,25 @@ public class ServerListPingEvent extends ServerEvent implements Iterable */ @NotNull public InetAddress getAddress() { - return address; + return this.address; + } + + /** + * Get the message of the day message. + * + * @return the message of the day + */ + public @NotNull Component motd() { + return this.motd; + } + + /** + * Change the message of the day message. + * + * @param motd the message of the day + */ + public void motd(@NotNull Component motd) { + this.motd = motd; } /** @@ -156,20 +138,20 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * @deprecated in favour of {@link #motd()} */ @NotNull - @Deprecated // Paper + @Deprecated public String getMotd() { - return net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().serialize(this.motd); // Paper + return LegacyComponentSerializer.legacySection().serialize(this.motd); } /** * Change the message of the day message. * * @param motd the message of the day - * @deprecated in favour of {@link #motd(net.kyori.adventure.text.Component)} + * @deprecated in favour of {@link #motd(Component)} */ - @Deprecated // Paper + @Deprecated public void setMotd(@NotNull String motd) { - this.motd = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(motd); // Paper + this.motd = LegacyComponentSerializer.legacySection().deserialize(motd); } /** @@ -194,19 +176,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * @return the maximum number of players */ public int getMaxPlayers() { - return maxPlayers; - } - - /** - * Gets whether the server needs to send a preview of the chat to the - * client. - * - * @return true if chat preview is enabled, false otherwise - * @deprecated chat previews have been removed - */ - @Deprecated(since = "1.19.3", forRemoval = true) - public boolean shouldSendChatPreviews() { - return false; + return this.maxPlayers; } /** @@ -218,12 +188,25 @@ public class ServerListPingEvent extends ServerEvent implements Iterable this.maxPlayers = maxPlayers; } + /** + * Gets whether the server needs to send a preview of the chat to the + * client. + * + * @return {@code true} if chat preview is enabled, {@code false} otherwise + * @deprecated chat previews have been removed + */ + @Contract("-> false") + @Deprecated(since = "1.19.3", forRemoval = true) + public boolean shouldSendChatPreviews() { + return false; + } + /** * Sets the server-icon sent to the client. * * @param icon the icon to send to the client * @throws IllegalArgumentException if the {@link CachedServerIcon} is not - * created by the caller of this event; null may be accepted for some + * created by the caller of this event; {@code null} may be accepted for some * implementations * @throws UnsupportedOperationException if the caller of this event does * not support setting the server icon @@ -232,17 +215,6 @@ public class ServerListPingEvent extends ServerEvent implements Iterable throw new UnsupportedOperationException(); } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - /** * {@inheritDoc} *

    @@ -252,7 +224,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable * any new iterator. *
    * Note: The players here will not be shown in the server info if - * {@link Bukkit#getHideOnlinePlayers()} is true. + * {@link Bukkit#getHideOnlinePlayers()} is {@code true}. * * @throws UnsupportedOperationException if the caller of this event does * not support removing players @@ -264,4 +236,15 @@ public class ServerListPingEvent extends ServerEvent implements Iterable public Iterator iterator() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java index c9a252d7e..bf8b8c323 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServerLoadEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -8,21 +9,11 @@ import org.jetbrains.annotations.NotNull; */ public class ServerLoadEvent extends ServerEvent { - /** - * Represents the context in which the enclosing event has been completed. - */ - public enum LoadType { - STARTUP, RELOAD; - } + private static final HandlerList HANDLER_LIST = new HandlerList(); - private static final HandlerList handlers = new HandlerList(); private final LoadType type; - /** - * Creates a {@code ServerLoadEvent} with a given loading type. - * - * @param type the context in which the server was loaded - */ + @ApiStatus.Internal public ServerLoadEvent(@NotNull LoadType type) { this.type = type; } @@ -34,17 +25,25 @@ public class ServerLoadEvent extends ServerEvent { */ @NotNull public LoadType getType() { - return type; + return this.type; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; + } + + /** + * Represents the context in which the enclosing event has been completed. + */ + public enum LoadType { + STARTUP, + RELOAD } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java index 55e278cd0..442081920 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceEvent.java @@ -1,6 +1,7 @@ package org.bukkit.event.server; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -8,14 +9,15 @@ import org.jetbrains.annotations.NotNull; * org.bukkit.plugin.ServicesManager} */ public abstract class ServiceEvent extends ServerEvent { + private final RegisteredServiceProvider provider; - public ServiceEvent(@NotNull final RegisteredServiceProvider provider) { + protected ServiceEvent(@NotNull final RegisteredServiceProvider provider) { this.provider = provider; } @NotNull public RegisteredServiceProvider getProvider() { - return provider; + return this.provider; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java index d7f9227ef..d51c0a980 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceRegisterEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,8 +12,10 @@ import org.jetbrains.annotations.NotNull; * should not be relied upon. */ public class ServiceRegisterEvent extends ServiceEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public ServiceRegisterEvent(@NotNull RegisteredServiceProvider registeredProvider) { super(registeredProvider); } @@ -20,11 +23,11 @@ public class ServiceRegisterEvent extends ServiceEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java b/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java index f286799ee..639d379b0 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/ServiceUnregisterEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.server; import org.bukkit.event.HandlerList; import org.bukkit.plugin.RegisteredServiceProvider; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,8 +12,10 @@ import org.jetbrains.annotations.NotNull; * should not be relied upon. */ public class ServiceUnregisterEvent extends ServiceEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public ServiceUnregisterEvent(@NotNull RegisteredServiceProvider serviceProvider) { super(serviceProvider); } @@ -20,11 +23,11 @@ public class ServiceUnregisterEvent extends ServiceEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java b/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java index c71c122cc..a136f6974 100644 --- a/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/server/TabCompleteEvent.java @@ -1,13 +1,18 @@ package org.bukkit.event.server; import com.google.common.base.Preconditions; +import java.util.ArrayList; import java.util.List; +import org.bukkit.Location; import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerCommandSendEvent; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a {@link CommandSender} of any description (ie: player or @@ -18,33 +23,34 @@ import org.jetbrains.annotations.NotNull; * themselves. Plugins wishing to remove commands from tab completion are * advised to ensure the client does not have permission for the relevant * commands, or use {@link PlayerCommandSendEvent}. + * * @apiNote Only called for bukkit API commands {@link org.bukkit.command.Command} and * {@link org.bukkit.command.CommandExecutor} and not for brigadier commands ({@link io.papermc.paper.command.brigadier.Commands}). */ public class TabCompleteEvent extends Event implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final CommandSender sender; private final String buffer; + private final boolean isCommand; + private final Location location; private List completions; + private boolean cancelled; + @ApiStatus.Internal public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List completions) { - // Paper start - this(sender, buffer, completions, sender instanceof org.bukkit.command.ConsoleCommandSender || buffer.startsWith("/"), null); + this(sender, buffer, completions, sender instanceof ConsoleCommandSender || buffer.startsWith("/"), null); } - public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List completions, boolean isCommand, @org.jetbrains.annotations.Nullable org.bukkit.Location location) { - this.isCommand = isCommand; - this.loc = location; - // Paper end - Preconditions.checkArgument(sender != null, "sender"); - Preconditions.checkArgument(buffer != null, "buffer"); - Preconditions.checkArgument(completions != null, "completions"); + @ApiStatus.Internal + public TabCompleteEvent(@NotNull CommandSender sender, @NotNull String buffer, @NotNull List completions, boolean isCommand, @Nullable Location location) { this.sender = sender; this.buffer = buffer; - this.completions = new java.util.ArrayList<>(completions); // Paper - Completions must be mutable + this.completions = new ArrayList<>(completions); + this.isCommand = isCommand; + this.location = location; } /** @@ -54,7 +60,7 @@ public class TabCompleteEvent extends Event implements Cancellable { */ @NotNull public CommandSender getSender() { - return sender; + return this.sender; } /** @@ -64,7 +70,7 @@ public class TabCompleteEvent extends Event implements Cancellable { */ @NotNull public String getBuffer() { - return buffer; + return this.buffer; } /** @@ -75,43 +81,39 @@ public class TabCompleteEvent extends Event implements Cancellable { */ @NotNull public List getCompletions() { - return completions; + return this.completions; } - // Paper start - private final boolean isCommand; - private final org.bukkit.Location loc; - /** - * @return True if it is a command being tab completed, false if it is a chat message. - */ - public boolean isCommand() { - return isCommand; - } - - /** - * @return The position looked at by the sender, or null if none - */ - @org.jetbrains.annotations.Nullable - public org.bukkit.Location getLocation() { - return this.loc != null ? this.loc.clone() : null; - } - // Paper end - /** * Set the completions offered, overriding any already set. - * + *
    * The passed collection will be cloned to a new List. You must call {{@link #getCompletions()}} to mutate from here * * @param completions the new completions */ public void setCompletions(@NotNull List completions) { - Preconditions.checkArgument(completions != null); - this.completions = new java.util.ArrayList<>(completions); // Paper - completions must be mutable + Preconditions.checkArgument(completions != null, "completions cannot be null"); + this.completions = new ArrayList<>(completions); + } + + /** + * @return {@code true} if it is a command being tab completed, {@code false} if it is a chat message. + */ + public boolean isCommand() { + return this.isCommand; + } + + /** + * @return The position looked at by the sender, or {@code null} if none + */ + @Nullable + public Location getLocation() { + return this.location != null ? this.location.clone() : null; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -122,11 +124,11 @@ public class TabCompleteEvent extends Event implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java index d7cfd5f8a..0ac2e2304 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleBlockCollisionEvent.java @@ -2,7 +2,7 @@ package org.bukkit.event.vehicle; import org.bukkit.block.Block; import org.bukkit.entity.Vehicle; -import org.bukkit.event.HandlerList; +import org.bukkit.util.Vector; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; @@ -10,33 +10,23 @@ import org.jetbrains.annotations.NotNull; * Raised when a vehicle collides with a block. */ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { - private final Block block; - private final org.bukkit.util.Vector velocity; // Paper - // Paper start - Add pre-collision velocity + private final Block block; + private final Vector velocity; + + @ApiStatus.Internal @Deprecated(forRemoval = true) public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block) { this(vehicle, block, vehicle.getVelocity()); } @ApiStatus.Internal - public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block, @NotNull final org.bukkit.util.Vector velocity) { // Paper - Added velocity + public VehicleBlockCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Block block, @NotNull final Vector velocity) { super(vehicle); this.block = block; this.velocity = velocity; } - /** - * Gets velocity at which the vehicle collided with the block - * - * @return pre-collision moving velocity - */ - @NotNull - public org.bukkit.util.Vector getVelocity() { - return velocity.clone(); - } - // Paper end - /** * Gets the block the vehicle collided with * @@ -44,6 +34,16 @@ public class VehicleBlockCollisionEvent extends VehicleCollisionEvent { */ @NotNull public Block getBlock() { - return block; + return this.block; + } + + /** + * Gets velocity at which the vehicle collided with the block + * + * @return pre-collision moving velocity + */ + @NotNull + public Vector getVelocity() { + return this.velocity.clone(); } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java index aa1d74ead..183e57b07 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCollisionEvent.java @@ -1,24 +1,28 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; +import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle collides. */ public abstract class VehicleCollisionEvent extends VehicleEvent { - private static final org.bukkit.event.HandlerList HANDLER_LIST = new org.bukkit.event.HandlerList(); // Paper - public VehicleCollisionEvent(@NotNull final Vehicle vehicle) { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + protected VehicleCollisionEvent(@NotNull final Vehicle vehicle) { super(vehicle); } - // Paper start + + @NotNull @Override - public org.bukkit.event.@org.jetbrains.annotations.NotNull HandlerList getHandlers() { + public HandlerList getHandlers() { return HANDLER_LIST; } - public static org.bukkit.event.@NotNull HandlerList getHandlerList() { + @NotNull + public static HandlerList getHandlerList() { return HANDLER_LIST; } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java index c1f107db9..99297def3 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleCreateEvent.java @@ -3,22 +3,26 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle is created. */ public class VehicleCreateEvent extends VehicleEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private boolean cancelled; + @ApiStatus.Internal public VehicleCreateEvent(@NotNull final Vehicle vehicle) { super(vehicle); } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -29,11 +33,11 @@ public class VehicleCreateEvent extends VehicleEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java index 45da51d59..ab7f8f301 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDamageEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -11,11 +12,15 @@ import org.jetbrains.annotations.Nullable; * Raised when a vehicle receives damage. */ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity attacker; private double damage; + private boolean cancelled; + @ApiStatus.Internal public VehicleDamageEvent(@NotNull final Vehicle vehicle, @Nullable final Entity attacker, final double damage) { super(vehicle); this.attacker = attacker; @@ -29,7 +34,7 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { */ @Nullable public Entity getAttacker() { - return attacker; + return this.attacker; } /** @@ -38,7 +43,7 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { * @return the damage done to the vehicle */ public double getDamage() { - return damage; + return this.damage; } /** @@ -52,7 +57,7 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -63,11 +68,11 @@ public class VehicleDamageEvent extends VehicleEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java index 26bc6898f..49cd9d22c 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleDestroyEvent.java @@ -4,6 +4,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -13,10 +14,13 @@ import org.jetbrains.annotations.Nullable; * 'removed' due to other means. */ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity attacker; private boolean cancelled; + @ApiStatus.Internal public VehicleDestroyEvent(@NotNull final Vehicle vehicle, @Nullable final Entity attacker) { super(vehicle); this.attacker = attacker; @@ -29,12 +33,12 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { */ @Nullable public Entity getAttacker() { - return attacker; + return this.attacker; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -45,11 +49,11 @@ public class VehicleDestroyEvent extends VehicleEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java index 64f21f684..15453a419 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEnterEvent.java @@ -4,16 +4,20 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Raised when an entity enters a vehicle. */ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final Entity entered; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final Entity entered; + private boolean cancelled; + + @ApiStatus.Internal public VehicleEnterEvent(@NotNull final Vehicle vehicle, @NotNull final Entity entered) { super(vehicle); this.entered = entered; @@ -26,12 +30,12 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { */ @NotNull public Entity getEntered() { - return entered; + return this.entered; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override @@ -42,11 +46,11 @@ public class VehicleEnterEvent extends VehicleEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java index 77fb04bdf..384fdc7e0 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEntityCollisionEvent.java @@ -4,17 +4,21 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle collides with an entity. */ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implements Cancellable { - private final Entity entity; - private boolean cancelled = false; - private boolean cancelledPickup = false; - private boolean cancelledCollision = false; + private final Entity entity; + private boolean cancelledPickup; + private boolean cancelledCollision; + + private boolean cancelled; + + @ApiStatus.Internal public VehicleEntityCollisionEvent(@NotNull final Vehicle vehicle, @NotNull final Entity entity) { super(vehicle); this.entity = entity; @@ -22,36 +26,36 @@ public class VehicleEntityCollisionEvent extends VehicleCollisionEvent implement @NotNull public Entity getEntity() { - return entity; + return this.entity; + } + + @Deprecated(forRemoval = true) + public boolean isPickupCancelled() { + return this.cancelledPickup; + } + + @Deprecated(forRemoval = true) + public void setPickupCancelled(boolean cancel) { + this.cancelledPickup = cancel; + } + + @Deprecated(forRemoval = true) + public boolean isCollisionCancelled() { + return this.cancelledCollision; + } + + @Deprecated(forRemoval = true) + public void setCollisionCancelled(boolean cancel) { + this.cancelledCollision = cancel; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { this.cancelled = cancel; } - - @Deprecated(forRemoval = true) // Paper - Unused - public boolean isPickupCancelled() { - return cancelledPickup; - } - - @Deprecated(forRemoval = true) // Paper - Unused - public void setPickupCancelled(boolean cancel) { - cancelledPickup = cancel; - } - - @Deprecated(forRemoval = true) // Paper - Unused - public boolean isCollisionCancelled() { - return cancelledCollision; - } - - @Deprecated(forRemoval = true) // Paper - Unused - public void setCollisionCancelled(boolean cancel) { - cancelledCollision = cancel; - } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java index 63df27056..554c5f509 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleEvent.java @@ -8,9 +8,10 @@ import org.jetbrains.annotations.NotNull; * Represents a vehicle-related event. */ public abstract class VehicleEvent extends Event { + protected Vehicle vehicle; - public VehicleEvent(@NotNull final Vehicle vehicle) { + protected VehicleEvent(@NotNull final Vehicle vehicle) { this.vehicle = vehicle; } @@ -21,6 +22,6 @@ public abstract class VehicleEvent extends Event { */ @NotNull public final Vehicle getVehicle() { - return vehicle; + return this.vehicle; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java index 39f6afd2f..68db484a8 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleExitEvent.java @@ -4,27 +4,31 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Vehicle; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Raised when a living entity exits a vehicle. */ public class VehicleExitEvent extends VehicleEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; - private final LivingEntity exited; - private final boolean isCancellable; // Paper - public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited, boolean isCancellable) { // Paper + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final LivingEntity exited; + private final boolean isCancellable; + + private boolean cancelled; + + @ApiStatus.Internal + public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited, boolean isCancellable) { super(vehicle); this.exited = exited; - // Paper start this.isCancellable = isCancellable; } + @ApiStatus.Internal public VehicleExitEvent(@NotNull final Vehicle vehicle, @NotNull final LivingEntity exited) { this(vehicle, exited, true); - // Paper end } /** @@ -34,36 +38,34 @@ public class VehicleExitEvent extends VehicleEvent implements Cancellable { */ @NotNull public LivingEntity getExited() { - return exited; + return this.exited; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - // Paper start - if (cancel && !isCancellable) { + if (cancel && !this.isCancellable) { return; } this.cancelled = cancel; } public boolean isCancellable() { - return isCancellable; - // Paper end + return this.isCancellable; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java index fc4cf7b21..efa834add 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleMoveEvent.java @@ -3,16 +3,20 @@ package org.bukkit.event.vehicle; import org.bukkit.Location; import org.bukkit.entity.Vehicle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Raised when a vehicle moves. */ public class VehicleMoveEvent extends VehicleEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Location from; private final Location to; + @ApiStatus.Internal public VehicleMoveEvent(@NotNull final Vehicle vehicle, @NotNull final Location from, @NotNull final Location to) { super(vehicle); @@ -27,7 +31,7 @@ public class VehicleMoveEvent extends VehicleEvent { */ @NotNull public Location getFrom() { - return from.clone(); // Paper - clone to avoid changes + return this.from.clone(); } /** @@ -37,18 +41,17 @@ public class VehicleMoveEvent extends VehicleEvent { */ @NotNull public Location getTo() { - return to.clone(); // Paper - clone to avoid changes + return this.to.clone(); } - @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java index 098192a5e..192169b59 100644 --- a/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/vehicle/VehicleUpdateEvent.java @@ -2,14 +2,17 @@ package org.bukkit.event.vehicle; import org.bukkit.entity.Vehicle; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a vehicle updates */ public class VehicleUpdateEvent extends VehicleEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public VehicleUpdateEvent(@NotNull final Vehicle vehicle) { super(vehicle); } @@ -17,11 +20,11 @@ public class VehicleUpdateEvent extends VehicleEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java index 50696f04f..a16aadada 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/LightningStrikeEvent.java @@ -11,11 +11,15 @@ import org.jetbrains.annotations.NotNull; * Stores data for lightning striking */ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final LightningStrike bolt; private final Cause cause; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.13.1", forRemoval = true) public LightningStrikeEvent(@NotNull final World world, @NotNull final LightningStrike bolt) { this(world, bolt, Cause.UNKNOWN); @@ -28,16 +32,6 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { this.cause = cause; } - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; - } - /** * Gets the bolt which is striking the earth. * @@ -45,7 +39,7 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { */ @NotNull public LightningStrike getLightning() { - return bolt; + return this.bolt; } /** @@ -55,18 +49,28 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { */ @NotNull public Cause getCause() { - return cause; + return this.cause; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } public enum Cause { @@ -101,6 +105,6 @@ public class LightningStrikeEvent extends WeatherEvent implements Cancellable { /** * Unknown trigger. */ - UNKNOWN; + UNKNOWN } } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java index f787596d2..2c022f51d 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/ThunderChangeEvent.java @@ -10,55 +10,36 @@ import org.jetbrains.annotations.NotNull; * Stores data for thunder state changing in a world */ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; - private final boolean to; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean newThunderState; private final Cause cause; + private boolean cancelled; + @ApiStatus.Internal - public ThunderChangeEvent(@NotNull final World world, final boolean to, @NotNull final Cause cause) { + public ThunderChangeEvent(@NotNull final World world, final boolean newThunderState, @NotNull final Cause cause) { super(world); - this.to = to; + this.newThunderState = newThunderState; this.cause = cause; } + @ApiStatus.Internal @Deprecated(forRemoval = true) - public ThunderChangeEvent(@NotNull final World world, final boolean to) { - super(world); - this.to = to; - this.cause = Cause.UNKNOWN; // Paper - } - - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; + public ThunderChangeEvent(@NotNull final World world, final boolean newThunderState) { + this(world, newThunderState, Cause.UNKNOWN); } /** * Gets the state of thunder that the world is being set to * - * @return true if the weather is being set to thundering, false otherwise + * @return {@code true} if the weather is being set to thundering, {@code false} otherwise */ public boolean toThunderState() { - return to; + return this.newThunderState; } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - // Paper start /** * Gets the cause of the weather change. * @@ -69,6 +50,27 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { return this.cause; } + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } + public enum Cause { COMMAND, NATURAL, @@ -76,5 +78,4 @@ public class ThunderChangeEvent extends WeatherEvent implements Cancellable { PLUGIN, UNKNOWN } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java index c8aa324b7..4a985c42a 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherChangeEvent.java @@ -10,55 +10,36 @@ import org.jetbrains.annotations.NotNull; * Stores data for weather changing in a world */ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean canceled; - private final boolean to; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private final boolean newWeatherState; private final Cause cause; + private boolean cancelled; + @ApiStatus.Internal - public WeatherChangeEvent(@NotNull final World world, final boolean to, @NotNull Cause cause) { + public WeatherChangeEvent(@NotNull final World world, final boolean newWeatherState, @NotNull Cause cause) { super(world); - this.to = to; + this.newWeatherState = newWeatherState; this.cause = cause; } + @ApiStatus.Internal @Deprecated(forRemoval = true) - public WeatherChangeEvent(@NotNull final World world, final boolean to) { - super(world); - this.to = to; - this.cause = Cause.UNKNOWN; // Paper - } - - @Override - public boolean isCancelled() { - return canceled; - } - - @Override - public void setCancelled(boolean cancel) { - canceled = cancel; + public WeatherChangeEvent(@NotNull final World world, final boolean newWeatherState) { + this(world, newWeatherState, Cause.UNKNOWN); } /** * Gets the state of weather that the world is being set to * - * @return true if the weather is being set to raining, false otherwise + * @return {@code true} if the weather is being set to raining, {@code false} otherwise */ public boolean toWeatherState() { - return to; + return this.newWeatherState; } - @NotNull - @Override - public HandlerList getHandlers() { - return handlers; - } - - @NotNull - public static HandlerList getHandlerList() { - return handlers; - } - // Paper start /** * Gets the cause of the weather change. * @@ -66,7 +47,28 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { */ @NotNull public Cause getCause() { - return cause; + return this.cause; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; + } + + @NotNull + @Override + public HandlerList getHandlers() { + return HANDLER_LIST; + } + + @NotNull + public static HandlerList getHandlerList() { + return HANDLER_LIST; } public enum Cause { @@ -76,5 +78,4 @@ public class WeatherChangeEvent extends WeatherEvent implements Cancellable { PLUGIN, UNKNOWN } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java index e1854d807..df4c35126 100644 --- a/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/weather/WeatherEvent.java @@ -8,10 +8,11 @@ import org.jetbrains.annotations.NotNull; * Represents a Weather-related event */ public abstract class WeatherEvent extends Event { + protected World world; - public WeatherEvent(@NotNull final World where) { - world = where; + protected WeatherEvent(@NotNull final World where) { + this.world = where; } /** @@ -21,6 +22,6 @@ public abstract class WeatherEvent extends Event { */ @NotNull public final World getWorld() { - return world; + return this.world; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureGenerateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureGenerateEvent.java index 91a137379..b3d68f1f3 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureGenerateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureGenerateEvent.java @@ -14,6 +14,7 @@ import org.bukkit.util.EntityTransformer; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.Unmodifiable; /** * This event will sometimes fire synchronously, depending on how it was @@ -26,7 +27,7 @@ import org.jetbrains.annotations.Nullable; * If a {@link Structure} is naturally placed in a chunk of the world, this * event will be asynchronous. If a player executes the '/place structure' * command, this event will be synchronous. - * + *
    * Allows to register transformers that can modify the blocks placed and * entities spawned by the structure. *

    @@ -37,13 +38,7 @@ import org.jetbrains.annotations.Nullable; @ApiStatus.Experimental public class AsyncStructureGenerateEvent extends WorldEvent { - public static enum Cause { - COMMAND, - WORLD_GENERATION, - CUSTOM; - } - - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); private final Cause cause; @@ -55,13 +50,14 @@ public class AsyncStructureGenerateEvent extends WorldEvent { private final Map blockTransformers = new LinkedHashMap<>(); private final Map entityTransformers = new LinkedHashMap<>(); + @ApiStatus.Internal public AsyncStructureGenerateEvent(@NotNull World world, boolean async, @NotNull Cause cause, @NotNull Structure structure, @NotNull BoundingBox boundingBox, int chunkX, int chunkZ) { super(world, async); + this.cause = cause; this.structure = structure; this.boundingBox = boundingBox; this.chunkX = chunkX; this.chunkZ = chunkZ; - this.cause = cause; } /** @@ -71,111 +67,7 @@ public class AsyncStructureGenerateEvent extends WorldEvent { */ @NotNull public Cause getCause() { - return cause; - } - - /** - * Gets a block transformer by key. - * - * @param key the key of the block transformer - * - * @return the block transformer or null - */ - @Nullable - public BlockTransformer getBlockTransformer(@NotNull NamespacedKey key) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - return blockTransformers.get(key); - } - - /** - * Sets a block transformer to a key. - * - * @param key the key - * @param transformer the block transformer - */ - public void setBlockTransformer(@NotNull NamespacedKey key, @NotNull BlockTransformer transformer) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - Preconditions.checkNotNull(transformer, "BlockTransformer cannot be null"); - blockTransformers.put(key, transformer); - } - - /** - * Removes a block transformer. - * - * @param key the key of the block transformer - */ - public void removeBlockTransformer(@NotNull NamespacedKey key) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - blockTransformers.remove(key); - } - - /** - * Removes all block transformers. - */ - public void clearBlockTransformers() { - blockTransformers.clear(); - } - - /** - * Gets all block transformers in a unmodifiable map. - * - * @return the block transformers in a map - */ - @NotNull - public Map getBlockTransformers() { - return Collections.unmodifiableMap(blockTransformers); - } - - /** - * Gets a entity transformer by key. - * - * @param key the key of the entity transformer - * - * @return the entity transformer or null - */ - @Nullable - public EntityTransformer getEntityTransformer(@NotNull NamespacedKey key) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - return entityTransformers.get(key); - } - - /** - * Sets a entity transformer to a key. - * - * @param key the key - * @param transformer the entity transformer - */ - public void setEntityTransformer(@NotNull NamespacedKey key, @NotNull EntityTransformer transformer) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - Preconditions.checkNotNull(transformer, "EntityTransformer cannot be null"); - entityTransformers.put(key, transformer); - } - - /** - * Removes a entity transformer. - * - * @param key the key of the entity transformer - */ - public void removeEntityTransformer(@NotNull NamespacedKey key) { - Preconditions.checkNotNull(key, "NamespacedKey cannot be null"); - entityTransformers.remove(key); - } - - /** - * Removes all entity transformers. - */ - public void clearEntityTransformers() { - entityTransformers.clear(); - } - - /** - * Gets all entity transformers in a unmodifiable map. - * - * @return the entity transformers in a map - */ - @NotNull - public Map getEntityTransformers() { - return Collections.unmodifiableMap(entityTransformers); + return this.cause; } /** @@ -185,7 +77,7 @@ public class AsyncStructureGenerateEvent extends WorldEvent { */ @NotNull public Structure getStructure() { - return structure; + return this.structure; } /** @@ -195,7 +87,7 @@ public class AsyncStructureGenerateEvent extends WorldEvent { */ @NotNull public BoundingBox getBoundingBox() { - return boundingBox.clone(); + return this.boundingBox.clone(); } /** @@ -204,7 +96,7 @@ public class AsyncStructureGenerateEvent extends WorldEvent { * @return the chunk x coordinate */ public int getChunkX() { - return chunkX; + return this.chunkX; } /** @@ -213,17 +105,127 @@ public class AsyncStructureGenerateEvent extends WorldEvent { * @return the chunk z coordinate */ public int getChunkZ() { - return chunkZ; + return this.chunkZ; + } + + /** + * Gets a block transformer by key. + * + * @param key the key of the block transformer + * + * @return the block transformer or {@code null} + */ + @Nullable + public BlockTransformer getBlockTransformer(@NotNull NamespacedKey key) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + return this.blockTransformers.get(key); + } + + /** + * Sets a block transformer to a key. + * + * @param key the key + * @param transformer the block transformer + */ + public void setBlockTransformer(@NotNull NamespacedKey key, @NotNull BlockTransformer transformer) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + Preconditions.checkArgument(transformer != null, "BlockTransformer cannot be null"); + this.blockTransformers.put(key, transformer); + } + + /** + * Removes a block transformer. + * + * @param key the key of the block transformer + */ + public void removeBlockTransformer(@NotNull NamespacedKey key) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + this.blockTransformers.remove(key); + } + + /** + * Removes all block transformers. + */ + public void clearBlockTransformers() { + this.blockTransformers.clear(); + } + + /** + * Gets all block transformers in an unmodifiable map. + * + * @return the block transformers in a map + */ + @NotNull + public @Unmodifiable Map getBlockTransformers() { + return Collections.unmodifiableMap(this.blockTransformers); + } + + /** + * Gets an entity transformer by key. + * + * @param key the key of the entity transformer + * + * @return the entity transformer or {@code null} + */ + @Nullable + public EntityTransformer getEntityTransformer(@NotNull NamespacedKey key) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + return this.entityTransformers.get(key); + } + + /** + * Sets an entity transformer to a key. + * + * @param key the key + * @param transformer the entity transformer + */ + public void setEntityTransformer(@NotNull NamespacedKey key, @NotNull EntityTransformer transformer) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + Preconditions.checkArgument(transformer != null, "EntityTransformer cannot be null"); + this.entityTransformers.put(key, transformer); + } + + /** + * Removes an entity transformer. + * + * @param key the key of the entity transformer + */ + public void removeEntityTransformer(@NotNull NamespacedKey key) { + Preconditions.checkArgument(key != null, "NamespacedKey cannot be null"); + this.entityTransformers.remove(key); + } + + /** + * Removes all entity transformers. + */ + public void clearEntityTransformers() { + this.entityTransformers.clear(); + } + + /** + * Gets all entity transformers in an unmodifiable map. + * + * @return the entity transformers in a map + */ + @NotNull + public @Unmodifiable Map getEntityTransformers() { + return Collections.unmodifiableMap(this.entityTransformers); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; + } + + public enum Cause { + COMMAND, + WORLD_GENERATION, + CUSTOM } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureSpawnEvent.java b/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureSpawnEvent.java index 978790b97..1ed7a83ee 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureSpawnEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/AsyncStructureSpawnEvent.java @@ -5,6 +5,7 @@ import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.bukkit.generator.structure.Structure; import org.bukkit.util.BoundingBox; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,14 +13,16 @@ import org.jetbrains.annotations.NotNull; */ public class AsyncStructureSpawnEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; + private static final HandlerList HANDLER_LIST = new HandlerList(); private final Structure structure; private final BoundingBox boundingBox; private final int chunkX, chunkZ; + private boolean cancelled; + + @ApiStatus.Internal public AsyncStructureSpawnEvent(@NotNull World world, @NotNull Structure structure, @NotNull BoundingBox boundingBox, int chunkX, int chunkZ) { super(world, true); this.structure = structure; @@ -35,7 +38,7 @@ public class AsyncStructureSpawnEvent extends WorldEvent implements Cancellable */ @NotNull public Structure getStructure() { - return structure; + return this.structure; } /** @@ -45,51 +48,51 @@ public class AsyncStructureSpawnEvent extends WorldEvent implements Cancellable */ @NotNull public BoundingBox getBoundingBox() { - return boundingBox.clone(); + return this.boundingBox.clone(); } /** * Get the x coordinate of the origin chunk of the structure. - * + *

    * Note, it is not safe to attempt to retrieve or interact with this * chunk. This event is informative only! * * @return the chunk x coordinate */ public int getChunkX() { - return chunkX; + return this.chunkX; } /** * Get the z coordinate of the origin chunk of the structure. - * + *

    * Note, it is not safe to attempt to retrieve or interact with this * chunk. This event is informative only! * * @return the chunk z coordinate */ public int getChunkZ() { - return chunkZ; + return this.chunkZ; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java index 7ffc6a77b..518ac1382 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkEvent.java @@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull; * Represents a Chunk related event */ public abstract class ChunkEvent extends WorldEvent { + protected Chunk chunk; protected ChunkEvent(@NotNull final Chunk chunk) { @@ -21,6 +22,6 @@ public abstract class ChunkEvent extends WorldEvent { */ @NotNull public Chunk getChunk() { - return chunk; + return this.chunk; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java index 7873d387f..37ec37d8d 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkLoadEvent.java @@ -3,15 +3,19 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.HandlerList; import org.bukkit.generator.BlockPopulator; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a chunk is loaded */ public class ChunkLoadEvent extends ChunkEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final boolean newChunk; + @ApiStatus.Internal public ChunkLoadEvent(@NotNull final Chunk chunk, final boolean newChunk) { super(chunk); this.newChunk = newChunk; @@ -23,20 +27,20 @@ public class ChunkLoadEvent extends ChunkEvent { * Note: Do not use this to generated blocks in a newly generated chunk. * Use a {@link BlockPopulator} instead. * - * @return true if the chunk is new, otherwise false + * @return {@code true} if the chunk is new, otherwise {@code false} */ public boolean isNewChunk() { - return newChunk; + return this.newChunk; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java index 7b323c057..4ec3591cb 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkPopulateEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.HandlerList; import org.bukkit.generator.BlockPopulator; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,8 +13,10 @@ import org.jetbrains.annotations.NotNull; * Use a {@link BlockPopulator} instead. */ public class ChunkPopulateEvent extends ChunkEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public ChunkPopulateEvent(@NotNull final Chunk chunk) { super(chunk); } @@ -21,11 +24,11 @@ public class ChunkPopulateEvent extends ChunkEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java index 5d8271626..4b21544c4 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/ChunkUnloadEvent.java @@ -2,19 +2,24 @@ package org.bukkit.event.world; import org.bukkit.Chunk; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a chunk is unloaded */ public class ChunkUnloadEvent extends ChunkEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private boolean saveChunk; + @ApiStatus.Internal public ChunkUnloadEvent(@NotNull final Chunk chunk) { this(chunk, true); } + @ApiStatus.Internal public ChunkUnloadEvent(@NotNull Chunk chunk, boolean save) { super(chunk); this.saveChunk = save; @@ -26,7 +31,7 @@ public class ChunkUnloadEvent extends ChunkEvent { * @return chunk save status */ public boolean isSaveChunk() { - return saveChunk; + return this.saveChunk; } /** @@ -41,11 +46,11 @@ public class ChunkUnloadEvent extends ChunkEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java index 88b13a481..f3ace8a15 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/EntitiesLoadEvent.java @@ -4,18 +4,22 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; /** * Called when entities are loaded. - * + *
    * The provided chunk may or may not be loaded. */ public class EntitiesLoadEvent extends ChunkEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List entities; + @ApiStatus.Internal public EntitiesLoadEvent(@NotNull Chunk chunk, @NotNull List entities) { super(chunk); this.entities = entities; @@ -27,18 +31,18 @@ public class EntitiesLoadEvent extends ChunkEvent { * @return unmodifiable list of loaded entities. */ @NotNull - public List getEntities() { - return entities; + public @Unmodifiable List getEntities() { + return this.entities; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java index 1e3f144f1..d5ff3b5de 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/EntitiesUnloadEvent.java @@ -4,18 +4,22 @@ import java.util.List; import org.bukkit.Chunk; import org.bukkit.entity.Entity; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Unmodifiable; /** * Called when entities are unloaded. - * + *
    * The provided chunk may or may not be loaded. */ public class EntitiesUnloadEvent extends ChunkEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List entities; + @ApiStatus.Internal public EntitiesUnloadEvent(@NotNull Chunk chunk, @NotNull List entities) { super(chunk); this.entities = entities; @@ -27,18 +31,18 @@ public class EntitiesUnloadEvent extends ChunkEvent { * @return unmodifiable list of unloaded entities. */ @NotNull - public List getEntities() { - return entities; + public @Unmodifiable List getEntities() { + return this.entities; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/GenericGameEvent.java b/paper-api/src/main/java/org/bukkit/event/world/GenericGameEvent.java index fb975fefc..5a275c57a 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/GenericGameEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/GenericGameEvent.java @@ -6,24 +6,28 @@ import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Represents a generic Mojang game event. - * + *
    * Specific Bukkit events should be used where possible, this event is mainly * used internally by Sculk sensors. */ public class GenericGameEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final GameEvent event; private final Location location; private final Entity entity; private int radius; + private boolean cancelled; + @ApiStatus.Internal public GenericGameEvent(@NotNull GameEvent event, @NotNull Location location, @Nullable Entity entity, int radius, boolean isAsync) { super(location.getWorld(), isAsync); this.event = event; @@ -39,7 +43,7 @@ public class GenericGameEvent extends WorldEvent implements Cancellable { */ @NotNull public GameEvent getEvent() { - return event; + return this.event; } /** @@ -49,17 +53,17 @@ public class GenericGameEvent extends WorldEvent implements Cancellable { */ @NotNull public Location getLocation() { - return location.clone(); // Paper - clone to avoid changes + return this.location.clone(); } /** * Get the entity which triggered this event, if present. * - * @return triggering entity or null + * @return triggering entity or {@code null} */ @Nullable public Entity getEntity() { - return entity; + return this.entity; } /** @@ -68,7 +72,7 @@ public class GenericGameEvent extends WorldEvent implements Cancellable { * @return broadcast radius */ public int getRadius() { - return radius; + return this.radius; } /** @@ -88,17 +92,17 @@ public class GenericGameEvent extends WorldEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/LootGenerateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/LootGenerateEvent.java index e051dc8b9..b78d36576 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/LootGenerateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/LootGenerateEvent.java @@ -11,13 +11,14 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; import org.bukkit.loot.LootContext; import org.bukkit.loot.LootTable; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * Called when a {@link LootTable} is generated in the world for an * {@link InventoryHolder}. - * + *

    * This event is NOT currently called when an entity's loot table has been * generated (use {@link EntityDeathEvent#getDrops()}, but WILL be called by * plugins invoking @@ -25,8 +26,8 @@ import org.jetbrains.annotations.Nullable; */ public class LootGenerateEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Entity entity; private final InventoryHolder inventoryHolder; private final LootTable lootTable; @@ -34,6 +35,9 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { private final List loot; private final boolean plugin; + private boolean cancelled; + + @ApiStatus.Internal public LootGenerateEvent(@NotNull World world, @Nullable Entity entity, @Nullable InventoryHolder inventoryHolder, @NotNull LootTable lootTable, @NotNull LootContext lootContext, @NotNull List items, boolean plugin) { super(world); this.entity = entity; @@ -46,10 +50,10 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { /** * Get the entity used as context for loot generation (if applicable). - * + *

    * For inventories where entities are not required to generate loot, such as - * hoppers, null will be returned. - * + * hoppers, {@code null} will be returned. + *
    * This is a convenience method for * {@code getLootContext().getLootedEntity()}. * @@ -57,20 +61,20 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { */ @Nullable public Entity getEntity() { - return entity; + return this.entity; } /** * Get the inventory holder in which the loot was generated. - * + *

    * If the loot was generated as a result of the block being broken, the - * inventory holder will be null as this event is called post block break. + * inventory holder will be {@code null} as this event is called post block break. * * @return the inventory holder */ @Nullable public InventoryHolder getInventoryHolder() { - return inventoryHolder; + return this.inventoryHolder; } /** @@ -80,7 +84,7 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { */ @NotNull public LootTable getLootTable() { - return lootTable; + return this.lootTable; } /** @@ -91,16 +95,16 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { */ @NotNull public LootContext getLootContext() { - return lootContext; + return this.lootContext; } /** - * Set the loot to be generated. Null items will be treated as air. - * + * Set the loot to be generated. {@code null} items will be treated as air. + *
    * Note: the set collection is not the one which will be returned by * {@link #getLoot()}. * - * @param loot the loot to generate, null to clear all loot + * @param loot the loot to generate, {@code null} to clear all loot */ public void setLoot(@Nullable Collection loot) { this.loot.clear(); @@ -111,26 +115,26 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { /** * Get a mutable list of all loot to be generated. - * + *

    * Any items added or removed from the returned list will be reflected in - * the loot generation. Null items will be treated as air. + * the loot generation. {@code null} items will be treated as air. * * @return the loot to generate */ @NotNull public List getLoot() { - return loot; + return this.loot; } /** - * Check whether or not this event was called as a result of a plugin + * Check whether this event was called as a result of a plugin * invoking * {@link LootTable#fillInventory(org.bukkit.inventory.Inventory, java.util.Random, LootContext)}. * - * @return true if plugin caused, false otherwise + * @return {@code true} if plugin caused, {@code false} otherwise */ public boolean isPlugin() { - return plugin; + return this.plugin; } @Override @@ -140,17 +144,17 @@ public class LootGenerateEvent extends WorldEvent implements Cancellable { @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java index b7789781f..0bf1d2974 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/PortalCreateEvent.java @@ -14,12 +14,16 @@ import org.jetbrains.annotations.Nullable; * Called when a portal is created */ public class PortalCreateEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancel = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final List blocks; private final Entity entity; private final CreateReason reason; + private boolean cancelled; + + @ApiStatus.Internal @Deprecated(since = "1.14.1", forRemoval = true) public PortalCreateEvent(@NotNull final List blocks, @NotNull final World world, @NotNull CreateReason reason) { this(blocks, world, null, reason); @@ -51,17 +55,7 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { */ @Nullable public Entity getEntity() { - return entity; - } - - @Override - public boolean isCancelled() { - return cancel; - } - - @Override - public void setCancelled(boolean cancel) { - this.cancel = cancel; + return this.entity; } /** @@ -71,18 +65,28 @@ public class PortalCreateEvent extends WorldEvent implements Cancellable { */ @NotNull public CreateReason getReason() { - return reason; + return this.reason; + } + + @Override + public boolean isCancelled() { + return this.cancelled; + } + + @Override + public void setCancelled(boolean cancel) { + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java index 73997ae04..c77b49e6b 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/SpawnChangeEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -10,9 +11,12 @@ import org.jetbrains.annotations.NotNull; * spawn location is included. */ public class SpawnChangeEvent extends WorldEvent { - private static final HandlerList handlers = new HandlerList(); + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Location previousLocation; + @ApiStatus.Internal public SpawnChangeEvent(@NotNull final World world, @NotNull final Location previousLocation) { super(world); this.previousLocation = previousLocation; @@ -25,17 +29,17 @@ public class SpawnChangeEvent extends WorldEvent { */ @NotNull public Location getPreviousLocation() { - return previousLocation.clone(); // Paper - clone to avoid changes + return this.previousLocation.clone(); } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java index 783e74bc3..461269240 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/StructureGrowEvent.java @@ -7,6 +7,7 @@ import org.bukkit.block.BlockState; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -15,14 +16,18 @@ import org.jetbrains.annotations.Nullable; * Tree), (Mushroom {@literal ->} Huge Mushroom), naturally or using bonemeal. */ public class StructureGrowEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean cancelled = false; + + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final Location location; private final TreeType species; private final boolean bonemeal; private final Player player; private final List blocks; + private boolean cancelled; + + @ApiStatus.Internal public StructureGrowEvent(@NotNull final Location location, @NotNull final TreeType species, final boolean bonemeal, @Nullable final Player player, @NotNull final List blocks) { super(location.getWorld()); this.location = location; @@ -39,7 +44,7 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { */ @NotNull public Location getLocation() { - return location.clone(); // Paper - clone to avoid changes + return this.location.clone(); } /** @@ -50,27 +55,27 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { */ @NotNull public TreeType getSpecies() { - return species; + return this.species; } /** * Checks if structure was grown using bonemeal. * - * @return True if the structure was grown using bonemeal. + * @return {@code true} if the structure was grown using bonemeal. */ public boolean isFromBonemeal() { - return bonemeal; + return this.bonemeal; } /** * Gets the player that created the structure. * - * @return Player that created the structure, null if was not created + * @return Player that created the structure, {@code null} if was not created * manually */ @Nullable public Player getPlayer() { - return player; + return this.player; } /** @@ -80,27 +85,27 @@ public class StructureGrowEvent extends WorldEvent implements Cancellable { */ @NotNull public List getBlocks() { - return blocks; + return this.blocks; } @Override public boolean isCancelled() { - return cancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - cancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/TimeSkipEvent.java b/paper-api/src/main/java/org/bukkit/event/world/TimeSkipEvent.java index cb50cbbb2..0a9134e7e 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/TimeSkipEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/TimeSkipEvent.java @@ -3,6 +3,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -12,12 +13,14 @@ import org.jetbrains.annotations.NotNull; */ public class TimeSkipEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - // - private boolean cancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + private final SkipReason skipReason; private long skipAmount; + private boolean cancelled; + + @ApiStatus.Internal public TimeSkipEvent(@NotNull World world, @NotNull SkipReason skipReason, long skipAmount) { super(world); this.skipReason = skipReason; @@ -31,7 +34,7 @@ public class TimeSkipEvent extends WorldEvent implements Cancellable { */ @NotNull public SkipReason getSkipReason() { - return skipReason; + return this.skipReason; } /** @@ -40,7 +43,7 @@ public class TimeSkipEvent extends WorldEvent implements Cancellable { * @return Amount of time skipped */ public long getSkipAmount() { - return skipAmount; + return this.skipAmount; } /** @@ -65,12 +68,12 @@ public class TimeSkipEvent extends WorldEvent implements Cancellable { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } /** diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java index 6d58b4adb..48c929c6d 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldEvent.java @@ -8,13 +8,14 @@ import org.jetbrains.annotations.NotNull; * Represents events within a world */ public abstract class WorldEvent extends Event { - private final World world; - public WorldEvent(@NotNull final World world) { + protected final World world; + + protected WorldEvent(@NotNull final World world) { this(world, false); } - public WorldEvent(@NotNull World world, boolean isAsync) { + protected WorldEvent(@NotNull World world, boolean isAsync) { super(isAsync); this.world = world; } @@ -26,6 +27,6 @@ public abstract class WorldEvent extends Event { */ @NotNull public World getWorld() { - return world; + return this.world; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java index 2cb1ed0cc..2c1f1683b 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldInitEvent.java @@ -2,6 +2,7 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -11,8 +12,10 @@ import org.jetbrains.annotations.NotNull; *

    load: STARTUP
    */ public class WorldInitEvent extends WorldEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public WorldInitEvent(@NotNull final World world) { super(world); } @@ -20,11 +23,11 @@ public class WorldInitEvent extends WorldEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java index 552e15cd4..8a19bec2c 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldLoadEvent.java @@ -2,14 +2,17 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a World is loaded */ public class WorldLoadEvent extends WorldEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public WorldLoadEvent(@NotNull final World world) { super(world); } @@ -17,11 +20,11 @@ public class WorldLoadEvent extends WorldEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java index 9a9bb1362..50ce1c7ac 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldSaveEvent.java @@ -2,14 +2,17 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a World is saved. */ public class WorldSaveEvent extends WorldEvent { - private static final HandlerList handlers = new HandlerList(); + private static final HandlerList HANDLER_LIST = new HandlerList(); + + @ApiStatus.Internal public WorldSaveEvent(@NotNull final World world) { super(world); } @@ -17,11 +20,11 @@ public class WorldSaveEvent extends WorldEvent { @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java index 8eeeada87..10eed265e 100644 --- a/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/world/WorldUnloadEvent.java @@ -3,37 +3,41 @@ package org.bukkit.event.world; import org.bukkit.World; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** * Called when a World is unloaded */ public class WorldUnloadEvent extends WorldEvent implements Cancellable { - private static final HandlerList handlers = new HandlerList(); - private boolean isCancelled; + private static final HandlerList HANDLER_LIST = new HandlerList(); + + private boolean cancelled; + + @ApiStatus.Internal public WorldUnloadEvent(@NotNull final World world) { super(world); } @Override public boolean isCancelled() { - return this.isCancelled; + return this.cancelled; } @Override public void setCancelled(boolean cancel) { - this.isCancelled = cancel; + this.cancelled = cancel; } @NotNull @Override public HandlerList getHandlers() { - return handlers; + return HANDLER_LIST; } @NotNull public static HandlerList getHandlerList() { - return handlers; + return HANDLER_LIST; } } diff --git a/paper-api/src/main/java/org/bukkit/generator/structure/Structure.java b/paper-api/src/main/java/org/bukkit/generator/structure/Structure.java index 228df69a6..e8a8c70dc 100644 --- a/paper-api/src/main/java/org/bukkit/generator/structure/Structure.java +++ b/paper-api/src/main/java/org/bukkit/generator/structure/Structure.java @@ -16,41 +16,77 @@ import org.jetbrains.annotations.NotNull; */ public abstract class Structure implements Keyed { - public static final Structure PILLAGER_OUTPOST = getStructure("pillager_outpost"); - public static final Structure MINESHAFT = getStructure("mineshaft"); - public static final Structure MINESHAFT_MESA = getStructure("mineshaft_mesa"); - public static final Structure MANSION = getStructure("mansion"); - public static final Structure JUNGLE_PYRAMID = getStructure("jungle_pyramid"); - public static final Structure DESERT_PYRAMID = getStructure("desert_pyramid"); - public static final Structure IGLOO = getStructure("igloo"); - public static final Structure SHIPWRECK = getStructure("shipwreck"); - public static final Structure SHIPWRECK_BEACHED = getStructure("shipwreck_beached"); - public static final Structure SWAMP_HUT = getStructure("swamp_hut"); - public static final Structure STRONGHOLD = getStructure("stronghold"); - public static final Structure MONUMENT = getStructure("monument"); - public static final Structure OCEAN_RUIN_COLD = getStructure("ocean_ruin_cold"); - public static final Structure OCEAN_RUIN_WARM = getStructure("ocean_ruin_warm"); - public static final Structure FORTRESS = getStructure("fortress"); - public static final Structure NETHER_FOSSIL = getStructure("nether_fossil"); - public static final Structure END_CITY = getStructure("end_city"); - public static final Structure BURIED_TREASURE = getStructure("buried_treasure"); - public static final Structure BASTION_REMNANT = getStructure("bastion_remnant"); - public static final Structure VILLAGE_PLAINS = getStructure("village_plains"); - public static final Structure VILLAGE_DESERT = getStructure("village_desert"); - public static final Structure VILLAGE_SAVANNA = getStructure("village_savanna"); - public static final Structure VILLAGE_SNOWY = getStructure("village_snowy"); - public static final Structure VILLAGE_TAIGA = getStructure("village_taiga"); - public static final Structure RUINED_PORTAL = getStructure("ruined_portal"); - public static final Structure RUINED_PORTAL_DESERT = getStructure("ruined_portal_desert"); - public static final Structure RUINED_PORTAL_JUNGLE = getStructure("ruined_portal_jungle"); - public static final Structure RUINED_PORTAL_SWAMP = getStructure("ruined_portal_swamp"); - public static final Structure RUINED_PORTAL_MOUNTAIN = getStructure("ruined_portal_mountain"); - public static final Structure RUINED_PORTAL_OCEAN = getStructure("ruined_portal_ocean"); - public static final Structure RUINED_PORTAL_NETHER = getStructure("ruined_portal_nether"); + // Start generate - Structure + // @GeneratedFrom 1.21.5 public static final Structure ANCIENT_CITY = getStructure("ancient_city"); + + public static final Structure BASTION_REMNANT = getStructure("bastion_remnant"); + + public static final Structure BURIED_TREASURE = getStructure("buried_treasure"); + + public static final Structure DESERT_PYRAMID = getStructure("desert_pyramid"); + + public static final Structure END_CITY = getStructure("end_city"); + + public static final Structure FORTRESS = getStructure("fortress"); + + public static final Structure IGLOO = getStructure("igloo"); + + public static final Structure JUNGLE_PYRAMID = getStructure("jungle_pyramid"); + + public static final Structure MANSION = getStructure("mansion"); + + public static final Structure MINESHAFT = getStructure("mineshaft"); + + public static final Structure MINESHAFT_MESA = getStructure("mineshaft_mesa"); + + public static final Structure MONUMENT = getStructure("monument"); + + public static final Structure NETHER_FOSSIL = getStructure("nether_fossil"); + + public static final Structure OCEAN_RUIN_COLD = getStructure("ocean_ruin_cold"); + + public static final Structure OCEAN_RUIN_WARM = getStructure("ocean_ruin_warm"); + + public static final Structure PILLAGER_OUTPOST = getStructure("pillager_outpost"); + + public static final Structure RUINED_PORTAL = getStructure("ruined_portal"); + + public static final Structure RUINED_PORTAL_DESERT = getStructure("ruined_portal_desert"); + + public static final Structure RUINED_PORTAL_JUNGLE = getStructure("ruined_portal_jungle"); + + public static final Structure RUINED_PORTAL_MOUNTAIN = getStructure("ruined_portal_mountain"); + + public static final Structure RUINED_PORTAL_NETHER = getStructure("ruined_portal_nether"); + + public static final Structure RUINED_PORTAL_OCEAN = getStructure("ruined_portal_ocean"); + + public static final Structure RUINED_PORTAL_SWAMP = getStructure("ruined_portal_swamp"); + + public static final Structure SHIPWRECK = getStructure("shipwreck"); + + public static final Structure SHIPWRECK_BEACHED = getStructure("shipwreck_beached"); + + public static final Structure STRONGHOLD = getStructure("stronghold"); + + public static final Structure SWAMP_HUT = getStructure("swamp_hut"); + public static final Structure TRAIL_RUINS = getStructure("trail_ruins"); + public static final Structure TRIAL_CHAMBERS = getStructure("trial_chambers"); + public static final Structure VILLAGE_DESERT = getStructure("village_desert"); + + public static final Structure VILLAGE_PLAINS = getStructure("village_plains"); + + public static final Structure VILLAGE_SAVANNA = getStructure("village_savanna"); + + public static final Structure VILLAGE_SNOWY = getStructure("village_snowy"); + + public static final Structure VILLAGE_TAIGA = getStructure("village_taiga"); + // End generate - Structure + @NotNull private static Structure getStructure(@NotNull String name) { return RegistryAccess.registryAccess().getRegistry(RegistryKey.STRUCTURE).getOrThrow(NamespacedKey.minecraft(name)); diff --git a/paper-api/src/main/java/org/bukkit/generator/structure/StructureType.java b/paper-api/src/main/java/org/bukkit/generator/structure/StructureType.java index ffa0fc250..11e5c9e23 100644 --- a/paper-api/src/main/java/org/bukkit/generator/structure/StructureType.java +++ b/paper-api/src/main/java/org/bukkit/generator/structure/StructureType.java @@ -15,22 +15,40 @@ import org.jetbrains.annotations.NotNull; */ public abstract class StructureType implements Keyed { + // Start generate - StructureType + // @GeneratedFrom 1.21.5 public static final StructureType BURIED_TREASURE = getStructureType("buried_treasure"); + public static final StructureType DESERT_PYRAMID = getStructureType("desert_pyramid"); + public static final StructureType END_CITY = getStructureType("end_city"); + public static final StructureType FORTRESS = getStructureType("fortress"); + public static final StructureType IGLOO = getStructureType("igloo"); + public static final StructureType JIGSAW = getStructureType("jigsaw"); + public static final StructureType JUNGLE_TEMPLE = getStructureType("jungle_temple"); + public static final StructureType MINESHAFT = getStructureType("mineshaft"); + public static final StructureType NETHER_FOSSIL = getStructureType("nether_fossil"); + public static final StructureType OCEAN_MONUMENT = getStructureType("ocean_monument"); + public static final StructureType OCEAN_RUIN = getStructureType("ocean_ruin"); + public static final StructureType RUINED_PORTAL = getStructureType("ruined_portal"); + public static final StructureType SHIPWRECK = getStructureType("shipwreck"); + public static final StructureType STRONGHOLD = getStructureType("stronghold"); + public static final StructureType SWAMP_HUT = getStructureType("swamp_hut"); + public static final StructureType WOODLAND_MANSION = getStructureType("woodland_mansion"); + // End generate - StructureType @NotNull private static StructureType getStructureType(@NotNull String name) { diff --git a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java index 1bedf9b7e..71d95c164 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlot.java @@ -15,7 +15,11 @@ public enum EquipmentSlot { /** * Only for certain entities such as horses and wolves. */ - BODY(() -> EquipmentSlotGroup.BODY); // Paper - add missing slot type + BODY(() -> EquipmentSlotGroup.BODY), + /** + * Only for certain entities such as pigs, horses and striders. + */ + SADDLE(() -> EquipmentSlotGroup.SADDLE); private final Supplier group; // Supplier because of class loading order, since EquipmentSlot and EquipmentSlotGroup reference each other on class init @@ -33,7 +37,7 @@ public enum EquipmentSlot { public EquipmentSlotGroup getGroup() { return group.get(); } - // Paper start + /** * Checks whether this equipment slot is a hand: * either {@link #HAND} or {@link #OFF_HAND} @@ -70,5 +74,4 @@ public enum EquipmentSlot { public boolean isArmor() { return this == HEAD || this == CHEST || this == LEGS || this == FEET || this == BODY; } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java index 83b5128f9..c2bde1cb8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java +++ b/paper-api/src/main/java/org/bukkit/inventory/EquipmentSlotGroup.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable; public final class EquipmentSlotGroup implements Predicate { private static final Map BY_NAME = new HashMap<>(); - // + public static final EquipmentSlotGroup ANY = get("any", (test) -> true, EquipmentSlot.HAND); public static final EquipmentSlotGroup MAINHAND = get("mainhand", EquipmentSlot.HAND); public static final EquipmentSlotGroup OFFHAND = get("offhand", EquipmentSlot.OFF_HAND); @@ -26,8 +26,9 @@ public final class EquipmentSlotGroup implements Predicate { public static final EquipmentSlotGroup CHEST = get("chest", EquipmentSlot.CHEST); public static final EquipmentSlotGroup HEAD = get("head", EquipmentSlot.HEAD); public static final EquipmentSlotGroup ARMOR = get("armor", (test) -> test == EquipmentSlot.FEET || test == EquipmentSlot.LEGS || test == EquipmentSlot.CHEST || test == EquipmentSlot.HEAD || test == EquipmentSlot.BODY, EquipmentSlot.CHEST); // Paper - add missing slot type - public static final EquipmentSlotGroup BODY = get("body", EquipmentSlot.BODY); // Paper - add missing slot group - // + public static final EquipmentSlotGroup BODY = get("body", EquipmentSlot.BODY); + public static final EquipmentSlotGroup SADDLE = get("saddle", EquipmentSlot.SADDLE); + private final String key; private final Predicate predicate; private final EquipmentSlot example; diff --git a/paper-api/src/main/java/org/bukkit/inventory/Inventory.java b/paper-api/src/main/java/org/bukkit/inventory/Inventory.java index dfcb16dfe..2fa6a5266 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/Inventory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/Inventory.java @@ -400,7 +400,7 @@ public interface Inventory extends Iterable { /** * Gets the block or entity belonging to the open inventory * - * @param useSnapshot Create a snapshot if the holder is a tile entity + * @param useSnapshot Create a snapshot if the holder is a block entity * @return The holder of the inventory; null if it has no holder. */ @Nullable diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java b/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java index 1af15fd32..a23680e2b 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemFlag.java @@ -1,5 +1,7 @@ package org.bukkit.inventory; +import io.papermc.paper.datacomponent.DataComponentType; + /** * A ItemFlag can hide some Attributes from ItemStacks * @apiNote Setting these without also setting the data they are hiding @@ -27,27 +29,6 @@ public enum ItemFlag { * Setting to show/hide where this ItemStack can be build/placed on */ HIDE_PLACED_ON, - /** - * Setting to show/hide potion effects, book and firework information, map - * tooltips, patterns of banners. - * @see #HIDE_STORED_ENCHANTS HIDE_STORED_ENCHANTS for hiding stored enchants (like on enchanted books) - */ - HIDE_ADDITIONAL_TOOLTIP, - /** - * Setting to show/hide dyes from colored leather armor. - */ - HIDE_DYE, - /** - * Setting to show/hide armor trim from armor. - */ - HIDE_ARMOR_TRIM, - /** - * Setting to show/hide stored enchants on an item, such as enchantments - * on an enchanted book. - */ - HIDE_STORED_ENCHANTS, - ; - // Paper start /** * Setting to show/hide item-specific information, including, but not limited to: *
      @@ -65,9 +46,24 @@ public enum ItemFlag { *
    • Shulker box contents
    • *
    • Spawner descriptions
    • *
    - * @deprecated use {@link #HIDE_ADDITIONAL_TOOLTIP} + * + * @see #HIDE_STORED_ENCHANTS HIDE_STORED_ENCHANTS for hiding stored enchants (like on enchanted books) + * @deprecated does not exist anymore and will not properly work with individually hidden data components; see {@link io.papermc.paper.datacomponent.item.TooltipDisplay} and {@link ItemStack#setData(DataComponentType.Valued, Object)} */ - @Deprecated(since = "1.20.5") - public static final ItemFlag HIDE_ITEM_SPECIFICS = HIDE_ADDITIONAL_TOOLTIP; - // Paper end + @Deprecated + HIDE_ADDITIONAL_TOOLTIP, + /** + * Setting to show/hide dyes from colored leather armor. + */ + HIDE_DYE, + /** + * Setting to show/hide armor trim from armor. + */ + HIDE_ARMOR_TRIM, + /** + * Setting to show/hide stored enchants on an item, such as enchantments + * on an enchanted book. + */ + HIDE_STORED_ENCHANTS, + ; } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemRarity.java b/paper-api/src/main/java/org/bukkit/inventory/ItemRarity.java index cbce835ed..3547e1578 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemRarity.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemRarity.java @@ -1,29 +1,24 @@ package org.bukkit.inventory; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextColor; + /** - * A item's rarity determines the default color of its name. This enum is + * An item's rarity determines the default color of its name. This enum is * ordered from least rare to most rare. */ public enum ItemRarity { - /** - * White item name. - */ - COMMON(net.kyori.adventure.text.format.NamedTextColor.WHITE), // Paper - /** - * Yellow item name. - */ - UNCOMMON(net.kyori.adventure.text.format.NamedTextColor.YELLOW), // Paper - /** - * Aqua item name. - */ - RARE(net.kyori.adventure.text.format.NamedTextColor.AQUA), // Paper - /** - * Light purple item name. - */ - EPIC(net.kyori.adventure.text.format.NamedTextColor.LIGHT_PURPLE); // Paper - // Paper start - improve ItemRarity + // Start generate - ItemRarity + // @GeneratedFrom 1.21.5 + COMMON(NamedTextColor.WHITE), + UNCOMMON(NamedTextColor.YELLOW), + RARE(NamedTextColor.AQUA), + EPIC(NamedTextColor.LIGHT_PURPLE); + // End generate - ItemRarity + private final net.kyori.adventure.text.format.NamedTextColor color; + ItemRarity(final net.kyori.adventure.text.format.NamedTextColor color) { this.color = color; } @@ -33,8 +28,7 @@ public enum ItemRarity { * * @return the color */ - public net.kyori.adventure.text.format.@org.jetbrains.annotations.NotNull TextColor color() { + public @org.jetbrains.annotations.NotNull TextColor color() { return this.color; } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java index aad9b078a..3179607e8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemStack.java @@ -1,6 +1,7 @@ package org.bukkit.inventory; import com.google.common.base.Preconditions; +import io.papermc.paper.datacomponent.DataComponentHolder; import io.papermc.paper.registry.RegistryKey; import java.util.LinkedHashMap; import java.util.Locale; @@ -30,7 +31,7 @@ import org.jetbrains.annotations.Nullable; * use this class to encapsulate Materials for which {@link Material#isItem()} * returns false.
    */ -public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.translation.Translatable, io.papermc.paper.persistence.PersistentDataViewHolder { // Paper +public class ItemStack implements Cloneable, ConfigurationSerializable, Translatable, net.kyori.adventure.text.event.HoverEventSource, net.kyori.adventure.translation.Translatable, io.papermc.paper.persistence.PersistentDataViewHolder, DataComponentHolder { // Paper private ItemStack craftDelegate; // Paper - always delegate to server-backed stack private MaterialData data = null; @@ -370,21 +371,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat /** * Checks if this ItemStack contains the given {@link Enchantment} * - * @param ench Enchantment to test + * @param enchant Enchantment to test * @return True if this has the given enchantment */ - public boolean containsEnchantment(@NotNull Enchantment ench) { - return this.craftDelegate.containsEnchantment(ench); // Paper - delegate + public boolean containsEnchantment(@NotNull Enchantment enchant) { + return this.craftDelegate.containsEnchantment(enchant); // Paper - delegate } /** * Gets the level of the specified enchantment on this item stack * - * @param ench Enchantment to check + * @param enchant Enchantment to check * @return Level of the enchantment, or 0 */ - public int getEnchantmentLevel(@NotNull Enchantment ench) { - return this.craftDelegate.getEnchantmentLevel(ench); // Paper - delegate + public int getEnchantmentLevel(@NotNull Enchantment enchant) { + return this.craftDelegate.getEnchantmentLevel(enchant); // Paper - delegate } /** @@ -424,21 +425,21 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat * If this item stack already contained the given enchantment (at any * level), it will be replaced. * - * @param ench Enchantment to add + * @param enchant Enchantment to add * @param level Level of the enchantment * @throws IllegalArgumentException if enchantment null, or enchantment is * not applicable */ @Utility - public void addEnchantment(@NotNull Enchantment ench, int level) { - Preconditions.checkArgument(ench != null, "Enchantment cannot be null"); - if ((level < ench.getStartLevel()) || (level > ench.getMaxLevel())) { - throw new IllegalArgumentException("Enchantment level is either too low or too high (given " + level + ", bounds are " + ench.getStartLevel() + " to " + ench.getMaxLevel() + ")"); - } else if (!ench.canEnchantItem(this)) { + public void addEnchantment(@NotNull Enchantment enchant, int level) { + Preconditions.checkArgument(enchant != null, "Enchantment cannot be null"); + if ((level < enchant.getStartLevel()) || (level > enchant.getMaxLevel())) { + throw new IllegalArgumentException("Enchantment level is either too low or too high (given " + level + ", bounds are " + enchant.getStartLevel() + " to " + enchant.getMaxLevel() + ")"); + } else if (!enchant.canEnchantItem(this)) { throw new IllegalArgumentException("Specified enchantment cannot be applied to this itemstack"); } - addUnsafeEnchantment(ench, level); + addUnsafeEnchantment(enchant, level); } /** @@ -466,22 +467,22 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat * This method is unsafe and will ignore level restrictions or item type. * Use at your own discretion. * - * @param ench Enchantment to add + * @param enchant Enchantment to add * @param level Level of the enchantment */ - public void addUnsafeEnchantment(@NotNull Enchantment ench, int level) { - this.craftDelegate.addUnsafeEnchantment(ench, level); // Paper - delegate + public void addUnsafeEnchantment(@NotNull Enchantment enchant, int level) { + this.craftDelegate.addUnsafeEnchantment(enchant, level); // Paper - delegate } /** * Removes the specified {@link Enchantment} if it exists on this * ItemStack * - * @param ench Enchantment to remove + * @param enchant Enchantment to remove * @return Previous level, or 0 */ - public int removeEnchantment(@NotNull Enchantment ench) { - return this.craftDelegate.removeEnchantment(ench); // Paper - delegate + public int removeEnchantment(@NotNull Enchantment enchant) { + return this.craftDelegate.removeEnchantment(enchant); // Paper - delegate } /** @@ -495,21 +496,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat @NotNull @Utility public Map serialize() { - Map result = new LinkedHashMap(); - - result.put("v", Bukkit.getUnsafe().getDataVersion()); // Include version to indicate we are using modern material names (or LEGACY prefix) - result.put("type", getType().name()); - - if (getAmount() != 1) { - result.put("amount", getAmount()); - } - - ItemMeta meta = getItemMeta(); - if (!Bukkit.getItemFactory().equals(meta, null)) { - result.put("meta", meta); - } - - return result; + return Bukkit.getUnsafe().serializeStack(this); } /** @@ -521,6 +508,11 @@ public class ItemStack implements Cloneable, ConfigurationSerializable, Translat */ @NotNull public static ItemStack deserialize(@NotNull Map args) { + // Parse internally, if schema_version is not defined, assume legacy and fall through to unsafe legacy deserialization logic + if (args.containsKey("schema_version")) { + return org.bukkit.Bukkit.getUnsafe().deserializeStack(args); + } + int version = (args.containsKey("v")) ? ((Number) args.get("v")).intValue() : -1; short damage = 0; int amount = 1; diff --git a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java index 6389f7610..23f8747d8 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/ItemType.java +++ b/paper-api/src/main/java/org/bukkit/inventory/ItemType.java @@ -89,2138 +89,2800 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans } // - /** - * Air does not have any ItemMeta - */ - ItemType AIR = getItemType("air"); - ItemType.Typed STONE = getItemType("stone"); - ItemType.Typed GRANITE = getItemType("granite"); - ItemType.Typed POLISHED_GRANITE = getItemType("polished_granite"); - ItemType.Typed DIORITE = getItemType("diorite"); - ItemType.Typed POLISHED_DIORITE = getItemType("polished_diorite"); - ItemType.Typed ANDESITE = getItemType("andesite"); - ItemType.Typed POLISHED_ANDESITE = getItemType("polished_andesite"); - ItemType.Typed DEEPSLATE = getItemType("deepslate"); - ItemType.Typed COBBLED_DEEPSLATE = getItemType("cobbled_deepslate"); - ItemType.Typed POLISHED_DEEPSLATE = getItemType("polished_deepslate"); - ItemType.Typed CALCITE = getItemType("calcite"); - ItemType.Typed TUFF = getItemType("tuff"); - ItemType.Typed TUFF_SLAB = getItemType("tuff_slab"); - ItemType.Typed TUFF_STAIRS = getItemType("tuff_stairs"); - ItemType.Typed TUFF_WALL = getItemType("tuff_wall"); - ItemType.Typed CHISELED_TUFF = getItemType("chiseled_tuff"); - ItemType.Typed POLISHED_TUFF = getItemType("polished_tuff"); - ItemType.Typed POLISHED_TUFF_SLAB = getItemType("polished_tuff_slab"); - ItemType.Typed POLISHED_TUFF_STAIRS = getItemType("polished_tuff_stairs"); - ItemType.Typed POLISHED_TUFF_WALL = getItemType("polished_tuff_wall"); - ItemType.Typed TUFF_BRICKS = getItemType("tuff_bricks"); - ItemType.Typed TUFF_BRICK_SLAB = getItemType("tuff_brick_slab"); - ItemType.Typed TUFF_BRICK_STAIRS = getItemType("tuff_brick_stairs"); - ItemType.Typed TUFF_BRICK_WALL = getItemType("tuff_brick_wall"); - ItemType.Typed CHISELED_TUFF_BRICKS = getItemType("chiseled_tuff_bricks"); - ItemType.Typed DRIPSTONE_BLOCK = getItemType("dripstone_block"); - ItemType.Typed GRASS_BLOCK = getItemType("grass_block"); - ItemType.Typed DIRT = getItemType("dirt"); - ItemType.Typed COARSE_DIRT = getItemType("coarse_dirt"); - ItemType.Typed PODZOL = getItemType("podzol"); - ItemType.Typed ROOTED_DIRT = getItemType("rooted_dirt"); - ItemType.Typed MUD = getItemType("mud"); - ItemType.Typed CRIMSON_NYLIUM = getItemType("crimson_nylium"); - ItemType.Typed WARPED_NYLIUM = getItemType("warped_nylium"); - ItemType.Typed COBBLESTONE = getItemType("cobblestone"); - ItemType.Typed OAK_PLANKS = getItemType("oak_planks"); - ItemType.Typed SPRUCE_PLANKS = getItemType("spruce_planks"); - ItemType.Typed BIRCH_PLANKS = getItemType("birch_planks"); - ItemType.Typed JUNGLE_PLANKS = getItemType("jungle_planks"); - ItemType.Typed ACACIA_PLANKS = getItemType("acacia_planks"); - ItemType.Typed CHERRY_PLANKS = getItemType("cherry_planks"); - ItemType.Typed DARK_OAK_PLANKS = getItemType("dark_oak_planks"); - ItemType.Typed PALE_OAK_PLANKS = getItemType("pale_oak_planks"); - ItemType.Typed MANGROVE_PLANKS = getItemType("mangrove_planks"); - ItemType.Typed BAMBOO_PLANKS = getItemType("bamboo_planks"); - ItemType.Typed CRIMSON_PLANKS = getItemType("crimson_planks"); - ItemType.Typed WARPED_PLANKS = getItemType("warped_planks"); - ItemType.Typed BAMBOO_MOSAIC = getItemType("bamboo_mosaic"); - ItemType.Typed OAK_SAPLING = getItemType("oak_sapling"); - ItemType.Typed SPRUCE_SAPLING = getItemType("spruce_sapling"); - ItemType.Typed BIRCH_SAPLING = getItemType("birch_sapling"); - ItemType.Typed JUNGLE_SAPLING = getItemType("jungle_sapling"); - ItemType.Typed ACACIA_SAPLING = getItemType("acacia_sapling"); - ItemType.Typed CHERRY_SAPLING = getItemType("cherry_sapling"); - ItemType.Typed DARK_OAK_SAPLING = getItemType("dark_oak_sapling"); - ItemType.Typed PALE_OAK_SAPLING = getItemType("pale_oak_sapling"); - ItemType.Typed MANGROVE_PROPAGULE = getItemType("mangrove_propagule"); - ItemType.Typed BEDROCK = getItemType("bedrock"); - ItemType.Typed SAND = getItemType("sand"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SUSPICIOUS_SAND = getItemType("suspicious_sand"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SUSPICIOUS_GRAVEL = getItemType("suspicious_gravel"); - ItemType.Typed RED_SAND = getItemType("red_sand"); - ItemType.Typed GRAVEL = getItemType("gravel"); - ItemType.Typed COAL_ORE = getItemType("coal_ore"); - ItemType.Typed DEEPSLATE_COAL_ORE = getItemType("deepslate_coal_ore"); - ItemType.Typed IRON_ORE = getItemType("iron_ore"); - ItemType.Typed DEEPSLATE_IRON_ORE = getItemType("deepslate_iron_ore"); - ItemType.Typed COPPER_ORE = getItemType("copper_ore"); - ItemType.Typed DEEPSLATE_COPPER_ORE = getItemType("deepslate_copper_ore"); - ItemType.Typed GOLD_ORE = getItemType("gold_ore"); - ItemType.Typed DEEPSLATE_GOLD_ORE = getItemType("deepslate_gold_ore"); - ItemType.Typed REDSTONE_ORE = getItemType("redstone_ore"); - ItemType.Typed DEEPSLATE_REDSTONE_ORE = getItemType("deepslate_redstone_ore"); - ItemType.Typed EMERALD_ORE = getItemType("emerald_ore"); - ItemType.Typed DEEPSLATE_EMERALD_ORE = getItemType("deepslate_emerald_ore"); - ItemType.Typed LAPIS_ORE = getItemType("lapis_ore"); - ItemType.Typed DEEPSLATE_LAPIS_ORE = getItemType("deepslate_lapis_ore"); - ItemType.Typed DIAMOND_ORE = getItemType("diamond_ore"); - ItemType.Typed DEEPSLATE_DIAMOND_ORE = getItemType("deepslate_diamond_ore"); - ItemType.Typed NETHER_GOLD_ORE = getItemType("nether_gold_ore"); - ItemType.Typed NETHER_QUARTZ_ORE = getItemType("nether_quartz_ore"); - ItemType.Typed ANCIENT_DEBRIS = getItemType("ancient_debris"); - ItemType.Typed COAL_BLOCK = getItemType("coal_block"); - ItemType.Typed RAW_IRON_BLOCK = getItemType("raw_iron_block"); - ItemType.Typed RAW_COPPER_BLOCK = getItemType("raw_copper_block"); - ItemType.Typed RAW_GOLD_BLOCK = getItemType("raw_gold_block"); - ItemType.Typed HEAVY_CORE = getItemType("heavy_core"); - ItemType.Typed AMETHYST_BLOCK = getItemType("amethyst_block"); - ItemType.Typed BUDDING_AMETHYST = getItemType("budding_amethyst"); - ItemType.Typed IRON_BLOCK = getItemType("iron_block"); - ItemType.Typed COPPER_BLOCK = getItemType("copper_block"); - ItemType.Typed GOLD_BLOCK = getItemType("gold_block"); - ItemType.Typed DIAMOND_BLOCK = getItemType("diamond_block"); - ItemType.Typed NETHERITE_BLOCK = getItemType("netherite_block"); - ItemType.Typed EXPOSED_COPPER = getItemType("exposed_copper"); - ItemType.Typed WEATHERED_COPPER = getItemType("weathered_copper"); - ItemType.Typed OXIDIZED_COPPER = getItemType("oxidized_copper"); - ItemType.Typed CHISELED_COPPER = getItemType("chiseled_copper"); - ItemType.Typed EXPOSED_CHISELED_COPPER = getItemType("exposed_chiseled_copper"); - ItemType.Typed WEATHERED_CHISELED_COPPER = getItemType("weathered_chiseled_copper"); - ItemType.Typed OXIDIZED_CHISELED_COPPER = getItemType("oxidized_chiseled_copper"); - ItemType.Typed CUT_COPPER = getItemType("cut_copper"); - ItemType.Typed EXPOSED_CUT_COPPER = getItemType("exposed_cut_copper"); - ItemType.Typed WEATHERED_CUT_COPPER = getItemType("weathered_cut_copper"); - ItemType.Typed OXIDIZED_CUT_COPPER = getItemType("oxidized_cut_copper"); - ItemType.Typed CUT_COPPER_STAIRS = getItemType("cut_copper_stairs"); - ItemType.Typed EXPOSED_CUT_COPPER_STAIRS = getItemType("exposed_cut_copper_stairs"); - ItemType.Typed WEATHERED_CUT_COPPER_STAIRS = getItemType("weathered_cut_copper_stairs"); - ItemType.Typed OXIDIZED_CUT_COPPER_STAIRS = getItemType("oxidized_cut_copper_stairs"); - ItemType.Typed CUT_COPPER_SLAB = getItemType("cut_copper_slab"); - ItemType.Typed EXPOSED_CUT_COPPER_SLAB = getItemType("exposed_cut_copper_slab"); - ItemType.Typed WEATHERED_CUT_COPPER_SLAB = getItemType("weathered_cut_copper_slab"); - ItemType.Typed OXIDIZED_CUT_COPPER_SLAB = getItemType("oxidized_cut_copper_slab"); - ItemType.Typed WAXED_COPPER_BLOCK = getItemType("waxed_copper_block"); - ItemType.Typed WAXED_EXPOSED_COPPER = getItemType("waxed_exposed_copper"); - ItemType.Typed WAXED_WEATHERED_COPPER = getItemType("waxed_weathered_copper"); - ItemType.Typed WAXED_OXIDIZED_COPPER = getItemType("waxed_oxidized_copper"); - ItemType.Typed WAXED_CHISELED_COPPER = getItemType("waxed_chiseled_copper"); - ItemType.Typed WAXED_EXPOSED_CHISELED_COPPER = getItemType("waxed_exposed_chiseled_copper"); - ItemType.Typed WAXED_WEATHERED_CHISELED_COPPER = getItemType("waxed_weathered_chiseled_copper"); - ItemType.Typed WAXED_OXIDIZED_CHISELED_COPPER = getItemType("waxed_oxidized_chiseled_copper"); - ItemType.Typed WAXED_CUT_COPPER = getItemType("waxed_cut_copper"); - ItemType.Typed WAXED_EXPOSED_CUT_COPPER = getItemType("waxed_exposed_cut_copper"); - ItemType.Typed WAXED_WEATHERED_CUT_COPPER = getItemType("waxed_weathered_cut_copper"); - ItemType.Typed WAXED_OXIDIZED_CUT_COPPER = getItemType("waxed_oxidized_cut_copper"); - ItemType.Typed WAXED_CUT_COPPER_STAIRS = getItemType("waxed_cut_copper_stairs"); - ItemType.Typed WAXED_EXPOSED_CUT_COPPER_STAIRS = getItemType("waxed_exposed_cut_copper_stairs"); - ItemType.Typed WAXED_WEATHERED_CUT_COPPER_STAIRS = getItemType("waxed_weathered_cut_copper_stairs"); - ItemType.Typed WAXED_OXIDIZED_CUT_COPPER_STAIRS = getItemType("waxed_oxidized_cut_copper_stairs"); - ItemType.Typed WAXED_CUT_COPPER_SLAB = getItemType("waxed_cut_copper_slab"); - ItemType.Typed WAXED_EXPOSED_CUT_COPPER_SLAB = getItemType("waxed_exposed_cut_copper_slab"); - ItemType.Typed WAXED_WEATHERED_CUT_COPPER_SLAB = getItemType("waxed_weathered_cut_copper_slab"); - ItemType.Typed WAXED_OXIDIZED_CUT_COPPER_SLAB = getItemType("waxed_oxidized_cut_copper_slab"); - ItemType.Typed OAK_LOG = getItemType("oak_log"); - ItemType.Typed SPRUCE_LOG = getItemType("spruce_log"); - ItemType.Typed BIRCH_LOG = getItemType("birch_log"); - ItemType.Typed JUNGLE_LOG = getItemType("jungle_log"); - ItemType.Typed ACACIA_LOG = getItemType("acacia_log"); - ItemType.Typed CHERRY_LOG = getItemType("cherry_log"); - ItemType.Typed DARK_OAK_LOG = getItemType("dark_oak_log"); - ItemType.Typed PALE_OAK_LOG = getItemType("pale_oak_log"); - ItemType.Typed MANGROVE_LOG = getItemType("mangrove_log"); - ItemType.Typed MANGROVE_ROOTS = getItemType("mangrove_roots"); - ItemType.Typed MUDDY_MANGROVE_ROOTS = getItemType("muddy_mangrove_roots"); - ItemType.Typed CRIMSON_STEM = getItemType("crimson_stem"); - ItemType.Typed WARPED_STEM = getItemType("warped_stem"); - ItemType.Typed BAMBOO_BLOCK = getItemType("bamboo_block"); - ItemType.Typed STRIPPED_OAK_LOG = getItemType("stripped_oak_log"); - ItemType.Typed STRIPPED_SPRUCE_LOG = getItemType("stripped_spruce_log"); - ItemType.Typed STRIPPED_BIRCH_LOG = getItemType("stripped_birch_log"); - ItemType.Typed STRIPPED_JUNGLE_LOG = getItemType("stripped_jungle_log"); - ItemType.Typed STRIPPED_ACACIA_LOG = getItemType("stripped_acacia_log"); - ItemType.Typed STRIPPED_CHERRY_LOG = getItemType("stripped_cherry_log"); - ItemType.Typed STRIPPED_DARK_OAK_LOG = getItemType("stripped_dark_oak_log"); - ItemType.Typed STRIPPED_PALE_OAK_LOG = getItemType("stripped_pale_oak_log"); - ItemType.Typed STRIPPED_MANGROVE_LOG = getItemType("stripped_mangrove_log"); - ItemType.Typed STRIPPED_CRIMSON_STEM = getItemType("stripped_crimson_stem"); - ItemType.Typed STRIPPED_WARPED_STEM = getItemType("stripped_warped_stem"); - ItemType.Typed STRIPPED_OAK_WOOD = getItemType("stripped_oak_wood"); - ItemType.Typed STRIPPED_SPRUCE_WOOD = getItemType("stripped_spruce_wood"); - ItemType.Typed STRIPPED_BIRCH_WOOD = getItemType("stripped_birch_wood"); - ItemType.Typed STRIPPED_JUNGLE_WOOD = getItemType("stripped_jungle_wood"); - ItemType.Typed STRIPPED_ACACIA_WOOD = getItemType("stripped_acacia_wood"); - ItemType.Typed STRIPPED_CHERRY_WOOD = getItemType("stripped_cherry_wood"); - ItemType.Typed STRIPPED_DARK_OAK_WOOD = getItemType("stripped_dark_oak_wood"); - ItemType.Typed STRIPPED_PALE_OAK_WOOD = getItemType("stripped_pale_oak_wood"); - ItemType.Typed STRIPPED_MANGROVE_WOOD = getItemType("stripped_mangrove_wood"); - ItemType.Typed STRIPPED_CRIMSON_HYPHAE = getItemType("stripped_crimson_hyphae"); - ItemType.Typed STRIPPED_WARPED_HYPHAE = getItemType("stripped_warped_hyphae"); - ItemType.Typed STRIPPED_BAMBOO_BLOCK = getItemType("stripped_bamboo_block"); - ItemType.Typed OAK_WOOD = getItemType("oak_wood"); - ItemType.Typed SPRUCE_WOOD = getItemType("spruce_wood"); - ItemType.Typed BIRCH_WOOD = getItemType("birch_wood"); - ItemType.Typed JUNGLE_WOOD = getItemType("jungle_wood"); - ItemType.Typed ACACIA_WOOD = getItemType("acacia_wood"); - ItemType.Typed CHERRY_WOOD = getItemType("cherry_wood"); - ItemType.Typed DARK_OAK_WOOD = getItemType("dark_oak_wood"); - ItemType.Typed PALE_OAK_WOOD = getItemType("pale_oak_wood"); - ItemType.Typed MANGROVE_WOOD = getItemType("mangrove_wood"); - ItemType.Typed CRIMSON_HYPHAE = getItemType("crimson_hyphae"); - ItemType.Typed WARPED_HYPHAE = getItemType("warped_hyphae"); - ItemType.Typed OAK_LEAVES = getItemType("oak_leaves"); - ItemType.Typed SPRUCE_LEAVES = getItemType("spruce_leaves"); - ItemType.Typed BIRCH_LEAVES = getItemType("birch_leaves"); - ItemType.Typed JUNGLE_LEAVES = getItemType("jungle_leaves"); - ItemType.Typed ACACIA_LEAVES = getItemType("acacia_leaves"); - ItemType.Typed CHERRY_LEAVES = getItemType("cherry_leaves"); - ItemType.Typed DARK_OAK_LEAVES = getItemType("dark_oak_leaves"); - ItemType.Typed PALE_OAK_LEAVES = getItemType("pale_oak_leaves"); - ItemType.Typed MANGROVE_LEAVES = getItemType("mangrove_leaves"); - ItemType.Typed AZALEA_LEAVES = getItemType("azalea_leaves"); - ItemType.Typed FLOWERING_AZALEA_LEAVES = getItemType("flowering_azalea_leaves"); - ItemType.Typed SPONGE = getItemType("sponge"); - ItemType.Typed WET_SPONGE = getItemType("wet_sponge"); - ItemType.Typed GLASS = getItemType("glass"); - ItemType.Typed TINTED_GLASS = getItemType("tinted_glass"); - ItemType.Typed LAPIS_BLOCK = getItemType("lapis_block"); - ItemType.Typed SANDSTONE = getItemType("sandstone"); - ItemType.Typed CHISELED_SANDSTONE = getItemType("chiseled_sandstone"); - ItemType.Typed CUT_SANDSTONE = getItemType("cut_sandstone"); - ItemType.Typed COBWEB = getItemType("cobweb"); - ItemType.Typed SHORT_GRASS = getItemType("short_grass"); - ItemType.Typed FERN = getItemType("fern"); - ItemType.Typed AZALEA = getItemType("azalea"); - ItemType.Typed FLOWERING_AZALEA = getItemType("flowering_azalea"); - ItemType.Typed DEAD_BUSH = getItemType("dead_bush"); - ItemType.Typed SEAGRASS = getItemType("seagrass"); - ItemType.Typed SEA_PICKLE = getItemType("sea_pickle"); - ItemType.Typed WHITE_WOOL = getItemType("white_wool"); - ItemType.Typed ORANGE_WOOL = getItemType("orange_wool"); - ItemType.Typed MAGENTA_WOOL = getItemType("magenta_wool"); - ItemType.Typed LIGHT_BLUE_WOOL = getItemType("light_blue_wool"); - ItemType.Typed YELLOW_WOOL = getItemType("yellow_wool"); - ItemType.Typed LIME_WOOL = getItemType("lime_wool"); - ItemType.Typed PINK_WOOL = getItemType("pink_wool"); - ItemType.Typed GRAY_WOOL = getItemType("gray_wool"); - ItemType.Typed LIGHT_GRAY_WOOL = getItemType("light_gray_wool"); - ItemType.Typed CYAN_WOOL = getItemType("cyan_wool"); - ItemType.Typed PURPLE_WOOL = getItemType("purple_wool"); - ItemType.Typed BLUE_WOOL = getItemType("blue_wool"); - ItemType.Typed BROWN_WOOL = getItemType("brown_wool"); - ItemType.Typed GREEN_WOOL = getItemType("green_wool"); - ItemType.Typed RED_WOOL = getItemType("red_wool"); - ItemType.Typed BLACK_WOOL = getItemType("black_wool"); - ItemType.Typed DANDELION = getItemType("dandelion"); - ItemType.Typed OPEN_EYEBLOSSOM = getItemType("open_eyeblossom"); - ItemType.Typed CLOSED_EYEBLOSSOM = getItemType("closed_eyeblossom"); - ItemType.Typed POPPY = getItemType("poppy"); - ItemType.Typed BLUE_ORCHID = getItemType("blue_orchid"); - ItemType.Typed ALLIUM = getItemType("allium"); - ItemType.Typed AZURE_BLUET = getItemType("azure_bluet"); - ItemType.Typed RED_TULIP = getItemType("red_tulip"); - ItemType.Typed ORANGE_TULIP = getItemType("orange_tulip"); - ItemType.Typed WHITE_TULIP = getItemType("white_tulip"); - ItemType.Typed PINK_TULIP = getItemType("pink_tulip"); - ItemType.Typed OXEYE_DAISY = getItemType("oxeye_daisy"); - ItemType.Typed CORNFLOWER = getItemType("cornflower"); - ItemType.Typed LILY_OF_THE_VALLEY = getItemType("lily_of_the_valley"); - ItemType.Typed WITHER_ROSE = getItemType("wither_rose"); - ItemType.Typed TORCHFLOWER = getItemType("torchflower"); - ItemType.Typed PITCHER_PLANT = getItemType("pitcher_plant"); - ItemType.Typed SPORE_BLOSSOM = getItemType("spore_blossom"); - ItemType.Typed BROWN_MUSHROOM = getItemType("brown_mushroom"); - ItemType.Typed RED_MUSHROOM = getItemType("red_mushroom"); - ItemType.Typed CRIMSON_FUNGUS = getItemType("crimson_fungus"); - ItemType.Typed WARPED_FUNGUS = getItemType("warped_fungus"); - ItemType.Typed CRIMSON_ROOTS = getItemType("crimson_roots"); - ItemType.Typed WARPED_ROOTS = getItemType("warped_roots"); - ItemType.Typed NETHER_SPROUTS = getItemType("nether_sprouts"); - ItemType.Typed WEEPING_VINES = getItemType("weeping_vines"); - ItemType.Typed TWISTING_VINES = getItemType("twisting_vines"); - ItemType.Typed SUGAR_CANE = getItemType("sugar_cane"); - ItemType.Typed KELP = getItemType("kelp"); - ItemType.Typed PINK_PETALS = getItemType("pink_petals"); - ItemType.Typed MOSS_CARPET = getItemType("moss_carpet"); - ItemType.Typed MOSS_BLOCK = getItemType("moss_block"); - ItemType.Typed PALE_MOSS_CARPET = getItemType("pale_moss_carpet"); - ItemType.Typed PALE_HANGING_MOSS = getItemType("pale_hanging_moss"); - ItemType.Typed PALE_MOSS_BLOCK = getItemType("pale_moss_block"); - ItemType.Typed HANGING_ROOTS = getItemType("hanging_roots"); - ItemType.Typed BIG_DRIPLEAF = getItemType("big_dripleaf"); - ItemType.Typed SMALL_DRIPLEAF = getItemType("small_dripleaf"); - ItemType.Typed BAMBOO = getItemType("bamboo"); - ItemType.Typed OAK_SLAB = getItemType("oak_slab"); - ItemType.Typed SPRUCE_SLAB = getItemType("spruce_slab"); - ItemType.Typed BIRCH_SLAB = getItemType("birch_slab"); - ItemType.Typed JUNGLE_SLAB = getItemType("jungle_slab"); - ItemType.Typed ACACIA_SLAB = getItemType("acacia_slab"); - ItemType.Typed CHERRY_SLAB = getItemType("cherry_slab"); - ItemType.Typed DARK_OAK_SLAB = getItemType("dark_oak_slab"); - ItemType.Typed PALE_OAK_SLAB = getItemType("pale_oak_slab"); - ItemType.Typed MANGROVE_SLAB = getItemType("mangrove_slab"); - ItemType.Typed BAMBOO_SLAB = getItemType("bamboo_slab"); - ItemType.Typed BAMBOO_MOSAIC_SLAB = getItemType("bamboo_mosaic_slab"); - ItemType.Typed CRIMSON_SLAB = getItemType("crimson_slab"); - ItemType.Typed WARPED_SLAB = getItemType("warped_slab"); - ItemType.Typed STONE_SLAB = getItemType("stone_slab"); - ItemType.Typed SMOOTH_STONE_SLAB = getItemType("smooth_stone_slab"); - ItemType.Typed SANDSTONE_SLAB = getItemType("sandstone_slab"); - ItemType.Typed CUT_SANDSTONE_SLAB = getItemType("cut_sandstone_slab"); - ItemType.Typed PETRIFIED_OAK_SLAB = getItemType("petrified_oak_slab"); - ItemType.Typed COBBLESTONE_SLAB = getItemType("cobblestone_slab"); - ItemType.Typed BRICK_SLAB = getItemType("brick_slab"); - ItemType.Typed STONE_BRICK_SLAB = getItemType("stone_brick_slab"); - ItemType.Typed MUD_BRICK_SLAB = getItemType("mud_brick_slab"); - ItemType.Typed NETHER_BRICK_SLAB = getItemType("nether_brick_slab"); - ItemType.Typed QUARTZ_SLAB = getItemType("quartz_slab"); - ItemType.Typed RED_SANDSTONE_SLAB = getItemType("red_sandstone_slab"); - ItemType.Typed CUT_RED_SANDSTONE_SLAB = getItemType("cut_red_sandstone_slab"); - ItemType.Typed PURPUR_SLAB = getItemType("purpur_slab"); - ItemType.Typed PRISMARINE_SLAB = getItemType("prismarine_slab"); - ItemType.Typed PRISMARINE_BRICK_SLAB = getItemType("prismarine_brick_slab"); - ItemType.Typed DARK_PRISMARINE_SLAB = getItemType("dark_prismarine_slab"); - ItemType.Typed SMOOTH_QUARTZ = getItemType("smooth_quartz"); - ItemType.Typed SMOOTH_RED_SANDSTONE = getItemType("smooth_red_sandstone"); - ItemType.Typed SMOOTH_SANDSTONE = getItemType("smooth_sandstone"); - ItemType.Typed SMOOTH_STONE = getItemType("smooth_stone"); - ItemType.Typed BRICKS = getItemType("bricks"); - ItemType.Typed BOOKSHELF = getItemType("bookshelf"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CHISELED_BOOKSHELF = getItemType("chiseled_bookshelf"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DECORATED_POT = getItemType("decorated_pot"); - ItemType.Typed MOSSY_COBBLESTONE = getItemType("mossy_cobblestone"); - ItemType.Typed OBSIDIAN = getItemType("obsidian"); - ItemType.Typed TORCH = getItemType("torch"); - ItemType.Typed END_ROD = getItemType("end_rod"); - ItemType.Typed CHORUS_PLANT = getItemType("chorus_plant"); - ItemType.Typed CHORUS_FLOWER = getItemType("chorus_flower"); - ItemType.Typed PURPUR_BLOCK = getItemType("purpur_block"); - ItemType.Typed PURPUR_PILLAR = getItemType("purpur_pillar"); - ItemType.Typed PURPUR_STAIRS = getItemType("purpur_stairs"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SPAWNER = getItemType("spawner"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CREAKING_HEART = getItemType("creaking_heart"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CHEST = getItemType("chest"); - ItemType.Typed CRAFTING_TABLE = getItemType("crafting_table"); - ItemType.Typed FARMLAND = getItemType("farmland"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed FURNACE = getItemType("furnace"); - ItemType.Typed LADDER = getItemType("ladder"); - ItemType.Typed COBBLESTONE_STAIRS = getItemType("cobblestone_stairs"); - ItemType.Typed SNOW = getItemType("snow"); - ItemType.Typed ICE = getItemType("ice"); - ItemType.Typed SNOW_BLOCK = getItemType("snow_block"); - ItemType.Typed CACTUS = getItemType("cactus"); - ItemType.Typed CLAY = getItemType("clay"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed JUKEBOX = getItemType("jukebox"); - ItemType.Typed OAK_FENCE = getItemType("oak_fence"); - ItemType.Typed SPRUCE_FENCE = getItemType("spruce_fence"); - ItemType.Typed BIRCH_FENCE = getItemType("birch_fence"); - ItemType.Typed JUNGLE_FENCE = getItemType("jungle_fence"); - ItemType.Typed ACACIA_FENCE = getItemType("acacia_fence"); - ItemType.Typed CHERRY_FENCE = getItemType("cherry_fence"); - ItemType.Typed DARK_OAK_FENCE = getItemType("dark_oak_fence"); - ItemType.Typed PALE_OAK_FENCE = getItemType("pale_oak_fence"); - ItemType.Typed MANGROVE_FENCE = getItemType("mangrove_fence"); - ItemType.Typed BAMBOO_FENCE = getItemType("bamboo_fence"); - ItemType.Typed CRIMSON_FENCE = getItemType("crimson_fence"); - ItemType.Typed WARPED_FENCE = getItemType("warped_fence"); - ItemType.Typed PUMPKIN = getItemType("pumpkin"); - ItemType.Typed CARVED_PUMPKIN = getItemType("carved_pumpkin"); - ItemType.Typed JACK_O_LANTERN = getItemType("jack_o_lantern"); - ItemType.Typed NETHERRACK = getItemType("netherrack"); - ItemType.Typed SOUL_SAND = getItemType("soul_sand"); - ItemType.Typed SOUL_SOIL = getItemType("soul_soil"); - ItemType.Typed BASALT = getItemType("basalt"); - ItemType.Typed POLISHED_BASALT = getItemType("polished_basalt"); - ItemType.Typed SMOOTH_BASALT = getItemType("smooth_basalt"); - ItemType.Typed SOUL_TORCH = getItemType("soul_torch"); - ItemType.Typed GLOWSTONE = getItemType("glowstone"); - ItemType.Typed INFESTED_STONE = getItemType("infested_stone"); - ItemType.Typed INFESTED_COBBLESTONE = getItemType("infested_cobblestone"); - ItemType.Typed INFESTED_STONE_BRICKS = getItemType("infested_stone_bricks"); - ItemType.Typed INFESTED_MOSSY_STONE_BRICKS = getItemType("infested_mossy_stone_bricks"); - ItemType.Typed INFESTED_CRACKED_STONE_BRICKS = getItemType("infested_cracked_stone_bricks"); - ItemType.Typed INFESTED_CHISELED_STONE_BRICKS = getItemType("infested_chiseled_stone_bricks"); - ItemType.Typed INFESTED_DEEPSLATE = getItemType("infested_deepslate"); - ItemType.Typed STONE_BRICKS = getItemType("stone_bricks"); - ItemType.Typed MOSSY_STONE_BRICKS = getItemType("mossy_stone_bricks"); - ItemType.Typed CRACKED_STONE_BRICKS = getItemType("cracked_stone_bricks"); - ItemType.Typed CHISELED_STONE_BRICKS = getItemType("chiseled_stone_bricks"); - ItemType.Typed PACKED_MUD = getItemType("packed_mud"); - ItemType.Typed MUD_BRICKS = getItemType("mud_bricks"); - ItemType.Typed DEEPSLATE_BRICKS = getItemType("deepslate_bricks"); - ItemType.Typed CRACKED_DEEPSLATE_BRICKS = getItemType("cracked_deepslate_bricks"); - ItemType.Typed DEEPSLATE_TILES = getItemType("deepslate_tiles"); - ItemType.Typed CRACKED_DEEPSLATE_TILES = getItemType("cracked_deepslate_tiles"); - ItemType.Typed CHISELED_DEEPSLATE = getItemType("chiseled_deepslate"); - ItemType.Typed REINFORCED_DEEPSLATE = getItemType("reinforced_deepslate"); - ItemType.Typed BROWN_MUSHROOM_BLOCK = getItemType("brown_mushroom_block"); - ItemType.Typed RED_MUSHROOM_BLOCK = getItemType("red_mushroom_block"); - ItemType.Typed MUSHROOM_STEM = getItemType("mushroom_stem"); - ItemType.Typed IRON_BARS = getItemType("iron_bars"); - ItemType.Typed CHAIN = getItemType("chain"); - ItemType.Typed GLASS_PANE = getItemType("glass_pane"); - ItemType.Typed MELON = getItemType("melon"); - ItemType.Typed VINE = getItemType("vine"); - ItemType.Typed GLOW_LICHEN = getItemType("glow_lichen"); - ItemType.Typed RESIN_CLUMP = getItemType("resin_clump"); - ItemType.Typed RESIN_BLOCK = getItemType("resin_block"); - ItemType.Typed RESIN_BRICKS = getItemType("resin_bricks"); - ItemType.Typed RESIN_BRICK_STAIRS = getItemType("resin_brick_stairs"); - ItemType.Typed RESIN_BRICK_SLAB = getItemType("resin_brick_slab"); - ItemType.Typed RESIN_BRICK_WALL = getItemType("resin_brick_wall"); - ItemType.Typed CHISELED_RESIN_BRICKS = getItemType("chiseled_resin_bricks"); - ItemType.Typed BRICK_STAIRS = getItemType("brick_stairs"); - ItemType.Typed STONE_BRICK_STAIRS = getItemType("stone_brick_stairs"); - ItemType.Typed MUD_BRICK_STAIRS = getItemType("mud_brick_stairs"); - ItemType.Typed MYCELIUM = getItemType("mycelium"); - ItemType.Typed LILY_PAD = getItemType("lily_pad"); - ItemType.Typed NETHER_BRICKS = getItemType("nether_bricks"); - ItemType.Typed CRACKED_NETHER_BRICKS = getItemType("cracked_nether_bricks"); - ItemType.Typed CHISELED_NETHER_BRICKS = getItemType("chiseled_nether_bricks"); - ItemType.Typed NETHER_BRICK_FENCE = getItemType("nether_brick_fence"); - ItemType.Typed NETHER_BRICK_STAIRS = getItemType("nether_brick_stairs"); - ItemType.Typed SCULK = getItemType("sculk"); - ItemType.Typed SCULK_VEIN = getItemType("sculk_vein"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SCULK_CATALYST = getItemType("sculk_catalyst"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SCULK_SHRIEKER = getItemType("sculk_shrieker"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed ENCHANTING_TABLE = getItemType("enchanting_table"); - ItemType.Typed END_PORTAL_FRAME = getItemType("end_portal_frame"); - ItemType.Typed END_STONE = getItemType("end_stone"); - ItemType.Typed END_STONE_BRICKS = getItemType("end_stone_bricks"); - ItemType.Typed DRAGON_EGG = getItemType("dragon_egg"); - ItemType.Typed SANDSTONE_STAIRS = getItemType("sandstone_stairs"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed ENDER_CHEST = getItemType("ender_chest"); - ItemType.Typed EMERALD_BLOCK = getItemType("emerald_block"); - ItemType.Typed OAK_STAIRS = getItemType("oak_stairs"); - ItemType.Typed SPRUCE_STAIRS = getItemType("spruce_stairs"); - ItemType.Typed BIRCH_STAIRS = getItemType("birch_stairs"); - ItemType.Typed JUNGLE_STAIRS = getItemType("jungle_stairs"); - ItemType.Typed ACACIA_STAIRS = getItemType("acacia_stairs"); - ItemType.Typed CHERRY_STAIRS = getItemType("cherry_stairs"); - ItemType.Typed DARK_OAK_STAIRS = getItemType("dark_oak_stairs"); - ItemType.Typed PALE_OAK_STAIRS = getItemType("pale_oak_stairs"); - ItemType.Typed MANGROVE_STAIRS = getItemType("mangrove_stairs"); - ItemType.Typed BAMBOO_STAIRS = getItemType("bamboo_stairs"); - ItemType.Typed BAMBOO_MOSAIC_STAIRS = getItemType("bamboo_mosaic_stairs"); - ItemType.Typed CRIMSON_STAIRS = getItemType("crimson_stairs"); - ItemType.Typed WARPED_STAIRS = getItemType("warped_stairs"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed COMMAND_BLOCK = getItemType("command_block"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BEACON = getItemType("beacon"); - ItemType.Typed COBBLESTONE_WALL = getItemType("cobblestone_wall"); - ItemType.Typed MOSSY_COBBLESTONE_WALL = getItemType("mossy_cobblestone_wall"); - ItemType.Typed BRICK_WALL = getItemType("brick_wall"); - ItemType.Typed PRISMARINE_WALL = getItemType("prismarine_wall"); - ItemType.Typed RED_SANDSTONE_WALL = getItemType("red_sandstone_wall"); - ItemType.Typed MOSSY_STONE_BRICK_WALL = getItemType("mossy_stone_brick_wall"); - ItemType.Typed GRANITE_WALL = getItemType("granite_wall"); - ItemType.Typed STONE_BRICK_WALL = getItemType("stone_brick_wall"); - ItemType.Typed MUD_BRICK_WALL = getItemType("mud_brick_wall"); - ItemType.Typed NETHER_BRICK_WALL = getItemType("nether_brick_wall"); - ItemType.Typed ANDESITE_WALL = getItemType("andesite_wall"); - ItemType.Typed RED_NETHER_BRICK_WALL = getItemType("red_nether_brick_wall"); - ItemType.Typed SANDSTONE_WALL = getItemType("sandstone_wall"); - ItemType.Typed END_STONE_BRICK_WALL = getItemType("end_stone_brick_wall"); - ItemType.Typed DIORITE_WALL = getItemType("diorite_wall"); - ItemType.Typed BLACKSTONE_WALL = getItemType("blackstone_wall"); - ItemType.Typed POLISHED_BLACKSTONE_WALL = getItemType("polished_blackstone_wall"); - ItemType.Typed POLISHED_BLACKSTONE_BRICK_WALL = getItemType("polished_blackstone_brick_wall"); - ItemType.Typed COBBLED_DEEPSLATE_WALL = getItemType("cobbled_deepslate_wall"); - ItemType.Typed POLISHED_DEEPSLATE_WALL = getItemType("polished_deepslate_wall"); - ItemType.Typed DEEPSLATE_BRICK_WALL = getItemType("deepslate_brick_wall"); - ItemType.Typed DEEPSLATE_TILE_WALL = getItemType("deepslate_tile_wall"); - ItemType.Typed ANVIL = getItemType("anvil"); - ItemType.Typed CHIPPED_ANVIL = getItemType("chipped_anvil"); - ItemType.Typed DAMAGED_ANVIL = getItemType("damaged_anvil"); - ItemType.Typed CHISELED_QUARTZ_BLOCK = getItemType("chiseled_quartz_block"); - ItemType.Typed QUARTZ_BLOCK = getItemType("quartz_block"); - ItemType.Typed QUARTZ_BRICKS = getItemType("quartz_bricks"); - ItemType.Typed QUARTZ_PILLAR = getItemType("quartz_pillar"); - ItemType.Typed QUARTZ_STAIRS = getItemType("quartz_stairs"); - ItemType.Typed WHITE_TERRACOTTA = getItemType("white_terracotta"); - ItemType.Typed ORANGE_TERRACOTTA = getItemType("orange_terracotta"); - ItemType.Typed MAGENTA_TERRACOTTA = getItemType("magenta_terracotta"); - ItemType.Typed LIGHT_BLUE_TERRACOTTA = getItemType("light_blue_terracotta"); - ItemType.Typed YELLOW_TERRACOTTA = getItemType("yellow_terracotta"); - ItemType.Typed LIME_TERRACOTTA = getItemType("lime_terracotta"); - ItemType.Typed PINK_TERRACOTTA = getItemType("pink_terracotta"); - ItemType.Typed GRAY_TERRACOTTA = getItemType("gray_terracotta"); - ItemType.Typed LIGHT_GRAY_TERRACOTTA = getItemType("light_gray_terracotta"); - ItemType.Typed CYAN_TERRACOTTA = getItemType("cyan_terracotta"); - ItemType.Typed PURPLE_TERRACOTTA = getItemType("purple_terracotta"); - ItemType.Typed BLUE_TERRACOTTA = getItemType("blue_terracotta"); - ItemType.Typed BROWN_TERRACOTTA = getItemType("brown_terracotta"); - ItemType.Typed GREEN_TERRACOTTA = getItemType("green_terracotta"); - ItemType.Typed RED_TERRACOTTA = getItemType("red_terracotta"); - ItemType.Typed BLACK_TERRACOTTA = getItemType("black_terracotta"); - ItemType.Typed BARRIER = getItemType("barrier"); - ItemType.Typed LIGHT = getItemType("light"); - ItemType.Typed HAY_BLOCK = getItemType("hay_block"); - ItemType.Typed WHITE_CARPET = getItemType("white_carpet"); - ItemType.Typed ORANGE_CARPET = getItemType("orange_carpet"); - ItemType.Typed MAGENTA_CARPET = getItemType("magenta_carpet"); - ItemType.Typed LIGHT_BLUE_CARPET = getItemType("light_blue_carpet"); - ItemType.Typed YELLOW_CARPET = getItemType("yellow_carpet"); - ItemType.Typed LIME_CARPET = getItemType("lime_carpet"); - ItemType.Typed PINK_CARPET = getItemType("pink_carpet"); - ItemType.Typed GRAY_CARPET = getItemType("gray_carpet"); - ItemType.Typed LIGHT_GRAY_CARPET = getItemType("light_gray_carpet"); - ItemType.Typed CYAN_CARPET = getItemType("cyan_carpet"); - ItemType.Typed PURPLE_CARPET = getItemType("purple_carpet"); - ItemType.Typed BLUE_CARPET = getItemType("blue_carpet"); - ItemType.Typed BROWN_CARPET = getItemType("brown_carpet"); - ItemType.Typed GREEN_CARPET = getItemType("green_carpet"); - ItemType.Typed RED_CARPET = getItemType("red_carpet"); - ItemType.Typed BLACK_CARPET = getItemType("black_carpet"); - ItemType.Typed TERRACOTTA = getItemType("terracotta"); - ItemType.Typed PACKED_ICE = getItemType("packed_ice"); - ItemType.Typed DIRT_PATH = getItemType("dirt_path"); - ItemType.Typed SUNFLOWER = getItemType("sunflower"); - ItemType.Typed LILAC = getItemType("lilac"); - ItemType.Typed ROSE_BUSH = getItemType("rose_bush"); - ItemType.Typed PEONY = getItemType("peony"); - ItemType.Typed TALL_GRASS = getItemType("tall_grass"); - ItemType.Typed LARGE_FERN = getItemType("large_fern"); - ItemType.Typed WHITE_STAINED_GLASS = getItemType("white_stained_glass"); - ItemType.Typed ORANGE_STAINED_GLASS = getItemType("orange_stained_glass"); - ItemType.Typed MAGENTA_STAINED_GLASS = getItemType("magenta_stained_glass"); - ItemType.Typed LIGHT_BLUE_STAINED_GLASS = getItemType("light_blue_stained_glass"); - ItemType.Typed YELLOW_STAINED_GLASS = getItemType("yellow_stained_glass"); - ItemType.Typed LIME_STAINED_GLASS = getItemType("lime_stained_glass"); - ItemType.Typed PINK_STAINED_GLASS = getItemType("pink_stained_glass"); - ItemType.Typed GRAY_STAINED_GLASS = getItemType("gray_stained_glass"); - ItemType.Typed LIGHT_GRAY_STAINED_GLASS = getItemType("light_gray_stained_glass"); - ItemType.Typed CYAN_STAINED_GLASS = getItemType("cyan_stained_glass"); - ItemType.Typed PURPLE_STAINED_GLASS = getItemType("purple_stained_glass"); - ItemType.Typed BLUE_STAINED_GLASS = getItemType("blue_stained_glass"); - ItemType.Typed BROWN_STAINED_GLASS = getItemType("brown_stained_glass"); - ItemType.Typed GREEN_STAINED_GLASS = getItemType("green_stained_glass"); - ItemType.Typed RED_STAINED_GLASS = getItemType("red_stained_glass"); - ItemType.Typed BLACK_STAINED_GLASS = getItemType("black_stained_glass"); - ItemType.Typed WHITE_STAINED_GLASS_PANE = getItemType("white_stained_glass_pane"); - ItemType.Typed ORANGE_STAINED_GLASS_PANE = getItemType("orange_stained_glass_pane"); - ItemType.Typed MAGENTA_STAINED_GLASS_PANE = getItemType("magenta_stained_glass_pane"); - ItemType.Typed LIGHT_BLUE_STAINED_GLASS_PANE = getItemType("light_blue_stained_glass_pane"); - ItemType.Typed YELLOW_STAINED_GLASS_PANE = getItemType("yellow_stained_glass_pane"); - ItemType.Typed LIME_STAINED_GLASS_PANE = getItemType("lime_stained_glass_pane"); - ItemType.Typed PINK_STAINED_GLASS_PANE = getItemType("pink_stained_glass_pane"); - ItemType.Typed GRAY_STAINED_GLASS_PANE = getItemType("gray_stained_glass_pane"); - ItemType.Typed LIGHT_GRAY_STAINED_GLASS_PANE = getItemType("light_gray_stained_glass_pane"); - ItemType.Typed CYAN_STAINED_GLASS_PANE = getItemType("cyan_stained_glass_pane"); - ItemType.Typed PURPLE_STAINED_GLASS_PANE = getItemType("purple_stained_glass_pane"); - ItemType.Typed BLUE_STAINED_GLASS_PANE = getItemType("blue_stained_glass_pane"); - ItemType.Typed BROWN_STAINED_GLASS_PANE = getItemType("brown_stained_glass_pane"); - ItemType.Typed GREEN_STAINED_GLASS_PANE = getItemType("green_stained_glass_pane"); - ItemType.Typed RED_STAINED_GLASS_PANE = getItemType("red_stained_glass_pane"); - ItemType.Typed BLACK_STAINED_GLASS_PANE = getItemType("black_stained_glass_pane"); - ItemType.Typed PRISMARINE = getItemType("prismarine"); - ItemType.Typed PRISMARINE_BRICKS = getItemType("prismarine_bricks"); - ItemType.Typed DARK_PRISMARINE = getItemType("dark_prismarine"); - ItemType.Typed PRISMARINE_STAIRS = getItemType("prismarine_stairs"); - ItemType.Typed PRISMARINE_BRICK_STAIRS = getItemType("prismarine_brick_stairs"); - ItemType.Typed DARK_PRISMARINE_STAIRS = getItemType("dark_prismarine_stairs"); - ItemType.Typed SEA_LANTERN = getItemType("sea_lantern"); - ItemType.Typed RED_SANDSTONE = getItemType("red_sandstone"); - ItemType.Typed CHISELED_RED_SANDSTONE = getItemType("chiseled_red_sandstone"); - ItemType.Typed CUT_RED_SANDSTONE = getItemType("cut_red_sandstone"); - ItemType.Typed RED_SANDSTONE_STAIRS = getItemType("red_sandstone_stairs"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed REPEATING_COMMAND_BLOCK = getItemType("repeating_command_block"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CHAIN_COMMAND_BLOCK = getItemType("chain_command_block"); - ItemType.Typed MAGMA_BLOCK = getItemType("magma_block"); - ItemType.Typed NETHER_WART_BLOCK = getItemType("nether_wart_block"); - ItemType.Typed WARPED_WART_BLOCK = getItemType("warped_wart_block"); - ItemType.Typed RED_NETHER_BRICKS = getItemType("red_nether_bricks"); - ItemType.Typed BONE_BLOCK = getItemType("bone_block"); - ItemType.Typed STRUCTURE_VOID = getItemType("structure_void"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SHULKER_BOX = getItemType("shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed WHITE_SHULKER_BOX = getItemType("white_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed ORANGE_SHULKER_BOX = getItemType("orange_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed MAGENTA_SHULKER_BOX = getItemType("magenta_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed LIGHT_BLUE_SHULKER_BOX = getItemType("light_blue_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed YELLOW_SHULKER_BOX = getItemType("yellow_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed LIME_SHULKER_BOX = getItemType("lime_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed PINK_SHULKER_BOX = getItemType("pink_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed GRAY_SHULKER_BOX = getItemType("gray_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed LIGHT_GRAY_SHULKER_BOX = getItemType("light_gray_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CYAN_SHULKER_BOX = getItemType("cyan_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed PURPLE_SHULKER_BOX = getItemType("purple_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BLUE_SHULKER_BOX = getItemType("blue_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BROWN_SHULKER_BOX = getItemType("brown_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed GREEN_SHULKER_BOX = getItemType("green_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed RED_SHULKER_BOX = getItemType("red_shulker_box"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BLACK_SHULKER_BOX = getItemType("black_shulker_box"); - ItemType.Typed WHITE_GLAZED_TERRACOTTA = getItemType("white_glazed_terracotta"); - ItemType.Typed ORANGE_GLAZED_TERRACOTTA = getItemType("orange_glazed_terracotta"); - ItemType.Typed MAGENTA_GLAZED_TERRACOTTA = getItemType("magenta_glazed_terracotta"); - ItemType.Typed LIGHT_BLUE_GLAZED_TERRACOTTA = getItemType("light_blue_glazed_terracotta"); - ItemType.Typed YELLOW_GLAZED_TERRACOTTA = getItemType("yellow_glazed_terracotta"); - ItemType.Typed LIME_GLAZED_TERRACOTTA = getItemType("lime_glazed_terracotta"); - ItemType.Typed PINK_GLAZED_TERRACOTTA = getItemType("pink_glazed_terracotta"); - ItemType.Typed GRAY_GLAZED_TERRACOTTA = getItemType("gray_glazed_terracotta"); - ItemType.Typed LIGHT_GRAY_GLAZED_TERRACOTTA = getItemType("light_gray_glazed_terracotta"); - ItemType.Typed CYAN_GLAZED_TERRACOTTA = getItemType("cyan_glazed_terracotta"); - ItemType.Typed PURPLE_GLAZED_TERRACOTTA = getItemType("purple_glazed_terracotta"); - ItemType.Typed BLUE_GLAZED_TERRACOTTA = getItemType("blue_glazed_terracotta"); - ItemType.Typed BROWN_GLAZED_TERRACOTTA = getItemType("brown_glazed_terracotta"); - ItemType.Typed GREEN_GLAZED_TERRACOTTA = getItemType("green_glazed_terracotta"); - ItemType.Typed RED_GLAZED_TERRACOTTA = getItemType("red_glazed_terracotta"); - ItemType.Typed BLACK_GLAZED_TERRACOTTA = getItemType("black_glazed_terracotta"); - ItemType.Typed WHITE_CONCRETE = getItemType("white_concrete"); - ItemType.Typed ORANGE_CONCRETE = getItemType("orange_concrete"); - ItemType.Typed MAGENTA_CONCRETE = getItemType("magenta_concrete"); - ItemType.Typed LIGHT_BLUE_CONCRETE = getItemType("light_blue_concrete"); - ItemType.Typed YELLOW_CONCRETE = getItemType("yellow_concrete"); - ItemType.Typed LIME_CONCRETE = getItemType("lime_concrete"); - ItemType.Typed PINK_CONCRETE = getItemType("pink_concrete"); - ItemType.Typed GRAY_CONCRETE = getItemType("gray_concrete"); - ItemType.Typed LIGHT_GRAY_CONCRETE = getItemType("light_gray_concrete"); - ItemType.Typed CYAN_CONCRETE = getItemType("cyan_concrete"); - ItemType.Typed PURPLE_CONCRETE = getItemType("purple_concrete"); - ItemType.Typed BLUE_CONCRETE = getItemType("blue_concrete"); - ItemType.Typed BROWN_CONCRETE = getItemType("brown_concrete"); - ItemType.Typed GREEN_CONCRETE = getItemType("green_concrete"); - ItemType.Typed RED_CONCRETE = getItemType("red_concrete"); - ItemType.Typed BLACK_CONCRETE = getItemType("black_concrete"); - ItemType.Typed WHITE_CONCRETE_POWDER = getItemType("white_concrete_powder"); - ItemType.Typed ORANGE_CONCRETE_POWDER = getItemType("orange_concrete_powder"); - ItemType.Typed MAGENTA_CONCRETE_POWDER = getItemType("magenta_concrete_powder"); - ItemType.Typed LIGHT_BLUE_CONCRETE_POWDER = getItemType("light_blue_concrete_powder"); - ItemType.Typed YELLOW_CONCRETE_POWDER = getItemType("yellow_concrete_powder"); - ItemType.Typed LIME_CONCRETE_POWDER = getItemType("lime_concrete_powder"); - ItemType.Typed PINK_CONCRETE_POWDER = getItemType("pink_concrete_powder"); - ItemType.Typed GRAY_CONCRETE_POWDER = getItemType("gray_concrete_powder"); - ItemType.Typed LIGHT_GRAY_CONCRETE_POWDER = getItemType("light_gray_concrete_powder"); - ItemType.Typed CYAN_CONCRETE_POWDER = getItemType("cyan_concrete_powder"); - ItemType.Typed PURPLE_CONCRETE_POWDER = getItemType("purple_concrete_powder"); - ItemType.Typed BLUE_CONCRETE_POWDER = getItemType("blue_concrete_powder"); - ItemType.Typed BROWN_CONCRETE_POWDER = getItemType("brown_concrete_powder"); - ItemType.Typed GREEN_CONCRETE_POWDER = getItemType("green_concrete_powder"); - ItemType.Typed RED_CONCRETE_POWDER = getItemType("red_concrete_powder"); - ItemType.Typed BLACK_CONCRETE_POWDER = getItemType("black_concrete_powder"); - ItemType.Typed TURTLE_EGG = getItemType("turtle_egg"); - ItemType.Typed SNIFFER_EGG = getItemType("sniffer_egg"); - ItemType.Typed DEAD_TUBE_CORAL_BLOCK = getItemType("dead_tube_coral_block"); - ItemType.Typed DEAD_BRAIN_CORAL_BLOCK = getItemType("dead_brain_coral_block"); - ItemType.Typed DEAD_BUBBLE_CORAL_BLOCK = getItemType("dead_bubble_coral_block"); - ItemType.Typed DEAD_FIRE_CORAL_BLOCK = getItemType("dead_fire_coral_block"); - ItemType.Typed DEAD_HORN_CORAL_BLOCK = getItemType("dead_horn_coral_block"); - ItemType.Typed TUBE_CORAL_BLOCK = getItemType("tube_coral_block"); - ItemType.Typed BRAIN_CORAL_BLOCK = getItemType("brain_coral_block"); - ItemType.Typed BUBBLE_CORAL_BLOCK = getItemType("bubble_coral_block"); - ItemType.Typed FIRE_CORAL_BLOCK = getItemType("fire_coral_block"); - ItemType.Typed HORN_CORAL_BLOCK = getItemType("horn_coral_block"); - ItemType.Typed TUBE_CORAL = getItemType("tube_coral"); - ItemType.Typed BRAIN_CORAL = getItemType("brain_coral"); - ItemType.Typed BUBBLE_CORAL = getItemType("bubble_coral"); - ItemType.Typed FIRE_CORAL = getItemType("fire_coral"); - ItemType.Typed HORN_CORAL = getItemType("horn_coral"); - ItemType.Typed DEAD_BRAIN_CORAL = getItemType("dead_brain_coral"); - ItemType.Typed DEAD_BUBBLE_CORAL = getItemType("dead_bubble_coral"); - ItemType.Typed DEAD_FIRE_CORAL = getItemType("dead_fire_coral"); - ItemType.Typed DEAD_HORN_CORAL = getItemType("dead_horn_coral"); - ItemType.Typed DEAD_TUBE_CORAL = getItemType("dead_tube_coral"); - ItemType.Typed TUBE_CORAL_FAN = getItemType("tube_coral_fan"); - ItemType.Typed BRAIN_CORAL_FAN = getItemType("brain_coral_fan"); - ItemType.Typed BUBBLE_CORAL_FAN = getItemType("bubble_coral_fan"); - ItemType.Typed FIRE_CORAL_FAN = getItemType("fire_coral_fan"); - ItemType.Typed HORN_CORAL_FAN = getItemType("horn_coral_fan"); - ItemType.Typed DEAD_TUBE_CORAL_FAN = getItemType("dead_tube_coral_fan"); - ItemType.Typed DEAD_BRAIN_CORAL_FAN = getItemType("dead_brain_coral_fan"); - ItemType.Typed DEAD_BUBBLE_CORAL_FAN = getItemType("dead_bubble_coral_fan"); - ItemType.Typed DEAD_FIRE_CORAL_FAN = getItemType("dead_fire_coral_fan"); - ItemType.Typed DEAD_HORN_CORAL_FAN = getItemType("dead_horn_coral_fan"); - ItemType.Typed BLUE_ICE = getItemType("blue_ice"); - ItemType.Typed CONDUIT = getItemType("conduit"); - ItemType.Typed POLISHED_GRANITE_STAIRS = getItemType("polished_granite_stairs"); - ItemType.Typed SMOOTH_RED_SANDSTONE_STAIRS = getItemType("smooth_red_sandstone_stairs"); - ItemType.Typed MOSSY_STONE_BRICK_STAIRS = getItemType("mossy_stone_brick_stairs"); - ItemType.Typed POLISHED_DIORITE_STAIRS = getItemType("polished_diorite_stairs"); - ItemType.Typed MOSSY_COBBLESTONE_STAIRS = getItemType("mossy_cobblestone_stairs"); - ItemType.Typed END_STONE_BRICK_STAIRS = getItemType("end_stone_brick_stairs"); - ItemType.Typed STONE_STAIRS = getItemType("stone_stairs"); - ItemType.Typed SMOOTH_SANDSTONE_STAIRS = getItemType("smooth_sandstone_stairs"); - ItemType.Typed SMOOTH_QUARTZ_STAIRS = getItemType("smooth_quartz_stairs"); - ItemType.Typed GRANITE_STAIRS = getItemType("granite_stairs"); - ItemType.Typed ANDESITE_STAIRS = getItemType("andesite_stairs"); - ItemType.Typed RED_NETHER_BRICK_STAIRS = getItemType("red_nether_brick_stairs"); - ItemType.Typed POLISHED_ANDESITE_STAIRS = getItemType("polished_andesite_stairs"); - ItemType.Typed DIORITE_STAIRS = getItemType("diorite_stairs"); - ItemType.Typed COBBLED_DEEPSLATE_STAIRS = getItemType("cobbled_deepslate_stairs"); - ItemType.Typed POLISHED_DEEPSLATE_STAIRS = getItemType("polished_deepslate_stairs"); - ItemType.Typed DEEPSLATE_BRICK_STAIRS = getItemType("deepslate_brick_stairs"); - ItemType.Typed DEEPSLATE_TILE_STAIRS = getItemType("deepslate_tile_stairs"); - ItemType.Typed POLISHED_GRANITE_SLAB = getItemType("polished_granite_slab"); - ItemType.Typed SMOOTH_RED_SANDSTONE_SLAB = getItemType("smooth_red_sandstone_slab"); - ItemType.Typed MOSSY_STONE_BRICK_SLAB = getItemType("mossy_stone_brick_slab"); - ItemType.Typed POLISHED_DIORITE_SLAB = getItemType("polished_diorite_slab"); - ItemType.Typed MOSSY_COBBLESTONE_SLAB = getItemType("mossy_cobblestone_slab"); - ItemType.Typed END_STONE_BRICK_SLAB = getItemType("end_stone_brick_slab"); - ItemType.Typed SMOOTH_SANDSTONE_SLAB = getItemType("smooth_sandstone_slab"); - ItemType.Typed SMOOTH_QUARTZ_SLAB = getItemType("smooth_quartz_slab"); - ItemType.Typed GRANITE_SLAB = getItemType("granite_slab"); - ItemType.Typed ANDESITE_SLAB = getItemType("andesite_slab"); - ItemType.Typed RED_NETHER_BRICK_SLAB = getItemType("red_nether_brick_slab"); - ItemType.Typed POLISHED_ANDESITE_SLAB = getItemType("polished_andesite_slab"); - ItemType.Typed DIORITE_SLAB = getItemType("diorite_slab"); - ItemType.Typed COBBLED_DEEPSLATE_SLAB = getItemType("cobbled_deepslate_slab"); - ItemType.Typed POLISHED_DEEPSLATE_SLAB = getItemType("polished_deepslate_slab"); - ItemType.Typed DEEPSLATE_BRICK_SLAB = getItemType("deepslate_brick_slab"); - ItemType.Typed DEEPSLATE_TILE_SLAB = getItemType("deepslate_tile_slab"); - ItemType.Typed SCAFFOLDING = getItemType("scaffolding"); - ItemType.Typed REDSTONE = getItemType("redstone"); - ItemType.Typed REDSTONE_TORCH = getItemType("redstone_torch"); - ItemType.Typed REDSTONE_BLOCK = getItemType("redstone_block"); - ItemType.Typed REPEATER = getItemType("repeater"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed COMPARATOR = getItemType("comparator"); - ItemType.Typed PISTON = getItemType("piston"); - ItemType.Typed STICKY_PISTON = getItemType("sticky_piston"); - ItemType.Typed SLIME_BLOCK = getItemType("slime_block"); - ItemType.Typed HONEY_BLOCK = getItemType("honey_block"); - ItemType.Typed OBSERVER = getItemType("observer"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed HOPPER = getItemType("hopper"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DISPENSER = getItemType("dispenser"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DROPPER = getItemType("dropper"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed LECTERN = getItemType("lectern"); - ItemType.Typed TARGET = getItemType("target"); - ItemType.Typed LEVER = getItemType("lever"); - ItemType.Typed LIGHTNING_ROD = getItemType("lightning_rod"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DAYLIGHT_DETECTOR = getItemType("daylight_detector"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SCULK_SENSOR = getItemType("sculk_sensor"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CALIBRATED_SCULK_SENSOR = getItemType("calibrated_sculk_sensor"); - ItemType.Typed TRIPWIRE_HOOK = getItemType("tripwire_hook"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed TRAPPED_CHEST = getItemType("trapped_chest"); - ItemType.Typed TNT = getItemType("tnt"); - ItemType.Typed REDSTONE_LAMP = getItemType("redstone_lamp"); - ItemType.Typed NOTE_BLOCK = getItemType("note_block"); - ItemType.Typed STONE_BUTTON = getItemType("stone_button"); - ItemType.Typed POLISHED_BLACKSTONE_BUTTON = getItemType("polished_blackstone_button"); - ItemType.Typed OAK_BUTTON = getItemType("oak_button"); - ItemType.Typed SPRUCE_BUTTON = getItemType("spruce_button"); - ItemType.Typed BIRCH_BUTTON = getItemType("birch_button"); - ItemType.Typed JUNGLE_BUTTON = getItemType("jungle_button"); - ItemType.Typed ACACIA_BUTTON = getItemType("acacia_button"); - ItemType.Typed CHERRY_BUTTON = getItemType("cherry_button"); - ItemType.Typed DARK_OAK_BUTTON = getItemType("dark_oak_button"); - ItemType.Typed PALE_OAK_BUTTON = getItemType("pale_oak_button"); - ItemType.Typed MANGROVE_BUTTON = getItemType("mangrove_button"); - ItemType.Typed BAMBOO_BUTTON = getItemType("bamboo_button"); - ItemType.Typed CRIMSON_BUTTON = getItemType("crimson_button"); - ItemType.Typed WARPED_BUTTON = getItemType("warped_button"); - ItemType.Typed STONE_PRESSURE_PLATE = getItemType("stone_pressure_plate"); - ItemType.Typed POLISHED_BLACKSTONE_PRESSURE_PLATE = getItemType("polished_blackstone_pressure_plate"); - ItemType.Typed LIGHT_WEIGHTED_PRESSURE_PLATE = getItemType("light_weighted_pressure_plate"); - ItemType.Typed HEAVY_WEIGHTED_PRESSURE_PLATE = getItemType("heavy_weighted_pressure_plate"); - ItemType.Typed OAK_PRESSURE_PLATE = getItemType("oak_pressure_plate"); - ItemType.Typed SPRUCE_PRESSURE_PLATE = getItemType("spruce_pressure_plate"); - ItemType.Typed BIRCH_PRESSURE_PLATE = getItemType("birch_pressure_plate"); - ItemType.Typed JUNGLE_PRESSURE_PLATE = getItemType("jungle_pressure_plate"); - ItemType.Typed ACACIA_PRESSURE_PLATE = getItemType("acacia_pressure_plate"); - ItemType.Typed CHERRY_PRESSURE_PLATE = getItemType("cherry_pressure_plate"); - ItemType.Typed DARK_OAK_PRESSURE_PLATE = getItemType("dark_oak_pressure_plate"); - ItemType.Typed PALE_OAK_PRESSURE_PLATE = getItemType("pale_oak_pressure_plate"); - ItemType.Typed MANGROVE_PRESSURE_PLATE = getItemType("mangrove_pressure_plate"); - ItemType.Typed BAMBOO_PRESSURE_PLATE = getItemType("bamboo_pressure_plate"); - ItemType.Typed CRIMSON_PRESSURE_PLATE = getItemType("crimson_pressure_plate"); - ItemType.Typed WARPED_PRESSURE_PLATE = getItemType("warped_pressure_plate"); - ItemType.Typed IRON_DOOR = getItemType("iron_door"); - ItemType.Typed OAK_DOOR = getItemType("oak_door"); - ItemType.Typed SPRUCE_DOOR = getItemType("spruce_door"); - ItemType.Typed BIRCH_DOOR = getItemType("birch_door"); - ItemType.Typed JUNGLE_DOOR = getItemType("jungle_door"); - ItemType.Typed ACACIA_DOOR = getItemType("acacia_door"); - ItemType.Typed CHERRY_DOOR = getItemType("cherry_door"); - ItemType.Typed DARK_OAK_DOOR = getItemType("dark_oak_door"); - ItemType.Typed PALE_OAK_DOOR = getItemType("pale_oak_door"); - ItemType.Typed MANGROVE_DOOR = getItemType("mangrove_door"); - ItemType.Typed BAMBOO_DOOR = getItemType("bamboo_door"); - ItemType.Typed CRIMSON_DOOR = getItemType("crimson_door"); - ItemType.Typed WARPED_DOOR = getItemType("warped_door"); - ItemType.Typed COPPER_DOOR = getItemType("copper_door"); - ItemType.Typed EXPOSED_COPPER_DOOR = getItemType("exposed_copper_door"); - ItemType.Typed WEATHERED_COPPER_DOOR = getItemType("weathered_copper_door"); - ItemType.Typed OXIDIZED_COPPER_DOOR = getItemType("oxidized_copper_door"); - ItemType.Typed WAXED_COPPER_DOOR = getItemType("waxed_copper_door"); - ItemType.Typed WAXED_EXPOSED_COPPER_DOOR = getItemType("waxed_exposed_copper_door"); - ItemType.Typed WAXED_WEATHERED_COPPER_DOOR = getItemType("waxed_weathered_copper_door"); - ItemType.Typed WAXED_OXIDIZED_COPPER_DOOR = getItemType("waxed_oxidized_copper_door"); - ItemType.Typed IRON_TRAPDOOR = getItemType("iron_trapdoor"); - ItemType.Typed OAK_TRAPDOOR = getItemType("oak_trapdoor"); - ItemType.Typed SPRUCE_TRAPDOOR = getItemType("spruce_trapdoor"); - ItemType.Typed BIRCH_TRAPDOOR = getItemType("birch_trapdoor"); - ItemType.Typed JUNGLE_TRAPDOOR = getItemType("jungle_trapdoor"); - ItemType.Typed ACACIA_TRAPDOOR = getItemType("acacia_trapdoor"); - ItemType.Typed CHERRY_TRAPDOOR = getItemType("cherry_trapdoor"); - ItemType.Typed DARK_OAK_TRAPDOOR = getItemType("dark_oak_trapdoor"); - ItemType.Typed PALE_OAK_TRAPDOOR = getItemType("pale_oak_trapdoor"); - ItemType.Typed MANGROVE_TRAPDOOR = getItemType("mangrove_trapdoor"); - ItemType.Typed BAMBOO_TRAPDOOR = getItemType("bamboo_trapdoor"); - ItemType.Typed CRIMSON_TRAPDOOR = getItemType("crimson_trapdoor"); - ItemType.Typed WARPED_TRAPDOOR = getItemType("warped_trapdoor"); - ItemType.Typed COPPER_TRAPDOOR = getItemType("copper_trapdoor"); - ItemType.Typed EXPOSED_COPPER_TRAPDOOR = getItemType("exposed_copper_trapdoor"); - ItemType.Typed WEATHERED_COPPER_TRAPDOOR = getItemType("weathered_copper_trapdoor"); - ItemType.Typed OXIDIZED_COPPER_TRAPDOOR = getItemType("oxidized_copper_trapdoor"); - ItemType.Typed WAXED_COPPER_TRAPDOOR = getItemType("waxed_copper_trapdoor"); - ItemType.Typed WAXED_EXPOSED_COPPER_TRAPDOOR = getItemType("waxed_exposed_copper_trapdoor"); - ItemType.Typed WAXED_WEATHERED_COPPER_TRAPDOOR = getItemType("waxed_weathered_copper_trapdoor"); - ItemType.Typed WAXED_OXIDIZED_COPPER_TRAPDOOR = getItemType("waxed_oxidized_copper_trapdoor"); - ItemType.Typed OAK_FENCE_GATE = getItemType("oak_fence_gate"); - ItemType.Typed SPRUCE_FENCE_GATE = getItemType("spruce_fence_gate"); - ItemType.Typed BIRCH_FENCE_GATE = getItemType("birch_fence_gate"); - ItemType.Typed JUNGLE_FENCE_GATE = getItemType("jungle_fence_gate"); - ItemType.Typed ACACIA_FENCE_GATE = getItemType("acacia_fence_gate"); - ItemType.Typed CHERRY_FENCE_GATE = getItemType("cherry_fence_gate"); - ItemType.Typed DARK_OAK_FENCE_GATE = getItemType("dark_oak_fence_gate"); - ItemType.Typed PALE_OAK_FENCE_GATE = getItemType("pale_oak_fence_gate"); - ItemType.Typed MANGROVE_FENCE_GATE = getItemType("mangrove_fence_gate"); - ItemType.Typed BAMBOO_FENCE_GATE = getItemType("bamboo_fence_gate"); - ItemType.Typed CRIMSON_FENCE_GATE = getItemType("crimson_fence_gate"); - ItemType.Typed WARPED_FENCE_GATE = getItemType("warped_fence_gate"); - ItemType.Typed POWERED_RAIL = getItemType("powered_rail"); - ItemType.Typed DETECTOR_RAIL = getItemType("detector_rail"); - ItemType.Typed RAIL = getItemType("rail"); - ItemType.Typed ACTIVATOR_RAIL = getItemType("activator_rail"); - ItemType.Typed SADDLE = getItemType("saddle"); - ItemType.Typed MINECART = getItemType("minecart"); - ItemType.Typed CHEST_MINECART = getItemType("chest_minecart"); - ItemType.Typed FURNACE_MINECART = getItemType("furnace_minecart"); - ItemType.Typed TNT_MINECART = getItemType("tnt_minecart"); - ItemType.Typed HOPPER_MINECART = getItemType("hopper_minecart"); - ItemType.Typed CARROT_ON_A_STICK = getItemType("carrot_on_a_stick"); - ItemType.Typed WARPED_FUNGUS_ON_A_STICK = getItemType("warped_fungus_on_a_stick"); - ItemType.Typed PHANTOM_MEMBRANE = getItemType("phantom_membrane"); - ItemType.Typed ELYTRA = getItemType("elytra"); - ItemType.Typed OAK_BOAT = getItemType("oak_boat"); - ItemType.Typed OAK_CHEST_BOAT = getItemType("oak_chest_boat"); - ItemType.Typed SPRUCE_BOAT = getItemType("spruce_boat"); - ItemType.Typed SPRUCE_CHEST_BOAT = getItemType("spruce_chest_boat"); - ItemType.Typed BIRCH_BOAT = getItemType("birch_boat"); - ItemType.Typed BIRCH_CHEST_BOAT = getItemType("birch_chest_boat"); - ItemType.Typed JUNGLE_BOAT = getItemType("jungle_boat"); - ItemType.Typed JUNGLE_CHEST_BOAT = getItemType("jungle_chest_boat"); + // Start generate - ItemType + // @GeneratedFrom 1.21.5 ItemType.Typed ACACIA_BOAT = getItemType("acacia_boat"); + + ItemType.Typed ACACIA_BUTTON = getItemType("acacia_button"); + ItemType.Typed ACACIA_CHEST_BOAT = getItemType("acacia_chest_boat"); - ItemType.Typed CHERRY_BOAT = getItemType("cherry_boat"); - ItemType.Typed CHERRY_CHEST_BOAT = getItemType("cherry_chest_boat"); - ItemType.Typed DARK_OAK_BOAT = getItemType("dark_oak_boat"); - ItemType.Typed DARK_OAK_CHEST_BOAT = getItemType("dark_oak_chest_boat"); - ItemType.Typed PALE_OAK_BOAT = getItemType("pale_oak_boat"); - ItemType.Typed PALE_OAK_CHEST_BOAT = getItemType("pale_oak_chest_boat"); - ItemType.Typed MANGROVE_BOAT = getItemType("mangrove_boat"); - ItemType.Typed MANGROVE_CHEST_BOAT = getItemType("mangrove_chest_boat"); - ItemType.Typed BAMBOO_RAFT = getItemType("bamboo_raft"); - ItemType.Typed BAMBOO_CHEST_RAFT = getItemType("bamboo_chest_raft"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed STRUCTURE_BLOCK = getItemType("structure_block"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed JIGSAW = getItemType("jigsaw"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed TURTLE_HELMET = getItemType("turtle_helmet"); - ItemType.Typed TURTLE_SCUTE = getItemType("turtle_scute"); - ItemType.Typed ARMADILLO_SCUTE = getItemType("armadillo_scute"); - /** - * ItemMeta: {@link ColorableArmorMeta} - */ - ItemType.Typed WOLF_ARMOR = getItemType("wolf_armor"); - ItemType.Typed FLINT_AND_STEEL = getItemType("flint_and_steel"); - ItemType.Typed BOWL = getItemType("bowl"); - ItemType.Typed APPLE = getItemType("apple"); - ItemType.Typed BOW = getItemType("bow"); - ItemType.Typed ARROW = getItemType("arrow"); - ItemType.Typed COAL = getItemType("coal"); - ItemType.Typed CHARCOAL = getItemType("charcoal"); - ItemType.Typed DIAMOND = getItemType("diamond"); - ItemType.Typed EMERALD = getItemType("emerald"); - ItemType.Typed LAPIS_LAZULI = getItemType("lapis_lazuli"); - ItemType.Typed QUARTZ = getItemType("quartz"); - ItemType.Typed AMETHYST_SHARD = getItemType("amethyst_shard"); - ItemType.Typed RAW_IRON = getItemType("raw_iron"); - ItemType.Typed IRON_INGOT = getItemType("iron_ingot"); - ItemType.Typed RAW_COPPER = getItemType("raw_copper"); - ItemType.Typed COPPER_INGOT = getItemType("copper_ingot"); - ItemType.Typed RAW_GOLD = getItemType("raw_gold"); - ItemType.Typed GOLD_INGOT = getItemType("gold_ingot"); - ItemType.Typed NETHERITE_INGOT = getItemType("netherite_ingot"); - ItemType.Typed NETHERITE_SCRAP = getItemType("netherite_scrap"); - ItemType.Typed WOODEN_SWORD = getItemType("wooden_sword"); - ItemType.Typed WOODEN_SHOVEL = getItemType("wooden_shovel"); - ItemType.Typed WOODEN_PICKAXE = getItemType("wooden_pickaxe"); - ItemType.Typed WOODEN_AXE = getItemType("wooden_axe"); - ItemType.Typed WOODEN_HOE = getItemType("wooden_hoe"); - ItemType.Typed STONE_SWORD = getItemType("stone_sword"); - ItemType.Typed STONE_SHOVEL = getItemType("stone_shovel"); - ItemType.Typed STONE_PICKAXE = getItemType("stone_pickaxe"); - ItemType.Typed STONE_AXE = getItemType("stone_axe"); - ItemType.Typed STONE_HOE = getItemType("stone_hoe"); - ItemType.Typed GOLDEN_SWORD = getItemType("golden_sword"); - ItemType.Typed GOLDEN_SHOVEL = getItemType("golden_shovel"); - ItemType.Typed GOLDEN_PICKAXE = getItemType("golden_pickaxe"); - ItemType.Typed GOLDEN_AXE = getItemType("golden_axe"); - ItemType.Typed GOLDEN_HOE = getItemType("golden_hoe"); - ItemType.Typed IRON_SWORD = getItemType("iron_sword"); - ItemType.Typed IRON_SHOVEL = getItemType("iron_shovel"); - ItemType.Typed IRON_PICKAXE = getItemType("iron_pickaxe"); - ItemType.Typed IRON_AXE = getItemType("iron_axe"); - ItemType.Typed IRON_HOE = getItemType("iron_hoe"); - ItemType.Typed DIAMOND_SWORD = getItemType("diamond_sword"); - ItemType.Typed DIAMOND_SHOVEL = getItemType("diamond_shovel"); - ItemType.Typed DIAMOND_PICKAXE = getItemType("diamond_pickaxe"); - ItemType.Typed DIAMOND_AXE = getItemType("diamond_axe"); - ItemType.Typed DIAMOND_HOE = getItemType("diamond_hoe"); - ItemType.Typed NETHERITE_SWORD = getItemType("netherite_sword"); - ItemType.Typed NETHERITE_SHOVEL = getItemType("netherite_shovel"); - ItemType.Typed NETHERITE_PICKAXE = getItemType("netherite_pickaxe"); - ItemType.Typed NETHERITE_AXE = getItemType("netherite_axe"); - ItemType.Typed NETHERITE_HOE = getItemType("netherite_hoe"); - ItemType.Typed STICK = getItemType("stick"); - ItemType.Typed MUSHROOM_STEW = getItemType("mushroom_stew"); - ItemType.Typed STRING = getItemType("string"); - ItemType.Typed FEATHER = getItemType("feather"); - ItemType.Typed GUNPOWDER = getItemType("gunpowder"); - ItemType.Typed WHEAT_SEEDS = getItemType("wheat_seeds"); - ItemType.Typed WHEAT = getItemType("wheat"); - ItemType.Typed BREAD = getItemType("bread"); - /** - * ItemMeta: {@link ColorableArmorMeta} - */ - ItemType.Typed LEATHER_HELMET = getItemType("leather_helmet"); - /** - * ItemMeta: {@link ColorableArmorMeta} - */ - ItemType.Typed LEATHER_CHESTPLATE = getItemType("leather_chestplate"); - /** - * ItemMeta: {@link ColorableArmorMeta} - */ - ItemType.Typed LEATHER_LEGGINGS = getItemType("leather_leggings"); - /** - * ItemMeta: {@link ColorableArmorMeta} - */ - ItemType.Typed LEATHER_BOOTS = getItemType("leather_boots"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed CHAINMAIL_HELMET = getItemType("chainmail_helmet"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed CHAINMAIL_CHESTPLATE = getItemType("chainmail_chestplate"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed CHAINMAIL_LEGGINGS = getItemType("chainmail_leggings"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed CHAINMAIL_BOOTS = getItemType("chainmail_boots"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed IRON_HELMET = getItemType("iron_helmet"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed IRON_CHESTPLATE = getItemType("iron_chestplate"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed IRON_LEGGINGS = getItemType("iron_leggings"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed IRON_BOOTS = getItemType("iron_boots"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed DIAMOND_HELMET = getItemType("diamond_helmet"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed DIAMOND_CHESTPLATE = getItemType("diamond_chestplate"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed DIAMOND_LEGGINGS = getItemType("diamond_leggings"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed DIAMOND_BOOTS = getItemType("diamond_boots"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed GOLDEN_HELMET = getItemType("golden_helmet"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed GOLDEN_CHESTPLATE = getItemType("golden_chestplate"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed GOLDEN_LEGGINGS = getItemType("golden_leggings"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed GOLDEN_BOOTS = getItemType("golden_boots"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed NETHERITE_HELMET = getItemType("netherite_helmet"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed NETHERITE_CHESTPLATE = getItemType("netherite_chestplate"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed NETHERITE_LEGGINGS = getItemType("netherite_leggings"); - /** - * ItemMeta: {@link ArmorMeta} - */ - ItemType.Typed NETHERITE_BOOTS = getItemType("netherite_boots"); - ItemType.Typed FLINT = getItemType("flint"); - ItemType.Typed PORKCHOP = getItemType("porkchop"); - ItemType.Typed COOKED_PORKCHOP = getItemType("cooked_porkchop"); - ItemType.Typed PAINTING = getItemType("painting"); - ItemType.Typed GOLDEN_APPLE = getItemType("golden_apple"); - ItemType.Typed ENCHANTED_GOLDEN_APPLE = getItemType("enchanted_golden_apple"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed OAK_SIGN = getItemType("oak_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SPRUCE_SIGN = getItemType("spruce_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BIRCH_SIGN = getItemType("birch_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed JUNGLE_SIGN = getItemType("jungle_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed ACACIA_SIGN = getItemType("acacia_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CHERRY_SIGN = getItemType("cherry_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DARK_OAK_SIGN = getItemType("dark_oak_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed PALE_OAK_SIGN = getItemType("pale_oak_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed MANGROVE_SIGN = getItemType("mangrove_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BAMBOO_SIGN = getItemType("bamboo_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CRIMSON_SIGN = getItemType("crimson_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed WARPED_SIGN = getItemType("warped_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed OAK_HANGING_SIGN = getItemType("oak_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SPRUCE_HANGING_SIGN = getItemType("spruce_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BIRCH_HANGING_SIGN = getItemType("birch_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed JUNGLE_HANGING_SIGN = getItemType("jungle_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ + + ItemType.Typed ACACIA_DOOR = getItemType("acacia_door"); + + ItemType.Typed ACACIA_FENCE = getItemType("acacia_fence"); + + ItemType.Typed ACACIA_FENCE_GATE = getItemType("acacia_fence_gate"); + ItemType.Typed ACACIA_HANGING_SIGN = getItemType("acacia_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CHERRY_HANGING_SIGN = getItemType("cherry_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed DARK_OAK_HANGING_SIGN = getItemType("dark_oak_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed PALE_OAK_HANGING_SIGN = getItemType("pale_oak_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed MANGROVE_HANGING_SIGN = getItemType("mangrove_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BAMBOO_HANGING_SIGN = getItemType("bamboo_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CRIMSON_HANGING_SIGN = getItemType("crimson_hanging_sign"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed WARPED_HANGING_SIGN = getItemType("warped_hanging_sign"); - ItemType.Typed BUCKET = getItemType("bucket"); - ItemType.Typed WATER_BUCKET = getItemType("water_bucket"); - ItemType.Typed LAVA_BUCKET = getItemType("lava_bucket"); - ItemType.Typed POWDER_SNOW_BUCKET = getItemType("powder_snow_bucket"); - ItemType.Typed SNOWBALL = getItemType("snowball"); - ItemType.Typed LEATHER = getItemType("leather"); - ItemType.Typed MILK_BUCKET = getItemType("milk_bucket"); - ItemType.Typed PUFFERFISH_BUCKET = getItemType("pufferfish_bucket"); - ItemType.Typed SALMON_BUCKET = getItemType("salmon_bucket"); - ItemType.Typed COD_BUCKET = getItemType("cod_bucket"); - /** - * ItemMeta: {@link TropicalFishBucketMeta} - */ - ItemType.Typed TROPICAL_FISH_BUCKET = getItemType("tropical_fish_bucket"); - /** - * ItemMeta: {@link AxolotlBucketMeta} - */ - ItemType.Typed AXOLOTL_BUCKET = getItemType("axolotl_bucket"); - ItemType.Typed TADPOLE_BUCKET = getItemType("tadpole_bucket"); - ItemType.Typed BRICK = getItemType("brick"); - ItemType.Typed CLAY_BALL = getItemType("clay_ball"); - ItemType.Typed DRIED_KELP_BLOCK = getItemType("dried_kelp_block"); - ItemType.Typed PAPER = getItemType("paper"); - ItemType.Typed BOOK = getItemType("book"); - ItemType.Typed SLIME_BALL = getItemType("slime_ball"); - ItemType.Typed EGG = getItemType("egg"); - /** - * ItemMeta: {@link CompassMeta} - */ - ItemType.Typed COMPASS = getItemType("compass"); - ItemType.Typed RECOVERY_COMPASS = getItemType("recovery_compass"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed BUNDLE = getItemType("bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed WHITE_BUNDLE = getItemType("white_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed ORANGE_BUNDLE = getItemType("orange_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed MAGENTA_BUNDLE = getItemType("magenta_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed LIGHT_BLUE_BUNDLE = getItemType("light_blue_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed YELLOW_BUNDLE = getItemType("yellow_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed LIME_BUNDLE = getItemType("lime_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed PINK_BUNDLE = getItemType("pink_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed GRAY_BUNDLE = getItemType("gray_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed LIGHT_GRAY_BUNDLE = getItemType("light_gray_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed CYAN_BUNDLE = getItemType("cyan_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed PURPLE_BUNDLE = getItemType("purple_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed BLUE_BUNDLE = getItemType("blue_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed BROWN_BUNDLE = getItemType("brown_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed GREEN_BUNDLE = getItemType("green_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed RED_BUNDLE = getItemType("red_bundle"); - /** - * ItemMeta: {@link BundleMeta} - */ - ItemType.Typed BLACK_BUNDLE = getItemType("black_bundle"); - ItemType.Typed FISHING_ROD = getItemType("fishing_rod"); - ItemType.Typed CLOCK = getItemType("clock"); - ItemType.Typed SPYGLASS = getItemType("spyglass"); - ItemType.Typed GLOWSTONE_DUST = getItemType("glowstone_dust"); - ItemType.Typed COD = getItemType("cod"); - ItemType.Typed SALMON = getItemType("salmon"); - ItemType.Typed TROPICAL_FISH = getItemType("tropical_fish"); - ItemType.Typed PUFFERFISH = getItemType("pufferfish"); - ItemType.Typed COOKED_COD = getItemType("cooked_cod"); - ItemType.Typed COOKED_SALMON = getItemType("cooked_salmon"); - ItemType.Typed INK_SAC = getItemType("ink_sac"); - ItemType.Typed GLOW_INK_SAC = getItemType("glow_ink_sac"); - ItemType.Typed COCOA_BEANS = getItemType("cocoa_beans"); - ItemType.Typed WHITE_DYE = getItemType("white_dye"); - ItemType.Typed ORANGE_DYE = getItemType("orange_dye"); - ItemType.Typed MAGENTA_DYE = getItemType("magenta_dye"); - ItemType.Typed LIGHT_BLUE_DYE = getItemType("light_blue_dye"); - ItemType.Typed YELLOW_DYE = getItemType("yellow_dye"); - ItemType.Typed LIME_DYE = getItemType("lime_dye"); - ItemType.Typed PINK_DYE = getItemType("pink_dye"); - ItemType.Typed GRAY_DYE = getItemType("gray_dye"); - ItemType.Typed LIGHT_GRAY_DYE = getItemType("light_gray_dye"); - ItemType.Typed CYAN_DYE = getItemType("cyan_dye"); - ItemType.Typed PURPLE_DYE = getItemType("purple_dye"); - ItemType.Typed BLUE_DYE = getItemType("blue_dye"); - ItemType.Typed BROWN_DYE = getItemType("brown_dye"); - ItemType.Typed GREEN_DYE = getItemType("green_dye"); - ItemType.Typed RED_DYE = getItemType("red_dye"); - ItemType.Typed BLACK_DYE = getItemType("black_dye"); - ItemType.Typed BONE_MEAL = getItemType("bone_meal"); - ItemType.Typed BONE = getItemType("bone"); - ItemType.Typed SUGAR = getItemType("sugar"); - ItemType.Typed CAKE = getItemType("cake"); - ItemType.Typed WHITE_BED = getItemType("white_bed"); - ItemType.Typed ORANGE_BED = getItemType("orange_bed"); - ItemType.Typed MAGENTA_BED = getItemType("magenta_bed"); - ItemType.Typed LIGHT_BLUE_BED = getItemType("light_blue_bed"); - ItemType.Typed YELLOW_BED = getItemType("yellow_bed"); - ItemType.Typed LIME_BED = getItemType("lime_bed"); - ItemType.Typed PINK_BED = getItemType("pink_bed"); - ItemType.Typed GRAY_BED = getItemType("gray_bed"); - ItemType.Typed LIGHT_GRAY_BED = getItemType("light_gray_bed"); - ItemType.Typed CYAN_BED = getItemType("cyan_bed"); - ItemType.Typed PURPLE_BED = getItemType("purple_bed"); - ItemType.Typed BLUE_BED = getItemType("blue_bed"); - ItemType.Typed BROWN_BED = getItemType("brown_bed"); - ItemType.Typed GREEN_BED = getItemType("green_bed"); - ItemType.Typed RED_BED = getItemType("red_bed"); - ItemType.Typed BLACK_BED = getItemType("black_bed"); - ItemType.Typed COOKIE = getItemType("cookie"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CRAFTER = getItemType("crafter"); - /** - * ItemMeta: {@link MapMeta} - */ - ItemType.Typed FILLED_MAP = getItemType("filled_map"); - ItemType.Typed SHEARS = getItemType("shears"); - ItemType.Typed MELON_SLICE = getItemType("melon_slice"); - ItemType.Typed DRIED_KELP = getItemType("dried_kelp"); - ItemType.Typed PUMPKIN_SEEDS = getItemType("pumpkin_seeds"); - ItemType.Typed MELON_SEEDS = getItemType("melon_seeds"); - ItemType.Typed BEEF = getItemType("beef"); - ItemType.Typed COOKED_BEEF = getItemType("cooked_beef"); - ItemType.Typed CHICKEN = getItemType("chicken"); - ItemType.Typed COOKED_CHICKEN = getItemType("cooked_chicken"); - ItemType.Typed ROTTEN_FLESH = getItemType("rotten_flesh"); - ItemType.Typed ENDER_PEARL = getItemType("ender_pearl"); - ItemType.Typed BLAZE_ROD = getItemType("blaze_rod"); - ItemType.Typed GHAST_TEAR = getItemType("ghast_tear"); - ItemType.Typed GOLD_NUGGET = getItemType("gold_nugget"); - ItemType.Typed NETHER_WART = getItemType("nether_wart"); - ItemType.Typed GLASS_BOTTLE = getItemType("glass_bottle"); - /** - * ItemMeta: {@link PotionMeta} - */ - ItemType.Typed POTION = getItemType("potion"); - ItemType.Typed SPIDER_EYE = getItemType("spider_eye"); - ItemType.Typed FERMENTED_SPIDER_EYE = getItemType("fermented_spider_eye"); - ItemType.Typed BLAZE_POWDER = getItemType("blaze_powder"); - ItemType.Typed MAGMA_CREAM = getItemType("magma_cream"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BREWING_STAND = getItemType("brewing_stand"); - ItemType.Typed CAULDRON = getItemType("cauldron"); - ItemType.Typed ENDER_EYE = getItemType("ender_eye"); - ItemType.Typed GLISTERING_MELON_SLICE = getItemType("glistering_melon_slice"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ARMADILLO_SPAWN_EGG = getItemType("armadillo_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ + + ItemType.Typed ACACIA_LEAVES = getItemType("acacia_leaves"); + + ItemType.Typed ACACIA_LOG = getItemType("acacia_log"); + + ItemType.Typed ACACIA_PLANKS = getItemType("acacia_planks"); + + ItemType.Typed ACACIA_PRESSURE_PLATE = getItemType("acacia_pressure_plate"); + + ItemType.Typed ACACIA_SAPLING = getItemType("acacia_sapling"); + + ItemType.Typed ACACIA_SIGN = getItemType("acacia_sign"); + + ItemType.Typed ACACIA_SLAB = getItemType("acacia_slab"); + + ItemType.Typed ACACIA_STAIRS = getItemType("acacia_stairs"); + + ItemType.Typed ACACIA_TRAPDOOR = getItemType("acacia_trapdoor"); + + ItemType.Typed ACACIA_WOOD = getItemType("acacia_wood"); + + ItemType.Typed ACTIVATOR_RAIL = getItemType("activator_rail"); + + ItemType AIR = getItemType("air"); + ItemType.Typed ALLAY_SPAWN_EGG = getItemType("allay_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed AXOLOTL_SPAWN_EGG = getItemType("axolotl_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed BAT_SPAWN_EGG = getItemType("bat_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed BEE_SPAWN_EGG = getItemType("bee_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed BLAZE_SPAWN_EGG = getItemType("blaze_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed BOGGED_SPAWN_EGG = getItemType("bogged_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed BREEZE_SPAWN_EGG = getItemType("breeze_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CAT_SPAWN_EGG = getItemType("cat_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CAVE_SPIDER_SPAWN_EGG = getItemType("cave_spider_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CHICKEN_SPAWN_EGG = getItemType("chicken_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed COD_SPAWN_EGG = getItemType("cod_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed COW_SPAWN_EGG = getItemType("cow_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CREAKING_SPAWN_EGG = getItemType("creaking_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed CREEPER_SPAWN_EGG = getItemType("creeper_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed DOLPHIN_SPAWN_EGG = getItemType("dolphin_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed DONKEY_SPAWN_EGG = getItemType("donkey_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed DROWNED_SPAWN_EGG = getItemType("drowned_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ELDER_GUARDIAN_SPAWN_EGG = getItemType("elder_guardian_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ENDER_DRAGON_SPAWN_EGG = getItemType("ender_dragon_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ENDERMAN_SPAWN_EGG = getItemType("enderman_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ENDERMITE_SPAWN_EGG = getItemType("endermite_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed EVOKER_SPAWN_EGG = getItemType("evoker_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed FOX_SPAWN_EGG = getItemType("fox_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed FROG_SPAWN_EGG = getItemType("frog_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed GHAST_SPAWN_EGG = getItemType("ghast_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed GLOW_SQUID_SPAWN_EGG = getItemType("glow_squid_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed GOAT_SPAWN_EGG = getItemType("goat_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed GUARDIAN_SPAWN_EGG = getItemType("guardian_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed HOGLIN_SPAWN_EGG = getItemType("hoglin_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed HORSE_SPAWN_EGG = getItemType("horse_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed HUSK_SPAWN_EGG = getItemType("husk_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed IRON_GOLEM_SPAWN_EGG = getItemType("iron_golem_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed LLAMA_SPAWN_EGG = getItemType("llama_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed MAGMA_CUBE_SPAWN_EGG = getItemType("magma_cube_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed MOOSHROOM_SPAWN_EGG = getItemType("mooshroom_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed MULE_SPAWN_EGG = getItemType("mule_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed OCELOT_SPAWN_EGG = getItemType("ocelot_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PANDA_SPAWN_EGG = getItemType("panda_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PARROT_SPAWN_EGG = getItemType("parrot_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PHANTOM_SPAWN_EGG = getItemType("phantom_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PIG_SPAWN_EGG = getItemType("pig_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PIGLIN_SPAWN_EGG = getItemType("piglin_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PIGLIN_BRUTE_SPAWN_EGG = getItemType("piglin_brute_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PILLAGER_SPAWN_EGG = getItemType("pillager_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed POLAR_BEAR_SPAWN_EGG = getItemType("polar_bear_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed PUFFERFISH_SPAWN_EGG = getItemType("pufferfish_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed RABBIT_SPAWN_EGG = getItemType("rabbit_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed RAVAGER_SPAWN_EGG = getItemType("ravager_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SALMON_SPAWN_EGG = getItemType("salmon_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SHEEP_SPAWN_EGG = getItemType("sheep_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SHULKER_SPAWN_EGG = getItemType("shulker_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SILVERFISH_SPAWN_EGG = getItemType("silverfish_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SKELETON_SPAWN_EGG = getItemType("skeleton_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SKELETON_HORSE_SPAWN_EGG = getItemType("skeleton_horse_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SLIME_SPAWN_EGG = getItemType("slime_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SNIFFER_SPAWN_EGG = getItemType("sniffer_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SNOW_GOLEM_SPAWN_EGG = getItemType("snow_golem_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SPIDER_SPAWN_EGG = getItemType("spider_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed SQUID_SPAWN_EGG = getItemType("squid_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed STRAY_SPAWN_EGG = getItemType("stray_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed STRIDER_SPAWN_EGG = getItemType("strider_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed TADPOLE_SPAWN_EGG = getItemType("tadpole_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed TRADER_LLAMA_SPAWN_EGG = getItemType("trader_llama_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed TROPICAL_FISH_SPAWN_EGG = getItemType("tropical_fish_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed TURTLE_SPAWN_EGG = getItemType("turtle_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed VEX_SPAWN_EGG = getItemType("vex_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed VILLAGER_SPAWN_EGG = getItemType("villager_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed VINDICATOR_SPAWN_EGG = getItemType("vindicator_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WANDERING_TRADER_SPAWN_EGG = getItemType("wandering_trader_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WARDEN_SPAWN_EGG = getItemType("warden_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WITCH_SPAWN_EGG = getItemType("witch_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WITHER_SPAWN_EGG = getItemType("wither_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WITHER_SKELETON_SPAWN_EGG = getItemType("wither_skeleton_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed WOLF_SPAWN_EGG = getItemType("wolf_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ZOGLIN_SPAWN_EGG = getItemType("zoglin_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ZOMBIE_SPAWN_EGG = getItemType("zombie_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ZOMBIE_HORSE_SPAWN_EGG = getItemType("zombie_horse_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ZOMBIE_VILLAGER_SPAWN_EGG = getItemType("zombie_villager_spawn_egg"); - /** - * ItemMeta: {@link SpawnEggMeta} - */ - ItemType.Typed ZOMBIFIED_PIGLIN_SPAWN_EGG = getItemType("zombified_piglin_spawn_egg"); - ItemType.Typed EXPERIENCE_BOTTLE = getItemType("experience_bottle"); - ItemType.Typed FIRE_CHARGE = getItemType("fire_charge"); - ItemType.Typed WIND_CHARGE = getItemType("wind_charge"); - /** - * ItemMeta: {@link BookMeta} - */ - ItemType.Typed WRITABLE_BOOK = getItemType("writable_book"); - /** - * ItemMeta: {@link BookMeta} - */ - ItemType.Typed WRITTEN_BOOK = getItemType("written_book"); - ItemType.Typed BREEZE_ROD = getItemType("breeze_rod"); - ItemType.Typed MACE = getItemType("mace"); - ItemType.Typed ITEM_FRAME = getItemType("item_frame"); - ItemType.Typed GLOW_ITEM_FRAME = getItemType("glow_item_frame"); - ItemType.Typed FLOWER_POT = getItemType("flower_pot"); - ItemType.Typed CARROT = getItemType("carrot"); - ItemType.Typed POTATO = getItemType("potato"); - ItemType.Typed BAKED_POTATO = getItemType("baked_potato"); - ItemType.Typed POISONOUS_POTATO = getItemType("poisonous_potato"); - ItemType.Typed MAP = getItemType("map"); - ItemType.Typed GOLDEN_CARROT = getItemType("golden_carrot"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed SKELETON_SKULL = getItemType("skeleton_skull"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed WITHER_SKELETON_SKULL = getItemType("wither_skeleton_skull"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed PLAYER_HEAD = getItemType("player_head"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed ZOMBIE_HEAD = getItemType("zombie_head"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed CREEPER_HEAD = getItemType("creeper_head"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed DRAGON_HEAD = getItemType("dragon_head"); - /** - * ItemMeta: {@link SkullMeta} - */ - ItemType.Typed PIGLIN_HEAD = getItemType("piglin_head"); - ItemType.Typed NETHER_STAR = getItemType("nether_star"); - ItemType.Typed PUMPKIN_PIE = getItemType("pumpkin_pie"); - /** - * ItemMeta: {@link FireworkMeta} - */ - ItemType.Typed FIREWORK_ROCKET = getItemType("firework_rocket"); - /** - * ItemMeta: {@link FireworkEffectMeta} - */ - ItemType.Typed FIREWORK_STAR = getItemType("firework_star"); - /** - * ItemMeta: {@link EnchantmentStorageMeta} - */ - ItemType.Typed ENCHANTED_BOOK = getItemType("enchanted_book"); - ItemType.Typed NETHER_BRICK = getItemType("nether_brick"); - ItemType.Typed RESIN_BRICK = getItemType("resin_brick"); - ItemType.Typed PRISMARINE_SHARD = getItemType("prismarine_shard"); - ItemType.Typed PRISMARINE_CRYSTALS = getItemType("prismarine_crystals"); - ItemType.Typed RABBIT = getItemType("rabbit"); - ItemType.Typed COOKED_RABBIT = getItemType("cooked_rabbit"); - ItemType.Typed RABBIT_STEW = getItemType("rabbit_stew"); - ItemType.Typed RABBIT_FOOT = getItemType("rabbit_foot"); - ItemType.Typed RABBIT_HIDE = getItemType("rabbit_hide"); - ItemType.Typed ARMOR_STAND = getItemType("armor_stand"); - ItemType.Typed IRON_HORSE_ARMOR = getItemType("iron_horse_armor"); - ItemType.Typed GOLDEN_HORSE_ARMOR = getItemType("golden_horse_armor"); - ItemType.Typed DIAMOND_HORSE_ARMOR = getItemType("diamond_horse_armor"); - /** - * ItemMeta: {@link LeatherArmorMeta} - */ - ItemType.Typed LEATHER_HORSE_ARMOR = getItemType("leather_horse_armor"); - ItemType.Typed LEAD = getItemType("lead"); - ItemType.Typed NAME_TAG = getItemType("name_tag"); - ItemType.Typed COMMAND_BLOCK_MINECART = getItemType("command_block_minecart"); - ItemType.Typed MUTTON = getItemType("mutton"); - ItemType.Typed COOKED_MUTTON = getItemType("cooked_mutton"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed WHITE_BANNER = getItemType("white_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed ORANGE_BANNER = getItemType("orange_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed MAGENTA_BANNER = getItemType("magenta_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed LIGHT_BLUE_BANNER = getItemType("light_blue_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed YELLOW_BANNER = getItemType("yellow_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed LIME_BANNER = getItemType("lime_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed PINK_BANNER = getItemType("pink_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed GRAY_BANNER = getItemType("gray_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed LIGHT_GRAY_BANNER = getItemType("light_gray_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed CYAN_BANNER = getItemType("cyan_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed PURPLE_BANNER = getItemType("purple_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed BLUE_BANNER = getItemType("blue_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed BROWN_BANNER = getItemType("brown_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed GREEN_BANNER = getItemType("green_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed RED_BANNER = getItemType("red_banner"); - /** - * ItemMeta: {@link BannerMeta} - */ - ItemType.Typed BLACK_BANNER = getItemType("black_banner"); - ItemType.Typed END_CRYSTAL = getItemType("end_crystal"); - ItemType.Typed CHORUS_FRUIT = getItemType("chorus_fruit"); - ItemType.Typed POPPED_CHORUS_FRUIT = getItemType("popped_chorus_fruit"); - ItemType.Typed TORCHFLOWER_SEEDS = getItemType("torchflower_seeds"); - ItemType.Typed PITCHER_POD = getItemType("pitcher_pod"); - ItemType.Typed BEETROOT = getItemType("beetroot"); - ItemType.Typed BEETROOT_SEEDS = getItemType("beetroot_seeds"); - ItemType.Typed BEETROOT_SOUP = getItemType("beetroot_soup"); - ItemType.Typed DRAGON_BREATH = getItemType("dragon_breath"); - /** - * ItemMeta: {@link PotionMeta} - */ - ItemType.Typed SPLASH_POTION = getItemType("splash_potion"); - ItemType.Typed SPECTRAL_ARROW = getItemType("spectral_arrow"); - /** - * ItemMeta: {@link PotionMeta} - */ - ItemType.Typed TIPPED_ARROW = getItemType("tipped_arrow"); - /** - * ItemMeta: {@link PotionMeta} - */ - ItemType.Typed LINGERING_POTION = getItemType("lingering_potion"); - /** - * ItemMeta: {@link ShieldMeta} - */ - ItemType.Typed SHIELD = getItemType("shield"); - ItemType.Typed TOTEM_OF_UNDYING = getItemType("totem_of_undying"); - ItemType.Typed SHULKER_SHELL = getItemType("shulker_shell"); - ItemType.Typed IRON_NUGGET = getItemType("iron_nugget"); - /** - * ItemMeta: {@link KnowledgeBookMeta} - */ - ItemType.Typed KNOWLEDGE_BOOK = getItemType("knowledge_book"); - ItemType.Typed DEBUG_STICK = getItemType("debug_stick"); - ItemType.Typed MUSIC_DISC_13 = getItemType("music_disc_13"); - ItemType.Typed MUSIC_DISC_CAT = getItemType("music_disc_cat"); - ItemType.Typed MUSIC_DISC_BLOCKS = getItemType("music_disc_blocks"); - ItemType.Typed MUSIC_DISC_CHIRP = getItemType("music_disc_chirp"); - ItemType.Typed MUSIC_DISC_CREATOR = getItemType("music_disc_creator"); - ItemType.Typed MUSIC_DISC_CREATOR_MUSIC_BOX = getItemType("music_disc_creator_music_box"); - ItemType.Typed MUSIC_DISC_FAR = getItemType("music_disc_far"); - ItemType.Typed MUSIC_DISC_MALL = getItemType("music_disc_mall"); - ItemType.Typed MUSIC_DISC_MELLOHI = getItemType("music_disc_mellohi"); - ItemType.Typed MUSIC_DISC_STAL = getItemType("music_disc_stal"); - ItemType.Typed MUSIC_DISC_STRAD = getItemType("music_disc_strad"); - ItemType.Typed MUSIC_DISC_WARD = getItemType("music_disc_ward"); - ItemType.Typed MUSIC_DISC_11 = getItemType("music_disc_11"); - ItemType.Typed MUSIC_DISC_WAIT = getItemType("music_disc_wait"); - ItemType.Typed MUSIC_DISC_OTHERSIDE = getItemType("music_disc_otherside"); - ItemType.Typed MUSIC_DISC_RELIC = getItemType("music_disc_relic"); - ItemType.Typed MUSIC_DISC_5 = getItemType("music_disc_5"); - ItemType.Typed MUSIC_DISC_PIGSTEP = getItemType("music_disc_pigstep"); - ItemType.Typed MUSIC_DISC_PRECIPICE = getItemType("music_disc_precipice"); - ItemType.Typed DISC_FRAGMENT_5 = getItemType("disc_fragment_5"); - ItemType.Typed TRIDENT = getItemType("trident"); - ItemType.Typed NAUTILUS_SHELL = getItemType("nautilus_shell"); - ItemType.Typed HEART_OF_THE_SEA = getItemType("heart_of_the_sea"); - /** - * ItemMeta: {@link CrossbowMeta} - */ - ItemType.Typed CROSSBOW = getItemType("crossbow"); - /** - * ItemMeta: {@link SuspiciousStewMeta} - */ - ItemType.Typed SUSPICIOUS_STEW = getItemType("suspicious_stew"); - ItemType.Typed LOOM = getItemType("loom"); - ItemType.Typed FLOWER_BANNER_PATTERN = getItemType("flower_banner_pattern"); - ItemType.Typed CREEPER_BANNER_PATTERN = getItemType("creeper_banner_pattern"); - ItemType.Typed SKULL_BANNER_PATTERN = getItemType("skull_banner_pattern"); - ItemType.Typed MOJANG_BANNER_PATTERN = getItemType("mojang_banner_pattern"); - ItemType.Typed GLOBE_BANNER_PATTERN = getItemType("globe_banner_pattern"); - ItemType.Typed PIGLIN_BANNER_PATTERN = getItemType("piglin_banner_pattern"); - ItemType.Typed FLOW_BANNER_PATTERN = getItemType("flow_banner_pattern"); - ItemType.Typed GUSTER_BANNER_PATTERN = getItemType("guster_banner_pattern"); - ItemType.Typed FIELD_MASONED_BANNER_PATTERN = getItemType("field_masoned_banner_pattern"); - ItemType.Typed BORDURE_INDENTED_BANNER_PATTERN = getItemType("bordure_indented_banner_pattern"); - /** - * ItemMeta: {@link MusicInstrumentMeta} - */ - ItemType.Typed GOAT_HORN = getItemType("goat_horn"); - ItemType.Typed COMPOSTER = getItemType("composter"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BARREL = getItemType("barrel"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SMOKER = getItemType("smoker"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BLAST_FURNACE = getItemType("blast_furnace"); - ItemType.Typed CARTOGRAPHY_TABLE = getItemType("cartography_table"); - ItemType.Typed FLETCHING_TABLE = getItemType("fletching_table"); - ItemType.Typed GRINDSTONE = getItemType("grindstone"); - ItemType.Typed SMITHING_TABLE = getItemType("smithing_table"); - ItemType.Typed STONECUTTER = getItemType("stonecutter"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BELL = getItemType("bell"); - ItemType.Typed LANTERN = getItemType("lantern"); - ItemType.Typed SOUL_LANTERN = getItemType("soul_lantern"); - ItemType.Typed SWEET_BERRIES = getItemType("sweet_berries"); - ItemType.Typed GLOW_BERRIES = getItemType("glow_berries"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed CAMPFIRE = getItemType("campfire"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed SOUL_CAMPFIRE = getItemType("soul_campfire"); - ItemType.Typed SHROOMLIGHT = getItemType("shroomlight"); - ItemType.Typed HONEYCOMB = getItemType("honeycomb"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BEE_NEST = getItemType("bee_nest"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed BEEHIVE = getItemType("beehive"); - ItemType.Typed HONEY_BOTTLE = getItemType("honey_bottle"); - ItemType.Typed HONEYCOMB_BLOCK = getItemType("honeycomb_block"); - ItemType.Typed LODESTONE = getItemType("lodestone"); - ItemType.Typed CRYING_OBSIDIAN = getItemType("crying_obsidian"); - ItemType.Typed BLACKSTONE = getItemType("blackstone"); - ItemType.Typed BLACKSTONE_SLAB = getItemType("blackstone_slab"); - ItemType.Typed BLACKSTONE_STAIRS = getItemType("blackstone_stairs"); - ItemType.Typed GILDED_BLACKSTONE = getItemType("gilded_blackstone"); - ItemType.Typed POLISHED_BLACKSTONE = getItemType("polished_blackstone"); - ItemType.Typed POLISHED_BLACKSTONE_SLAB = getItemType("polished_blackstone_slab"); - ItemType.Typed POLISHED_BLACKSTONE_STAIRS = getItemType("polished_blackstone_stairs"); - ItemType.Typed CHISELED_POLISHED_BLACKSTONE = getItemType("chiseled_polished_blackstone"); - ItemType.Typed POLISHED_BLACKSTONE_BRICKS = getItemType("polished_blackstone_bricks"); - ItemType.Typed POLISHED_BLACKSTONE_BRICK_SLAB = getItemType("polished_blackstone_brick_slab"); - ItemType.Typed POLISHED_BLACKSTONE_BRICK_STAIRS = getItemType("polished_blackstone_brick_stairs"); - ItemType.Typed CRACKED_POLISHED_BLACKSTONE_BRICKS = getItemType("cracked_polished_blackstone_bricks"); - ItemType.Typed RESPAWN_ANCHOR = getItemType("respawn_anchor"); - ItemType.Typed CANDLE = getItemType("candle"); - ItemType.Typed WHITE_CANDLE = getItemType("white_candle"); - ItemType.Typed ORANGE_CANDLE = getItemType("orange_candle"); - ItemType.Typed MAGENTA_CANDLE = getItemType("magenta_candle"); - ItemType.Typed LIGHT_BLUE_CANDLE = getItemType("light_blue_candle"); - ItemType.Typed YELLOW_CANDLE = getItemType("yellow_candle"); - ItemType.Typed LIME_CANDLE = getItemType("lime_candle"); - ItemType.Typed PINK_CANDLE = getItemType("pink_candle"); - ItemType.Typed GRAY_CANDLE = getItemType("gray_candle"); - ItemType.Typed LIGHT_GRAY_CANDLE = getItemType("light_gray_candle"); - ItemType.Typed CYAN_CANDLE = getItemType("cyan_candle"); - ItemType.Typed PURPLE_CANDLE = getItemType("purple_candle"); - ItemType.Typed BLUE_CANDLE = getItemType("blue_candle"); - ItemType.Typed BROWN_CANDLE = getItemType("brown_candle"); - ItemType.Typed GREEN_CANDLE = getItemType("green_candle"); - ItemType.Typed RED_CANDLE = getItemType("red_candle"); - ItemType.Typed BLACK_CANDLE = getItemType("black_candle"); - ItemType.Typed SMALL_AMETHYST_BUD = getItemType("small_amethyst_bud"); - ItemType.Typed MEDIUM_AMETHYST_BUD = getItemType("medium_amethyst_bud"); - ItemType.Typed LARGE_AMETHYST_BUD = getItemType("large_amethyst_bud"); + + ItemType.Typed ALLIUM = getItemType("allium"); + + ItemType.Typed AMETHYST_BLOCK = getItemType("amethyst_block"); + ItemType.Typed AMETHYST_CLUSTER = getItemType("amethyst_cluster"); - ItemType.Typed POINTED_DRIPSTONE = getItemType("pointed_dripstone"); - ItemType.Typed OCHRE_FROGLIGHT = getItemType("ochre_froglight"); - ItemType.Typed VERDANT_FROGLIGHT = getItemType("verdant_froglight"); - ItemType.Typed PEARLESCENT_FROGLIGHT = getItemType("pearlescent_froglight"); - ItemType.Typed FROGSPAWN = getItemType("frogspawn"); - ItemType.Typed ECHO_SHARD = getItemType("echo_shard"); - ItemType.Typed BRUSH = getItemType("brush"); - ItemType.Typed NETHERITE_UPGRADE_SMITHING_TEMPLATE = getItemType("netherite_upgrade_smithing_template"); - ItemType.Typed SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("sentry_armor_trim_smithing_template"); - ItemType.Typed DUNE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("dune_armor_trim_smithing_template"); - ItemType.Typed COAST_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("coast_armor_trim_smithing_template"); - ItemType.Typed WILD_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("wild_armor_trim_smithing_template"); - ItemType.Typed WARD_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("ward_armor_trim_smithing_template"); - ItemType.Typed EYE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("eye_armor_trim_smithing_template"); - ItemType.Typed VEX_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("vex_armor_trim_smithing_template"); - ItemType.Typed TIDE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("tide_armor_trim_smithing_template"); - ItemType.Typed SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("snout_armor_trim_smithing_template"); - ItemType.Typed RIB_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("rib_armor_trim_smithing_template"); - ItemType.Typed SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("spire_armor_trim_smithing_template"); - ItemType.Typed WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("wayfinder_armor_trim_smithing_template"); - ItemType.Typed SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("shaper_armor_trim_smithing_template"); - ItemType.Typed SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("silence_armor_trim_smithing_template"); - ItemType.Typed RAISER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("raiser_armor_trim_smithing_template"); - ItemType.Typed HOST_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("host_armor_trim_smithing_template"); - ItemType.Typed FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("flow_armor_trim_smithing_template"); - ItemType.Typed BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("bolt_armor_trim_smithing_template"); + + ItemType.Typed AMETHYST_SHARD = getItemType("amethyst_shard"); + + ItemType.Typed ANCIENT_DEBRIS = getItemType("ancient_debris"); + + ItemType.Typed ANDESITE = getItemType("andesite"); + + ItemType.Typed ANDESITE_SLAB = getItemType("andesite_slab"); + + ItemType.Typed ANDESITE_STAIRS = getItemType("andesite_stairs"); + + ItemType.Typed ANDESITE_WALL = getItemType("andesite_wall"); + ItemType.Typed ANGLER_POTTERY_SHERD = getItemType("angler_pottery_sherd"); + + ItemType.Typed ANVIL = getItemType("anvil"); + + ItemType.Typed APPLE = getItemType("apple"); + ItemType.Typed ARCHER_POTTERY_SHERD = getItemType("archer_pottery_sherd"); + + ItemType.Typed ARMADILLO_SCUTE = getItemType("armadillo_scute"); + + ItemType.Typed ARMADILLO_SPAWN_EGG = getItemType("armadillo_spawn_egg"); + + ItemType.Typed ARMOR_STAND = getItemType("armor_stand"); + ItemType.Typed ARMS_UP_POTTERY_SHERD = getItemType("arms_up_pottery_sherd"); + + ItemType.Typed ARROW = getItemType("arrow"); + + ItemType.Typed AXOLOTL_BUCKET = getItemType("axolotl_bucket"); + + ItemType.Typed AXOLOTL_SPAWN_EGG = getItemType("axolotl_spawn_egg"); + + ItemType.Typed AZALEA = getItemType("azalea"); + + ItemType.Typed AZALEA_LEAVES = getItemType("azalea_leaves"); + + ItemType.Typed AZURE_BLUET = getItemType("azure_bluet"); + + ItemType.Typed BAKED_POTATO = getItemType("baked_potato"); + + ItemType.Typed BAMBOO = getItemType("bamboo"); + + ItemType.Typed BAMBOO_BLOCK = getItemType("bamboo_block"); + + ItemType.Typed BAMBOO_BUTTON = getItemType("bamboo_button"); + + ItemType.Typed BAMBOO_CHEST_RAFT = getItemType("bamboo_chest_raft"); + + ItemType.Typed BAMBOO_DOOR = getItemType("bamboo_door"); + + ItemType.Typed BAMBOO_FENCE = getItemType("bamboo_fence"); + + ItemType.Typed BAMBOO_FENCE_GATE = getItemType("bamboo_fence_gate"); + + ItemType.Typed BAMBOO_HANGING_SIGN = getItemType("bamboo_hanging_sign"); + + ItemType.Typed BAMBOO_MOSAIC = getItemType("bamboo_mosaic"); + + ItemType.Typed BAMBOO_MOSAIC_SLAB = getItemType("bamboo_mosaic_slab"); + + ItemType.Typed BAMBOO_MOSAIC_STAIRS = getItemType("bamboo_mosaic_stairs"); + + ItemType.Typed BAMBOO_PLANKS = getItemType("bamboo_planks"); + + ItemType.Typed BAMBOO_PRESSURE_PLATE = getItemType("bamboo_pressure_plate"); + + ItemType.Typed BAMBOO_RAFT = getItemType("bamboo_raft"); + + ItemType.Typed BAMBOO_SIGN = getItemType("bamboo_sign"); + + ItemType.Typed BAMBOO_SLAB = getItemType("bamboo_slab"); + + ItemType.Typed BAMBOO_STAIRS = getItemType("bamboo_stairs"); + + ItemType.Typed BAMBOO_TRAPDOOR = getItemType("bamboo_trapdoor"); + + ItemType.Typed BARREL = getItemType("barrel"); + + ItemType.Typed BARRIER = getItemType("barrier"); + + ItemType.Typed BASALT = getItemType("basalt"); + + ItemType.Typed BAT_SPAWN_EGG = getItemType("bat_spawn_egg"); + + ItemType.Typed BEACON = getItemType("beacon"); + + ItemType.Typed BEDROCK = getItemType("bedrock"); + + ItemType.Typed BEE_NEST = getItemType("bee_nest"); + + ItemType.Typed BEE_SPAWN_EGG = getItemType("bee_spawn_egg"); + + ItemType.Typed BEEF = getItemType("beef"); + + ItemType.Typed BEEHIVE = getItemType("beehive"); + + ItemType.Typed BEETROOT = getItemType("beetroot"); + + ItemType.Typed BEETROOT_SEEDS = getItemType("beetroot_seeds"); + + ItemType.Typed BEETROOT_SOUP = getItemType("beetroot_soup"); + + ItemType.Typed BELL = getItemType("bell"); + + ItemType.Typed BIG_DRIPLEAF = getItemType("big_dripleaf"); + + ItemType.Typed BIRCH_BOAT = getItemType("birch_boat"); + + ItemType.Typed BIRCH_BUTTON = getItemType("birch_button"); + + ItemType.Typed BIRCH_CHEST_BOAT = getItemType("birch_chest_boat"); + + ItemType.Typed BIRCH_DOOR = getItemType("birch_door"); + + ItemType.Typed BIRCH_FENCE = getItemType("birch_fence"); + + ItemType.Typed BIRCH_FENCE_GATE = getItemType("birch_fence_gate"); + + ItemType.Typed BIRCH_HANGING_SIGN = getItemType("birch_hanging_sign"); + + ItemType.Typed BIRCH_LEAVES = getItemType("birch_leaves"); + + ItemType.Typed BIRCH_LOG = getItemType("birch_log"); + + ItemType.Typed BIRCH_PLANKS = getItemType("birch_planks"); + + ItemType.Typed BIRCH_PRESSURE_PLATE = getItemType("birch_pressure_plate"); + + ItemType.Typed BIRCH_SAPLING = getItemType("birch_sapling"); + + ItemType.Typed BIRCH_SIGN = getItemType("birch_sign"); + + ItemType.Typed BIRCH_SLAB = getItemType("birch_slab"); + + ItemType.Typed BIRCH_STAIRS = getItemType("birch_stairs"); + + ItemType.Typed BIRCH_TRAPDOOR = getItemType("birch_trapdoor"); + + ItemType.Typed BIRCH_WOOD = getItemType("birch_wood"); + + ItemType.Typed BLACK_BANNER = getItemType("black_banner"); + + ItemType.Typed BLACK_BED = getItemType("black_bed"); + + ItemType.Typed BLACK_BUNDLE = getItemType("black_bundle"); + + ItemType.Typed BLACK_CANDLE = getItemType("black_candle"); + + ItemType.Typed BLACK_CARPET = getItemType("black_carpet"); + + ItemType.Typed BLACK_CONCRETE = getItemType("black_concrete"); + + ItemType.Typed BLACK_CONCRETE_POWDER = getItemType("black_concrete_powder"); + + ItemType.Typed BLACK_DYE = getItemType("black_dye"); + + ItemType.Typed BLACK_GLAZED_TERRACOTTA = getItemType("black_glazed_terracotta"); + + ItemType.Typed BLACK_SHULKER_BOX = getItemType("black_shulker_box"); + + ItemType.Typed BLACK_STAINED_GLASS = getItemType("black_stained_glass"); + + ItemType.Typed BLACK_STAINED_GLASS_PANE = getItemType("black_stained_glass_pane"); + + ItemType.Typed BLACK_TERRACOTTA = getItemType("black_terracotta"); + + ItemType.Typed BLACK_WOOL = getItemType("black_wool"); + + ItemType.Typed BLACKSTONE = getItemType("blackstone"); + + ItemType.Typed BLACKSTONE_SLAB = getItemType("blackstone_slab"); + + ItemType.Typed BLACKSTONE_STAIRS = getItemType("blackstone_stairs"); + + ItemType.Typed BLACKSTONE_WALL = getItemType("blackstone_wall"); + ItemType.Typed BLADE_POTTERY_SHERD = getItemType("blade_pottery_sherd"); + + ItemType.Typed BLAST_FURNACE = getItemType("blast_furnace"); + + ItemType.Typed BLAZE_POWDER = getItemType("blaze_powder"); + + ItemType.Typed BLAZE_ROD = getItemType("blaze_rod"); + + ItemType.Typed BLAZE_SPAWN_EGG = getItemType("blaze_spawn_egg"); + + ItemType.Typed BLUE_BANNER = getItemType("blue_banner"); + + ItemType.Typed BLUE_BED = getItemType("blue_bed"); + + ItemType.Typed BLUE_BUNDLE = getItemType("blue_bundle"); + + ItemType.Typed BLUE_CANDLE = getItemType("blue_candle"); + + ItemType.Typed BLUE_CARPET = getItemType("blue_carpet"); + + ItemType.Typed BLUE_CONCRETE = getItemType("blue_concrete"); + + ItemType.Typed BLUE_CONCRETE_POWDER = getItemType("blue_concrete_powder"); + + ItemType.Typed BLUE_DYE = getItemType("blue_dye"); + + ItemType.Typed BLUE_EGG = getItemType("blue_egg"); + + ItemType.Typed BLUE_GLAZED_TERRACOTTA = getItemType("blue_glazed_terracotta"); + + ItemType.Typed BLUE_ICE = getItemType("blue_ice"); + + ItemType.Typed BLUE_ORCHID = getItemType("blue_orchid"); + + ItemType.Typed BLUE_SHULKER_BOX = getItemType("blue_shulker_box"); + + ItemType.Typed BLUE_STAINED_GLASS = getItemType("blue_stained_glass"); + + ItemType.Typed BLUE_STAINED_GLASS_PANE = getItemType("blue_stained_glass_pane"); + + ItemType.Typed BLUE_TERRACOTTA = getItemType("blue_terracotta"); + + ItemType.Typed BLUE_WOOL = getItemType("blue_wool"); + + ItemType.Typed BOGGED_SPAWN_EGG = getItemType("bogged_spawn_egg"); + + ItemType.Typed BOLT_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("bolt_armor_trim_smithing_template"); + + ItemType.Typed BONE = getItemType("bone"); + + ItemType.Typed BONE_BLOCK = getItemType("bone_block"); + + ItemType.Typed BONE_MEAL = getItemType("bone_meal"); + + ItemType.Typed BOOK = getItemType("book"); + + ItemType.Typed BOOKSHELF = getItemType("bookshelf"); + + ItemType.Typed BORDURE_INDENTED_BANNER_PATTERN = getItemType("bordure_indented_banner_pattern"); + + ItemType.Typed BOW = getItemType("bow"); + + ItemType.Typed BOWL = getItemType("bowl"); + + ItemType.Typed BRAIN_CORAL = getItemType("brain_coral"); + + ItemType.Typed BRAIN_CORAL_BLOCK = getItemType("brain_coral_block"); + + ItemType.Typed BRAIN_CORAL_FAN = getItemType("brain_coral_fan"); + + ItemType.Typed BREAD = getItemType("bread"); + + ItemType.Typed BREEZE_ROD = getItemType("breeze_rod"); + + ItemType.Typed BREEZE_SPAWN_EGG = getItemType("breeze_spawn_egg"); + ItemType.Typed BREWER_POTTERY_SHERD = getItemType("brewer_pottery_sherd"); + + ItemType.Typed BREWING_STAND = getItemType("brewing_stand"); + + ItemType.Typed BRICK = getItemType("brick"); + + ItemType.Typed BRICK_SLAB = getItemType("brick_slab"); + + ItemType.Typed BRICK_STAIRS = getItemType("brick_stairs"); + + ItemType.Typed BRICK_WALL = getItemType("brick_wall"); + + ItemType.Typed BRICKS = getItemType("bricks"); + + ItemType.Typed BROWN_BANNER = getItemType("brown_banner"); + + ItemType.Typed BROWN_BED = getItemType("brown_bed"); + + ItemType.Typed BROWN_BUNDLE = getItemType("brown_bundle"); + + ItemType.Typed BROWN_CANDLE = getItemType("brown_candle"); + + ItemType.Typed BROWN_CARPET = getItemType("brown_carpet"); + + ItemType.Typed BROWN_CONCRETE = getItemType("brown_concrete"); + + ItemType.Typed BROWN_CONCRETE_POWDER = getItemType("brown_concrete_powder"); + + ItemType.Typed BROWN_DYE = getItemType("brown_dye"); + + ItemType.Typed BROWN_EGG = getItemType("brown_egg"); + + ItemType.Typed BROWN_GLAZED_TERRACOTTA = getItemType("brown_glazed_terracotta"); + + ItemType.Typed BROWN_MUSHROOM = getItemType("brown_mushroom"); + + ItemType.Typed BROWN_MUSHROOM_BLOCK = getItemType("brown_mushroom_block"); + + ItemType.Typed BROWN_SHULKER_BOX = getItemType("brown_shulker_box"); + + ItemType.Typed BROWN_STAINED_GLASS = getItemType("brown_stained_glass"); + + ItemType.Typed BROWN_STAINED_GLASS_PANE = getItemType("brown_stained_glass_pane"); + + ItemType.Typed BROWN_TERRACOTTA = getItemType("brown_terracotta"); + + ItemType.Typed BROWN_WOOL = getItemType("brown_wool"); + + ItemType.Typed BRUSH = getItemType("brush"); + + ItemType.Typed BUBBLE_CORAL = getItemType("bubble_coral"); + + ItemType.Typed BUBBLE_CORAL_BLOCK = getItemType("bubble_coral_block"); + + ItemType.Typed BUBBLE_CORAL_FAN = getItemType("bubble_coral_fan"); + + ItemType.Typed BUCKET = getItemType("bucket"); + + ItemType.Typed BUDDING_AMETHYST = getItemType("budding_amethyst"); + + ItemType.Typed BUNDLE = getItemType("bundle"); + ItemType.Typed BURN_POTTERY_SHERD = getItemType("burn_pottery_sherd"); - ItemType.Typed DANGER_POTTERY_SHERD = getItemType("danger_pottery_sherd"); - ItemType.Typed EXPLORER_POTTERY_SHERD = getItemType("explorer_pottery_sherd"); - ItemType.Typed FLOW_POTTERY_SHERD = getItemType("flow_pottery_sherd"); - ItemType.Typed FRIEND_POTTERY_SHERD = getItemType("friend_pottery_sherd"); - ItemType.Typed GUSTER_POTTERY_SHERD = getItemType("guster_pottery_sherd"); - ItemType.Typed HEART_POTTERY_SHERD = getItemType("heart_pottery_sherd"); - ItemType.Typed HEARTBREAK_POTTERY_SHERD = getItemType("heartbreak_pottery_sherd"); - ItemType.Typed HOWL_POTTERY_SHERD = getItemType("howl_pottery_sherd"); - ItemType.Typed MINER_POTTERY_SHERD = getItemType("miner_pottery_sherd"); - ItemType.Typed MOURNER_POTTERY_SHERD = getItemType("mourner_pottery_sherd"); - ItemType.Typed PLENTY_POTTERY_SHERD = getItemType("plenty_pottery_sherd"); - ItemType.Typed PRIZE_POTTERY_SHERD = getItemType("prize_pottery_sherd"); - ItemType.Typed SCRAPE_POTTERY_SHERD = getItemType("scrape_pottery_sherd"); - ItemType.Typed SHEAF_POTTERY_SHERD = getItemType("sheaf_pottery_sherd"); - ItemType.Typed SHELTER_POTTERY_SHERD = getItemType("shelter_pottery_sherd"); - ItemType.Typed SKULL_POTTERY_SHERD = getItemType("skull_pottery_sherd"); - ItemType.Typed SNORT_POTTERY_SHERD = getItemType("snort_pottery_sherd"); - ItemType.Typed COPPER_GRATE = getItemType("copper_grate"); - ItemType.Typed EXPOSED_COPPER_GRATE = getItemType("exposed_copper_grate"); - ItemType.Typed WEATHERED_COPPER_GRATE = getItemType("weathered_copper_grate"); - ItemType.Typed OXIDIZED_COPPER_GRATE = getItemType("oxidized_copper_grate"); - ItemType.Typed WAXED_COPPER_GRATE = getItemType("waxed_copper_grate"); - ItemType.Typed WAXED_EXPOSED_COPPER_GRATE = getItemType("waxed_exposed_copper_grate"); - ItemType.Typed WAXED_WEATHERED_COPPER_GRATE = getItemType("waxed_weathered_copper_grate"); - ItemType.Typed WAXED_OXIDIZED_COPPER_GRATE = getItemType("waxed_oxidized_copper_grate"); + + ItemType.Typed BUSH = getItemType("bush"); + + ItemType.Typed CACTUS = getItemType("cactus"); + + ItemType.Typed CACTUS_FLOWER = getItemType("cactus_flower"); + + ItemType.Typed CAKE = getItemType("cake"); + + ItemType.Typed CALCITE = getItemType("calcite"); + + ItemType.Typed CALIBRATED_SCULK_SENSOR = getItemType("calibrated_sculk_sensor"); + + ItemType.Typed CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg"); + + ItemType.Typed CAMPFIRE = getItemType("campfire"); + + ItemType.Typed CANDLE = getItemType("candle"); + + ItemType.Typed CARROT = getItemType("carrot"); + + ItemType.Typed CARROT_ON_A_STICK = getItemType("carrot_on_a_stick"); + + ItemType.Typed CARTOGRAPHY_TABLE = getItemType("cartography_table"); + + ItemType.Typed CARVED_PUMPKIN = getItemType("carved_pumpkin"); + + ItemType.Typed CAT_SPAWN_EGG = getItemType("cat_spawn_egg"); + + ItemType.Typed CAULDRON = getItemType("cauldron"); + + ItemType.Typed CAVE_SPIDER_SPAWN_EGG = getItemType("cave_spider_spawn_egg"); + + ItemType.Typed CHAIN = getItemType("chain"); + + ItemType.Typed CHAIN_COMMAND_BLOCK = getItemType("chain_command_block"); + + ItemType.Typed CHAINMAIL_BOOTS = getItemType("chainmail_boots"); + + ItemType.Typed CHAINMAIL_CHESTPLATE = getItemType("chainmail_chestplate"); + + ItemType.Typed CHAINMAIL_HELMET = getItemType("chainmail_helmet"); + + ItemType.Typed CHAINMAIL_LEGGINGS = getItemType("chainmail_leggings"); + + ItemType.Typed CHARCOAL = getItemType("charcoal"); + + ItemType.Typed CHERRY_BOAT = getItemType("cherry_boat"); + + ItemType.Typed CHERRY_BUTTON = getItemType("cherry_button"); + + ItemType.Typed CHERRY_CHEST_BOAT = getItemType("cherry_chest_boat"); + + ItemType.Typed CHERRY_DOOR = getItemType("cherry_door"); + + ItemType.Typed CHERRY_FENCE = getItemType("cherry_fence"); + + ItemType.Typed CHERRY_FENCE_GATE = getItemType("cherry_fence_gate"); + + ItemType.Typed CHERRY_HANGING_SIGN = getItemType("cherry_hanging_sign"); + + ItemType.Typed CHERRY_LEAVES = getItemType("cherry_leaves"); + + ItemType.Typed CHERRY_LOG = getItemType("cherry_log"); + + ItemType.Typed CHERRY_PLANKS = getItemType("cherry_planks"); + + ItemType.Typed CHERRY_PRESSURE_PLATE = getItemType("cherry_pressure_plate"); + + ItemType.Typed CHERRY_SAPLING = getItemType("cherry_sapling"); + + ItemType.Typed CHERRY_SIGN = getItemType("cherry_sign"); + + ItemType.Typed CHERRY_SLAB = getItemType("cherry_slab"); + + ItemType.Typed CHERRY_STAIRS = getItemType("cherry_stairs"); + + ItemType.Typed CHERRY_TRAPDOOR = getItemType("cherry_trapdoor"); + + ItemType.Typed CHERRY_WOOD = getItemType("cherry_wood"); + + ItemType.Typed CHEST = getItemType("chest"); + + ItemType.Typed CHEST_MINECART = getItemType("chest_minecart"); + + ItemType.Typed CHICKEN = getItemType("chicken"); + + ItemType.Typed CHICKEN_SPAWN_EGG = getItemType("chicken_spawn_egg"); + + ItemType.Typed CHIPPED_ANVIL = getItemType("chipped_anvil"); + + ItemType.Typed CHISELED_BOOKSHELF = getItemType("chiseled_bookshelf"); + + ItemType.Typed CHISELED_COPPER = getItemType("chiseled_copper"); + + ItemType.Typed CHISELED_DEEPSLATE = getItemType("chiseled_deepslate"); + + ItemType.Typed CHISELED_NETHER_BRICKS = getItemType("chiseled_nether_bricks"); + + ItemType.Typed CHISELED_POLISHED_BLACKSTONE = getItemType("chiseled_polished_blackstone"); + + ItemType.Typed CHISELED_QUARTZ_BLOCK = getItemType("chiseled_quartz_block"); + + ItemType.Typed CHISELED_RED_SANDSTONE = getItemType("chiseled_red_sandstone"); + + ItemType.Typed CHISELED_RESIN_BRICKS = getItemType("chiseled_resin_bricks"); + + ItemType.Typed CHISELED_SANDSTONE = getItemType("chiseled_sandstone"); + + ItemType.Typed CHISELED_STONE_BRICKS = getItemType("chiseled_stone_bricks"); + + ItemType.Typed CHISELED_TUFF = getItemType("chiseled_tuff"); + + ItemType.Typed CHISELED_TUFF_BRICKS = getItemType("chiseled_tuff_bricks"); + + ItemType.Typed CHORUS_FLOWER = getItemType("chorus_flower"); + + ItemType.Typed CHORUS_FRUIT = getItemType("chorus_fruit"); + + ItemType.Typed CHORUS_PLANT = getItemType("chorus_plant"); + + ItemType.Typed CLAY = getItemType("clay"); + + ItemType.Typed CLAY_BALL = getItemType("clay_ball"); + + ItemType.Typed CLOCK = getItemType("clock"); + + ItemType.Typed CLOSED_EYEBLOSSOM = getItemType("closed_eyeblossom"); + + ItemType.Typed COAL = getItemType("coal"); + + ItemType.Typed COAL_BLOCK = getItemType("coal_block"); + + ItemType.Typed COAL_ORE = getItemType("coal_ore"); + + ItemType.Typed COARSE_DIRT = getItemType("coarse_dirt"); + + ItemType.Typed COAST_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("coast_armor_trim_smithing_template"); + + ItemType.Typed COBBLED_DEEPSLATE = getItemType("cobbled_deepslate"); + + ItemType.Typed COBBLED_DEEPSLATE_SLAB = getItemType("cobbled_deepslate_slab"); + + ItemType.Typed COBBLED_DEEPSLATE_STAIRS = getItemType("cobbled_deepslate_stairs"); + + ItemType.Typed COBBLED_DEEPSLATE_WALL = getItemType("cobbled_deepslate_wall"); + + ItemType.Typed COBBLESTONE = getItemType("cobblestone"); + + ItemType.Typed COBBLESTONE_SLAB = getItemType("cobblestone_slab"); + + ItemType.Typed COBBLESTONE_STAIRS = getItemType("cobblestone_stairs"); + + ItemType.Typed COBBLESTONE_WALL = getItemType("cobblestone_wall"); + + ItemType.Typed COBWEB = getItemType("cobweb"); + + ItemType.Typed COCOA_BEANS = getItemType("cocoa_beans"); + + ItemType.Typed COD = getItemType("cod"); + + ItemType.Typed COD_BUCKET = getItemType("cod_bucket"); + + ItemType.Typed COD_SPAWN_EGG = getItemType("cod_spawn_egg"); + + ItemType.Typed COMMAND_BLOCK = getItemType("command_block"); + + ItemType.Typed COMMAND_BLOCK_MINECART = getItemType("command_block_minecart"); + + ItemType.Typed COMPARATOR = getItemType("comparator"); + + ItemType.Typed COMPASS = getItemType("compass"); + + ItemType.Typed COMPOSTER = getItemType("composter"); + + ItemType.Typed CONDUIT = getItemType("conduit"); + + ItemType.Typed COOKED_BEEF = getItemType("cooked_beef"); + + ItemType.Typed COOKED_CHICKEN = getItemType("cooked_chicken"); + + ItemType.Typed COOKED_COD = getItemType("cooked_cod"); + + ItemType.Typed COOKED_MUTTON = getItemType("cooked_mutton"); + + ItemType.Typed COOKED_PORKCHOP = getItemType("cooked_porkchop"); + + ItemType.Typed COOKED_RABBIT = getItemType("cooked_rabbit"); + + ItemType.Typed COOKED_SALMON = getItemType("cooked_salmon"); + + ItemType.Typed COOKIE = getItemType("cookie"); + + ItemType.Typed COPPER_BLOCK = getItemType("copper_block"); + ItemType.Typed COPPER_BULB = getItemType("copper_bulb"); + + ItemType.Typed COPPER_DOOR = getItemType("copper_door"); + + ItemType.Typed COPPER_GRATE = getItemType("copper_grate"); + + ItemType.Typed COPPER_INGOT = getItemType("copper_ingot"); + + ItemType.Typed COPPER_ORE = getItemType("copper_ore"); + + ItemType.Typed COPPER_TRAPDOOR = getItemType("copper_trapdoor"); + + ItemType.Typed CORNFLOWER = getItemType("cornflower"); + + ItemType.Typed COW_SPAWN_EGG = getItemType("cow_spawn_egg"); + + ItemType.Typed CRACKED_DEEPSLATE_BRICKS = getItemType("cracked_deepslate_bricks"); + + ItemType.Typed CRACKED_DEEPSLATE_TILES = getItemType("cracked_deepslate_tiles"); + + ItemType.Typed CRACKED_NETHER_BRICKS = getItemType("cracked_nether_bricks"); + + ItemType.Typed CRACKED_POLISHED_BLACKSTONE_BRICKS = getItemType("cracked_polished_blackstone_bricks"); + + ItemType.Typed CRACKED_STONE_BRICKS = getItemType("cracked_stone_bricks"); + + ItemType.Typed CRAFTER = getItemType("crafter"); + + ItemType.Typed CRAFTING_TABLE = getItemType("crafting_table"); + + ItemType.Typed CREAKING_HEART = getItemType("creaking_heart"); + + ItemType.Typed CREAKING_SPAWN_EGG = getItemType("creaking_spawn_egg"); + + ItemType.Typed CREEPER_BANNER_PATTERN = getItemType("creeper_banner_pattern"); + + ItemType.Typed CREEPER_HEAD = getItemType("creeper_head"); + + ItemType.Typed CREEPER_SPAWN_EGG = getItemType("creeper_spawn_egg"); + + ItemType.Typed CRIMSON_BUTTON = getItemType("crimson_button"); + + ItemType.Typed CRIMSON_DOOR = getItemType("crimson_door"); + + ItemType.Typed CRIMSON_FENCE = getItemType("crimson_fence"); + + ItemType.Typed CRIMSON_FENCE_GATE = getItemType("crimson_fence_gate"); + + ItemType.Typed CRIMSON_FUNGUS = getItemType("crimson_fungus"); + + ItemType.Typed CRIMSON_HANGING_SIGN = getItemType("crimson_hanging_sign"); + + ItemType.Typed CRIMSON_HYPHAE = getItemType("crimson_hyphae"); + + ItemType.Typed CRIMSON_NYLIUM = getItemType("crimson_nylium"); + + ItemType.Typed CRIMSON_PLANKS = getItemType("crimson_planks"); + + ItemType.Typed CRIMSON_PRESSURE_PLATE = getItemType("crimson_pressure_plate"); + + ItemType.Typed CRIMSON_ROOTS = getItemType("crimson_roots"); + + ItemType.Typed CRIMSON_SIGN = getItemType("crimson_sign"); + + ItemType.Typed CRIMSON_SLAB = getItemType("crimson_slab"); + + ItemType.Typed CRIMSON_STAIRS = getItemType("crimson_stairs"); + + ItemType.Typed CRIMSON_STEM = getItemType("crimson_stem"); + + ItemType.Typed CRIMSON_TRAPDOOR = getItemType("crimson_trapdoor"); + + ItemType.Typed CROSSBOW = getItemType("crossbow"); + + ItemType.Typed CRYING_OBSIDIAN = getItemType("crying_obsidian"); + + ItemType.Typed CUT_COPPER = getItemType("cut_copper"); + + ItemType.Typed CUT_COPPER_SLAB = getItemType("cut_copper_slab"); + + ItemType.Typed CUT_COPPER_STAIRS = getItemType("cut_copper_stairs"); + + ItemType.Typed CUT_RED_SANDSTONE = getItemType("cut_red_sandstone"); + + ItemType.Typed CUT_RED_SANDSTONE_SLAB = getItemType("cut_red_sandstone_slab"); + + ItemType.Typed CUT_SANDSTONE = getItemType("cut_sandstone"); + + ItemType.Typed CUT_SANDSTONE_SLAB = getItemType("cut_sandstone_slab"); + + ItemType.Typed CYAN_BANNER = getItemType("cyan_banner"); + + ItemType.Typed CYAN_BED = getItemType("cyan_bed"); + + ItemType.Typed CYAN_BUNDLE = getItemType("cyan_bundle"); + + ItemType.Typed CYAN_CANDLE = getItemType("cyan_candle"); + + ItemType.Typed CYAN_CARPET = getItemType("cyan_carpet"); + + ItemType.Typed CYAN_CONCRETE = getItemType("cyan_concrete"); + + ItemType.Typed CYAN_CONCRETE_POWDER = getItemType("cyan_concrete_powder"); + + ItemType.Typed CYAN_DYE = getItemType("cyan_dye"); + + ItemType.Typed CYAN_GLAZED_TERRACOTTA = getItemType("cyan_glazed_terracotta"); + + ItemType.Typed CYAN_SHULKER_BOX = getItemType("cyan_shulker_box"); + + ItemType.Typed CYAN_STAINED_GLASS = getItemType("cyan_stained_glass"); + + ItemType.Typed CYAN_STAINED_GLASS_PANE = getItemType("cyan_stained_glass_pane"); + + ItemType.Typed CYAN_TERRACOTTA = getItemType("cyan_terracotta"); + + ItemType.Typed CYAN_WOOL = getItemType("cyan_wool"); + + ItemType.Typed DAMAGED_ANVIL = getItemType("damaged_anvil"); + + ItemType.Typed DANDELION = getItemType("dandelion"); + + ItemType.Typed DANGER_POTTERY_SHERD = getItemType("danger_pottery_sherd"); + + ItemType.Typed DARK_OAK_BOAT = getItemType("dark_oak_boat"); + + ItemType.Typed DARK_OAK_BUTTON = getItemType("dark_oak_button"); + + ItemType.Typed DARK_OAK_CHEST_BOAT = getItemType("dark_oak_chest_boat"); + + ItemType.Typed DARK_OAK_DOOR = getItemType("dark_oak_door"); + + ItemType.Typed DARK_OAK_FENCE = getItemType("dark_oak_fence"); + + ItemType.Typed DARK_OAK_FENCE_GATE = getItemType("dark_oak_fence_gate"); + + ItemType.Typed DARK_OAK_HANGING_SIGN = getItemType("dark_oak_hanging_sign"); + + ItemType.Typed DARK_OAK_LEAVES = getItemType("dark_oak_leaves"); + + ItemType.Typed DARK_OAK_LOG = getItemType("dark_oak_log"); + + ItemType.Typed DARK_OAK_PLANKS = getItemType("dark_oak_planks"); + + ItemType.Typed DARK_OAK_PRESSURE_PLATE = getItemType("dark_oak_pressure_plate"); + + ItemType.Typed DARK_OAK_SAPLING = getItemType("dark_oak_sapling"); + + ItemType.Typed DARK_OAK_SIGN = getItemType("dark_oak_sign"); + + ItemType.Typed DARK_OAK_SLAB = getItemType("dark_oak_slab"); + + ItemType.Typed DARK_OAK_STAIRS = getItemType("dark_oak_stairs"); + + ItemType.Typed DARK_OAK_TRAPDOOR = getItemType("dark_oak_trapdoor"); + + ItemType.Typed DARK_OAK_WOOD = getItemType("dark_oak_wood"); + + ItemType.Typed DARK_PRISMARINE = getItemType("dark_prismarine"); + + ItemType.Typed DARK_PRISMARINE_SLAB = getItemType("dark_prismarine_slab"); + + ItemType.Typed DARK_PRISMARINE_STAIRS = getItemType("dark_prismarine_stairs"); + + ItemType.Typed DAYLIGHT_DETECTOR = getItemType("daylight_detector"); + + ItemType.Typed DEAD_BRAIN_CORAL = getItemType("dead_brain_coral"); + + ItemType.Typed DEAD_BRAIN_CORAL_BLOCK = getItemType("dead_brain_coral_block"); + + ItemType.Typed DEAD_BRAIN_CORAL_FAN = getItemType("dead_brain_coral_fan"); + + ItemType.Typed DEAD_BUBBLE_CORAL = getItemType("dead_bubble_coral"); + + ItemType.Typed DEAD_BUBBLE_CORAL_BLOCK = getItemType("dead_bubble_coral_block"); + + ItemType.Typed DEAD_BUBBLE_CORAL_FAN = getItemType("dead_bubble_coral_fan"); + + ItemType.Typed DEAD_BUSH = getItemType("dead_bush"); + + ItemType.Typed DEAD_FIRE_CORAL = getItemType("dead_fire_coral"); + + ItemType.Typed DEAD_FIRE_CORAL_BLOCK = getItemType("dead_fire_coral_block"); + + ItemType.Typed DEAD_FIRE_CORAL_FAN = getItemType("dead_fire_coral_fan"); + + ItemType.Typed DEAD_HORN_CORAL = getItemType("dead_horn_coral"); + + ItemType.Typed DEAD_HORN_CORAL_BLOCK = getItemType("dead_horn_coral_block"); + + ItemType.Typed DEAD_HORN_CORAL_FAN = getItemType("dead_horn_coral_fan"); + + ItemType.Typed DEAD_TUBE_CORAL = getItemType("dead_tube_coral"); + + ItemType.Typed DEAD_TUBE_CORAL_BLOCK = getItemType("dead_tube_coral_block"); + + ItemType.Typed DEAD_TUBE_CORAL_FAN = getItemType("dead_tube_coral_fan"); + + ItemType.Typed DEBUG_STICK = getItemType("debug_stick"); + + ItemType.Typed DECORATED_POT = getItemType("decorated_pot"); + + ItemType.Typed DEEPSLATE = getItemType("deepslate"); + + ItemType.Typed DEEPSLATE_BRICK_SLAB = getItemType("deepslate_brick_slab"); + + ItemType.Typed DEEPSLATE_BRICK_STAIRS = getItemType("deepslate_brick_stairs"); + + ItemType.Typed DEEPSLATE_BRICK_WALL = getItemType("deepslate_brick_wall"); + + ItemType.Typed DEEPSLATE_BRICKS = getItemType("deepslate_bricks"); + + ItemType.Typed DEEPSLATE_COAL_ORE = getItemType("deepslate_coal_ore"); + + ItemType.Typed DEEPSLATE_COPPER_ORE = getItemType("deepslate_copper_ore"); + + ItemType.Typed DEEPSLATE_DIAMOND_ORE = getItemType("deepslate_diamond_ore"); + + ItemType.Typed DEEPSLATE_EMERALD_ORE = getItemType("deepslate_emerald_ore"); + + ItemType.Typed DEEPSLATE_GOLD_ORE = getItemType("deepslate_gold_ore"); + + ItemType.Typed DEEPSLATE_IRON_ORE = getItemType("deepslate_iron_ore"); + + ItemType.Typed DEEPSLATE_LAPIS_ORE = getItemType("deepslate_lapis_ore"); + + ItemType.Typed DEEPSLATE_REDSTONE_ORE = getItemType("deepslate_redstone_ore"); + + ItemType.Typed DEEPSLATE_TILE_SLAB = getItemType("deepslate_tile_slab"); + + ItemType.Typed DEEPSLATE_TILE_STAIRS = getItemType("deepslate_tile_stairs"); + + ItemType.Typed DEEPSLATE_TILE_WALL = getItemType("deepslate_tile_wall"); + + ItemType.Typed DEEPSLATE_TILES = getItemType("deepslate_tiles"); + + ItemType.Typed DETECTOR_RAIL = getItemType("detector_rail"); + + ItemType.Typed DIAMOND = getItemType("diamond"); + + ItemType.Typed DIAMOND_AXE = getItemType("diamond_axe"); + + ItemType.Typed DIAMOND_BLOCK = getItemType("diamond_block"); + + ItemType.Typed DIAMOND_BOOTS = getItemType("diamond_boots"); + + ItemType.Typed DIAMOND_CHESTPLATE = getItemType("diamond_chestplate"); + + ItemType.Typed DIAMOND_HELMET = getItemType("diamond_helmet"); + + ItemType.Typed DIAMOND_HOE = getItemType("diamond_hoe"); + + ItemType.Typed DIAMOND_HORSE_ARMOR = getItemType("diamond_horse_armor"); + + ItemType.Typed DIAMOND_LEGGINGS = getItemType("diamond_leggings"); + + ItemType.Typed DIAMOND_ORE = getItemType("diamond_ore"); + + ItemType.Typed DIAMOND_PICKAXE = getItemType("diamond_pickaxe"); + + ItemType.Typed DIAMOND_SHOVEL = getItemType("diamond_shovel"); + + ItemType.Typed DIAMOND_SWORD = getItemType("diamond_sword"); + + ItemType.Typed DIORITE = getItemType("diorite"); + + ItemType.Typed DIORITE_SLAB = getItemType("diorite_slab"); + + ItemType.Typed DIORITE_STAIRS = getItemType("diorite_stairs"); + + ItemType.Typed DIORITE_WALL = getItemType("diorite_wall"); + + ItemType.Typed DIRT = getItemType("dirt"); + + ItemType.Typed DIRT_PATH = getItemType("dirt_path"); + + ItemType.Typed DOLPHIN_SPAWN_EGG = getItemType("dolphin_spawn_egg"); + + ItemType.Typed DONKEY_SPAWN_EGG = getItemType("donkey_spawn_egg"); + + ItemType.Typed DRAGON_BREATH = getItemType("dragon_breath"); + + ItemType.Typed DRAGON_HEAD = getItemType("dragon_head"); + + ItemType.Typed DROWNED_SPAWN_EGG = getItemType("drowned_spawn_egg"); + + ItemType.Typed ELDER_GUARDIAN_SPAWN_EGG = getItemType("elder_guardian_spawn_egg"); + + ItemType.Typed ENCHANTED_BOOK = getItemType("enchanted_book"); + + ItemType.Typed END_CRYSTAL = getItemType("end_crystal"); + + ItemType.Typed ENDER_DRAGON_SPAWN_EGG = getItemType("ender_dragon_spawn_egg"); + + ItemType.Typed ENDER_EYE = getItemType("ender_eye"); + + ItemType.Typed ENDERMAN_SPAWN_EGG = getItemType("enderman_spawn_egg"); + + ItemType.Typed ENDERMITE_SPAWN_EGG = getItemType("endermite_spawn_egg"); + + ItemType.Typed EVOKER_SPAWN_EGG = getItemType("evoker_spawn_egg"); + + ItemType.Typed EXPERIENCE_BOTTLE = getItemType("experience_bottle"); + + ItemType.Typed FERMENTED_SPIDER_EYE = getItemType("fermented_spider_eye"); + + ItemType.Typed FIRE_CHARGE = getItemType("fire_charge"); + + ItemType.Typed FIREWORK_ROCKET = getItemType("firework_rocket"); + + ItemType.Typed FIREWORK_STAR = getItemType("firework_star"); + + ItemType.Typed FLOW_BANNER_PATTERN = getItemType("flow_banner_pattern"); + + ItemType.Typed FLOWER_BANNER_PATTERN = getItemType("flower_banner_pattern"); + + ItemType.Typed FLOWER_POT = getItemType("flower_pot"); + + ItemType.Typed FOX_SPAWN_EGG = getItemType("fox_spawn_egg"); + + ItemType.Typed FROG_SPAWN_EGG = getItemType("frog_spawn_egg"); + + ItemType.Typed GHAST_SPAWN_EGG = getItemType("ghast_spawn_egg"); + + ItemType.Typed GLASS_BOTTLE = getItemType("glass_bottle"); + + ItemType.Typed GLISTERING_MELON_SLICE = getItemType("glistering_melon_slice"); + + ItemType.Typed GLOW_ITEM_FRAME = getItemType("glow_item_frame"); + + ItemType.Typed GLOW_SQUID_SPAWN_EGG = getItemType("glow_squid_spawn_egg"); + + ItemType.Typed GOAT_SPAWN_EGG = getItemType("goat_spawn_egg"); + + ItemType.Typed GOLD_NUGGET = getItemType("gold_nugget"); + + ItemType.Typed GOLDEN_CARROT = getItemType("golden_carrot"); + + ItemType.Typed GOLDEN_HORSE_ARMOR = getItemType("golden_horse_armor"); + + ItemType.Typed GRAY_BANNER = getItemType("gray_banner"); + + ItemType.Typed GREEN_BANNER = getItemType("green_banner"); + + ItemType.Typed GUARDIAN_SPAWN_EGG = getItemType("guardian_spawn_egg"); + + ItemType.Typed HOGLIN_SPAWN_EGG = getItemType("hoglin_spawn_egg"); + + ItemType.Typed HORSE_SPAWN_EGG = getItemType("horse_spawn_egg"); + + ItemType.Typed HUSK_SPAWN_EGG = getItemType("husk_spawn_egg"); + + ItemType.Typed IRON_GOLEM_SPAWN_EGG = getItemType("iron_golem_spawn_egg"); + + ItemType.Typed IRON_HORSE_ARMOR = getItemType("iron_horse_armor"); + + ItemType.Typed ITEM_FRAME = getItemType("item_frame"); + + ItemType.Typed LEAD = getItemType("lead"); + + ItemType.Typed LEATHER_HORSE_ARMOR = getItemType("leather_horse_armor"); + + ItemType.Typed LIGHT_BLUE_BANNER = getItemType("light_blue_banner"); + + ItemType.Typed LIGHT_GRAY_BANNER = getItemType("light_gray_banner"); + + ItemType.Typed LIME_BANNER = getItemType("lime_banner"); + + ItemType.Typed LLAMA_SPAWN_EGG = getItemType("llama_spawn_egg"); + + ItemType.Typed MACE = getItemType("mace"); + + ItemType.Typed MAGENTA_BANNER = getItemType("magenta_banner"); + + ItemType.Typed MAGMA_CREAM = getItemType("magma_cream"); + + ItemType.Typed MAGMA_CUBE_SPAWN_EGG = getItemType("magma_cube_spawn_egg"); + + ItemType.Typed MAP = getItemType("map"); + + ItemType.Typed MOOSHROOM_SPAWN_EGG = getItemType("mooshroom_spawn_egg"); + + ItemType.Typed MULE_SPAWN_EGG = getItemType("mule_spawn_egg"); + + ItemType.Typed MUSIC_DISC_5 = getItemType("music_disc_5"); + + ItemType.Typed DISC_FRAGMENT_5 = getItemType("disc_fragment_5"); + + ItemType.Typed DISPENSER = getItemType("dispenser"); + + ItemType.Typed DRAGON_EGG = getItemType("dragon_egg"); + + ItemType.Typed DRIED_KELP = getItemType("dried_kelp"); + + ItemType.Typed DRIED_KELP_BLOCK = getItemType("dried_kelp_block"); + + ItemType.Typed DRIPSTONE_BLOCK = getItemType("dripstone_block"); + + ItemType.Typed DROPPER = getItemType("dropper"); + + ItemType.Typed DUNE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("dune_armor_trim_smithing_template"); + + ItemType.Typed ECHO_SHARD = getItemType("echo_shard"); + + ItemType.Typed EGG = getItemType("egg"); + + ItemType.Typed ELYTRA = getItemType("elytra"); + + ItemType.Typed EMERALD = getItemType("emerald"); + + ItemType.Typed EMERALD_BLOCK = getItemType("emerald_block"); + + ItemType.Typed EMERALD_ORE = getItemType("emerald_ore"); + + ItemType.Typed ENCHANTED_GOLDEN_APPLE = getItemType("enchanted_golden_apple"); + + ItemType.Typed ENCHANTING_TABLE = getItemType("enchanting_table"); + + ItemType.Typed END_PORTAL_FRAME = getItemType("end_portal_frame"); + + ItemType.Typed END_ROD = getItemType("end_rod"); + + ItemType.Typed END_STONE = getItemType("end_stone"); + + ItemType.Typed END_STONE_BRICK_SLAB = getItemType("end_stone_brick_slab"); + + ItemType.Typed END_STONE_BRICK_STAIRS = getItemType("end_stone_brick_stairs"); + + ItemType.Typed END_STONE_BRICK_WALL = getItemType("end_stone_brick_wall"); + + ItemType.Typed END_STONE_BRICKS = getItemType("end_stone_bricks"); + + ItemType.Typed ENDER_CHEST = getItemType("ender_chest"); + + ItemType.Typed ENDER_PEARL = getItemType("ender_pearl"); + + ItemType.Typed EXPLORER_POTTERY_SHERD = getItemType("explorer_pottery_sherd"); + + ItemType.Typed EXPOSED_CHISELED_COPPER = getItemType("exposed_chiseled_copper"); + + ItemType.Typed EXPOSED_COPPER = getItemType("exposed_copper"); + ItemType.Typed EXPOSED_COPPER_BULB = getItemType("exposed_copper_bulb"); - ItemType.Typed WEATHERED_COPPER_BULB = getItemType("weathered_copper_bulb"); - ItemType.Typed OXIDIZED_COPPER_BULB = getItemType("oxidized_copper_bulb"); - ItemType.Typed WAXED_COPPER_BULB = getItemType("waxed_copper_bulb"); - ItemType.Typed WAXED_EXPOSED_COPPER_BULB = getItemType("waxed_exposed_copper_bulb"); - ItemType.Typed WAXED_WEATHERED_COPPER_BULB = getItemType("waxed_weathered_copper_bulb"); - ItemType.Typed WAXED_OXIDIZED_COPPER_BULB = getItemType("waxed_oxidized_copper_bulb"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed TRIAL_SPAWNER = getItemType("trial_spawner"); - ItemType.Typed TRIAL_KEY = getItemType("trial_key"); - ItemType.Typed OMINOUS_TRIAL_KEY = getItemType("ominous_trial_key"); - /** - * ItemMeta: {@link BlockStateMeta} - */ - ItemType.Typed VAULT = getItemType("vault"); - /** - * ItemMeta: {@link OminousBottleMeta} - */ + + ItemType.Typed EXPOSED_COPPER_DOOR = getItemType("exposed_copper_door"); + + ItemType.Typed EXPOSED_COPPER_GRATE = getItemType("exposed_copper_grate"); + + ItemType.Typed EXPOSED_COPPER_TRAPDOOR = getItemType("exposed_copper_trapdoor"); + + ItemType.Typed EXPOSED_CUT_COPPER = getItemType("exposed_cut_copper"); + + ItemType.Typed EXPOSED_CUT_COPPER_SLAB = getItemType("exposed_cut_copper_slab"); + + ItemType.Typed EXPOSED_CUT_COPPER_STAIRS = getItemType("exposed_cut_copper_stairs"); + + ItemType.Typed EYE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("eye_armor_trim_smithing_template"); + + ItemType.Typed FARMLAND = getItemType("farmland"); + + ItemType.Typed FEATHER = getItemType("feather"); + + ItemType.Typed FERN = getItemType("fern"); + + ItemType.Typed FIELD_MASONED_BANNER_PATTERN = getItemType("field_masoned_banner_pattern"); + + ItemType.Typed FILLED_MAP = getItemType("filled_map"); + + ItemType.Typed FIRE_CORAL = getItemType("fire_coral"); + + ItemType.Typed FIRE_CORAL_BLOCK = getItemType("fire_coral_block"); + + ItemType.Typed FIRE_CORAL_FAN = getItemType("fire_coral_fan"); + + ItemType.Typed FIREFLY_BUSH = getItemType("firefly_bush"); + + ItemType.Typed FISHING_ROD = getItemType("fishing_rod"); + + ItemType.Typed FLETCHING_TABLE = getItemType("fletching_table"); + + ItemType.Typed FLINT = getItemType("flint"); + + ItemType.Typed FLINT_AND_STEEL = getItemType("flint_and_steel"); + + ItemType.Typed FLOW_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("flow_armor_trim_smithing_template"); + + ItemType.Typed FLOW_POTTERY_SHERD = getItemType("flow_pottery_sherd"); + + ItemType.Typed FLOWERING_AZALEA = getItemType("flowering_azalea"); + + ItemType.Typed FLOWERING_AZALEA_LEAVES = getItemType("flowering_azalea_leaves"); + + ItemType.Typed FRIEND_POTTERY_SHERD = getItemType("friend_pottery_sherd"); + + ItemType.Typed FROGSPAWN = getItemType("frogspawn"); + + ItemType.Typed FURNACE = getItemType("furnace"); + + ItemType.Typed FURNACE_MINECART = getItemType("furnace_minecart"); + + ItemType.Typed GHAST_TEAR = getItemType("ghast_tear"); + + ItemType.Typed GILDED_BLACKSTONE = getItemType("gilded_blackstone"); + + ItemType.Typed GLASS = getItemType("glass"); + + ItemType.Typed GLASS_PANE = getItemType("glass_pane"); + + ItemType.Typed GLOBE_BANNER_PATTERN = getItemType("globe_banner_pattern"); + + ItemType.Typed GLOW_BERRIES = getItemType("glow_berries"); + + ItemType.Typed GLOW_INK_SAC = getItemType("glow_ink_sac"); + + ItemType.Typed GLOW_LICHEN = getItemType("glow_lichen"); + + ItemType.Typed GLOWSTONE = getItemType("glowstone"); + + ItemType.Typed GLOWSTONE_DUST = getItemType("glowstone_dust"); + + ItemType.Typed GOAT_HORN = getItemType("goat_horn"); + + ItemType.Typed GOLD_BLOCK = getItemType("gold_block"); + + ItemType.Typed GOLD_INGOT = getItemType("gold_ingot"); + + ItemType.Typed GOLD_ORE = getItemType("gold_ore"); + + ItemType.Typed GOLDEN_APPLE = getItemType("golden_apple"); + + ItemType.Typed GOLDEN_AXE = getItemType("golden_axe"); + + ItemType.Typed GOLDEN_BOOTS = getItemType("golden_boots"); + + ItemType.Typed GOLDEN_CHESTPLATE = getItemType("golden_chestplate"); + + ItemType.Typed GOLDEN_HELMET = getItemType("golden_helmet"); + + ItemType.Typed GOLDEN_HOE = getItemType("golden_hoe"); + + ItemType.Typed GOLDEN_LEGGINGS = getItemType("golden_leggings"); + + ItemType.Typed GOLDEN_PICKAXE = getItemType("golden_pickaxe"); + + ItemType.Typed GOLDEN_SHOVEL = getItemType("golden_shovel"); + + ItemType.Typed GOLDEN_SWORD = getItemType("golden_sword"); + + ItemType.Typed GRANITE = getItemType("granite"); + + ItemType.Typed GRANITE_SLAB = getItemType("granite_slab"); + + ItemType.Typed GRANITE_STAIRS = getItemType("granite_stairs"); + + ItemType.Typed GRANITE_WALL = getItemType("granite_wall"); + + ItemType.Typed GRASS_BLOCK = getItemType("grass_block"); + + ItemType.Typed GRAVEL = getItemType("gravel"); + + ItemType.Typed GRAY_BED = getItemType("gray_bed"); + + ItemType.Typed GRAY_BUNDLE = getItemType("gray_bundle"); + + ItemType.Typed GRAY_CANDLE = getItemType("gray_candle"); + + ItemType.Typed GRAY_CARPET = getItemType("gray_carpet"); + + ItemType.Typed GRAY_CONCRETE = getItemType("gray_concrete"); + + ItemType.Typed GRAY_CONCRETE_POWDER = getItemType("gray_concrete_powder"); + + ItemType.Typed GRAY_DYE = getItemType("gray_dye"); + + ItemType.Typed GRAY_GLAZED_TERRACOTTA = getItemType("gray_glazed_terracotta"); + + ItemType.Typed GRAY_SHULKER_BOX = getItemType("gray_shulker_box"); + + ItemType.Typed GRAY_STAINED_GLASS = getItemType("gray_stained_glass"); + + ItemType.Typed GRAY_STAINED_GLASS_PANE = getItemType("gray_stained_glass_pane"); + + ItemType.Typed GRAY_TERRACOTTA = getItemType("gray_terracotta"); + + ItemType.Typed GRAY_WOOL = getItemType("gray_wool"); + + ItemType.Typed GREEN_BED = getItemType("green_bed"); + + ItemType.Typed GREEN_BUNDLE = getItemType("green_bundle"); + + ItemType.Typed GREEN_CANDLE = getItemType("green_candle"); + + ItemType.Typed GREEN_CARPET = getItemType("green_carpet"); + + ItemType.Typed GREEN_CONCRETE = getItemType("green_concrete"); + + ItemType.Typed GREEN_CONCRETE_POWDER = getItemType("green_concrete_powder"); + + ItemType.Typed GREEN_DYE = getItemType("green_dye"); + + ItemType.Typed GREEN_GLAZED_TERRACOTTA = getItemType("green_glazed_terracotta"); + + ItemType.Typed GREEN_SHULKER_BOX = getItemType("green_shulker_box"); + + ItemType.Typed GREEN_STAINED_GLASS = getItemType("green_stained_glass"); + + ItemType.Typed GREEN_STAINED_GLASS_PANE = getItemType("green_stained_glass_pane"); + + ItemType.Typed GREEN_TERRACOTTA = getItemType("green_terracotta"); + + ItemType.Typed GREEN_WOOL = getItemType("green_wool"); + + ItemType.Typed GRINDSTONE = getItemType("grindstone"); + + ItemType.Typed GUNPOWDER = getItemType("gunpowder"); + + ItemType.Typed GUSTER_BANNER_PATTERN = getItemType("guster_banner_pattern"); + + ItemType.Typed GUSTER_POTTERY_SHERD = getItemType("guster_pottery_sherd"); + + ItemType.Typed HANGING_ROOTS = getItemType("hanging_roots"); + + ItemType.Typed HAY_BLOCK = getItemType("hay_block"); + + ItemType.Typed HEART_OF_THE_SEA = getItemType("heart_of_the_sea"); + + ItemType.Typed HEART_POTTERY_SHERD = getItemType("heart_pottery_sherd"); + + ItemType.Typed HEARTBREAK_POTTERY_SHERD = getItemType("heartbreak_pottery_sherd"); + + ItemType.Typed HEAVY_CORE = getItemType("heavy_core"); + + ItemType.Typed HEAVY_WEIGHTED_PRESSURE_PLATE = getItemType("heavy_weighted_pressure_plate"); + + ItemType.Typed HONEY_BLOCK = getItemType("honey_block"); + + ItemType.Typed HONEY_BOTTLE = getItemType("honey_bottle"); + + ItemType.Typed HONEYCOMB = getItemType("honeycomb"); + + ItemType.Typed HONEYCOMB_BLOCK = getItemType("honeycomb_block"); + + ItemType.Typed HOPPER = getItemType("hopper"); + + ItemType.Typed HOPPER_MINECART = getItemType("hopper_minecart"); + + ItemType.Typed HORN_CORAL = getItemType("horn_coral"); + + ItemType.Typed HORN_CORAL_BLOCK = getItemType("horn_coral_block"); + + ItemType.Typed HORN_CORAL_FAN = getItemType("horn_coral_fan"); + + ItemType.Typed HOST_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("host_armor_trim_smithing_template"); + + ItemType.Typed HOWL_POTTERY_SHERD = getItemType("howl_pottery_sherd"); + + ItemType.Typed ICE = getItemType("ice"); + + ItemType.Typed INFESTED_CHISELED_STONE_BRICKS = getItemType("infested_chiseled_stone_bricks"); + + ItemType.Typed INFESTED_COBBLESTONE = getItemType("infested_cobblestone"); + + ItemType.Typed INFESTED_CRACKED_STONE_BRICKS = getItemType("infested_cracked_stone_bricks"); + + ItemType.Typed INFESTED_DEEPSLATE = getItemType("infested_deepslate"); + + ItemType.Typed INFESTED_MOSSY_STONE_BRICKS = getItemType("infested_mossy_stone_bricks"); + + ItemType.Typed INFESTED_STONE = getItemType("infested_stone"); + + ItemType.Typed INFESTED_STONE_BRICKS = getItemType("infested_stone_bricks"); + + ItemType.Typed INK_SAC = getItemType("ink_sac"); + + ItemType.Typed IRON_AXE = getItemType("iron_axe"); + + ItemType.Typed IRON_BARS = getItemType("iron_bars"); + + ItemType.Typed IRON_BLOCK = getItemType("iron_block"); + + ItemType.Typed IRON_BOOTS = getItemType("iron_boots"); + + ItemType.Typed IRON_CHESTPLATE = getItemType("iron_chestplate"); + + ItemType.Typed IRON_DOOR = getItemType("iron_door"); + + ItemType.Typed IRON_HELMET = getItemType("iron_helmet"); + + ItemType.Typed IRON_HOE = getItemType("iron_hoe"); + + ItemType.Typed IRON_INGOT = getItemType("iron_ingot"); + + ItemType.Typed IRON_LEGGINGS = getItemType("iron_leggings"); + + ItemType.Typed IRON_NUGGET = getItemType("iron_nugget"); + + ItemType.Typed IRON_ORE = getItemType("iron_ore"); + + ItemType.Typed IRON_PICKAXE = getItemType("iron_pickaxe"); + + ItemType.Typed IRON_SHOVEL = getItemType("iron_shovel"); + + ItemType.Typed IRON_SWORD = getItemType("iron_sword"); + + ItemType.Typed IRON_TRAPDOOR = getItemType("iron_trapdoor"); + + ItemType.Typed JACK_O_LANTERN = getItemType("jack_o_lantern"); + + ItemType.Typed JIGSAW = getItemType("jigsaw"); + + ItemType.Typed JUKEBOX = getItemType("jukebox"); + + ItemType.Typed JUNGLE_BOAT = getItemType("jungle_boat"); + + ItemType.Typed JUNGLE_BUTTON = getItemType("jungle_button"); + + ItemType.Typed JUNGLE_CHEST_BOAT = getItemType("jungle_chest_boat"); + + ItemType.Typed JUNGLE_DOOR = getItemType("jungle_door"); + + ItemType.Typed JUNGLE_FENCE = getItemType("jungle_fence"); + + ItemType.Typed JUNGLE_FENCE_GATE = getItemType("jungle_fence_gate"); + + ItemType.Typed JUNGLE_HANGING_SIGN = getItemType("jungle_hanging_sign"); + + ItemType.Typed JUNGLE_LEAVES = getItemType("jungle_leaves"); + + ItemType.Typed JUNGLE_LOG = getItemType("jungle_log"); + + ItemType.Typed JUNGLE_PLANKS = getItemType("jungle_planks"); + + ItemType.Typed JUNGLE_PRESSURE_PLATE = getItemType("jungle_pressure_plate"); + + ItemType.Typed JUNGLE_SAPLING = getItemType("jungle_sapling"); + + ItemType.Typed JUNGLE_SIGN = getItemType("jungle_sign"); + + ItemType.Typed JUNGLE_SLAB = getItemType("jungle_slab"); + + ItemType.Typed JUNGLE_STAIRS = getItemType("jungle_stairs"); + + ItemType.Typed JUNGLE_TRAPDOOR = getItemType("jungle_trapdoor"); + + ItemType.Typed JUNGLE_WOOD = getItemType("jungle_wood"); + + ItemType.Typed KELP = getItemType("kelp"); + + ItemType.Typed KNOWLEDGE_BOOK = getItemType("knowledge_book"); + + ItemType.Typed LADDER = getItemType("ladder"); + + ItemType.Typed LANTERN = getItemType("lantern"); + + ItemType.Typed LAPIS_BLOCK = getItemType("lapis_block"); + + ItemType.Typed LAPIS_LAZULI = getItemType("lapis_lazuli"); + + ItemType.Typed LAPIS_ORE = getItemType("lapis_ore"); + + ItemType.Typed LARGE_AMETHYST_BUD = getItemType("large_amethyst_bud"); + + ItemType.Typed LARGE_FERN = getItemType("large_fern"); + + ItemType.Typed LAVA_BUCKET = getItemType("lava_bucket"); + + ItemType.Typed LEAF_LITTER = getItemType("leaf_litter"); + + ItemType.Typed LEATHER = getItemType("leather"); + + ItemType.Typed LEATHER_BOOTS = getItemType("leather_boots"); + + ItemType.Typed LEATHER_CHESTPLATE = getItemType("leather_chestplate"); + + ItemType.Typed LEATHER_HELMET = getItemType("leather_helmet"); + + ItemType.Typed LEATHER_LEGGINGS = getItemType("leather_leggings"); + + ItemType.Typed LECTERN = getItemType("lectern"); + + ItemType.Typed LEVER = getItemType("lever"); + + ItemType.Typed LIGHT = getItemType("light"); + + ItemType.Typed LIGHT_BLUE_BED = getItemType("light_blue_bed"); + + ItemType.Typed LIGHT_BLUE_BUNDLE = getItemType("light_blue_bundle"); + + ItemType.Typed LIGHT_BLUE_CANDLE = getItemType("light_blue_candle"); + + ItemType.Typed LIGHT_BLUE_CARPET = getItemType("light_blue_carpet"); + + ItemType.Typed LIGHT_BLUE_CONCRETE = getItemType("light_blue_concrete"); + + ItemType.Typed LIGHT_BLUE_CONCRETE_POWDER = getItemType("light_blue_concrete_powder"); + + ItemType.Typed LIGHT_BLUE_DYE = getItemType("light_blue_dye"); + + ItemType.Typed LIGHT_BLUE_GLAZED_TERRACOTTA = getItemType("light_blue_glazed_terracotta"); + + ItemType.Typed LIGHT_BLUE_SHULKER_BOX = getItemType("light_blue_shulker_box"); + + ItemType.Typed LIGHT_BLUE_STAINED_GLASS = getItemType("light_blue_stained_glass"); + + ItemType.Typed LIGHT_BLUE_STAINED_GLASS_PANE = getItemType("light_blue_stained_glass_pane"); + + ItemType.Typed LIGHT_BLUE_TERRACOTTA = getItemType("light_blue_terracotta"); + + ItemType.Typed LIGHT_BLUE_WOOL = getItemType("light_blue_wool"); + + ItemType.Typed LIGHT_GRAY_BED = getItemType("light_gray_bed"); + + ItemType.Typed LIGHT_GRAY_BUNDLE = getItemType("light_gray_bundle"); + + ItemType.Typed LIGHT_GRAY_CANDLE = getItemType("light_gray_candle"); + + ItemType.Typed LIGHT_GRAY_CARPET = getItemType("light_gray_carpet"); + + ItemType.Typed LIGHT_GRAY_CONCRETE = getItemType("light_gray_concrete"); + + ItemType.Typed LIGHT_GRAY_CONCRETE_POWDER = getItemType("light_gray_concrete_powder"); + + ItemType.Typed LIGHT_GRAY_DYE = getItemType("light_gray_dye"); + + ItemType.Typed LIGHT_GRAY_GLAZED_TERRACOTTA = getItemType("light_gray_glazed_terracotta"); + + ItemType.Typed LIGHT_GRAY_SHULKER_BOX = getItemType("light_gray_shulker_box"); + + ItemType.Typed LIGHT_GRAY_STAINED_GLASS = getItemType("light_gray_stained_glass"); + + ItemType.Typed LIGHT_GRAY_STAINED_GLASS_PANE = getItemType("light_gray_stained_glass_pane"); + + ItemType.Typed LIGHT_GRAY_TERRACOTTA = getItemType("light_gray_terracotta"); + + ItemType.Typed LIGHT_GRAY_WOOL = getItemType("light_gray_wool"); + + ItemType.Typed LIGHT_WEIGHTED_PRESSURE_PLATE = getItemType("light_weighted_pressure_plate"); + + ItemType.Typed LIGHTNING_ROD = getItemType("lightning_rod"); + + ItemType.Typed LILAC = getItemType("lilac"); + + ItemType.Typed LILY_OF_THE_VALLEY = getItemType("lily_of_the_valley"); + + ItemType.Typed LILY_PAD = getItemType("lily_pad"); + + ItemType.Typed LIME_BED = getItemType("lime_bed"); + + ItemType.Typed LIME_BUNDLE = getItemType("lime_bundle"); + + ItemType.Typed LIME_CANDLE = getItemType("lime_candle"); + + ItemType.Typed LIME_CARPET = getItemType("lime_carpet"); + + ItemType.Typed LIME_CONCRETE = getItemType("lime_concrete"); + + ItemType.Typed LIME_CONCRETE_POWDER = getItemType("lime_concrete_powder"); + + ItemType.Typed LIME_DYE = getItemType("lime_dye"); + + ItemType.Typed LIME_GLAZED_TERRACOTTA = getItemType("lime_glazed_terracotta"); + + ItemType.Typed LIME_SHULKER_BOX = getItemType("lime_shulker_box"); + + ItemType.Typed LIME_STAINED_GLASS = getItemType("lime_stained_glass"); + + ItemType.Typed LIME_STAINED_GLASS_PANE = getItemType("lime_stained_glass_pane"); + + ItemType.Typed LIME_TERRACOTTA = getItemType("lime_terracotta"); + + ItemType.Typed LIME_WOOL = getItemType("lime_wool"); + + ItemType.Typed LINGERING_POTION = getItemType("lingering_potion"); + + ItemType.Typed LODESTONE = getItemType("lodestone"); + + ItemType.Typed LOOM = getItemType("loom"); + + ItemType.Typed MAGENTA_BED = getItemType("magenta_bed"); + + ItemType.Typed MAGENTA_BUNDLE = getItemType("magenta_bundle"); + + ItemType.Typed MAGENTA_CANDLE = getItemType("magenta_candle"); + + ItemType.Typed MAGENTA_CARPET = getItemType("magenta_carpet"); + + ItemType.Typed MAGENTA_CONCRETE = getItemType("magenta_concrete"); + + ItemType.Typed MAGENTA_CONCRETE_POWDER = getItemType("magenta_concrete_powder"); + + ItemType.Typed MAGENTA_DYE = getItemType("magenta_dye"); + + ItemType.Typed MAGENTA_GLAZED_TERRACOTTA = getItemType("magenta_glazed_terracotta"); + + ItemType.Typed MAGENTA_SHULKER_BOX = getItemType("magenta_shulker_box"); + + ItemType.Typed MAGENTA_STAINED_GLASS = getItemType("magenta_stained_glass"); + + ItemType.Typed MAGENTA_STAINED_GLASS_PANE = getItemType("magenta_stained_glass_pane"); + + ItemType.Typed MAGENTA_TERRACOTTA = getItemType("magenta_terracotta"); + + ItemType.Typed MAGENTA_WOOL = getItemType("magenta_wool"); + + ItemType.Typed MAGMA_BLOCK = getItemType("magma_block"); + + ItemType.Typed MANGROVE_BOAT = getItemType("mangrove_boat"); + + ItemType.Typed MANGROVE_BUTTON = getItemType("mangrove_button"); + + ItemType.Typed MANGROVE_CHEST_BOAT = getItemType("mangrove_chest_boat"); + + ItemType.Typed MANGROVE_DOOR = getItemType("mangrove_door"); + + ItemType.Typed MANGROVE_FENCE = getItemType("mangrove_fence"); + + ItemType.Typed MANGROVE_FENCE_GATE = getItemType("mangrove_fence_gate"); + + ItemType.Typed MANGROVE_HANGING_SIGN = getItemType("mangrove_hanging_sign"); + + ItemType.Typed MANGROVE_LEAVES = getItemType("mangrove_leaves"); + + ItemType.Typed MANGROVE_LOG = getItemType("mangrove_log"); + + ItemType.Typed MANGROVE_PLANKS = getItemType("mangrove_planks"); + + ItemType.Typed MANGROVE_PRESSURE_PLATE = getItemType("mangrove_pressure_plate"); + + ItemType.Typed MANGROVE_PROPAGULE = getItemType("mangrove_propagule"); + + ItemType.Typed MANGROVE_ROOTS = getItemType("mangrove_roots"); + + ItemType.Typed MANGROVE_SIGN = getItemType("mangrove_sign"); + + ItemType.Typed MANGROVE_SLAB = getItemType("mangrove_slab"); + + ItemType.Typed MANGROVE_STAIRS = getItemType("mangrove_stairs"); + + ItemType.Typed MANGROVE_TRAPDOOR = getItemType("mangrove_trapdoor"); + + ItemType.Typed MANGROVE_WOOD = getItemType("mangrove_wood"); + + ItemType.Typed MEDIUM_AMETHYST_BUD = getItemType("medium_amethyst_bud"); + + ItemType.Typed MELON = getItemType("melon"); + + ItemType.Typed MELON_SEEDS = getItemType("melon_seeds"); + + ItemType.Typed MELON_SLICE = getItemType("melon_slice"); + + ItemType.Typed MILK_BUCKET = getItemType("milk_bucket"); + + ItemType.Typed MINECART = getItemType("minecart"); + + ItemType.Typed MINER_POTTERY_SHERD = getItemType("miner_pottery_sherd"); + + ItemType.Typed MOJANG_BANNER_PATTERN = getItemType("mojang_banner_pattern"); + + ItemType.Typed MOSS_BLOCK = getItemType("moss_block"); + + ItemType.Typed MOSS_CARPET = getItemType("moss_carpet"); + + ItemType.Typed MOSSY_COBBLESTONE = getItemType("mossy_cobblestone"); + + ItemType.Typed MOSSY_COBBLESTONE_SLAB = getItemType("mossy_cobblestone_slab"); + + ItemType.Typed MOSSY_COBBLESTONE_STAIRS = getItemType("mossy_cobblestone_stairs"); + + ItemType.Typed MOSSY_COBBLESTONE_WALL = getItemType("mossy_cobblestone_wall"); + + ItemType.Typed MOSSY_STONE_BRICK_SLAB = getItemType("mossy_stone_brick_slab"); + + ItemType.Typed MOSSY_STONE_BRICK_STAIRS = getItemType("mossy_stone_brick_stairs"); + + ItemType.Typed MOSSY_STONE_BRICK_WALL = getItemType("mossy_stone_brick_wall"); + + ItemType.Typed MOSSY_STONE_BRICKS = getItemType("mossy_stone_bricks"); + + ItemType.Typed MOURNER_POTTERY_SHERD = getItemType("mourner_pottery_sherd"); + + ItemType.Typed MUD = getItemType("mud"); + + ItemType.Typed MUD_BRICK_SLAB = getItemType("mud_brick_slab"); + + ItemType.Typed MUD_BRICK_STAIRS = getItemType("mud_brick_stairs"); + + ItemType.Typed MUD_BRICK_WALL = getItemType("mud_brick_wall"); + + ItemType.Typed MUD_BRICKS = getItemType("mud_bricks"); + + ItemType.Typed MUDDY_MANGROVE_ROOTS = getItemType("muddy_mangrove_roots"); + + ItemType.Typed MUSHROOM_STEM = getItemType("mushroom_stem"); + + ItemType.Typed MUSHROOM_STEW = getItemType("mushroom_stew"); + + ItemType.Typed MUSIC_DISC_11 = getItemType("music_disc_11"); + + ItemType.Typed MUSIC_DISC_13 = getItemType("music_disc_13"); + + ItemType.Typed MUSIC_DISC_BLOCKS = getItemType("music_disc_blocks"); + + ItemType.Typed MUSIC_DISC_CAT = getItemType("music_disc_cat"); + + ItemType.Typed MUSIC_DISC_CHIRP = getItemType("music_disc_chirp"); + + ItemType.Typed MUSIC_DISC_CREATOR = getItemType("music_disc_creator"); + + ItemType.Typed MUSIC_DISC_CREATOR_MUSIC_BOX = getItemType("music_disc_creator_music_box"); + + ItemType.Typed MUSIC_DISC_FAR = getItemType("music_disc_far"); + + ItemType.Typed MUSIC_DISC_MALL = getItemType("music_disc_mall"); + + ItemType.Typed MUSIC_DISC_MELLOHI = getItemType("music_disc_mellohi"); + + ItemType.Typed MUSIC_DISC_OTHERSIDE = getItemType("music_disc_otherside"); + + ItemType.Typed MUSIC_DISC_PIGSTEP = getItemType("music_disc_pigstep"); + + ItemType.Typed MUSIC_DISC_PRECIPICE = getItemType("music_disc_precipice"); + + ItemType.Typed MUSIC_DISC_RELIC = getItemType("music_disc_relic"); + + ItemType.Typed MUSIC_DISC_STAL = getItemType("music_disc_stal"); + + ItemType.Typed MUSIC_DISC_STRAD = getItemType("music_disc_strad"); + + ItemType.Typed MUSIC_DISC_WAIT = getItemType("music_disc_wait"); + + ItemType.Typed MUSIC_DISC_WARD = getItemType("music_disc_ward"); + + ItemType.Typed MUTTON = getItemType("mutton"); + + ItemType.Typed MYCELIUM = getItemType("mycelium"); + + ItemType.Typed NAME_TAG = getItemType("name_tag"); + + ItemType.Typed NAUTILUS_SHELL = getItemType("nautilus_shell"); + + ItemType.Typed NETHER_BRICK = getItemType("nether_brick"); + + ItemType.Typed NETHER_BRICK_FENCE = getItemType("nether_brick_fence"); + + ItemType.Typed NETHER_BRICK_SLAB = getItemType("nether_brick_slab"); + + ItemType.Typed NETHER_BRICK_STAIRS = getItemType("nether_brick_stairs"); + + ItemType.Typed NETHER_BRICK_WALL = getItemType("nether_brick_wall"); + + ItemType.Typed NETHER_BRICKS = getItemType("nether_bricks"); + + ItemType.Typed NETHER_GOLD_ORE = getItemType("nether_gold_ore"); + + ItemType.Typed NETHER_QUARTZ_ORE = getItemType("nether_quartz_ore"); + + ItemType.Typed NETHER_SPROUTS = getItemType("nether_sprouts"); + + ItemType.Typed NETHER_STAR = getItemType("nether_star"); + + ItemType.Typed NETHER_WART = getItemType("nether_wart"); + + ItemType.Typed NETHER_WART_BLOCK = getItemType("nether_wart_block"); + + ItemType.Typed NETHERITE_AXE = getItemType("netherite_axe"); + + ItemType.Typed NETHERITE_BLOCK = getItemType("netherite_block"); + + ItemType.Typed NETHERITE_BOOTS = getItemType("netherite_boots"); + + ItemType.Typed NETHERITE_CHESTPLATE = getItemType("netherite_chestplate"); + + ItemType.Typed NETHERITE_HELMET = getItemType("netherite_helmet"); + + ItemType.Typed NETHERITE_HOE = getItemType("netherite_hoe"); + + ItemType.Typed NETHERITE_INGOT = getItemType("netherite_ingot"); + + ItemType.Typed NETHERITE_LEGGINGS = getItemType("netherite_leggings"); + + ItemType.Typed NETHERITE_PICKAXE = getItemType("netherite_pickaxe"); + + ItemType.Typed NETHERITE_SCRAP = getItemType("netherite_scrap"); + + ItemType.Typed NETHERITE_SHOVEL = getItemType("netherite_shovel"); + + ItemType.Typed NETHERITE_SWORD = getItemType("netherite_sword"); + + ItemType.Typed NETHERITE_UPGRADE_SMITHING_TEMPLATE = getItemType("netherite_upgrade_smithing_template"); + + ItemType.Typed NETHERRACK = getItemType("netherrack"); + + ItemType.Typed NOTE_BLOCK = getItemType("note_block"); + + ItemType.Typed OAK_BOAT = getItemType("oak_boat"); + + ItemType.Typed OAK_BUTTON = getItemType("oak_button"); + + ItemType.Typed OAK_CHEST_BOAT = getItemType("oak_chest_boat"); + + ItemType.Typed OAK_DOOR = getItemType("oak_door"); + + ItemType.Typed OAK_FENCE = getItemType("oak_fence"); + + ItemType.Typed OAK_FENCE_GATE = getItemType("oak_fence_gate"); + + ItemType.Typed OAK_HANGING_SIGN = getItemType("oak_hanging_sign"); + + ItemType.Typed OAK_LEAVES = getItemType("oak_leaves"); + + ItemType.Typed OAK_LOG = getItemType("oak_log"); + + ItemType.Typed OAK_PLANKS = getItemType("oak_planks"); + + ItemType.Typed OAK_PRESSURE_PLATE = getItemType("oak_pressure_plate"); + + ItemType.Typed OAK_SAPLING = getItemType("oak_sapling"); + + ItemType.Typed OAK_SIGN = getItemType("oak_sign"); + + ItemType.Typed OAK_SLAB = getItemType("oak_slab"); + + ItemType.Typed OAK_STAIRS = getItemType("oak_stairs"); + + ItemType.Typed OAK_TRAPDOOR = getItemType("oak_trapdoor"); + + ItemType.Typed OAK_WOOD = getItemType("oak_wood"); + + ItemType.Typed OBSERVER = getItemType("observer"); + + ItemType.Typed OBSIDIAN = getItemType("obsidian"); + + ItemType.Typed OCELOT_SPAWN_EGG = getItemType("ocelot_spawn_egg"); + + ItemType.Typed OCHRE_FROGLIGHT = getItemType("ochre_froglight"); + ItemType.Typed OMINOUS_BOTTLE = getItemType("ominous_bottle"); + + ItemType.Typed OMINOUS_TRIAL_KEY = getItemType("ominous_trial_key"); + + ItemType.Typed OPEN_EYEBLOSSOM = getItemType("open_eyeblossom"); + + ItemType.Typed ORANGE_BANNER = getItemType("orange_banner"); + + ItemType.Typed ORANGE_BED = getItemType("orange_bed"); + + ItemType.Typed ORANGE_BUNDLE = getItemType("orange_bundle"); + + ItemType.Typed ORANGE_CANDLE = getItemType("orange_candle"); + + ItemType.Typed ORANGE_CARPET = getItemType("orange_carpet"); + + ItemType.Typed ORANGE_CONCRETE = getItemType("orange_concrete"); + + ItemType.Typed ORANGE_CONCRETE_POWDER = getItemType("orange_concrete_powder"); + + ItemType.Typed ORANGE_DYE = getItemType("orange_dye"); + + ItemType.Typed ORANGE_GLAZED_TERRACOTTA = getItemType("orange_glazed_terracotta"); + + ItemType.Typed ORANGE_SHULKER_BOX = getItemType("orange_shulker_box"); + + ItemType.Typed ORANGE_STAINED_GLASS = getItemType("orange_stained_glass"); + + ItemType.Typed ORANGE_STAINED_GLASS_PANE = getItemType("orange_stained_glass_pane"); + + ItemType.Typed ORANGE_TERRACOTTA = getItemType("orange_terracotta"); + + ItemType.Typed ORANGE_TULIP = getItemType("orange_tulip"); + + ItemType.Typed ORANGE_WOOL = getItemType("orange_wool"); + + ItemType.Typed OXEYE_DAISY = getItemType("oxeye_daisy"); + + ItemType.Typed OXIDIZED_CHISELED_COPPER = getItemType("oxidized_chiseled_copper"); + + ItemType.Typed OXIDIZED_COPPER = getItemType("oxidized_copper"); + + ItemType.Typed OXIDIZED_COPPER_BULB = getItemType("oxidized_copper_bulb"); + + ItemType.Typed OXIDIZED_COPPER_DOOR = getItemType("oxidized_copper_door"); + + ItemType.Typed OXIDIZED_COPPER_GRATE = getItemType("oxidized_copper_grate"); + + ItemType.Typed OXIDIZED_COPPER_TRAPDOOR = getItemType("oxidized_copper_trapdoor"); + + ItemType.Typed OXIDIZED_CUT_COPPER = getItemType("oxidized_cut_copper"); + + ItemType.Typed OXIDIZED_CUT_COPPER_SLAB = getItemType("oxidized_cut_copper_slab"); + + ItemType.Typed OXIDIZED_CUT_COPPER_STAIRS = getItemType("oxidized_cut_copper_stairs"); + + ItemType.Typed PACKED_ICE = getItemType("packed_ice"); + + ItemType.Typed PACKED_MUD = getItemType("packed_mud"); + + ItemType.Typed PAINTING = getItemType("painting"); + + ItemType.Typed PALE_HANGING_MOSS = getItemType("pale_hanging_moss"); + + ItemType.Typed PALE_MOSS_BLOCK = getItemType("pale_moss_block"); + + ItemType.Typed PALE_MOSS_CARPET = getItemType("pale_moss_carpet"); + + ItemType.Typed PALE_OAK_BOAT = getItemType("pale_oak_boat"); + + ItemType.Typed PALE_OAK_BUTTON = getItemType("pale_oak_button"); + + ItemType.Typed PALE_OAK_CHEST_BOAT = getItemType("pale_oak_chest_boat"); + + ItemType.Typed PALE_OAK_DOOR = getItemType("pale_oak_door"); + + ItemType.Typed PALE_OAK_FENCE = getItemType("pale_oak_fence"); + + ItemType.Typed PALE_OAK_FENCE_GATE = getItemType("pale_oak_fence_gate"); + + ItemType.Typed PALE_OAK_HANGING_SIGN = getItemType("pale_oak_hanging_sign"); + + ItemType.Typed PALE_OAK_LEAVES = getItemType("pale_oak_leaves"); + + ItemType.Typed PALE_OAK_LOG = getItemType("pale_oak_log"); + + ItemType.Typed PALE_OAK_PLANKS = getItemType("pale_oak_planks"); + + ItemType.Typed PALE_OAK_PRESSURE_PLATE = getItemType("pale_oak_pressure_plate"); + + ItemType.Typed PALE_OAK_SAPLING = getItemType("pale_oak_sapling"); + + ItemType.Typed PALE_OAK_SIGN = getItemType("pale_oak_sign"); + + ItemType.Typed PALE_OAK_SLAB = getItemType("pale_oak_slab"); + + ItemType.Typed PALE_OAK_STAIRS = getItemType("pale_oak_stairs"); + + ItemType.Typed PALE_OAK_TRAPDOOR = getItemType("pale_oak_trapdoor"); + + ItemType.Typed PALE_OAK_WOOD = getItemType("pale_oak_wood"); + + ItemType.Typed PANDA_SPAWN_EGG = getItemType("panda_spawn_egg"); + + ItemType.Typed PAPER = getItemType("paper"); + + ItemType.Typed PARROT_SPAWN_EGG = getItemType("parrot_spawn_egg"); + + ItemType.Typed PEARLESCENT_FROGLIGHT = getItemType("pearlescent_froglight"); + + ItemType.Typed PEONY = getItemType("peony"); + + ItemType.Typed PETRIFIED_OAK_SLAB = getItemType("petrified_oak_slab"); + + ItemType.Typed PHANTOM_MEMBRANE = getItemType("phantom_membrane"); + + ItemType.Typed PHANTOM_SPAWN_EGG = getItemType("phantom_spawn_egg"); + + ItemType.Typed PIG_SPAWN_EGG = getItemType("pig_spawn_egg"); + + ItemType.Typed PIGLIN_BANNER_PATTERN = getItemType("piglin_banner_pattern"); + + ItemType.Typed PIGLIN_BRUTE_SPAWN_EGG = getItemType("piglin_brute_spawn_egg"); + + ItemType.Typed PIGLIN_HEAD = getItemType("piglin_head"); + + ItemType.Typed PIGLIN_SPAWN_EGG = getItemType("piglin_spawn_egg"); + + ItemType.Typed PILLAGER_SPAWN_EGG = getItemType("pillager_spawn_egg"); + + ItemType.Typed PINK_BANNER = getItemType("pink_banner"); + + ItemType.Typed PINK_BED = getItemType("pink_bed"); + + ItemType.Typed PINK_BUNDLE = getItemType("pink_bundle"); + + ItemType.Typed PINK_CANDLE = getItemType("pink_candle"); + + ItemType.Typed PINK_CARPET = getItemType("pink_carpet"); + + ItemType.Typed PINK_CONCRETE = getItemType("pink_concrete"); + + ItemType.Typed PINK_CONCRETE_POWDER = getItemType("pink_concrete_powder"); + + ItemType.Typed PINK_DYE = getItemType("pink_dye"); + + ItemType.Typed PINK_GLAZED_TERRACOTTA = getItemType("pink_glazed_terracotta"); + + ItemType.Typed PINK_PETALS = getItemType("pink_petals"); + + ItemType.Typed PINK_SHULKER_BOX = getItemType("pink_shulker_box"); + + ItemType.Typed PINK_STAINED_GLASS = getItemType("pink_stained_glass"); + + ItemType.Typed PINK_STAINED_GLASS_PANE = getItemType("pink_stained_glass_pane"); + + ItemType.Typed PINK_TERRACOTTA = getItemType("pink_terracotta"); + + ItemType.Typed PINK_TULIP = getItemType("pink_tulip"); + + ItemType.Typed PINK_WOOL = getItemType("pink_wool"); + + ItemType.Typed PISTON = getItemType("piston"); + + ItemType.Typed PITCHER_PLANT = getItemType("pitcher_plant"); + + ItemType.Typed PITCHER_POD = getItemType("pitcher_pod"); + + ItemType.Typed PLAYER_HEAD = getItemType("player_head"); + + ItemType.Typed PLENTY_POTTERY_SHERD = getItemType("plenty_pottery_sherd"); + + ItemType.Typed PODZOL = getItemType("podzol"); + + ItemType.Typed POINTED_DRIPSTONE = getItemType("pointed_dripstone"); + + ItemType.Typed POISONOUS_POTATO = getItemType("poisonous_potato"); + + ItemType.Typed POLAR_BEAR_SPAWN_EGG = getItemType("polar_bear_spawn_egg"); + + ItemType.Typed POLISHED_ANDESITE = getItemType("polished_andesite"); + + ItemType.Typed POLISHED_ANDESITE_SLAB = getItemType("polished_andesite_slab"); + + ItemType.Typed POLISHED_ANDESITE_STAIRS = getItemType("polished_andesite_stairs"); + + ItemType.Typed POLISHED_BASALT = getItemType("polished_basalt"); + + ItemType.Typed POLISHED_BLACKSTONE = getItemType("polished_blackstone"); + + ItemType.Typed POLISHED_BLACKSTONE_BRICK_SLAB = getItemType("polished_blackstone_brick_slab"); + + ItemType.Typed POLISHED_BLACKSTONE_BRICK_STAIRS = getItemType("polished_blackstone_brick_stairs"); + + ItemType.Typed POLISHED_BLACKSTONE_BRICK_WALL = getItemType("polished_blackstone_brick_wall"); + + ItemType.Typed POLISHED_BLACKSTONE_BRICKS = getItemType("polished_blackstone_bricks"); + + ItemType.Typed POLISHED_BLACKSTONE_BUTTON = getItemType("polished_blackstone_button"); + + ItemType.Typed POLISHED_BLACKSTONE_PRESSURE_PLATE = getItemType("polished_blackstone_pressure_plate"); + + ItemType.Typed POLISHED_BLACKSTONE_SLAB = getItemType("polished_blackstone_slab"); + + ItemType.Typed POLISHED_BLACKSTONE_STAIRS = getItemType("polished_blackstone_stairs"); + + ItemType.Typed POLISHED_BLACKSTONE_WALL = getItemType("polished_blackstone_wall"); + + ItemType.Typed POLISHED_DEEPSLATE = getItemType("polished_deepslate"); + + ItemType.Typed POLISHED_DEEPSLATE_SLAB = getItemType("polished_deepslate_slab"); + + ItemType.Typed POLISHED_DEEPSLATE_STAIRS = getItemType("polished_deepslate_stairs"); + + ItemType.Typed POLISHED_DEEPSLATE_WALL = getItemType("polished_deepslate_wall"); + + ItemType.Typed POLISHED_DIORITE = getItemType("polished_diorite"); + + ItemType.Typed POLISHED_DIORITE_SLAB = getItemType("polished_diorite_slab"); + + ItemType.Typed POLISHED_DIORITE_STAIRS = getItemType("polished_diorite_stairs"); + + ItemType.Typed POLISHED_GRANITE = getItemType("polished_granite"); + + ItemType.Typed POLISHED_GRANITE_SLAB = getItemType("polished_granite_slab"); + + ItemType.Typed POLISHED_GRANITE_STAIRS = getItemType("polished_granite_stairs"); + + ItemType.Typed POLISHED_TUFF = getItemType("polished_tuff"); + + ItemType.Typed POLISHED_TUFF_SLAB = getItemType("polished_tuff_slab"); + + ItemType.Typed POLISHED_TUFF_STAIRS = getItemType("polished_tuff_stairs"); + + ItemType.Typed POLISHED_TUFF_WALL = getItemType("polished_tuff_wall"); + + ItemType.Typed POPPED_CHORUS_FRUIT = getItemType("popped_chorus_fruit"); + + ItemType.Typed POPPY = getItemType("poppy"); + + ItemType.Typed PORKCHOP = getItemType("porkchop"); + + ItemType.Typed POTATO = getItemType("potato"); + + ItemType.Typed POTION = getItemType("potion"); + + ItemType.Typed POWDER_SNOW_BUCKET = getItemType("powder_snow_bucket"); + + ItemType.Typed POWERED_RAIL = getItemType("powered_rail"); + + ItemType.Typed PRISMARINE = getItemType("prismarine"); + + ItemType.Typed PRISMARINE_BRICK_SLAB = getItemType("prismarine_brick_slab"); + + ItemType.Typed PRISMARINE_BRICK_STAIRS = getItemType("prismarine_brick_stairs"); + + ItemType.Typed PRISMARINE_BRICKS = getItemType("prismarine_bricks"); + + ItemType.Typed PRISMARINE_CRYSTALS = getItemType("prismarine_crystals"); + + ItemType.Typed PRISMARINE_SHARD = getItemType("prismarine_shard"); + + ItemType.Typed PRISMARINE_SLAB = getItemType("prismarine_slab"); + + ItemType.Typed PRISMARINE_STAIRS = getItemType("prismarine_stairs"); + + ItemType.Typed PRISMARINE_WALL = getItemType("prismarine_wall"); + + ItemType.Typed PRIZE_POTTERY_SHERD = getItemType("prize_pottery_sherd"); + + ItemType.Typed PUFFERFISH = getItemType("pufferfish"); + + ItemType.Typed PUFFERFISH_BUCKET = getItemType("pufferfish_bucket"); + + ItemType.Typed PUFFERFISH_SPAWN_EGG = getItemType("pufferfish_spawn_egg"); + + ItemType.Typed PUMPKIN = getItemType("pumpkin"); + + ItemType.Typed PUMPKIN_PIE = getItemType("pumpkin_pie"); + + ItemType.Typed PUMPKIN_SEEDS = getItemType("pumpkin_seeds"); + + ItemType.Typed PURPLE_BANNER = getItemType("purple_banner"); + + ItemType.Typed PURPLE_BED = getItemType("purple_bed"); + + ItemType.Typed PURPLE_BUNDLE = getItemType("purple_bundle"); + + ItemType.Typed PURPLE_CANDLE = getItemType("purple_candle"); + + ItemType.Typed PURPLE_CARPET = getItemType("purple_carpet"); + + ItemType.Typed PURPLE_CONCRETE = getItemType("purple_concrete"); + + ItemType.Typed PURPLE_CONCRETE_POWDER = getItemType("purple_concrete_powder"); + + ItemType.Typed PURPLE_DYE = getItemType("purple_dye"); + + ItemType.Typed PURPLE_GLAZED_TERRACOTTA = getItemType("purple_glazed_terracotta"); + + ItemType.Typed PURPLE_SHULKER_BOX = getItemType("purple_shulker_box"); + + ItemType.Typed PURPLE_STAINED_GLASS = getItemType("purple_stained_glass"); + + ItemType.Typed PURPLE_STAINED_GLASS_PANE = getItemType("purple_stained_glass_pane"); + + ItemType.Typed PURPLE_TERRACOTTA = getItemType("purple_terracotta"); + + ItemType.Typed PURPLE_WOOL = getItemType("purple_wool"); + + ItemType.Typed PURPUR_BLOCK = getItemType("purpur_block"); + + ItemType.Typed PURPUR_PILLAR = getItemType("purpur_pillar"); + + ItemType.Typed PURPUR_SLAB = getItemType("purpur_slab"); + + ItemType.Typed PURPUR_STAIRS = getItemType("purpur_stairs"); + + ItemType.Typed QUARTZ = getItemType("quartz"); + + ItemType.Typed QUARTZ_BLOCK = getItemType("quartz_block"); + + ItemType.Typed QUARTZ_BRICKS = getItemType("quartz_bricks"); + + ItemType.Typed QUARTZ_PILLAR = getItemType("quartz_pillar"); + + ItemType.Typed QUARTZ_SLAB = getItemType("quartz_slab"); + + ItemType.Typed QUARTZ_STAIRS = getItemType("quartz_stairs"); + + ItemType.Typed RABBIT = getItemType("rabbit"); + + ItemType.Typed RABBIT_FOOT = getItemType("rabbit_foot"); + + ItemType.Typed RABBIT_HIDE = getItemType("rabbit_hide"); + + ItemType.Typed RABBIT_SPAWN_EGG = getItemType("rabbit_spawn_egg"); + + ItemType.Typed RABBIT_STEW = getItemType("rabbit_stew"); + + ItemType.Typed RAIL = getItemType("rail"); + + ItemType.Typed RAISER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("raiser_armor_trim_smithing_template"); + + ItemType.Typed RAVAGER_SPAWN_EGG = getItemType("ravager_spawn_egg"); + + ItemType.Typed RAW_COPPER = getItemType("raw_copper"); + + ItemType.Typed RAW_COPPER_BLOCK = getItemType("raw_copper_block"); + + ItemType.Typed RAW_GOLD = getItemType("raw_gold"); + + ItemType.Typed RAW_GOLD_BLOCK = getItemType("raw_gold_block"); + + ItemType.Typed RAW_IRON = getItemType("raw_iron"); + + ItemType.Typed RAW_IRON_BLOCK = getItemType("raw_iron_block"); + + ItemType.Typed RECOVERY_COMPASS = getItemType("recovery_compass"); + + ItemType.Typed RED_BANNER = getItemType("red_banner"); + + ItemType.Typed RED_BED = getItemType("red_bed"); + + ItemType.Typed RED_BUNDLE = getItemType("red_bundle"); + + ItemType.Typed RED_CANDLE = getItemType("red_candle"); + + ItemType.Typed RED_CARPET = getItemType("red_carpet"); + + ItemType.Typed RED_CONCRETE = getItemType("red_concrete"); + + ItemType.Typed RED_CONCRETE_POWDER = getItemType("red_concrete_powder"); + + ItemType.Typed RED_DYE = getItemType("red_dye"); + + ItemType.Typed RED_GLAZED_TERRACOTTA = getItemType("red_glazed_terracotta"); + + ItemType.Typed RED_MUSHROOM = getItemType("red_mushroom"); + + ItemType.Typed RED_MUSHROOM_BLOCK = getItemType("red_mushroom_block"); + + ItemType.Typed RED_NETHER_BRICK_SLAB = getItemType("red_nether_brick_slab"); + + ItemType.Typed RED_NETHER_BRICK_STAIRS = getItemType("red_nether_brick_stairs"); + + ItemType.Typed RED_NETHER_BRICK_WALL = getItemType("red_nether_brick_wall"); + + ItemType.Typed RED_NETHER_BRICKS = getItemType("red_nether_bricks"); + + ItemType.Typed RED_SAND = getItemType("red_sand"); + + ItemType.Typed RED_SANDSTONE = getItemType("red_sandstone"); + + ItemType.Typed RED_SANDSTONE_SLAB = getItemType("red_sandstone_slab"); + + ItemType.Typed RED_SANDSTONE_STAIRS = getItemType("red_sandstone_stairs"); + + ItemType.Typed RED_SANDSTONE_WALL = getItemType("red_sandstone_wall"); + + ItemType.Typed RED_SHULKER_BOX = getItemType("red_shulker_box"); + + ItemType.Typed RED_STAINED_GLASS = getItemType("red_stained_glass"); + + ItemType.Typed RED_STAINED_GLASS_PANE = getItemType("red_stained_glass_pane"); + + ItemType.Typed RED_TERRACOTTA = getItemType("red_terracotta"); + + ItemType.Typed RED_TULIP = getItemType("red_tulip"); + + ItemType.Typed RED_WOOL = getItemType("red_wool"); + + ItemType.Typed REDSTONE = getItemType("redstone"); + + ItemType.Typed REDSTONE_BLOCK = getItemType("redstone_block"); + + ItemType.Typed REDSTONE_LAMP = getItemType("redstone_lamp"); + + ItemType.Typed REDSTONE_ORE = getItemType("redstone_ore"); + + ItemType.Typed REDSTONE_TORCH = getItemType("redstone_torch"); + + ItemType.Typed REINFORCED_DEEPSLATE = getItemType("reinforced_deepslate"); + + ItemType.Typed REPEATER = getItemType("repeater"); + + ItemType.Typed REPEATING_COMMAND_BLOCK = getItemType("repeating_command_block"); + + ItemType.Typed RESIN_BLOCK = getItemType("resin_block"); + + ItemType.Typed RESIN_BRICK = getItemType("resin_brick"); + + ItemType.Typed RESIN_BRICK_SLAB = getItemType("resin_brick_slab"); + + ItemType.Typed RESIN_BRICK_STAIRS = getItemType("resin_brick_stairs"); + + ItemType.Typed RESIN_BRICK_WALL = getItemType("resin_brick_wall"); + + ItemType.Typed RESIN_BRICKS = getItemType("resin_bricks"); + + ItemType.Typed RESIN_CLUMP = getItemType("resin_clump"); + + ItemType.Typed RESPAWN_ANCHOR = getItemType("respawn_anchor"); + + ItemType.Typed RIB_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("rib_armor_trim_smithing_template"); + + ItemType.Typed ROOTED_DIRT = getItemType("rooted_dirt"); + + ItemType.Typed ROSE_BUSH = getItemType("rose_bush"); + + ItemType.Typed ROTTEN_FLESH = getItemType("rotten_flesh"); + + ItemType.Typed SADDLE = getItemType("saddle"); + + ItemType.Typed SALMON = getItemType("salmon"); + + ItemType.Typed SALMON_BUCKET = getItemType("salmon_bucket"); + + ItemType.Typed SALMON_SPAWN_EGG = getItemType("salmon_spawn_egg"); + + ItemType.Typed SAND = getItemType("sand"); + + ItemType.Typed SANDSTONE = getItemType("sandstone"); + + ItemType.Typed SANDSTONE_SLAB = getItemType("sandstone_slab"); + + ItemType.Typed SANDSTONE_STAIRS = getItemType("sandstone_stairs"); + + ItemType.Typed SANDSTONE_WALL = getItemType("sandstone_wall"); + + ItemType.Typed SCAFFOLDING = getItemType("scaffolding"); + + ItemType.Typed SCRAPE_POTTERY_SHERD = getItemType("scrape_pottery_sherd"); + + ItemType.Typed SCULK = getItemType("sculk"); + + ItemType.Typed SCULK_CATALYST = getItemType("sculk_catalyst"); + + ItemType.Typed SCULK_SENSOR = getItemType("sculk_sensor"); + + ItemType.Typed SCULK_SHRIEKER = getItemType("sculk_shrieker"); + + ItemType.Typed SCULK_VEIN = getItemType("sculk_vein"); + + ItemType.Typed SEA_LANTERN = getItemType("sea_lantern"); + + ItemType.Typed SEA_PICKLE = getItemType("sea_pickle"); + + ItemType.Typed SEAGRASS = getItemType("seagrass"); + + ItemType.Typed SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("sentry_armor_trim_smithing_template"); + + ItemType.Typed SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("shaper_armor_trim_smithing_template"); + + ItemType.Typed SHEAF_POTTERY_SHERD = getItemType("sheaf_pottery_sherd"); + + ItemType.Typed SHEARS = getItemType("shears"); + + ItemType.Typed SHEEP_SPAWN_EGG = getItemType("sheep_spawn_egg"); + + ItemType.Typed SHELTER_POTTERY_SHERD = getItemType("shelter_pottery_sherd"); + + ItemType.Typed SHIELD = getItemType("shield"); + + ItemType.Typed SHORT_DRY_GRASS = getItemType("short_dry_grass"); + + ItemType.Typed SHORT_GRASS = getItemType("short_grass"); + + ItemType.Typed SHROOMLIGHT = getItemType("shroomlight"); + + ItemType.Typed SHULKER_BOX = getItemType("shulker_box"); + + ItemType.Typed SHULKER_SHELL = getItemType("shulker_shell"); + + ItemType.Typed SHULKER_SPAWN_EGG = getItemType("shulker_spawn_egg"); + + ItemType.Typed SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("silence_armor_trim_smithing_template"); + + ItemType.Typed SILVERFISH_SPAWN_EGG = getItemType("silverfish_spawn_egg"); + + ItemType.Typed SKELETON_HORSE_SPAWN_EGG = getItemType("skeleton_horse_spawn_egg"); + + ItemType.Typed SKELETON_SKULL = getItemType("skeleton_skull"); + + ItemType.Typed SKELETON_SPAWN_EGG = getItemType("skeleton_spawn_egg"); + + ItemType.Typed SKULL_BANNER_PATTERN = getItemType("skull_banner_pattern"); + + ItemType.Typed SKULL_POTTERY_SHERD = getItemType("skull_pottery_sherd"); + + ItemType.Typed SLIME_BALL = getItemType("slime_ball"); + + ItemType.Typed SLIME_BLOCK = getItemType("slime_block"); + + ItemType.Typed SLIME_SPAWN_EGG = getItemType("slime_spawn_egg"); + + ItemType.Typed SMALL_AMETHYST_BUD = getItemType("small_amethyst_bud"); + + ItemType.Typed SMALL_DRIPLEAF = getItemType("small_dripleaf"); + + ItemType.Typed SMITHING_TABLE = getItemType("smithing_table"); + + ItemType.Typed SMOKER = getItemType("smoker"); + + ItemType.Typed SMOOTH_BASALT = getItemType("smooth_basalt"); + + ItemType.Typed SMOOTH_QUARTZ = getItemType("smooth_quartz"); + + ItemType.Typed SMOOTH_QUARTZ_SLAB = getItemType("smooth_quartz_slab"); + + ItemType.Typed SMOOTH_QUARTZ_STAIRS = getItemType("smooth_quartz_stairs"); + + ItemType.Typed SMOOTH_RED_SANDSTONE = getItemType("smooth_red_sandstone"); + + ItemType.Typed SMOOTH_RED_SANDSTONE_SLAB = getItemType("smooth_red_sandstone_slab"); + + ItemType.Typed SMOOTH_RED_SANDSTONE_STAIRS = getItemType("smooth_red_sandstone_stairs"); + + ItemType.Typed SMOOTH_SANDSTONE = getItemType("smooth_sandstone"); + + ItemType.Typed SMOOTH_SANDSTONE_SLAB = getItemType("smooth_sandstone_slab"); + + ItemType.Typed SMOOTH_SANDSTONE_STAIRS = getItemType("smooth_sandstone_stairs"); + + ItemType.Typed SMOOTH_STONE = getItemType("smooth_stone"); + + ItemType.Typed SMOOTH_STONE_SLAB = getItemType("smooth_stone_slab"); + + ItemType.Typed SNIFFER_EGG = getItemType("sniffer_egg"); + + ItemType.Typed SNIFFER_SPAWN_EGG = getItemType("sniffer_spawn_egg"); + + ItemType.Typed SNORT_POTTERY_SHERD = getItemType("snort_pottery_sherd"); + + ItemType.Typed SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("snout_armor_trim_smithing_template"); + + ItemType.Typed SNOW = getItemType("snow"); + + ItemType.Typed SNOW_BLOCK = getItemType("snow_block"); + + ItemType.Typed SNOW_GOLEM_SPAWN_EGG = getItemType("snow_golem_spawn_egg"); + + ItemType.Typed SNOWBALL = getItemType("snowball"); + + ItemType.Typed SOUL_CAMPFIRE = getItemType("soul_campfire"); + + ItemType.Typed SOUL_LANTERN = getItemType("soul_lantern"); + + ItemType.Typed SOUL_SAND = getItemType("soul_sand"); + + ItemType.Typed SOUL_SOIL = getItemType("soul_soil"); + + ItemType.Typed SOUL_TORCH = getItemType("soul_torch"); + + ItemType.Typed SPAWNER = getItemType("spawner"); + + ItemType.Typed SPECTRAL_ARROW = getItemType("spectral_arrow"); + + ItemType.Typed SPIDER_EYE = getItemType("spider_eye"); + + ItemType.Typed SPIDER_SPAWN_EGG = getItemType("spider_spawn_egg"); + + ItemType.Typed SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("spire_armor_trim_smithing_template"); + + ItemType.Typed SPLASH_POTION = getItemType("splash_potion"); + + ItemType.Typed SPONGE = getItemType("sponge"); + + ItemType.Typed SPORE_BLOSSOM = getItemType("spore_blossom"); + + ItemType.Typed SPRUCE_BOAT = getItemType("spruce_boat"); + + ItemType.Typed SPRUCE_BUTTON = getItemType("spruce_button"); + + ItemType.Typed SPRUCE_CHEST_BOAT = getItemType("spruce_chest_boat"); + + ItemType.Typed SPRUCE_DOOR = getItemType("spruce_door"); + + ItemType.Typed SPRUCE_FENCE = getItemType("spruce_fence"); + + ItemType.Typed SPRUCE_FENCE_GATE = getItemType("spruce_fence_gate"); + + ItemType.Typed SPRUCE_HANGING_SIGN = getItemType("spruce_hanging_sign"); + + ItemType.Typed SPRUCE_LEAVES = getItemType("spruce_leaves"); + + ItemType.Typed SPRUCE_LOG = getItemType("spruce_log"); + + ItemType.Typed SPRUCE_PLANKS = getItemType("spruce_planks"); + + ItemType.Typed SPRUCE_PRESSURE_PLATE = getItemType("spruce_pressure_plate"); + + ItemType.Typed SPRUCE_SAPLING = getItemType("spruce_sapling"); + + ItemType.Typed SPRUCE_SIGN = getItemType("spruce_sign"); + + ItemType.Typed SPRUCE_SLAB = getItemType("spruce_slab"); + + ItemType.Typed SPRUCE_STAIRS = getItemType("spruce_stairs"); + + ItemType.Typed SPRUCE_TRAPDOOR = getItemType("spruce_trapdoor"); + + ItemType.Typed SPRUCE_WOOD = getItemType("spruce_wood"); + + ItemType.Typed SPYGLASS = getItemType("spyglass"); + + ItemType.Typed SQUID_SPAWN_EGG = getItemType("squid_spawn_egg"); + + ItemType.Typed STICK = getItemType("stick"); + + ItemType.Typed STICKY_PISTON = getItemType("sticky_piston"); + + ItemType.Typed STONE = getItemType("stone"); + + ItemType.Typed STONE_AXE = getItemType("stone_axe"); + + ItemType.Typed STONE_BRICK_SLAB = getItemType("stone_brick_slab"); + + ItemType.Typed STONE_BRICK_STAIRS = getItemType("stone_brick_stairs"); + + ItemType.Typed STONE_BRICK_WALL = getItemType("stone_brick_wall"); + + ItemType.Typed STONE_BRICKS = getItemType("stone_bricks"); + + ItemType.Typed STONE_BUTTON = getItemType("stone_button"); + + ItemType.Typed STONE_HOE = getItemType("stone_hoe"); + + ItemType.Typed STONE_PICKAXE = getItemType("stone_pickaxe"); + + ItemType.Typed STONE_PRESSURE_PLATE = getItemType("stone_pressure_plate"); + + ItemType.Typed STONE_SHOVEL = getItemType("stone_shovel"); + + ItemType.Typed STONE_SLAB = getItemType("stone_slab"); + + ItemType.Typed STONE_STAIRS = getItemType("stone_stairs"); + + ItemType.Typed STONE_SWORD = getItemType("stone_sword"); + + ItemType.Typed STONECUTTER = getItemType("stonecutter"); + + ItemType.Typed STRAY_SPAWN_EGG = getItemType("stray_spawn_egg"); + + ItemType.Typed STRIDER_SPAWN_EGG = getItemType("strider_spawn_egg"); + + ItemType.Typed STRING = getItemType("string"); + + ItemType.Typed STRIPPED_ACACIA_LOG = getItemType("stripped_acacia_log"); + + ItemType.Typed STRIPPED_ACACIA_WOOD = getItemType("stripped_acacia_wood"); + + ItemType.Typed STRIPPED_BAMBOO_BLOCK = getItemType("stripped_bamboo_block"); + + ItemType.Typed STRIPPED_BIRCH_LOG = getItemType("stripped_birch_log"); + + ItemType.Typed STRIPPED_BIRCH_WOOD = getItemType("stripped_birch_wood"); + + ItemType.Typed STRIPPED_CHERRY_LOG = getItemType("stripped_cherry_log"); + + ItemType.Typed STRIPPED_CHERRY_WOOD = getItemType("stripped_cherry_wood"); + + ItemType.Typed STRIPPED_CRIMSON_HYPHAE = getItemType("stripped_crimson_hyphae"); + + ItemType.Typed STRIPPED_CRIMSON_STEM = getItemType("stripped_crimson_stem"); + + ItemType.Typed STRIPPED_DARK_OAK_LOG = getItemType("stripped_dark_oak_log"); + + ItemType.Typed STRIPPED_DARK_OAK_WOOD = getItemType("stripped_dark_oak_wood"); + + ItemType.Typed STRIPPED_JUNGLE_LOG = getItemType("stripped_jungle_log"); + + ItemType.Typed STRIPPED_JUNGLE_WOOD = getItemType("stripped_jungle_wood"); + + ItemType.Typed STRIPPED_MANGROVE_LOG = getItemType("stripped_mangrove_log"); + + ItemType.Typed STRIPPED_MANGROVE_WOOD = getItemType("stripped_mangrove_wood"); + + ItemType.Typed STRIPPED_OAK_LOG = getItemType("stripped_oak_log"); + + ItemType.Typed STRIPPED_OAK_WOOD = getItemType("stripped_oak_wood"); + + ItemType.Typed STRIPPED_PALE_OAK_LOG = getItemType("stripped_pale_oak_log"); + + ItemType.Typed STRIPPED_PALE_OAK_WOOD = getItemType("stripped_pale_oak_wood"); + + ItemType.Typed STRIPPED_SPRUCE_LOG = getItemType("stripped_spruce_log"); + + ItemType.Typed STRIPPED_SPRUCE_WOOD = getItemType("stripped_spruce_wood"); + + ItemType.Typed STRIPPED_WARPED_HYPHAE = getItemType("stripped_warped_hyphae"); + + ItemType.Typed STRIPPED_WARPED_STEM = getItemType("stripped_warped_stem"); + + ItemType.Typed STRUCTURE_BLOCK = getItemType("structure_block"); + + ItemType.Typed STRUCTURE_VOID = getItemType("structure_void"); + + ItemType.Typed SUGAR = getItemType("sugar"); + + ItemType.Typed SUGAR_CANE = getItemType("sugar_cane"); + + ItemType.Typed SUNFLOWER = getItemType("sunflower"); + + ItemType.Typed SUSPICIOUS_GRAVEL = getItemType("suspicious_gravel"); + + ItemType.Typed SUSPICIOUS_SAND = getItemType("suspicious_sand"); + + ItemType.Typed SUSPICIOUS_STEW = getItemType("suspicious_stew"); + + ItemType.Typed SWEET_BERRIES = getItemType("sweet_berries"); + + ItemType.Typed TADPOLE_BUCKET = getItemType("tadpole_bucket"); + + ItemType.Typed TADPOLE_SPAWN_EGG = getItemType("tadpole_spawn_egg"); + + ItemType.Typed TALL_DRY_GRASS = getItemType("tall_dry_grass"); + + ItemType.Typed TALL_GRASS = getItemType("tall_grass"); + + ItemType.Typed TARGET = getItemType("target"); + + ItemType.Typed TERRACOTTA = getItemType("terracotta"); + + ItemType.Typed TEST_BLOCK = getItemType("test_block"); + + ItemType.Typed TEST_INSTANCE_BLOCK = getItemType("test_instance_block"); + + ItemType.Typed TIDE_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("tide_armor_trim_smithing_template"); + + ItemType.Typed TINTED_GLASS = getItemType("tinted_glass"); + + ItemType.Typed TIPPED_ARROW = getItemType("tipped_arrow"); + + ItemType.Typed TNT = getItemType("tnt"); + + ItemType.Typed TNT_MINECART = getItemType("tnt_minecart"); + + ItemType.Typed TORCH = getItemType("torch"); + + ItemType.Typed TORCHFLOWER = getItemType("torchflower"); + + ItemType.Typed TORCHFLOWER_SEEDS = getItemType("torchflower_seeds"); + + ItemType.Typed TOTEM_OF_UNDYING = getItemType("totem_of_undying"); + + ItemType.Typed TRADER_LLAMA_SPAWN_EGG = getItemType("trader_llama_spawn_egg"); + + ItemType.Typed TRAPPED_CHEST = getItemType("trapped_chest"); + + ItemType.Typed TRIAL_KEY = getItemType("trial_key"); + + ItemType.Typed TRIAL_SPAWNER = getItemType("trial_spawner"); + + ItemType.Typed TRIDENT = getItemType("trident"); + + ItemType.Typed TRIPWIRE_HOOK = getItemType("tripwire_hook"); + + ItemType.Typed TROPICAL_FISH = getItemType("tropical_fish"); + + ItemType.Typed TROPICAL_FISH_BUCKET = getItemType("tropical_fish_bucket"); + + ItemType.Typed TROPICAL_FISH_SPAWN_EGG = getItemType("tropical_fish_spawn_egg"); + + ItemType.Typed TUBE_CORAL = getItemType("tube_coral"); + + ItemType.Typed TUBE_CORAL_BLOCK = getItemType("tube_coral_block"); + + ItemType.Typed TUBE_CORAL_FAN = getItemType("tube_coral_fan"); + + ItemType.Typed TUFF = getItemType("tuff"); + + ItemType.Typed TUFF_BRICK_SLAB = getItemType("tuff_brick_slab"); + + ItemType.Typed TUFF_BRICK_STAIRS = getItemType("tuff_brick_stairs"); + + ItemType.Typed TUFF_BRICK_WALL = getItemType("tuff_brick_wall"); + + ItemType.Typed TUFF_BRICKS = getItemType("tuff_bricks"); + + ItemType.Typed TUFF_SLAB = getItemType("tuff_slab"); + + ItemType.Typed TUFF_STAIRS = getItemType("tuff_stairs"); + + ItemType.Typed TUFF_WALL = getItemType("tuff_wall"); + + ItemType.Typed TURTLE_EGG = getItemType("turtle_egg"); + + ItemType.Typed TURTLE_HELMET = getItemType("turtle_helmet"); + + ItemType.Typed TURTLE_SCUTE = getItemType("turtle_scute"); + + ItemType.Typed TURTLE_SPAWN_EGG = getItemType("turtle_spawn_egg"); + + ItemType.Typed TWISTING_VINES = getItemType("twisting_vines"); + + ItemType.Typed VAULT = getItemType("vault"); + + ItemType.Typed VERDANT_FROGLIGHT = getItemType("verdant_froglight"); + + ItemType.Typed VEX_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("vex_armor_trim_smithing_template"); + + ItemType.Typed VEX_SPAWN_EGG = getItemType("vex_spawn_egg"); + + ItemType.Typed VILLAGER_SPAWN_EGG = getItemType("villager_spawn_egg"); + + ItemType.Typed VINDICATOR_SPAWN_EGG = getItemType("vindicator_spawn_egg"); + + ItemType.Typed VINE = getItemType("vine"); + + ItemType.Typed WANDERING_TRADER_SPAWN_EGG = getItemType("wandering_trader_spawn_egg"); + + ItemType.Typed WARD_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("ward_armor_trim_smithing_template"); + + ItemType.Typed WARDEN_SPAWN_EGG = getItemType("warden_spawn_egg"); + + ItemType.Typed WARPED_BUTTON = getItemType("warped_button"); + + ItemType.Typed WARPED_DOOR = getItemType("warped_door"); + + ItemType.Typed WARPED_FENCE = getItemType("warped_fence"); + + ItemType.Typed WARPED_FENCE_GATE = getItemType("warped_fence_gate"); + + ItemType.Typed WARPED_FUNGUS = getItemType("warped_fungus"); + + ItemType.Typed WARPED_FUNGUS_ON_A_STICK = getItemType("warped_fungus_on_a_stick"); + + ItemType.Typed WARPED_HANGING_SIGN = getItemType("warped_hanging_sign"); + + ItemType.Typed WARPED_HYPHAE = getItemType("warped_hyphae"); + + ItemType.Typed WARPED_NYLIUM = getItemType("warped_nylium"); + + ItemType.Typed WARPED_PLANKS = getItemType("warped_planks"); + + ItemType.Typed WARPED_PRESSURE_PLATE = getItemType("warped_pressure_plate"); + + ItemType.Typed WARPED_ROOTS = getItemType("warped_roots"); + + ItemType.Typed WARPED_SIGN = getItemType("warped_sign"); + + ItemType.Typed WARPED_SLAB = getItemType("warped_slab"); + + ItemType.Typed WARPED_STAIRS = getItemType("warped_stairs"); + + ItemType.Typed WARPED_STEM = getItemType("warped_stem"); + + ItemType.Typed WARPED_TRAPDOOR = getItemType("warped_trapdoor"); + + ItemType.Typed WARPED_WART_BLOCK = getItemType("warped_wart_block"); + + ItemType.Typed WATER_BUCKET = getItemType("water_bucket"); + + ItemType.Typed WAXED_CHISELED_COPPER = getItemType("waxed_chiseled_copper"); + + ItemType.Typed WAXED_COPPER_BLOCK = getItemType("waxed_copper_block"); + + ItemType.Typed WAXED_COPPER_BULB = getItemType("waxed_copper_bulb"); + + ItemType.Typed WAXED_COPPER_DOOR = getItemType("waxed_copper_door"); + + ItemType.Typed WAXED_COPPER_GRATE = getItemType("waxed_copper_grate"); + + ItemType.Typed WAXED_COPPER_TRAPDOOR = getItemType("waxed_copper_trapdoor"); + + ItemType.Typed WAXED_CUT_COPPER = getItemType("waxed_cut_copper"); + + ItemType.Typed WAXED_CUT_COPPER_SLAB = getItemType("waxed_cut_copper_slab"); + + ItemType.Typed WAXED_CUT_COPPER_STAIRS = getItemType("waxed_cut_copper_stairs"); + + ItemType.Typed WAXED_EXPOSED_CHISELED_COPPER = getItemType("waxed_exposed_chiseled_copper"); + + ItemType.Typed WAXED_EXPOSED_COPPER = getItemType("waxed_exposed_copper"); + + ItemType.Typed WAXED_EXPOSED_COPPER_BULB = getItemType("waxed_exposed_copper_bulb"); + + ItemType.Typed WAXED_EXPOSED_COPPER_DOOR = getItemType("waxed_exposed_copper_door"); + + ItemType.Typed WAXED_EXPOSED_COPPER_GRATE = getItemType("waxed_exposed_copper_grate"); + + ItemType.Typed WAXED_EXPOSED_COPPER_TRAPDOOR = getItemType("waxed_exposed_copper_trapdoor"); + + ItemType.Typed WAXED_EXPOSED_CUT_COPPER = getItemType("waxed_exposed_cut_copper"); + + ItemType.Typed WAXED_EXPOSED_CUT_COPPER_SLAB = getItemType("waxed_exposed_cut_copper_slab"); + + ItemType.Typed WAXED_EXPOSED_CUT_COPPER_STAIRS = getItemType("waxed_exposed_cut_copper_stairs"); + + ItemType.Typed WAXED_OXIDIZED_CHISELED_COPPER = getItemType("waxed_oxidized_chiseled_copper"); + + ItemType.Typed WAXED_OXIDIZED_COPPER = getItemType("waxed_oxidized_copper"); + + ItemType.Typed WAXED_OXIDIZED_COPPER_BULB = getItemType("waxed_oxidized_copper_bulb"); + + ItemType.Typed WAXED_OXIDIZED_COPPER_DOOR = getItemType("waxed_oxidized_copper_door"); + + ItemType.Typed WAXED_OXIDIZED_COPPER_GRATE = getItemType("waxed_oxidized_copper_grate"); + + ItemType.Typed WAXED_OXIDIZED_COPPER_TRAPDOOR = getItemType("waxed_oxidized_copper_trapdoor"); + + ItemType.Typed WAXED_OXIDIZED_CUT_COPPER = getItemType("waxed_oxidized_cut_copper"); + + ItemType.Typed WAXED_OXIDIZED_CUT_COPPER_SLAB = getItemType("waxed_oxidized_cut_copper_slab"); + + ItemType.Typed WAXED_OXIDIZED_CUT_COPPER_STAIRS = getItemType("waxed_oxidized_cut_copper_stairs"); + + ItemType.Typed WAXED_WEATHERED_CHISELED_COPPER = getItemType("waxed_weathered_chiseled_copper"); + + ItemType.Typed WAXED_WEATHERED_COPPER = getItemType("waxed_weathered_copper"); + + ItemType.Typed WAXED_WEATHERED_COPPER_BULB = getItemType("waxed_weathered_copper_bulb"); + + ItemType.Typed WAXED_WEATHERED_COPPER_DOOR = getItemType("waxed_weathered_copper_door"); + + ItemType.Typed WAXED_WEATHERED_COPPER_GRATE = getItemType("waxed_weathered_copper_grate"); + + ItemType.Typed WAXED_WEATHERED_COPPER_TRAPDOOR = getItemType("waxed_weathered_copper_trapdoor"); + + ItemType.Typed WAXED_WEATHERED_CUT_COPPER = getItemType("waxed_weathered_cut_copper"); + + ItemType.Typed WAXED_WEATHERED_CUT_COPPER_SLAB = getItemType("waxed_weathered_cut_copper_slab"); + + ItemType.Typed WAXED_WEATHERED_CUT_COPPER_STAIRS = getItemType("waxed_weathered_cut_copper_stairs"); + + ItemType.Typed WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("wayfinder_armor_trim_smithing_template"); + + ItemType.Typed WEATHERED_CHISELED_COPPER = getItemType("weathered_chiseled_copper"); + + ItemType.Typed WEATHERED_COPPER = getItemType("weathered_copper"); + + ItemType.Typed WEATHERED_COPPER_BULB = getItemType("weathered_copper_bulb"); + + ItemType.Typed WEATHERED_COPPER_DOOR = getItemType("weathered_copper_door"); + + ItemType.Typed WEATHERED_COPPER_GRATE = getItemType("weathered_copper_grate"); + + ItemType.Typed WEATHERED_COPPER_TRAPDOOR = getItemType("weathered_copper_trapdoor"); + + ItemType.Typed WEATHERED_CUT_COPPER = getItemType("weathered_cut_copper"); + + ItemType.Typed WEATHERED_CUT_COPPER_SLAB = getItemType("weathered_cut_copper_slab"); + + ItemType.Typed WEATHERED_CUT_COPPER_STAIRS = getItemType("weathered_cut_copper_stairs"); + + ItemType.Typed WEEPING_VINES = getItemType("weeping_vines"); + + ItemType.Typed WET_SPONGE = getItemType("wet_sponge"); + + ItemType.Typed WHEAT = getItemType("wheat"); + + ItemType.Typed WHEAT_SEEDS = getItemType("wheat_seeds"); + + ItemType.Typed WHITE_BANNER = getItemType("white_banner"); + + ItemType.Typed WHITE_BED = getItemType("white_bed"); + + ItemType.Typed WHITE_BUNDLE = getItemType("white_bundle"); + + ItemType.Typed WHITE_CANDLE = getItemType("white_candle"); + + ItemType.Typed WHITE_CARPET = getItemType("white_carpet"); + + ItemType.Typed WHITE_CONCRETE = getItemType("white_concrete"); + + ItemType.Typed WHITE_CONCRETE_POWDER = getItemType("white_concrete_powder"); + + ItemType.Typed WHITE_DYE = getItemType("white_dye"); + + ItemType.Typed WHITE_GLAZED_TERRACOTTA = getItemType("white_glazed_terracotta"); + + ItemType.Typed WHITE_SHULKER_BOX = getItemType("white_shulker_box"); + + ItemType.Typed WHITE_STAINED_GLASS = getItemType("white_stained_glass"); + + ItemType.Typed WHITE_STAINED_GLASS_PANE = getItemType("white_stained_glass_pane"); + + ItemType.Typed WHITE_TERRACOTTA = getItemType("white_terracotta"); + + ItemType.Typed WHITE_TULIP = getItemType("white_tulip"); + + ItemType.Typed WHITE_WOOL = getItemType("white_wool"); + + ItemType.Typed WILD_ARMOR_TRIM_SMITHING_TEMPLATE = getItemType("wild_armor_trim_smithing_template"); + + ItemType.Typed WILDFLOWERS = getItemType("wildflowers"); + + ItemType.Typed WIND_CHARGE = getItemType("wind_charge"); + + ItemType.Typed WITCH_SPAWN_EGG = getItemType("witch_spawn_egg"); + + ItemType.Typed WITHER_ROSE = getItemType("wither_rose"); + + ItemType.Typed WITHER_SKELETON_SKULL = getItemType("wither_skeleton_skull"); + + ItemType.Typed WITHER_SKELETON_SPAWN_EGG = getItemType("wither_skeleton_spawn_egg"); + + ItemType.Typed WITHER_SPAWN_EGG = getItemType("wither_spawn_egg"); + + ItemType.Typed WOLF_ARMOR = getItemType("wolf_armor"); + + ItemType.Typed WOLF_SPAWN_EGG = getItemType("wolf_spawn_egg"); + + ItemType.Typed WOODEN_AXE = getItemType("wooden_axe"); + + ItemType.Typed WOODEN_HOE = getItemType("wooden_hoe"); + + ItemType.Typed WOODEN_PICKAXE = getItemType("wooden_pickaxe"); + + ItemType.Typed WOODEN_SHOVEL = getItemType("wooden_shovel"); + + ItemType.Typed WOODEN_SWORD = getItemType("wooden_sword"); + + ItemType.Typed WRITABLE_BOOK = getItemType("writable_book"); + + ItemType.Typed WRITTEN_BOOK = getItemType("written_book"); + + ItemType.Typed YELLOW_BANNER = getItemType("yellow_banner"); + + ItemType.Typed YELLOW_BED = getItemType("yellow_bed"); + + ItemType.Typed YELLOW_BUNDLE = getItemType("yellow_bundle"); + + ItemType.Typed YELLOW_CANDLE = getItemType("yellow_candle"); + + ItemType.Typed YELLOW_CARPET = getItemType("yellow_carpet"); + + ItemType.Typed YELLOW_CONCRETE = getItemType("yellow_concrete"); + + ItemType.Typed YELLOW_CONCRETE_POWDER = getItemType("yellow_concrete_powder"); + + ItemType.Typed YELLOW_DYE = getItemType("yellow_dye"); + + ItemType.Typed YELLOW_GLAZED_TERRACOTTA = getItemType("yellow_glazed_terracotta"); + + ItemType.Typed YELLOW_SHULKER_BOX = getItemType("yellow_shulker_box"); + + ItemType.Typed YELLOW_STAINED_GLASS = getItemType("yellow_stained_glass"); + + ItemType.Typed YELLOW_STAINED_GLASS_PANE = getItemType("yellow_stained_glass_pane"); + + ItemType.Typed YELLOW_TERRACOTTA = getItemType("yellow_terracotta"); + + ItemType.Typed YELLOW_WOOL = getItemType("yellow_wool"); + + ItemType.Typed ZOGLIN_SPAWN_EGG = getItemType("zoglin_spawn_egg"); + + ItemType.Typed ZOMBIE_HEAD = getItemType("zombie_head"); + + ItemType.Typed ZOMBIE_HORSE_SPAWN_EGG = getItemType("zombie_horse_spawn_egg"); + + ItemType.Typed ZOMBIE_SPAWN_EGG = getItemType("zombie_spawn_egg"); + + ItemType.Typed ZOMBIE_VILLAGER_SPAWN_EGG = getItemType("zombie_villager_spawn_egg"); + + ItemType.Typed ZOMBIFIED_PIGLIN_SPAWN_EGG = getItemType("zombified_piglin_spawn_egg"); + // End generate - ItemType // @NotNull @@ -2401,7 +3063,7 @@ public interface ItemType extends Keyed, Translatable, net.kyori.adventure.trans * Get the {@link CreativeCategory} to which this item type belongs. * * @return the creative category. null if does not belong to a category - * @deprecated creative categories no longer exist on the server + */ @Nullable @Deprecated(since = "1.20.6", forRemoval = true) diff --git a/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java b/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java index a8e125ef6..eb4ba7ce2 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java +++ b/paper-api/src/main/java/org/bukkit/inventory/SmithingTrimRecipe.java @@ -2,8 +2,8 @@ package org.bukkit.inventory; import org.bukkit.Material; import org.bukkit.NamespacedKey; +import org.bukkit.inventory.meta.trim.TrimPattern; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Represents a smithing trim recipe. @@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable; public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe { private final RecipeChoice template; + private final TrimPattern pattern; /** * Create a smithing recipe to produce the specified result ItemStack. @@ -19,12 +20,44 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe * @param template The template item ({@link RecipeChoice#empty()} can be used) * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) + * @param pattern The trim pattern */ - public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { // Paper - fix issues with recipe api - prevent null choices + public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, @NotNull TrimPattern pattern) { super(key, new ItemStack(Material.AIR), base, addition); - this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper + this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Don't use null + this.pattern = pattern; } - // Paper start + + /** + * Create a smithing recipe to produce the specified result ItemStack. + * + * @param key The unique recipe key + * @param template The template item. ({@link RecipeChoice#empty()} can be used) + * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) + * @param pattern The trim pattern + * @param copyDataComponents whether to copy the data components from the input base item to the output + */ + public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, @NotNull TrimPattern pattern, boolean copyDataComponents) { + super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents); + this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Don't use null + this.pattern = pattern; + } + + /** + * Create a smithing recipe to produce the specified result ItemStack. + * + * @param key The unique recipe key + * @param template The template item ({@link RecipeChoice#empty()} can be used) + * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) + * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) + * @deprecated use {@link #SmithingTrimRecipe(NamespacedKey, RecipeChoice, RecipeChoice, RecipeChoice, TrimPattern)} instead + */ + @Deprecated(since = "1.21.5", forRemoval = true) + public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition) { + this(key, template, base, addition, patternFromTemplate(template)); + } + /** * Create a smithing recipe to produce the specified result ItemStack. * @@ -33,20 +66,64 @@ public class SmithingTrimRecipe extends SmithingRecipe implements ComplexRecipe * @param base The base ingredient ({@link RecipeChoice#empty()} can be used) * @param addition The addition ingredient ({@link RecipeChoice#empty()} can be used) * @param copyDataComponents whether to copy the data components from the input base item to the output + * @deprecated use {@link #SmithingTrimRecipe(NamespacedKey, RecipeChoice, RecipeChoice, RecipeChoice, TrimPattern, boolean)} instead */ - public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { // Paper - fix issues with recipe api - prevent null choices - super(key, new ItemStack(Material.AIR), base, addition, copyDataComponents); - this.template = template == null ? RecipeChoice.empty() : template.validate(true).clone(); // Paper + @Deprecated(since = "1.21.5", forRemoval = true) + public SmithingTrimRecipe(@NotNull NamespacedKey key, @NotNull RecipeChoice template, @NotNull RecipeChoice base, @NotNull RecipeChoice addition, boolean copyDataComponents) { + this(key, template, base, addition, patternFromTemplate(template), copyDataComponents); } - // Paper end /** * Get the template recipe item. * * @return template choice */ - @NotNull // Paper - fix issues with recipe api - prevent null choices + @NotNull public RecipeChoice getTemplate() { return (template != null) ? template.clone() : null; } + + /** + * Get the trim pattern. + * + * @return trim pattern + */ + @NotNull + public TrimPattern getTrimPattern() { + return pattern; + } + + private static TrimPattern patternFromTemplate(@NotNull RecipeChoice template) { + if (template instanceof RecipeChoice.ExactChoice exactChoice) { + return patternFromMaterial(exactChoice.getItemStack().getType()); + } else if (template instanceof RecipeChoice.MaterialChoice materialChoice) { + return patternFromMaterial(materialChoice.getItemStack().getType()); + } else { + return TrimPattern.BOLT; + } + } + + private static TrimPattern patternFromMaterial(final @NotNull Material material) { + return switch (material) { + case BOLT_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.BOLT; + case COAST_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.COAST; + case DUNE_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.DUNE; + case EYE_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.EYE; + case FLOW_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.FLOW; + case HOST_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.HOST; + case RAISER_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.RAISER; + case RIB_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.RIB; + case SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.SENTRY; + case SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.SHAPER; + case SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.SILENCE; + case SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.SNOUT; + case SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.SPIRE; + case TIDE_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.TIDE; + case VEX_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.VEX; + case WARD_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.WARD; + case WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.WAYFINDER; + case WILD_ARMOR_TRIM_SMITHING_TEMPLATE -> TrimPattern.WILD; + default -> TrimPattern.BOLT; + }; + } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java index aae2ed2ec..8b03d6eee 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/EnchantmentStorageMeta.java @@ -22,19 +22,19 @@ public interface EnchantmentStorageMeta extends ItemMeta { /** * Checks for storage of the specified enchantment. * - * @param ench enchantment to check + * @param enchant enchantment to check * @return true if this enchantment is stored in this meta */ - boolean hasStoredEnchant(@NotNull Enchantment ench); + boolean hasStoredEnchant(@NotNull Enchantment enchant); /** * Checks for the level of the stored enchantment. * - * @param ench enchantment to check + * @param enchant enchantment to check * @return The level that the specified stored enchantment has, or 0 if * none */ - int getStoredEnchantLevel(@NotNull Enchantment ench); + int getStoredEnchantLevel(@NotNull Enchantment enchant); /** * Gets a copy the stored enchantments in this ItemMeta. @@ -47,7 +47,7 @@ public interface EnchantmentStorageMeta extends ItemMeta { /** * Stores the specified enchantment in this item meta. * - * @param ench Enchantment to store + * @param enchant Enchantment to store * @param level Level for the enchantment * @param ignoreLevelRestriction this indicates the enchantment should be * applied, ignoring the level limit @@ -55,26 +55,26 @@ public interface EnchantmentStorageMeta extends ItemMeta { * otherwise * @throws IllegalArgumentException if enchantment is null */ - boolean addStoredEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction); + boolean addStoredEnchant(@NotNull Enchantment enchant, int level, boolean ignoreLevelRestriction); /** * Remove the specified stored enchantment from this item meta. * - * @param ench Enchantment to remove + * @param enchant Enchantment to remove * @return true if the item meta changed as a result of this call, false * otherwise * @throws IllegalArgumentException if enchantment is null */ - boolean removeStoredEnchant(@NotNull Enchantment ench) throws IllegalArgumentException; + boolean removeStoredEnchant(@NotNull Enchantment enchant) throws IllegalArgumentException; /** * Checks if the specified enchantment conflicts with any enchantments in * this ItemMeta. * - * @param ench enchantment to test + * @param enchant enchantment to test * @return true if the enchantment conflicts, false otherwise */ - boolean hasConflictingStoredEnchant(@NotNull Enchantment ench); + boolean hasConflictingStoredEnchant(@NotNull Enchantment enchant); @Override @NotNull diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java index e8c0b8848..a2eb229ef 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/ItemMeta.java @@ -400,18 +400,18 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste /** * Checks for existence of the specified enchantment. * - * @param ench enchantment to check + * @param enchant enchantment to check * @return true if this enchantment exists for this meta */ - boolean hasEnchant(@NotNull Enchantment ench); + boolean hasEnchant(@NotNull Enchantment enchant); /** * Checks for the level of the specified enchantment. * - * @param ench enchantment to check + * @param enchant enchantment to check * @return The level that the specified enchantment has, or 0 if none */ - int getEnchantLevel(@NotNull Enchantment ench); + int getEnchantLevel(@NotNull Enchantment enchant); /** * Returns a copy the enchantments in this ItemMeta.
    @@ -425,23 +425,23 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste /** * Adds the specified enchantment to this item meta. * - * @param ench Enchantment to add + * @param enchant Enchantment to add * @param level Level for the enchantment * @param ignoreLevelRestriction this indicates the enchantment should be * applied, ignoring the level limit * @return true if the item meta changed as a result of this call, false * otherwise */ - boolean addEnchant(@NotNull Enchantment ench, int level, boolean ignoreLevelRestriction); + boolean addEnchant(@NotNull Enchantment enchant, int level, boolean ignoreLevelRestriction); /** * Removes the specified enchantment from this item meta. * - * @param ench Enchantment to remove + * @param enchant Enchantment to remove * @return true if the item meta changed as a result of this call, false * otherwise */ - boolean removeEnchant(@NotNull Enchantment ench); + boolean removeEnchant(@NotNull Enchantment enchant); /** * Removes all enchantments from this item meta. @@ -452,10 +452,10 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable, Persiste * Checks if the specified enchantment conflicts with any enchantments in * this ItemMeta. * - * @param ench enchantment to test + * @param enchant enchantment to test * @return true if the enchantment conflicts, false otherwise */ - boolean hasConflictingEnchant(@NotNull Enchantment ench); + boolean hasConflictingEnchant(@NotNull Enchantment enchant); /** * Set itemflags which should be ignored when rendering a ItemStack in the Client. This Method does silently ignore double set itemFlags. diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/components/EquippableComponent.java b/paper-api/src/main/java/org/bukkit/inventory/meta/components/EquippableComponent.java index 16713c9d4..e462ae9f9 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/components/EquippableComponent.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/components/EquippableComponent.java @@ -150,4 +150,18 @@ public interface EquippableComponent extends ConfigurationSerializable { * @param damage whether the item will be damaged */ void setDamageOnHurt(boolean damage); + + /** + * Gets if the item should be equipped when interacting with an entity. + * + * @return whether the item equips on interact + */ + boolean isEquipOnInteract(); + + /** + * Sets if the item should be equipped when interacting with an entity. + * + * @param equip whether the item equips on interact + */ + void setEquipOnInteract(boolean equip); } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/components/JukeboxPlayableComponent.java b/paper-api/src/main/java/org/bukkit/inventory/meta/components/JukeboxPlayableComponent.java index 785c6b278..636cab6b5 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/components/JukeboxPlayableComponent.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/components/JukeboxPlayableComponent.java @@ -4,6 +4,7 @@ import org.bukkit.JukeboxSong; import org.bukkit.NamespacedKey; import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -47,13 +48,21 @@ public interface JukeboxPlayableComponent extends ConfigurationSerializable { * Gets if the song will show in the item tooltip. * * @return if the song will show in the tooltip + * @deprecated no longer available on the component directly */ - boolean isShowInTooltip(); + @Deprecated(since = "1.21.5", forRemoval = true) + @Contract("-> true") // todo add new item flag for compat? or just tell people to use the new data component api + default boolean isShowInTooltip() { + return true; + } /** * Sets if the song will show in the item tooltip. * * @param show true if the song will show in the tooltip + * @deprecated no longer available on the component directly */ - void setShowInTooltip(boolean show); + @Deprecated(since = "1.21.5", forRemoval = true) + default void setShowInTooltip(boolean show) { + } } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java index 0910dd287..060b02b1f 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimMaterial.java @@ -14,50 +14,30 @@ import org.jetbrains.annotations.NotNull; */ public interface TrimMaterial extends Keyed, Translatable { - /** - * {@link Material#QUARTZ}. - */ - public static final TrimMaterial QUARTZ = getTrimMaterial("quartz"); - /** - * {@link Material#IRON_INGOT}. - */ - public static final TrimMaterial IRON = getTrimMaterial("iron"); - /** - * {@link Material#NETHERITE_INGOT}. - */ - public static final TrimMaterial NETHERITE = getTrimMaterial("netherite"); - /** - * {@link Material#REDSTONE}. - */ - public static final TrimMaterial REDSTONE = getTrimMaterial("redstone"); - /** - * {@link Material#COPPER_INGOT}. - */ - public static final TrimMaterial COPPER = getTrimMaterial("copper"); - /** - * {@link Material#GOLD_INGOT}. - */ - public static final TrimMaterial GOLD = getTrimMaterial("gold"); - /** - * {@link Material#EMERALD}. - */ - public static final TrimMaterial EMERALD = getTrimMaterial("emerald"); - /** - * {@link Material#DIAMOND}. - */ - public static final TrimMaterial DIAMOND = getTrimMaterial("diamond"); - /** - * {@link Material#LAPIS_LAZULI}. - */ - public static final TrimMaterial LAPIS = getTrimMaterial("lapis"); - /** - * {@link Material#AMETHYST_SHARD}. - */ - public static final TrimMaterial AMETHYST = getTrimMaterial("amethyst"); - /** - * {@link Material#RESIN_BRICK}. - */ - public static final TrimMaterial RESIN = getTrimMaterial("resin"); + // Start generate - TrimMaterial + // @GeneratedFrom 1.21.5 + TrimMaterial AMETHYST = getTrimMaterial("amethyst"); + + TrimMaterial COPPER = getTrimMaterial("copper"); + + TrimMaterial DIAMOND = getTrimMaterial("diamond"); + + TrimMaterial EMERALD = getTrimMaterial("emerald"); + + TrimMaterial GOLD = getTrimMaterial("gold"); + + TrimMaterial IRON = getTrimMaterial("iron"); + + TrimMaterial LAPIS = getTrimMaterial("lapis"); + + TrimMaterial NETHERITE = getTrimMaterial("netherite"); + + TrimMaterial QUARTZ = getTrimMaterial("quartz"); + + TrimMaterial REDSTONE = getTrimMaterial("redstone"); + + TrimMaterial RESIN = getTrimMaterial("resin"); + // End generate - TrimMaterial @NotNull private static TrimMaterial getTrimMaterial(@NotNull String key) { @@ -99,6 +79,5 @@ public interface TrimMaterial extends Keyed, Translatable { default net.kyori.adventure.key.@org.jetbrains.annotations.NotNull Key key() { return org.bukkit.Keyed.super.key(); } - // Paper end - Registry#getKey } diff --git a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java index 9360e27b0..252afa699 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java +++ b/paper-api/src/main/java/org/bukkit/inventory/meta/trim/TrimPattern.java @@ -14,78 +14,44 @@ import org.jetbrains.annotations.NotNull; */ public interface TrimPattern extends Keyed, Translatable { - /** - * {@link Material#SENTRY_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern SENTRY = getTrimPattern("sentry"); - /** - * {@link Material#DUNE_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern DUNE = getTrimPattern("dune"); - /** - * {@link Material#COAST_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern COAST = getTrimPattern("coast"); - /** - * {@link Material#WILD_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern WILD = getTrimPattern("wild"); - /** - * {@link Material#WARD_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern WARD = getTrimPattern("ward"); - /** - * {@link Material#EYE_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern EYE = getTrimPattern("eye"); - /** - * {@link Material#VEX_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern VEX = getTrimPattern("vex"); - /** - * {@link Material#TIDE_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern TIDE = getTrimPattern("tide"); - /** - * {@link Material#SNOUT_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern SNOUT = getTrimPattern("snout"); - /** - * {@link Material#RIB_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern RIB = getTrimPattern("rib"); - /** - * {@link Material#SPIRE_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern SPIRE = getTrimPattern("spire"); - /** - * {@link Material#WAYFINDER_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern WAYFINDER = getTrimPattern("wayfinder"); - /** - * {@link Material#SHAPER_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern SHAPER = getTrimPattern("shaper"); - /** - * {@link Material#SILENCE_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern SILENCE = getTrimPattern("silence"); - /** - * {@link Material#RAISER_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern RAISER = getTrimPattern("raiser"); - /** - * {@link Material#HOST_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern HOST = getTrimPattern("host"); - /** - * {@link Material#FLOW_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern FLOW = getTrimPattern("flow"); - /** - * {@link Material#BOLT_ARMOR_TRIM_SMITHING_TEMPLATE}. - */ - public static final TrimPattern BOLT = getTrimPattern("bolt"); + // Start generate - TrimPattern + // @GeneratedFrom 1.21.5 + TrimPattern BOLT = getTrimPattern("bolt"); + + TrimPattern COAST = getTrimPattern("coast"); + + TrimPattern DUNE = getTrimPattern("dune"); + + TrimPattern EYE = getTrimPattern("eye"); + + TrimPattern FLOW = getTrimPattern("flow"); + + TrimPattern HOST = getTrimPattern("host"); + + TrimPattern RAISER = getTrimPattern("raiser"); + + TrimPattern RIB = getTrimPattern("rib"); + + TrimPattern SENTRY = getTrimPattern("sentry"); + + TrimPattern SHAPER = getTrimPattern("shaper"); + + TrimPattern SILENCE = getTrimPattern("silence"); + + TrimPattern SNOUT = getTrimPattern("snout"); + + TrimPattern SPIRE = getTrimPattern("spire"); + + TrimPattern TIDE = getTrimPattern("tide"); + + TrimPattern VEX = getTrimPattern("vex"); + + TrimPattern WARD = getTrimPattern("ward"); + + TrimPattern WAYFINDER = getTrimPattern("wayfinder"); + + TrimPattern WILD = getTrimPattern("wild"); + // End generate - TrimPattern @NotNull private static TrimPattern getTrimPattern(@NotNull String key) { diff --git a/paper-api/src/main/java/org/bukkit/inventory/recipe/CookingBookCategory.java b/paper-api/src/main/java/org/bukkit/inventory/recipe/CookingBookCategory.java index 9990a7abf..585cf467e 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/recipe/CookingBookCategory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/recipe/CookingBookCategory.java @@ -5,7 +5,10 @@ package org.bukkit.inventory.recipe; */ public enum CookingBookCategory { + // Start generate - CookingBookCategory + // @GeneratedFrom 1.21.5 FOOD, BLOCKS, MISC; + // End generate - CookingBookCategory } diff --git a/paper-api/src/main/java/org/bukkit/inventory/recipe/CraftingBookCategory.java b/paper-api/src/main/java/org/bukkit/inventory/recipe/CraftingBookCategory.java index 09a6a1b9b..51d41d8b7 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/recipe/CraftingBookCategory.java +++ b/paper-api/src/main/java/org/bukkit/inventory/recipe/CraftingBookCategory.java @@ -5,8 +5,11 @@ package org.bukkit.inventory.recipe; */ public enum CraftingBookCategory { + // Start generate - CraftingBookCategory + // @GeneratedFrom 1.21.5 BUILDING, REDSTONE, EQUIPMENT, MISC; + // End generate - CraftingBookCategory } diff --git a/paper-api/src/main/java/org/bukkit/inventory/view/builder/LocationInventoryViewBuilder.java b/paper-api/src/main/java/org/bukkit/inventory/view/builder/LocationInventoryViewBuilder.java index a53249727..a1cc5ed17 100644 --- a/paper-api/src/main/java/org/bukkit/inventory/view/builder/LocationInventoryViewBuilder.java +++ b/paper-api/src/main/java/org/bukkit/inventory/view/builder/LocationInventoryViewBuilder.java @@ -45,7 +45,7 @@ public interface LocationInventoryViewBuilder extends I * building this view it may come with the costs associated with chunk * loading. *

    - * Providing a location of a tile entity with a non matching menu comes with + * Providing a location of a block entity with a non matching menu comes with * extra costs associated with ensuring that the correct view is created. * * @param location the location to bind to this view diff --git a/paper-api/src/main/java/org/bukkit/map/MapCursor.java b/paper-api/src/main/java/org/bukkit/map/MapCursor.java index 7f5682c80..902402b7a 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapCursor.java +++ b/paper-api/src/main/java/org/bukkit/map/MapCursor.java @@ -7,6 +7,7 @@ import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.util.OldEnum; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -287,56 +288,79 @@ public final class MapCursor { */ public interface Type extends OldEnum, Keyed { - Type PLAYER = getType("player"); - Type FRAME = getType("frame"); - Type RED_MARKER = getType("red_marker"); - Type BLUE_MARKER = getType("blue_marker"); - Type TARGET_X = getType("target_x"); - Type TARGET_POINT = getType("target_point"); - Type PLAYER_OFF_MAP = getType("player_off_map"); - Type PLAYER_OFF_LIMITS = getType("player_off_limits"); - Type MANSION = getType("mansion"); - Type MONUMENT = getType("monument"); - Type BANNER_WHITE = getType("banner_white"); - Type BANNER_ORANGE = getType("banner_orange"); - Type BANNER_MAGENTA = getType("banner_magenta"); - Type BANNER_LIGHT_BLUE = getType("banner_light_blue"); - Type BANNER_YELLOW = getType("banner_yellow"); - Type BANNER_LIME = getType("banner_lime"); - Type BANNER_PINK = getType("banner_pink"); - Type BANNER_GRAY = getType("banner_gray"); - Type BANNER_LIGHT_GRAY = getType("banner_light_gray"); - Type BANNER_CYAN = getType("banner_cyan"); - Type BANNER_PURPLE = getType("banner_purple"); - Type BANNER_BLUE = getType("banner_blue"); - Type BANNER_BROWN = getType("banner_brown"); - Type BANNER_GREEN = getType("banner_green"); - Type BANNER_RED = getType("banner_red"); + // Start generate - MapCursorType + // @GeneratedFrom 1.21.5 Type BANNER_BLACK = getType("banner_black"); - Type RED_X = getType("red_x"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - Type VILLAGE_DESERT = getType("village_desert"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - Type VILLAGE_PLAINS = getType("village_plains"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - Type VILLAGE_SAVANNA = getType("village_savanna"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - Type VILLAGE_SNOWY = getType("village_snowy"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation - Type VILLAGE_TAIGA = getType("village_taiga"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation + + Type BANNER_BLUE = getType("banner_blue"); + + Type BANNER_BROWN = getType("banner_brown"); + + Type BANNER_CYAN = getType("banner_cyan"); + + Type BANNER_GRAY = getType("banner_gray"); + + Type BANNER_GREEN = getType("banner_green"); + + Type BANNER_LIGHT_BLUE = getType("banner_light_blue"); + + Type BANNER_LIGHT_GRAY = getType("banner_light_gray"); + + Type BANNER_LIME = getType("banner_lime"); + + Type BANNER_MAGENTA = getType("banner_magenta"); + + Type BANNER_ORANGE = getType("banner_orange"); + + Type BANNER_PINK = getType("banner_pink"); + + Type BANNER_PURPLE = getType("banner_purple"); + + Type BANNER_RED = getType("banner_red"); + + Type BANNER_WHITE = getType("banner_white"); + + Type BANNER_YELLOW = getType("banner_yellow"); + + Type BLUE_MARKER = getType("blue_marker"); + + Type FRAME = getType("frame"); + Type JUNGLE_TEMPLE = getType("jungle_temple"); - @org.bukkit.MinecraftExperimental(org.bukkit.MinecraftExperimental.Requires.TRADE_REBALANCE) // Paper - add missing annotation - @org.jetbrains.annotations.ApiStatus.Experimental // Paper - add missing annotation + + Type MANSION = getType("mansion"); + + Type MONUMENT = getType("monument"); + + Type PLAYER = getType("player"); + + Type PLAYER_OFF_LIMITS = getType("player_off_limits"); + + Type PLAYER_OFF_MAP = getType("player_off_map"); + + Type RED_MARKER = getType("red_marker"); + + Type RED_X = getType("red_x"); + Type SWAMP_HUT = getType("swamp_hut"); + + Type TARGET_POINT = getType("target_point"); + + Type TARGET_X = getType("target_x"); + Type TRIAL_CHAMBERS = getType("trial_chambers"); + Type VILLAGE_DESERT = getType("village_desert"); + + Type VILLAGE_PLAINS = getType("village_plains"); + + Type VILLAGE_SAVANNA = getType("village_savanna"); + + Type VILLAGE_SNOWY = getType("village_snowy"); + + Type VILLAGE_TAIGA = getType("village_taiga"); + // End generate - MapCursorType + @NotNull private static Type getType(@NotNull String key) { return Registry.MAP_DECORATION_TYPE.getOrThrow(NamespacedKey.minecraft(key)); @@ -348,7 +372,7 @@ public final class MapCursor { * @return the value * @apiNote Internal Use Only */ - @org.jetbrains.annotations.ApiStatus.Internal // Paper + @ApiStatus.Internal // Paper byte getValue(); /** @@ -358,7 +382,7 @@ public final class MapCursor { * @return the matching type * @apiNote Internal Use Only */ - @org.jetbrains.annotations.ApiStatus.Internal // Paper + @ApiStatus.Internal // Paper @Nullable static Type byValue(byte value) { for (Type t : values()) { @@ -373,7 +397,7 @@ public final class MapCursor { * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead. */ @NotNull - @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils + @Deprecated(since = "1.21", forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Type valueOf(@NotNull String name) { Type type = Registry.MAP_DECORATION_TYPE.get(NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); Preconditions.checkArgument(type != null, "No Type found with the name %s", name); @@ -385,7 +409,7 @@ public final class MapCursor { * @deprecated use {@link Registry#iterator()}. */ @NotNull - @Deprecated(since = "1.21", forRemoval = true) @org.jetbrains.annotations.ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils + @Deprecated(since = "1.21", forRemoval = true) @ApiStatus.ScheduledForRemoval(inVersion = "1.22") // Paper - will be removed via asm-utils static Type[] values() { return Lists.newArrayList(Registry.MAP_DECORATION_TYPE).toArray(new Type[0]); } diff --git a/paper-api/src/main/java/org/bukkit/map/MapPalette.java b/paper-api/src/main/java/org/bukkit/map/MapPalette.java index 6995f9cc0..fc9728342 100644 --- a/paper-api/src/main/java/org/bukkit/map/MapPalette.java +++ b/paper-api/src/main/java/org/bukkit/map/MapPalette.java @@ -18,16 +18,6 @@ public final class MapPalette { // Internal mechanisms private MapPalette() {} - @NotNull - private static Color c(int r, int g, int b) { - return new Color(r, g, b); - } - - @NotNull - private static Color c(int r, int g, int b, int a) { - return new Color(r, g, b, a); - } - private static double getDistance(@NotNull Color c1, @NotNull Color c2) { // Paper start - Optimize color distance calculation by removing floating point math int rsum = c1.getRed() + c2.getRed(); // Use sum instead of mean for no division @@ -46,68 +36,257 @@ public final class MapPalette { @NotNull static final Color[] colors = { - c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0), c(0, 0, 0, 0), - c(89, 125, 39), c(109, 153, 48), c(127, 178, 56), c(67, 94, 29), - c(174, 164, 115), c(213, 201, 140), c(247, 233, 163), c(130, 123, 86), - c(140, 140, 140), c(171, 171, 171), c(199, 199, 199), c(105, 105, 105), - c(180, 0, 0), c(220, 0, 0), c(255, 0, 0), c(135, 0, 0), - c(112, 112, 180), c(138, 138, 220), c(160, 160, 255), c(84, 84, 135), - c(117, 117, 117), c(144, 144, 144), c(167, 167, 167), c(88, 88, 88), - c(0, 87, 0), c(0, 106, 0), c(0, 124, 0), c(0, 65, 0), - c(180, 180, 180), c(220, 220, 220), c(255, 255, 255), c(135, 135, 135), - c(115, 118, 129), c(141, 144, 158), c(164, 168, 184), c(86, 88, 97), - c(106, 76, 54), c(130, 94, 66), c(151, 109, 77), c(79, 57, 40), - c(79, 79, 79), c(96, 96, 96), c(112, 112, 112), c(59, 59, 59), - c(45, 45, 180), c(55, 55, 220), c(64, 64, 255), c(33, 33, 135), - c(100, 84, 50), c(123, 102, 62), c(143, 119, 72), c(75, 63, 38), - c(180, 177, 172), c(220, 217, 211), c(255, 252, 245), c(135, 133, 129), - c(152, 89, 36), c(186, 109, 44), c(216, 127, 51), c(114, 67, 27), - c(125, 53, 152), c(153, 65, 186), c(178, 76, 216), c(94, 40, 114), - c(72, 108, 152), c(88, 132, 186), c(102, 153, 216), c(54, 81, 114), - c(161, 161, 36), c(197, 197, 44), c(229, 229, 51), c(121, 121, 27), - c(89, 144, 17), c(109, 176, 21), c(127, 204, 25), c(67, 108, 13), - c(170, 89, 116), c(208, 109, 142), c(242, 127, 165), c(128, 67, 87), - c(53, 53, 53), c(65, 65, 65), c(76, 76, 76), c(40, 40, 40), - c(108, 108, 108), c(132, 132, 132), c(153, 153, 153), c(81, 81, 81), - c(53, 89, 108), c(65, 109, 132), c(76, 127, 153), c(40, 67, 81), - c(89, 44, 125), c(109, 54, 153), c(127, 63, 178), c(67, 33, 94), - c(36, 53, 125), c(44, 65, 153), c(51, 76, 178), c(27, 40, 94), - c(72, 53, 36), c(88, 65, 44), c(102, 76, 51), c(54, 40, 27), - c(72, 89, 36), c(88, 109, 44), c(102, 127, 51), c(54, 67, 27), - c(108, 36, 36), c(132, 44, 44), c(153, 51, 51), c(81, 27, 27), - c(17, 17, 17), c(21, 21, 21), c(25, 25, 25), c(13, 13, 13), - c(176, 168, 54), c(215, 205, 66), c(250, 238, 77), c(132, 126, 40), - c(64, 154, 150), c(79, 188, 183), c(92, 219, 213), c(48, 115, 112), - c(52, 90, 180), c(63, 110, 220), c(74, 128, 255), c(39, 67, 135), - c(0, 153, 40), c(0, 187, 50), c(0, 217, 58), c(0, 114, 30), - c(91, 60, 34), c(111, 74, 42), c(129, 86, 49), c(68, 45, 25), - c(79, 1, 0), c(96, 1, 0), c(112, 2, 0), c(59, 1, 0), - c(147, 124, 113), c(180, 152, 138), c(209, 177, 161), c(110, 93, 85), - c(112, 57, 25), c(137, 70, 31), c(159, 82, 36), c(84, 43, 19), - c(105, 61, 76), c(128, 75, 93), c(149, 87, 108), c(78, 46, 57), - c(79, 76, 97), c(96, 93, 119), c(112, 108, 138), c(59, 57, 73), - c(131, 93, 25), c(160, 114, 31), c(186, 133, 36), c(98, 70, 19), - c(72, 82, 37), c(88, 100, 45), c(103, 117, 53), c(54, 61, 28), - c(112, 54, 55), c(138, 66, 67), c(160, 77, 78), c(84, 40, 41), - c(40, 28, 24), c(49, 35, 30), c(57, 41, 35), c(30, 21, 18), - c(95, 75, 69), c(116, 92, 84), c(135, 107, 98), c(71, 56, 51), - c(61, 64, 64), c(75, 79, 79), c(87, 92, 92), c(46, 48, 48), - c(86, 51, 62), c(105, 62, 75), c(122, 73, 88), c(64, 38, 46), - c(53, 43, 64), c(65, 53, 79), c(76, 62, 92), c(40, 32, 48), - c(53, 35, 24), c(65, 43, 30), c(76, 50, 35), c(40, 26, 18), - c(53, 57, 29), c(65, 70, 36), c(76, 82, 42), c(40, 43, 22), - c(100, 42, 32), c(122, 51, 39), c(142, 60, 46), c(75, 31, 24), - c(26, 15, 11), c(31, 18, 13), c(37, 22, 16), c(19, 11, 8), - c(133, 33, 34), c(163, 41, 42), c(189, 48, 49), c(100, 25, 25), - c(104, 44, 68), c(127, 54, 83), c(148, 63, 97), c(78, 33, 51), - c(64, 17, 20), c(79, 21, 25), c(92, 25, 29), c(48, 13, 15), - c(15, 88, 94), c(18, 108, 115), c(22, 126, 134), c(11, 66, 70), - c(40, 100, 98), c(50, 122, 120), c(58, 142, 140), c(30, 75, 74), - c(60, 31, 43), c(74, 37, 53), c(86, 44, 62), c(45, 23, 32), - c(14, 127, 93), c(17, 155, 114), c(20, 180, 133), c(10, 95, 70), - c(70, 70, 70), c(86, 86, 86), c(100, 100, 100), c(52, 52, 52), - c(152, 123, 103), c(186, 150, 126), c(216, 175, 147), c(114, 92, 77), - c(89, 117, 105), c(109, 144, 129), c(127, 167, 150), c(67, 88, 79) + // Start generate - MapPalette#colors + // @GeneratedFrom 1.21.5 + new Color(0x00000000, true), + new Color(0x00000000, true), + new Color(0x00000000, true), + new Color(0x00000000, true), + new Color(0x597D27), + new Color(0x6D9930), + new Color(0x7FB238), + new Color(0x435E1D), + new Color(0xAEA473), + new Color(0xD5C98C), + new Color(0xF7E9A3), + new Color(0x827B56), + new Color(0x8C8C8C), + new Color(0xABABAB), + new Color(0xC7C7C7), + new Color(0x696969), + new Color(0xB40000), + new Color(0xDC0000), + new Color(0xFF0000), + new Color(0x870000), + new Color(0x7070B4), + new Color(0x8A8ADC), + new Color(0xA0A0FF), + new Color(0x545487), + new Color(0x757575), + new Color(0x909090), + new Color(0xA7A7A7), + new Color(0x585858), + new Color(0x005700), + new Color(0x006A00), + new Color(0x007C00), + new Color(0x004100), + new Color(0xB4B4B4), + new Color(0xDCDCDC), + new Color(0xFFFFFF), + new Color(0x878787), + new Color(0x737681), + new Color(0x8D909E), + new Color(0xA4A8B8), + new Color(0x565861), + new Color(0x6A4C36), + new Color(0x825E42), + new Color(0x976D4D), + new Color(0x4F3928), + new Color(0x4F4F4F), + new Color(0x606060), + new Color(0x707070), + new Color(0x3B3B3B), + new Color(0x2D2DB4), + new Color(0x3737DC), + new Color(0x4040FF), + new Color(0x212187), + new Color(0x645432), + new Color(0x7B663E), + new Color(0x8F7748), + new Color(0x4B3F26), + new Color(0xB4B1AC), + new Color(0xDCD9D3), + new Color(0xFFFCF5), + new Color(0x878581), + new Color(0x985924), + new Color(0xBA6D2C), + new Color(0xD87F33), + new Color(0x72431B), + new Color(0x7D3598), + new Color(0x9941BA), + new Color(0xB24CD8), + new Color(0x5E2872), + new Color(0x486C98), + new Color(0x5884BA), + new Color(0x6699D8), + new Color(0x365172), + new Color(0xA1A124), + new Color(0xC5C52C), + new Color(0xE5E533), + new Color(0x79791B), + new Color(0x599011), + new Color(0x6DB015), + new Color(0x7FCC19), + new Color(0x436C0D), + new Color(0xAA5974), + new Color(0xD06D8E), + new Color(0xF27FA5), + new Color(0x804357), + new Color(0x353535), + new Color(0x414141), + new Color(0x4C4C4C), + new Color(0x282828), + new Color(0x6C6C6C), + new Color(0x848484), + new Color(0x999999), + new Color(0x515151), + new Color(0x35596C), + new Color(0x416D84), + new Color(0x4C7F99), + new Color(0x284351), + new Color(0x592C7D), + new Color(0x6D3699), + new Color(0x7F3FB2), + new Color(0x43215E), + new Color(0x24357D), + new Color(0x2C4199), + new Color(0x334CB2), + new Color(0x1B285E), + new Color(0x483524), + new Color(0x58412C), + new Color(0x664C33), + new Color(0x36281B), + new Color(0x485924), + new Color(0x586D2C), + new Color(0x667F33), + new Color(0x36431B), + new Color(0x6C2424), + new Color(0x842C2C), + new Color(0x993333), + new Color(0x511B1B), + new Color(0x111111), + new Color(0x151515), + new Color(0x191919), + new Color(0x0D0D0D), + new Color(0xB0A836), + new Color(0xD7CD42), + new Color(0xFAEE4D), + new Color(0x847E28), + new Color(0x409A96), + new Color(0x4FBCB7), + new Color(0x5CDBD5), + new Color(0x307370), + new Color(0x345AB4), + new Color(0x3F6EDC), + new Color(0x4A80FF), + new Color(0x274387), + new Color(0x009928), + new Color(0x00BB32), + new Color(0x00D93A), + new Color(0x00721E), + new Color(0x5B3C22), + new Color(0x6F4A2A), + new Color(0x815631), + new Color(0x442D19), + new Color(0x4F0100), + new Color(0x600100), + new Color(0x700200), + new Color(0x3B0100), + new Color(0x937C71), + new Color(0xB4988A), + new Color(0xD1B1A1), + new Color(0x6E5D55), + new Color(0x703919), + new Color(0x89461F), + new Color(0x9F5224), + new Color(0x542B13), + new Color(0x693D4C), + new Color(0x804B5D), + new Color(0x95576C), + new Color(0x4E2E39), + new Color(0x4F4C61), + new Color(0x605D77), + new Color(0x706C8A), + new Color(0x3B3949), + new Color(0x835D19), + new Color(0xA0721F), + new Color(0xBA8524), + new Color(0x624613), + new Color(0x485225), + new Color(0x58642D), + new Color(0x677535), + new Color(0x363D1C), + new Color(0x703637), + new Color(0x8A4243), + new Color(0xA04D4E), + new Color(0x542829), + new Color(0x281C18), + new Color(0x31231E), + new Color(0x392923), + new Color(0x1E1512), + new Color(0x5F4B45), + new Color(0x745C54), + new Color(0x876B62), + new Color(0x473833), + new Color(0x3D4040), + new Color(0x4B4F4F), + new Color(0x575C5C), + new Color(0x2E3030), + new Color(0x56333E), + new Color(0x693E4B), + new Color(0x7A4958), + new Color(0x40262E), + new Color(0x352B40), + new Color(0x41354F), + new Color(0x4C3E5C), + new Color(0x282030), + new Color(0x352318), + new Color(0x412B1E), + new Color(0x4C3223), + new Color(0x281A12), + new Color(0x35391D), + new Color(0x414624), + new Color(0x4C522A), + new Color(0x282B16), + new Color(0x642A20), + new Color(0x7A3327), + new Color(0x8E3C2E), + new Color(0x4B1F18), + new Color(0x1A0F0B), + new Color(0x1F120D), + new Color(0x251610), + new Color(0x130B08), + new Color(0x852122), + new Color(0xA3292A), + new Color(0xBD3031), + new Color(0x641919), + new Color(0x682C44), + new Color(0x7F3653), + new Color(0x943F61), + new Color(0x4E2133), + new Color(0x401114), + new Color(0x4F1519), + new Color(0x5C191D), + new Color(0x300D0F), + new Color(0x0F585E), + new Color(0x126C73), + new Color(0x167E86), + new Color(0x0B4246), + new Color(0x286462), + new Color(0x327A78), + new Color(0x3A8E8C), + new Color(0x1E4B4A), + new Color(0x3C1F2B), + new Color(0x4A2535), + new Color(0x562C3E), + new Color(0x2D1720), + new Color(0x0E7F5D), + new Color(0x119B72), + new Color(0x14B485), + new Color(0x0A5F46), + new Color(0x464646), + new Color(0x565656), + new Color(0x646464), + new Color(0x343434), + new Color(0x987B67), + new Color(0xBA967E), + new Color(0xD8AF93), + new Color(0x725C4D), + new Color(0x597569), + new Color(0x6D9081), + new Color(0x7FA796), + new Color(0x43584F), + // End generate - MapPalette#colors }; // Interface @@ -264,7 +443,7 @@ public final class MapPalette { } } - // Minecraft has 143 colors, some of which have negative byte representations + // Minecraft has 248 colors, some of which have negative byte representations return (byte) (index < 128 ? index : -129 + (index - 127)); } @@ -278,7 +457,7 @@ public final class MapPalette { @Deprecated(since = "1.6.2", forRemoval = true) // Paper @NotNull public static Color getColor(byte index) { - // Minecraft has 143 colors, some of which have negative byte representations + // Minecraft has 248 colors, some of which have negative byte representations return colors[index >= 0 ? index : index + 256]; } diff --git a/paper-api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java b/paper-api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java index 71f33c126..a1baffce5 100644 --- a/paper-api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java +++ b/paper-api/src/main/java/org/bukkit/persistence/PersistentDataHolder.java @@ -12,7 +12,7 @@ public interface PersistentDataHolder extends io.papermc.paper.persistence.Persi /** * Returns a custom tag container capable of storing tags on the object. - * + *

    * Note that the tags stored on this container are all stored under their * own custom namespace therefore modifying default tags using this * {@link PersistentDataHolder} is impossible. diff --git a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java index 3b3d9642a..2e1d20429 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java +++ b/paper-api/src/main/java/org/bukkit/plugin/RegisteredListener.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull; * Stores relevant information for plugin listeners */ public class RegisteredListener { + private final Listener listener; private final EventPriority priority; private final Plugin plugin; @@ -79,7 +80,6 @@ public class RegisteredListener { return ignoreCancelled; } - // Paper start /** * Get the executor for this registration. * @@ -100,5 +100,4 @@ public class RegisteredListener { + "\", ignoringCancelled=" + this.ignoreCancelled + "}"; } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java index fa65a03ec..e46a3720e 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPlugin.java @@ -1,6 +1,5 @@ package org.bukkit.plugin.java; -import com.google.common.base.Charsets; import com.google.common.base.Preconditions; import io.papermc.paper.command.brigadier.BasicCommand; import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents; @@ -13,6 +12,7 @@ import java.io.OutputStream; import java.io.Reader; import java.net.URL; import java.net.URLConnection; +import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -165,7 +165,7 @@ public abstract class JavaPlugin extends PluginBase { protected final @Nullable Reader getTextResource(String file) { final InputStream in = getResource(file); - return in == null ? null : new InputStreamReader(in, Charsets.UTF_8); + return in == null ? null : new InputStreamReader(in, StandardCharsets.UTF_8); } @Override @@ -177,7 +177,7 @@ public abstract class JavaPlugin extends PluginBase { return; } - newConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charsets.UTF_8))); + newConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, StandardCharsets.UTF_8))); } @Override diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index b412aaf08..163e9a0e1 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -39,11 +39,9 @@ import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.RegisteredListener; import org.bukkit.plugin.SimplePluginManager; -import org.bukkit.plugin.TimedRegisteredListener; import org.bukkit.plugin.UnknownDependencyException; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.spigotmc.CustomTimingsHandler; // Spigot import org.yaml.snakeyaml.error.YAMLException; /** @@ -232,13 +230,12 @@ public final class JavaPluginLoader implements PluginLoader { Preconditions.checkArgument(plugin != null, "Plugin can not be null"); Preconditions.checkArgument(listener != null, "Listener can not be null"); - boolean useTimings = server.getPluginManager().useTimings(); - Map, Set> ret = new HashMap, Set>(); + Map, Set> ret = new HashMap<>(); Set methods; try { Method[] publicMethods = listener.getClass().getMethods(); Method[] privateMethods = listener.getClass().getDeclaredMethods(); - methods = new HashSet(publicMethods.length + privateMethods.length, 1.0f); + methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f); for (Method method : publicMethods) { methods.add(method); } @@ -267,7 +264,7 @@ public final class JavaPluginLoader implements PluginLoader { method.setAccessible(true); Set eventSet = ret.get(eventClass); if (eventSet == null) { - eventSet = new HashSet(); + eventSet = new HashSet<>(); ret.put(eventClass, eventSet); } @@ -308,11 +305,7 @@ public final class JavaPluginLoader implements PluginLoader { } } }, plugin, method, eventClass); // Paper - if (false) { // Spigot - RL handles useTimings check now - eventSet.add(new TimedRegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); - } else { - eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); - } + eventSet.add(new RegisteredListener(listener, executor, eh.priority(), plugin, eh.ignoreCancelled())); } return ret; } @@ -376,8 +369,7 @@ public final class JavaPluginLoader implements PluginLoader { try { loader.close(); - } catch (IOException ex) { - // + } catch (IOException ignored) { } } } diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/LibraryLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/LibraryLoader.java index c66252802..3200a3c9a 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/LibraryLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/LibraryLoader.java @@ -1,4 +1,3 @@ -// CHECKSTYLE:OFF package org.bukkit.plugin.java; import java.io.File; @@ -38,9 +37,8 @@ import org.jetbrains.annotations.Nullable; // Paper start @org.jetbrains.annotations.ApiStatus.Internal -public class LibraryLoader +public class LibraryLoader { // Paper end -{ private final Logger logger; private final RepositorySystem repository; @@ -49,83 +47,83 @@ public class LibraryLoader public static java.util.function.BiFunction LIBRARY_LOADER_FACTORY; // Paper - rewrite reflection in libraries public static java.util.function.Function, List> REMAPPER; // Paper - remap libraries - public LibraryLoader(@NotNull Logger logger) - { + public LibraryLoader(@NotNull Logger logger) { this.logger = logger; DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); - locator.addService( RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class ); - locator.addService( TransporterFactory.class, HttpTransporterFactory.class ); + locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); + locator.addService(TransporterFactory.class, HttpTransporterFactory.class); - this.repository = locator.getService( RepositorySystem.class ); + this.repository = locator.getService(RepositorySystem.class); this.session = MavenRepositorySystemUtils.newSession(); session.setSystemProperties(System.getProperties()); // Paper - paper plugins, backport system properties fix for transitive dependency parsing, see #10116 - session.setChecksumPolicy( RepositoryPolicy.CHECKSUM_POLICY_FAIL ); - session.setLocalRepositoryManager( repository.newLocalRepositoryManager( session, new LocalRepository( "libraries" ) ) ); - session.setTransferListener( new AbstractTransferListener() - { + session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL); + session.setLocalRepositoryManager(repository.newLocalRepositoryManager(session, new LocalRepository("libraries"))); + session.setTransferListener(new AbstractTransferListener() { @Override - public void transferStarted(@NotNull TransferEvent event) throws TransferCancelledException - { - logger.log( Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName() ); + public void transferStarted(@NotNull TransferEvent event) { + logger.log(Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName()); } - } ); + }); // SPIGOT-7638: Add system properties, // since JdkVersionProfileActivator needs 'java.version' when a profile has the 'jdk' element // otherwise it will silently fail and not resolves the dependencies in the affected pom. - session.setSystemProperties( System.getProperties() ); + session.setSystemProperties(System.getProperties()); session.setReadOnly(); - this.repositories = repository.newResolutionRepositories( session, Arrays.asList( new RemoteRepository.Builder( "central", "default", "https://repo.maven.apache.org/maven2" ).build() ) ); + this.repositories = repository.newResolutionRepositories(session, Arrays.asList(new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build())); } @Nullable - public ClassLoader createLoader(@NotNull PluginDescriptionFile desc) - { + public ClassLoader createLoader(@NotNull PluginDescriptionFile desc) { // Paper start - plugin loader api return this.createLoader(desc, null); } + @Nullable public ClassLoader createLoader(@NotNull PluginDescriptionFile desc, java.util.@Nullable List paperLibraryPaths) { - if ( desc.getLibraries().isEmpty() && paperLibraryPaths == null ) - // Paper end - plugin loader api - { + if (desc.getLibraries().isEmpty() && paperLibraryPaths == null) { + // Paper end - plugin loader api return null; } - logger.log( Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[] - { - java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix - } ); + logger.log(Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[] + { + java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), desc.getLibraries().size() // Paper - use configured log prefix + }); List dependencies = new ArrayList<>(); - for ( String library : desc.getLibraries() ) - { - Artifact artifact = new DefaultArtifact( library ); - Dependency dependency = new Dependency( artifact, null ); + for (String library : desc.getLibraries()) { + Artifact artifact = new DefaultArtifact(library); + Dependency dependency = new Dependency(artifact, null); - dependencies.add( dependency ); + dependencies.add(dependency); } DependencyResult result; - if (!dependencies.isEmpty()) try // Paper - plugin loader api - { - result = repository.resolveDependencies( session, new DependencyRequest( new CollectRequest( (Dependency) null, dependencies, repositories ), null ) ); - } catch ( DependencyResolutionException ex ) - { - throw new RuntimeException( "Error resolving libraries", ex ); - } else result = null; // Paper - plugin loader api + if (!dependencies.isEmpty()) { + // Paper - plugin loader api + try + { + result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency) null, dependencies, repositories), null)); + } catch (DependencyResolutionException ex) { + throw new RuntimeException("Error resolving libraries", ex); + } + } else { + result = null; // Paper - plugin loader api + } List jarFiles = new ArrayList<>(); List jarPaths = new ArrayList<>(); // Paper - remap libraries // Paper start - plugin loader api if (paperLibraryPaths != null) jarPaths.addAll(paperLibraryPaths); - if (result != null) for ( ArtifactResult artifact : result.getArtifactResults() ) - // Paper end - plugin loader api - { - // Paper start - remap libraries - jarPaths.add(artifact.getArtifact().getFile().toPath()); + if (result != null) { + for (ArtifactResult artifact : result.getArtifactResults()) { + // Paper end - plugin loader api + // Paper start - remap libraries + jarPaths.add(artifact.getArtifact().getFile().toPath()); + } } if (REMAPPER != null) { jarPaths = REMAPPER.apply(jarPaths); @@ -135,27 +133,25 @@ public class LibraryLoader // Paper end - remap libraries URL url; - try - { + try { url = file.toURI().toURL(); - } catch ( MalformedURLException ex ) - { - throw new AssertionError( ex ); + } catch (MalformedURLException ex) { + throw new AssertionError(ex); } - jarFiles.add( url ); - logger.log( Level.INFO, "[{0}] Loaded library {1}", new Object[] - { - java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix - } ); + jarFiles.add(url); + logger.log(Level.INFO, "[{0}] Loaded library {1}", new Object[] + { + java.util.Objects.requireNonNullElseGet(desc.getPrefix(), desc::getName), file // Paper - use configured log prefix + }); } // Paper start - rewrite reflection in libraries URLClassLoader loader; if (LIBRARY_LOADER_FACTORY == null) { - loader = new URLClassLoader( jarFiles.toArray( new URL[ jarFiles.size() ] ), getClass().getClassLoader() ); + loader = new URLClassLoader(jarFiles.toArray(new URL[jarFiles.size()]), getClass().getClassLoader()); } else { - loader = LIBRARY_LOADER_FACTORY.apply(jarFiles.toArray( new URL[ jarFiles.size() ] ), getClass().getClassLoader()); + loader = LIBRARY_LOADER_FACTORY.apply(jarFiles.toArray(new URL[jarFiles.size()]), getClass().getClassLoader()); } // Paper end - rewrite reflection in libraries diff --git a/paper-api/src/main/java/org/bukkit/potion/PotionType.java b/paper-api/src/main/java/org/bukkit/potion/PotionType.java index f7b485952..c4ff2003d 100644 --- a/paper-api/src/main/java/org/bukkit/potion/PotionType.java +++ b/paper-api/src/main/java/org/bukkit/potion/PotionType.java @@ -15,53 +15,55 @@ import org.jetbrains.annotations.Nullable; * the Creative mode inventory */ public enum PotionType implements Keyed, io.papermc.paper.world.flag.FeatureDependant { // Paper - feature flag API - WATER("water"), - MUNDANE("mundane"), - THICK("thick"), + // Start generate - PotionType + // @GeneratedFrom 1.21.5 AWKWARD("awkward"), - NIGHT_VISION("night_vision"), - LONG_NIGHT_VISION("long_night_vision"), - INVISIBILITY("invisibility"), - LONG_INVISIBILITY("long_invisibility"), - LEAPING("leaping"), - LONG_LEAPING("long_leaping"), - STRONG_LEAPING("strong_leaping"), FIRE_RESISTANCE("fire_resistance"), - LONG_FIRE_RESISTANCE("long_fire_resistance"), - SWIFTNESS("swiftness"), - LONG_SWIFTNESS("long_swiftness"), - STRONG_SWIFTNESS("strong_swiftness"), - SLOWNESS("slowness"), - LONG_SLOWNESS("long_slowness"), - STRONG_SLOWNESS("strong_slowness"), - WATER_BREATHING("water_breathing"), - LONG_WATER_BREATHING("long_water_breathing"), - HEALING("healing"), - STRONG_HEALING("strong_healing"), HARMING("harming"), - STRONG_HARMING("strong_harming"), - POISON("poison"), + HEALING("healing"), + INFESTED("infested"), + INVISIBILITY("invisibility"), + LEAPING("leaping"), + LONG_FIRE_RESISTANCE("long_fire_resistance"), + LONG_INVISIBILITY("long_invisibility"), + LONG_LEAPING("long_leaping"), + LONG_NIGHT_VISION("long_night_vision"), LONG_POISON("long_poison"), - STRONG_POISON("strong_poison"), - REGENERATION("regeneration"), LONG_REGENERATION("long_regeneration"), - STRONG_REGENERATION("strong_regeneration"), - STRENGTH("strength"), + LONG_SLOW_FALLING("long_slow_falling"), + LONG_SLOWNESS("long_slowness"), LONG_STRENGTH("long_strength"), - STRONG_STRENGTH("strong_strength"), - WEAKNESS("weakness"), + LONG_SWIFTNESS("long_swiftness"), + LONG_TURTLE_MASTER("long_turtle_master"), + LONG_WATER_BREATHING("long_water_breathing"), LONG_WEAKNESS("long_weakness"), LUCK("luck"), - TURTLE_MASTER("turtle_master"), - LONG_TURTLE_MASTER("long_turtle_master"), - STRONG_TURTLE_MASTER("strong_turtle_master"), - SLOW_FALLING("slow_falling"), - LONG_SLOW_FALLING("long_slow_falling"), - WIND_CHARGED("wind_charged"), - WEAVING("weaving"), + MUNDANE("mundane"), + NIGHT_VISION("night_vision"), OOZING("oozing"), - INFESTED("infested"), - ; + POISON("poison"), + REGENERATION("regeneration"), + SLOW_FALLING("slow_falling"), + SLOWNESS("slowness"), + STRENGTH("strength"), + STRONG_HARMING("strong_harming"), + STRONG_HEALING("strong_healing"), + STRONG_LEAPING("strong_leaping"), + STRONG_POISON("strong_poison"), + STRONG_REGENERATION("strong_regeneration"), + STRONG_SLOWNESS("strong_slowness"), + STRONG_STRENGTH("strong_strength"), + STRONG_SWIFTNESS("strong_swiftness"), + STRONG_TURTLE_MASTER("strong_turtle_master"), + SWIFTNESS("swiftness"), + THICK("thick"), + TURTLE_MASTER("turtle_master"), + WATER("water"), + WATER_BREATHING("water_breathing"), + WEAKNESS("weakness"), + WEAVING("weaving"), + WIND_CHARGED("wind_charged"); + // End generate - PotionType private final NamespacedKey key; private final Supplier internalPotionDataSupplier; diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/DisplaySlot.java b/paper-api/src/main/java/org/bukkit/scoreboard/DisplaySlot.java index 21cd2ba65..96bba0962 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/DisplaySlot.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/DisplaySlot.java @@ -1,55 +1,54 @@ package org.bukkit.scoreboard; -import net.kyori.adventure.text.format.NamedTextColor; // Paper +import org.jspecify.annotations.NullMarked; + /** * Locations for displaying objectives to the player */ +@NullMarked public enum DisplaySlot { - // Paper start - BELOW_NAME("below_name"), + // Start generate - DisplaySlot + // @GeneratedFrom 1.21.5 PLAYER_LIST("list"), SIDEBAR("sidebar"), - SIDEBAR_TEAM_BLACK(NamedTextColor.BLACK), - SIDEBAR_TEAM_DARK_BLUE(NamedTextColor.DARK_BLUE), - SIDEBAR_TEAM_DARK_GREEN(NamedTextColor.DARK_GREEN), - SIDEBAR_TEAM_DARK_AQUA(NamedTextColor.DARK_AQUA), - SIDEBAR_TEAM_DARK_RED(NamedTextColor.DARK_RED), - SIDEBAR_TEAM_DARK_PURPLE(NamedTextColor.DARK_PURPLE), - SIDEBAR_TEAM_GOLD(NamedTextColor.GOLD), - SIDEBAR_TEAM_GRAY(NamedTextColor.GRAY), - SIDEBAR_TEAM_DARK_GRAY(NamedTextColor.DARK_GRAY), - SIDEBAR_TEAM_BLUE(NamedTextColor.BLUE), - SIDEBAR_TEAM_GREEN(NamedTextColor.GREEN), - SIDEBAR_TEAM_AQUA(NamedTextColor.AQUA), - SIDEBAR_TEAM_RED(NamedTextColor.RED), - SIDEBAR_TEAM_LIGHT_PURPLE(NamedTextColor.LIGHT_PURPLE), - SIDEBAR_TEAM_YELLOW(NamedTextColor.YELLOW), - SIDEBAR_TEAM_WHITE(NamedTextColor.WHITE); + BELOW_NAME("below_name"), + SIDEBAR_TEAM_BLACK("sidebar.team.black"), + SIDEBAR_TEAM_DARK_BLUE("sidebar.team.dark_blue"), + SIDEBAR_TEAM_DARK_GREEN("sidebar.team.dark_green"), + SIDEBAR_TEAM_DARK_AQUA("sidebar.team.dark_aqua"), + SIDEBAR_TEAM_DARK_RED("sidebar.team.dark_red"), + SIDEBAR_TEAM_DARK_PURPLE("sidebar.team.dark_purple"), + SIDEBAR_TEAM_GOLD("sidebar.team.gold"), + SIDEBAR_TEAM_GRAY("sidebar.team.gray"), + SIDEBAR_TEAM_DARK_GRAY("sidebar.team.dark_gray"), + SIDEBAR_TEAM_BLUE("sidebar.team.blue"), + SIDEBAR_TEAM_GREEN("sidebar.team.green"), + SIDEBAR_TEAM_AQUA("sidebar.team.aqua"), + SIDEBAR_TEAM_RED("sidebar.team.red"), + SIDEBAR_TEAM_LIGHT_PURPLE("sidebar.team.light_purple"), + SIDEBAR_TEAM_YELLOW("sidebar.team.yellow"), + SIDEBAR_TEAM_WHITE("sidebar.team.white"); + // End generate - DisplaySlot public static final net.kyori.adventure.util.Index NAMES = net.kyori.adventure.util.Index.create(DisplaySlot.class, DisplaySlot::getId); private final String id; - DisplaySlot(@org.jetbrains.annotations.NotNull String id) { + DisplaySlot(String id) { this.id = id; } - DisplaySlot(@org.jetbrains.annotations.NotNull NamedTextColor color) { - this.id = "sidebar.team." + color; - } - /** * Get the string id of this display slot. * * @return the string id */ - public @org.jetbrains.annotations.NotNull String getId() { - return id; + public String getId() { + return this.id; } @Override public String toString() { return this.id; } - // Paper end } diff --git a/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java b/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java index 81ca0c62c..f81fe1c49 100644 --- a/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java +++ b/paper-api/src/main/java/org/bukkit/scoreboard/Scoreboard.java @@ -24,9 +24,10 @@ public interface Scoreboard { */ @Deprecated(since = "1.13") @NotNull - Objective registerNewObjective(@NotNull String name, @NotNull String criteria); + default Objective registerNewObjective(@NotNull String name, @NotNull String criteria) { + return this.registerNewObjective(name, criteria, name); + } - // Paper start - Adventure /** * Registers an Objective on this Scoreboard * @@ -42,7 +43,10 @@ public interface Scoreboard { */ @NotNull @Deprecated - Objective registerNewObjective(@NotNull String name, @NotNull String criteria, net.kyori.adventure.text.@Nullable Component displayName); + default Objective registerNewObjective(@NotNull String name, @NotNull String criteria, net.kyori.adventure.text.@Nullable Component displayName) { + return this.registerNewObjective(name, criteria, displayName, RenderType.INTEGER); + } + /** * Registers an Objective on this Scoreboard * @@ -60,6 +64,7 @@ public interface Scoreboard { @NotNull @Deprecated Objective registerNewObjective(@NotNull String name, @NotNull String criteria, net.kyori.adventure.text.@Nullable Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException; + /** * Registers an Objective on this Scoreboard * @@ -73,7 +78,10 @@ public interface Scoreboard { * exists */ @NotNull - Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, net.kyori.adventure.text.@Nullable Component displayName) throws IllegalArgumentException; + default Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, net.kyori.adventure.text.@Nullable Component displayName) throws IllegalArgumentException { + return this.registerNewObjective(name, criteria, displayName, RenderType.INTEGER); + } + /** * Registers an Objective on this Scoreboard * @@ -89,7 +97,6 @@ public interface Scoreboard { */ @NotNull Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, net.kyori.adventure.text.@Nullable Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException; - // Paper end - Adventure /** * Registers an Objective on this Scoreboard @@ -106,7 +113,9 @@ public interface Scoreboard { */ @Deprecated(since = "1.20.5") @NotNull - Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName); + default Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName) { + return this.registerNewObjective(name, criteria, displayName, RenderType.INTEGER); + } /** * Registers an Objective on this Scoreboard @@ -141,7 +150,9 @@ public interface Scoreboard { */ @NotNull @Deprecated // Paper - Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName); + default Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName) { + return this.registerNewObjective(name, criteria, displayName, RenderType.INTEGER); + } /** * Registers an Objective on this Scoreboard @@ -159,7 +170,9 @@ public interface Scoreboard { */ @NotNull @Deprecated // Paper - Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType); + default Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType) { + return this.registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper - Adventure + } /** * Gets an Objective on this Scoreboard by name diff --git a/paper-api/src/main/java/org/bukkit/structure/Palette.java b/paper-api/src/main/java/org/bukkit/structure/Palette.java index 883189e54..bd1096665 100644 --- a/paper-api/src/main/java/org/bukkit/structure/Palette.java +++ b/paper-api/src/main/java/org/bukkit/structure/Palette.java @@ -6,7 +6,7 @@ import org.jetbrains.annotations.NotNull; /** * Represent a variation of a structure. - * + *

    * Most structures, like the ones generated with structure blocks, only have a * single variant. */ @@ -14,7 +14,7 @@ public interface Palette { /** * Gets a copy of the blocks this Palette is made of. - * + *

    * The {@link BlockState#getLocation() positions} of the returned block * states are offsets relative to the structure's position that is provided * once the structure is placed into the world. diff --git a/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java b/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java index 548122148..1296d98b6 100644 --- a/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java +++ b/paper-api/src/main/java/org/bukkit/tag/DamageTypeTags.java @@ -13,147 +13,81 @@ import org.jetbrains.annotations.Nullable; @ApiStatus.Experimental public final class DamageTypeTags { - /** - * Vanilla tag representing damage types which damage helmets. - */ - public static final Tag DAMAGES_HELMET = getTag("damages_helmet"); - /** - * Vanilla tag representing damage types which bypass armor. - */ - public static final Tag BYPASSES_ARMOR = getTag("bypasses_armor"); - /** - * Vanilla tag representing damage types which bypass shields. - */ - public static final Tag BYPASSES_SHIELD = getTag("bypasses_shield"); - /** - * Vanilla tag representing damage types which bypass invulnerability. - */ - public static final Tag BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability"); - /** - * Vanilla tag representing damage types which bypass cooldowns. - *
    - * Note: this can be null unless a datapack add values to this tag because vanilla not has any values for this. - */ - @Nullable - public static final Tag BYPASSES_COOLDOWN = getTag("bypasses_cooldown"); - /** - * Vanilla tag representing damage types which bypass effects. - */ - public static final Tag BYPASSES_EFFECTS = getTag("bypasses_effects"); - /** - * Vanilla tag representing damage types which bypass resistance. - */ - public static final Tag BYPASSES_RESISTANCE = getTag("bypasses_resistance"); - /** - * Vanilla tag representing damage types which bypass enchantments. - */ - public static final Tag BYPASSES_ENCHANTMENTS = getTag("bypasses_enchantments"); - /** - * Vanilla tag representing all fire damage types. - */ - public static final Tag IS_FIRE = getTag("is_fire"); - /** - * Vanilla tag representing damage types which originate from projectiles. - */ - public static final Tag IS_PROJECTILE = getTag("is_projectile"); - /** - * Vanilla tag representing damage types which witches are resistant to. - */ - public static final Tag WITCH_RESISTANT_TO = getTag("witch_resistant_to"); - /** - * Vanilla tag representing all explosion damage types. - */ - public static final Tag IS_EXPLOSION = getTag("is_explosion"); - /** - * Vanilla tag representing all fall damage types. - */ - public static final Tag IS_FALL = getTag("is_fall"); - /** - * Vanilla tag representing all drowning damage types. - */ - public static final Tag IS_DROWNING = getTag("is_drowning"); - /** - * Vanilla tag representing all freezing damage types. - */ - public static final Tag IS_FREEZING = getTag("is_freezing"); - /** - * Vanilla tag representing all lightning damage types. - */ - public static final Tag IS_LIGHTNING = getTag("is_lightning"); - /** - * Vanilla tag representing damage types which do not cause entities to - * anger. - */ - public static final Tag NO_ANGER = getTag("no_anger"); - /** - * Vanilla tag representing damage types which do not cause an impact. - */ - public static final Tag NO_IMPACT = getTag("no_impact"); - /** - * Vanilla tag representing damage types which cause maximum fall damage. - */ - public static final Tag ALWAYS_MOST_SIGNIFICANT_FALL = getTag("always_most_significant_fall"); - /** - * Vanilla tag representing damage types which withers are immune to. - */ - public static final Tag WITHER_IMMUNE_TO = getTag("wither_immune_to"); - /** - * Vanilla tag representing damage types which ignite armor stands. - */ - public static final Tag IGNITES_ARMOR_STANDS = getTag("ignites_armor_stands"); - /** - * Vanilla tag representing damage types which burn armor stands. - */ - public static final Tag BURNS_ARMOR_STANDS = getTag("burns_armor_stands"); - /** - * Vanilla tag representing damage types which avoid guardian thorn damage. - */ - public static final Tag AVOIDS_GUARDIAN_THORNS = getTag("avoids_guardian_thorns"); - /** - * Vanilla tag representing damage types which always trigger silverfish. - */ - public static final Tag ALWAYS_TRIGGERS_SILVERFISH = getTag("always_triggers_silverfish"); - /** - * Vanilla tag representing damage types which always hurt enderdragons. - */ + // Start generate - DamageTypeTags + // @GeneratedFrom 1.21.5 public static final Tag ALWAYS_HURTS_ENDER_DRAGONS = getTag("always_hurts_ender_dragons"); - /** - * Vanilla tag representing damage types which do not cause knockback. - */ - public static final Tag NO_KNOCKBACK = getTag("no_knockback"); - /** - * Vanilla tag representing damage types which always kill armor stands. - */ + public static final Tag ALWAYS_KILLS_ARMOR_STANDS = getTag("always_kills_armor_stands"); - /** - * Vanilla tag representing damage types which can break armor stands. - */ - public static final Tag CAN_BREAK_ARMOR_STAND = getTag("can_break_armor_stand"); - /** - * Vanilla tag representing damage types which bypass wolf armor. - */ - public static final Tag BYPASSES_WOLF_ARMOR = getTag("bypasses_wolf_armor"); - /** - * Vanilla tag representing damage types which are from player attacks. - */ - public static final Tag IS_PLAYER_ATTACK = getTag("is_player_attack"); - /** - * Vanilla tag representing damage types which originate from hot blocks. - */ + + public static final Tag ALWAYS_MOST_SIGNIFICANT_FALL = getTag("always_most_significant_fall"); + + public static final Tag ALWAYS_TRIGGERS_SILVERFISH = getTag("always_triggers_silverfish"); + + public static final Tag AVOIDS_GUARDIAN_THORNS = getTag("avoids_guardian_thorns"); + public static final Tag BURN_FROM_STEPPING = getTag("burn_from_stepping"); - /** - * Vanilla tag representing damage types which cause entities to panic. - */ + + public static final Tag BURNS_ARMOR_STANDS = getTag("burns_armor_stands"); + + public static final Tag BYPASSES_ARMOR = getTag("bypasses_armor"); + + public static final Tag BYPASSES_EFFECTS = getTag("bypasses_effects"); + + public static final Tag BYPASSES_ENCHANTMENTS = getTag("bypasses_enchantments"); + + public static final Tag BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability"); + + public static final Tag BYPASSES_RESISTANCE = getTag("bypasses_resistance"); + + public static final Tag BYPASSES_SHIELD = getTag("bypasses_shield"); + + public static final Tag BYPASSES_WOLF_ARMOR = getTag("bypasses_wolf_armor"); + + public static final Tag CAN_BREAK_ARMOR_STAND = getTag("can_break_armor_stand"); + + public static final Tag DAMAGES_HELMET = getTag("damages_helmet"); + + public static final Tag IGNITES_ARMOR_STANDS = getTag("ignites_armor_stands"); + + public static final Tag IS_DROWNING = getTag("is_drowning"); + + public static final Tag IS_EXPLOSION = getTag("is_explosion"); + + public static final Tag IS_FALL = getTag("is_fall"); + + public static final Tag IS_FIRE = getTag("is_fire"); + + public static final Tag IS_FREEZING = getTag("is_freezing"); + + public static final Tag IS_LIGHTNING = getTag("is_lightning"); + + public static final Tag IS_PLAYER_ATTACK = getTag("is_player_attack"); + + public static final Tag IS_PROJECTILE = getTag("is_projectile"); + + public static final Tag MACE_SMASH = getTag("mace_smash"); + + public static final Tag NO_ANGER = getTag("no_anger"); + + public static final Tag NO_IMPACT = getTag("no_impact"); + + public static final Tag NO_KNOCKBACK = getTag("no_knockback"); + public static final Tag PANIC_CAUSES = getTag("panic_causes"); - /** - * Vanilla tag representing environmental damage types which cause entities - * to panic. - */ + public static final Tag PANIC_ENVIRONMENTAL_CAUSES = getTag("panic_environmental_causes"); + + public static final Tag WITCH_RESISTANT_TO = getTag("witch_resistant_to"); + + public static final Tag WITHER_IMMUNE_TO = getTag("wither_immune_to"); + // End generate - DamageTypeTags /** * Vanilla tag representing damage types which originate from mace smashes. + * + * @deprecated use {@link #MACE_SMASH} */ - public static final Tag IS_MACE_SMASH = getTag("mace_smash"); + @Deprecated(since = "1.21.4", forRemoval = true) + public static final Tag IS_MACE_SMASH = MACE_SMASH; /** * Internal use only. */ diff --git a/paper-api/src/main/java/org/bukkit/util/CachedServerIcon.java b/paper-api/src/main/java/org/bukkit/util/CachedServerIcon.java index b74b21a1a..c39ae16ea 100644 --- a/paper-api/src/main/java/org/bukkit/util/CachedServerIcon.java +++ b/paper-api/src/main/java/org/bukkit/util/CachedServerIcon.java @@ -20,7 +20,7 @@ public interface CachedServerIcon { // Paper start default boolean isEmpty() { - return getData() == null; + return this.getData() == null; } // Paper end } diff --git a/paper-api/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java b/paper-api/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java index eeedfedc4..d1df19c0a 100644 --- a/paper-api/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java +++ b/paper-api/src/main/java/org/spigotmc/event/player/PlayerSpawnLocationEvent.java @@ -13,8 +13,8 @@ public class PlayerSpawnLocationEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private Location spawnLocation; - public PlayerSpawnLocationEvent(@NotNull final Player who, @NotNull Location spawnLocation) { - super(who); + public PlayerSpawnLocationEvent(@NotNull final Player player, @NotNull Location spawnLocation) { + super(player); this.spawnLocation = spawnLocation; } diff --git a/paper-api/src/test/java/org/bukkit/BukkitMirrorTest.java b/paper-api/src/test/java/org/bukkit/BukkitMirrorTest.java deleted file mode 100644 index 5974ceea5..000000000 --- a/paper-api/src/test/java/org/bukkit/BukkitMirrorTest.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.bukkit; - -import static org.bukkit.support.MatcherAssert.*; -import static org.hamcrest.Matchers.*; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.util.stream.Stream; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; - -@org.junit.jupiter.api.Disabled // Paper -public class BukkitMirrorTest { - - public static Stream data() { - return Stream.of(Server.class.getDeclaredMethods()) - .map(method -> { - try { - return Arguments.of( - method, - method.toGenericString().substring("public abstract ".length()).replace("(", "{").replace(")", "}"), - Bukkit.class.getDeclaredMethod(method.getName(), method.getParameterTypes()) - ); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - }); - } - - @ParameterizedTest - @MethodSource("data") - public void isStatic(Method server, String name, Method bukkit) throws Throwable { - assertThat(Modifier.isStatic(bukkit.getModifiers()), is(true)); - } - - @ParameterizedTest - @MethodSource("data") - public void isDeprecated(Method server, String name, Method bukkit) throws Throwable { - assertThat(bukkit.isAnnotationPresent(Deprecated.class), is(server.isAnnotationPresent(Deprecated.class))); - } - - @ParameterizedTest - @MethodSource("data") - public void returnType(Method server, String name, Method bukkit) throws Throwable { - assertThat(bukkit.getReturnType(), is((Object) server.getReturnType())); - // assertThat(bukkit.getGenericReturnType(), is(server.getGenericReturnType())); // too strict on type generics - } - - @ParameterizedTest - @MethodSource("data") - public void parameterTypes(Method server, String name, Method bukkit) throws Throwable { - // assertThat(bukkit.getGenericParameterTypes(), is(server.getGenericParameterTypes())); // too strict on type generics - } - - @ParameterizedTest - @MethodSource("data") - public void declaredException(Method server, String name, Method bukkit) throws Throwable { - assertThat(bukkit.getGenericExceptionTypes(), is(server.getGenericExceptionTypes())); - } -} diff --git a/paper-api/src/test/java/org/bukkit/NamespacedKeyTest.java b/paper-api/src/test/java/org/bukkit/NamespacedKeyTest.java index d4e9e24b7..7d81f9200 100644 --- a/paper-api/src/test/java/org/bukkit/NamespacedKeyTest.java +++ b/paper-api/src/test/java/org/bukkit/NamespacedKeyTest.java @@ -29,12 +29,6 @@ public class NamespacedKeyTest { assertNull(NamespacedKey.fromString("foo:bar:bazz")); } - @org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling - @Test - public void testFromStringEmptyInput() { - assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString("")); - } - @Test public void testFromStringNullInput() { assertThrows(IllegalArgumentException.class, () -> NamespacedKey.fromString(null)); @@ -75,12 +69,4 @@ public class NamespacedKeyTest { new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas", "loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString(); } - - @org.junit.jupiter.api.Disabled // Paper - Fixup NamespacedKey handling - @Test - public void testAboveLength() { - assertThrows(IllegalArgumentException.class, () -> new NamespacedKey("loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas", - "loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas/" - + "loremipsumdolorsitametconsecteturadipiscingelitduisvolutpatvelitsitametmaximusscelerisquemorbiullamcorperexacconsequategestas").toString()); - } } diff --git a/paper-api/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java b/paper-api/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java index c6b49c7e0..d9a9306e9 100644 --- a/paper-api/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java +++ b/paper-api/src/test/java/org/bukkit/configuration/ConfigurationSectionTest.java @@ -546,46 +546,6 @@ public abstract class ConfigurationSectionTest { assertFalse(section.isVector("doesntExist")); } - @Test - @org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server") - public void testGetItemStack_String() { - ConfigurationSection section = getConfigurationSection(); - String key = "exists"; - ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50); - - section.set(key, value); - - assertEquals(value, section.getItemStack(key)); - assertNull(section.getString("doesntExist")); - } - - @Test - @org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server") - public void testGetItemStack_String_ItemStack() { - ConfigurationSection section = getConfigurationSection(); - String key = "exists"; - ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50); - ItemStack def = new ItemStack(Material.STONE, 1); - - section.set(key, value); - - assertEquals(value, section.getItemStack(key, def)); - assertEquals(def, section.getItemStack("doesntExist", def)); - } - - @Test - @org.junit.jupiter.api.Disabled("ItemStack can't exist without the Server, test moved to server") - public void testIsItemStack() { - ConfigurationSection section = getConfigurationSection(); - String key = "exists"; - ItemStack value = new ItemStack(Material.ACACIA_WOOD, 50); - - section.set(key, value); - - assertTrue(section.isItemStack(key)); - assertFalse(section.isItemStack("doesntExist")); - } - @Test public void testGetConfigurationSection() { ConfigurationSection section = getConfigurationSection(); diff --git a/paper-api/src/test/java/org/bukkit/entity/memory/MemoryKeyTest.java b/paper-api/src/test/java/org/bukkit/entity/memory/MemoryKeyTest.java deleted file mode 100644 index 2e426a908..000000000 --- a/paper-api/src/test/java/org/bukkit/entity/memory/MemoryKeyTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.bukkit.entity.memory; - -import static org.junit.jupiter.api.Assertions.*; -import java.util.Arrays; -import java.util.List; -import org.bukkit.NamespacedKey; -import org.junit.jupiter.api.Test; - -public class MemoryKeyTest { - - @Test - public void shouldContainAllMemories() { - List memories = Arrays.asList(MemoryKey.HOME, MemoryKey.JOB_SITE, MemoryKey.MEETING_POINT); - assertTrue(MemoryKey.values().containsAll(memories)); - } - - @Test - public void shouldGetMemoryKeyHomeByNamespacedKey() { - assertEquals(MemoryKey.HOME, MemoryKey.getByKey(NamespacedKey.minecraft("home"))); - } - - @Test - public void shouldGetMemoryKeyJobSiteByNamespacedKey() { - assertEquals(MemoryKey.JOB_SITE, MemoryKey.getByKey(NamespacedKey.minecraft("job_site"))); - } - - @Test - public void shouldGetMemoryKeyMeetingPointByNamespacedKey() { - assertEquals(MemoryKey.MEETING_POINT, MemoryKey.getByKey(NamespacedKey.minecraft("meeting_point"))); - } - - @Test - public void shouldReturnNullWhenNamespacedKeyisNotPresentAsMemoryKey() { - assertNull(MemoryKey.getByKey(NamespacedKey.minecraft("not_present"))); - } - - @Test - public void shouldReturnNullWhenNamespacedKeyisNull() { - assertNull(MemoryKey.getByKey(null)); - } -} diff --git a/paper-generator/.editorconfig b/paper-generator/.editorconfig new file mode 100644 index 000000000..71c3cd0c3 --- /dev/null +++ b/paper-generator/.editorconfig @@ -0,0 +1,3 @@ +[*.java] +ij_java_generate_final_locals = false +ij_java_generate_final_parameters = false diff --git a/paper-generator/build.gradle.kts b/paper-generator/build.gradle.kts new file mode 100644 index 000000000..acd69cc8d --- /dev/null +++ b/paper-generator/build.gradle.kts @@ -0,0 +1,178 @@ +import io.papermc.paperweight.util.defaultJavaLauncher + +plugins { + java + id("io.papermc.paperweight.source-generator") +} + +paperweight { + atFile.set(layout.projectDirectory.file("wideners.at")) +} + +val serverRuntimeClasspath by configurations.registering { // resolvable? + isCanBeConsumed = false + isCanBeResolved = true +} + +dependencies { + minecraftJar(project(":paper-server", "mappedJarOutgoing")) + implementation(project(":paper-server", "macheMinecraftLibraries")) + + implementation("com.squareup:javapoet:1.13.0") + implementation(project(":paper-api")) + implementation("io.papermc.typewriter:typewriter:1.0.1") { + isTransitive = false // paper-api already have everything + } + implementation("info.picocli:picocli:4.7.6") + implementation("io.github.classgraph:classgraph:4.8.47") + implementation("org.jetbrains:annotations:26.0.1") + testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") + + serverRuntimeClasspath(project(":paper-server", "runtimeConfiguration")) +} + +val gameVersion = providers.gradleProperty("mcVersion") + +val rewriteApi = tasks.registerGenerationTask("rewriteApi", true, "api", { + bootstrapTags = true + sourceSet = rootProject.layout.projectDirectory.dir("paper-api") +}) { + description = "Rewrite existing API classes" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} + +val rewriteImpl = tasks.registerGenerationTask("rewriteImpl", true, "impl", { + sourceSet = rootProject.layout.projectDirectory.dir("paper-server") + serverClassPath.from(serverRuntimeClasspath) +}) { + description = "Rewrite existing implementation classes" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} + +tasks.register("rewrite") { + group = "generation" + description = "Rewrite existing API classes and its implementation" + dependsOn(rewriteApi, rewriteImpl) +} + + +val generateApi = tasks.registerGenerationTask("generateApi", false, "api", { + bootstrapTags = true + sourceSet = rootProject.layout.projectDirectory.dir("paper-api") +}) { + description = "Generate new API classes" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} + +val generateImpl = tasks.registerGenerationTask("generateImpl", false, "impl", { + sourceSet = rootProject.layout.projectDirectory.dir("paper-server") +}) { + description = "Generate new implementation classes" + classpath(sourceSets.main.map { it.runtimeClasspath }) +} + +tasks.register("generate") { + group = "generation" + description = "Generate new API classes and its implementation" + dependsOn(generateApi, generateImpl) +} + +if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) { + val scanOldGeneratedSourceCode by tasks.registering(JavaExec::class) { + group = "verification" + description = "Scan source code to detect outdated generated code" + javaLauncher = javaToolchains.defaultJavaLauncher(project) + mainClass.set("io.papermc.generator.rewriter.utils.ScanOldGeneratedSourceCode") + classpath(sourceSets.main.map { it.runtimeClasspath }) + + val projectDirs = listOf("paper-api", "paper-server").map { rootProject.layout.projectDirectory.dir(it) } + args(projectDirs.map { it.asFile.absolutePath }) + val workDirs = projectDirs.map { it.dir("src/main/java") } + + workDirs.forEach { inputs.dir(it) } + inputs.property("gameVersion", gameVersion) + outputs.dirs(workDirs) + } + tasks.check { + dependsOn(scanOldGeneratedSourceCode) + } +} + +fun TaskContainer.registerGenerationTask( + name: String, + rewrite: Boolean, + side: String, + args: (GenerationArgumentProvider.() -> Unit)? = null, + block: JavaExec.() -> Unit +): TaskProvider = register(name) { + group = "generation" + dependsOn(project.tasks.test) + javaLauncher = project.javaToolchains.defaultJavaLauncher(project) + inputs.property("gameVersion", gameVersion) + inputs.dir(layout.projectDirectory.dir("src/main/java")).withPathSensitivity(PathSensitivity.RELATIVE) + mainClass.set("io.papermc.generator.Main") + systemProperty("paper.updatingMinecraft", providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) + + val provider = objects.newInstance() + provider.side = side + provider.rewrite = rewrite + if (args != null) { + args(provider) + } + argumentProviders.add(provider) + + val targetDir = if (rewrite) "src/main/java" else "src/generated/java" + outputs.dir(provider.sourceSet.dir(targetDir)) + + block(this) +} + +@Suppress("LeakingThis") +abstract class GenerationArgumentProvider : CommandLineArgumentProvider { + + @get:PathSensitive(PathSensitivity.NONE) + @get:InputDirectory + abstract val sourceSet: DirectoryProperty + + @get:Input + abstract val rewrite: Property + + @get:Input + abstract val side: Property + + @get:CompileClasspath + abstract val serverClassPath: ConfigurableFileCollection + + @get:Input + @get:Optional + abstract val bootstrapTags: Property + + init { + bootstrapTags.convention(false) + } + + override fun asArguments(): Iterable { + val args = mutableListOf() + + args.add("--sourceset=${sourceSet.get().asFile.absolutePath}") + args.add("--side=${side.get()}") + args.add("--classpath=${serverClassPath.asPath}") + + if (rewrite.get()) { + args.add("--rewrite") + } + + if (bootstrapTags.get()) { + args.add(("--bootstrap-tags")) + } + return args.toList() + } +} + +tasks.test { + useJUnitPlatform() +} + +group = "io.papermc.paper" +version = "1.0-SNAPSHOT" diff --git a/paper-generator/src/main/java/io/papermc/generator/Generators.java b/paper-generator/src/main/java/io/papermc/generator/Generators.java new file mode 100644 index 000000000..ae7353b5b --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/Generators.java @@ -0,0 +1,23 @@ +package io.papermc.generator; + +import io.papermc.generator.registry.RegistryBootstrapper; +import io.papermc.generator.types.SourceGenerator; +import io.papermc.generator.types.craftblockdata.CraftBlockDataBootstrapper; +import io.papermc.generator.types.goal.MobGoalGenerator; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import net.minecraft.Util; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface Generators { + + List API = Collections.unmodifiableList(Util.make(new ArrayList<>(), list -> { + RegistryBootstrapper.bootstrap(list); + list.add(new MobGoalGenerator("VanillaGoal", "com.destroystokyo.paper.entity.ai")); + // todo extract fields for registry based api + })); + + List SERVER = Collections.unmodifiableList(Util.make(new ArrayList<>(), CraftBlockDataBootstrapper::bootstrap)); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/Main.java b/paper-generator/src/main/java/io/papermc/generator/Main.java new file mode 100644 index 000000000..3ce055469 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/Main.java @@ -0,0 +1,145 @@ +package io.papermc.generator; + +import com.google.common.util.concurrent.MoreExecutors; +import com.mojang.logging.LogUtils; +import io.papermc.generator.rewriter.registration.PaperPatternSourceSetRewriter; +import io.papermc.generator.rewriter.registration.PatternSourceSetRewriter; +import io.papermc.generator.types.SourceGenerator; +import io.papermc.generator.utils.experimental.ExperimentalCollector; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; +import net.minecraft.SharedConstants; +import net.minecraft.commands.Commands; +import net.minecraft.core.HolderLookup; +import net.minecraft.core.LayeredRegistryAccess; +import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.resources.RegistryDataLoader; +import net.minecraft.server.Bootstrap; +import net.minecraft.server.RegistryLayer; +import net.minecraft.server.ReloadableServerResources; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.repository.Pack; +import net.minecraft.server.packs.repository.PackRepository; +import net.minecraft.server.packs.repository.ServerPacksSource; +import net.minecraft.server.packs.resources.MultiPackResourceManager; +import net.minecraft.tags.TagKey; +import net.minecraft.tags.TagLoader; +import net.minecraft.world.flag.FeatureFlags; +import org.apache.commons.io.file.PathUtils; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.slf4j.Logger; +import picocli.CommandLine; + +@CommandLine.Command( + name = "generator", + description = "Rewrite and generate API classes and its implementation for Paper" +) +public class Main implements Callable { + + @CommandLine.Option(names = {"--sourceset"}, required = true) + Path sourceSet; + + @CommandLine.Option(names = {"-cp", "--classpath"}, split = ":", required = true) + Set classpath; + + @CommandLine.Option(names = {"--rewrite"}) + boolean isRewrite; + + @CommandLine.Option(names = {"--side"}, required = true) + String side; + + @CommandLine.Option(names = {"--bootstrap-tags"}) + boolean tagBootstrap; + + private static final Logger LOGGER = LogUtils.getLogger(); + + public static RegistryAccess.@MonotonicNonNull Frozen REGISTRY_ACCESS; + public static @MonotonicNonNull Map, String> EXPERIMENTAL_TAGS; + + public static CompletableFuture bootStrap(boolean withTags) { + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + Bootstrap.validate(); + + PackRepository resourceRepository = ServerPacksSource.createVanillaTrustedRepository(); + resourceRepository.reload(); + MultiPackResourceManager resourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, resourceRepository.getAvailablePacks().stream().map(Pack::open).toList()); + LayeredRegistryAccess layers = RegistryLayer.createRegistryAccess(); + List> pendingTags = TagLoader.loadTagsForExistingRegistries(resourceManager, layers.getLayer(RegistryLayer.STATIC)); + List> worldGenLayer = TagLoader.buildUpdatedLookups(layers.getAccessForLoading(RegistryLayer.WORLDGEN), pendingTags); + RegistryAccess.Frozen frozenWorldgenRegistries = RegistryDataLoader.load(resourceManager, worldGenLayer, RegistryDataLoader.WORLDGEN_REGISTRIES); + layers = layers.replaceFrom(RegistryLayer.WORLDGEN, frozenWorldgenRegistries); + REGISTRY_ACCESS = layers.compositeAccess().freeze(); + if (withTags) { + return ReloadableServerResources.loadResources( + resourceManager, + layers, + pendingTags, + FeatureFlags.VANILLA_SET, + Commands.CommandSelection.DEDICATED, + 0, + MoreExecutors.directExecutor(), + MoreExecutors.directExecutor() + ).whenComplete((result, ex) -> { + if (ex != null) { + resourceManager.close(); + } + }).thenAccept(resources -> { + resources.updateStaticRegistryTags(); + EXPERIMENTAL_TAGS = ExperimentalCollector.collectTags(resourceManager); + }); + } else { + EXPERIMENTAL_TAGS = Map.of(); + return CompletableFuture.completedFuture(null); + } + } + + @Override + public Integer call() { + bootStrap(this.tagBootstrap).join(); + + try { + if (this.isRewrite) { + rewrite(this.sourceSet, this.classpath, this.side.equals("api") ? Rewriters.API : Rewriters.SERVER); + } else { + generate(this.sourceSet, this.side.equals("api") ? Generators.API : Generators.SERVER); + } + } catch (RuntimeException ex) { + throw ex; + } catch (Exception e) { + throw new RuntimeException(e); + } + return 0; + } + + private static void rewrite(Path sourceSet, Set classpath, Consumer rewriters) throws IOException { + PatternSourceSetRewriter sourceSetRewriter = new PaperPatternSourceSetRewriter(classpath); + rewriters.accept(sourceSetRewriter); + sourceSetRewriter.apply(sourceSet.resolve("src/main/java")); + } + + private static void generate(Path sourceSet, Collection generators) throws IOException { + Path output = sourceSet.resolve("src/generated/java"); + if (Files.exists(output)) { + PathUtils.deleteDirectory(output); + } + + for (SourceGenerator generator : generators) { + generator.writeToFile(output); + } + LOGGER.info("Files written to {}", output.toAbsolutePath()); + } + + public static void main(String[] args) { + System.exit(new CommandLine(new Main()).execute(args)); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/Rewriters.java b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java new file mode 100644 index 000000000..15b137264 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/Rewriters.java @@ -0,0 +1,219 @@ +package io.papermc.generator; + +import io.papermc.generator.registry.RegistryBootstrapper; +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.rewriter.registration.PatternSourceSetRewriter; +import io.papermc.generator.rewriter.types.Types; +import io.papermc.generator.rewriter.types.registry.EnumRegistryRewriter; +import io.papermc.generator.rewriter.types.registry.FeatureFlagRewriter; +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.generator.rewriter.types.registry.RegistryTagRewriter; +import io.papermc.generator.rewriter.types.registry.TagRewriter; +import io.papermc.generator.rewriter.types.simple.BlockTypeRewriter; +import io.papermc.generator.rewriter.types.simple.CraftBlockDataMapping; +import io.papermc.generator.rewriter.types.simple.CraftBlockEntityStateMapping; +import io.papermc.generator.rewriter.types.simple.CraftPotionUtilRewriter; +import io.papermc.generator.rewriter.types.simple.EntityTypeRewriter; +import io.papermc.generator.rewriter.types.simple.MapPaletteRewriter; +import io.papermc.generator.rewriter.types.simple.MaterialRewriter; +import io.papermc.generator.rewriter.types.simple.MemoryKeyRewriter; +import io.papermc.generator.rewriter.types.registry.PaperFeatureFlagMapping; +import io.papermc.generator.rewriter.types.simple.StatisticRewriter; +import io.papermc.generator.rewriter.types.simple.trial.VillagerProfessionRewriter; +import io.papermc.generator.types.goal.MobGoalNames; +import io.papermc.generator.utils.Formatting; +import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation; +import io.papermc.typewriter.preset.EnumCloneRewriter; +import io.papermc.typewriter.preset.model.EnumValue; +import java.util.Map; +import java.util.function.Consumer; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import javax.lang.model.SourceVersion; +import net.kyori.adventure.text.format.NamedTextColor; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.Mob; +import net.minecraft.world.item.Rarity; +import org.bukkit.Art; +import org.bukkit.FeatureFlag; +import org.bukkit.Fluid; +import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; +import org.bukkit.Material; +import org.bukkit.MusicInstrument; +import org.bukkit.Sound; +import org.bukkit.Statistic; +import org.bukkit.Tag; +import org.bukkit.block.Biome; +import org.bukkit.block.BlockType; +import org.bukkit.block.banner.PatternType; +import org.bukkit.damage.DamageType; +import org.bukkit.entity.Boat; +import org.bukkit.entity.Cat; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Fox; +import org.bukkit.entity.Frog; +import org.bukkit.entity.Panda; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Salmon; +import org.bukkit.entity.Sniffer; +import org.bukkit.entity.TropicalFish; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.memory.MemoryKey; +import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.ItemRarity; +import org.bukkit.inventory.ItemType; +import org.bukkit.inventory.meta.trim.TrimMaterial; +import org.bukkit.inventory.meta.trim.TrimPattern; +import org.bukkit.inventory.recipe.CookingBookCategory; +import org.bukkit.inventory.recipe.CraftingBookCategory; +import org.bukkit.map.MapCursor; +import org.bukkit.map.MapPalette; +import org.bukkit.potion.PotionType; +import org.bukkit.scoreboard.DisplaySlot; +import org.bukkit.tag.DamageTypeTags; +import org.jspecify.annotations.NullMarked; + +import static io.papermc.generator.rewriter.registration.PaperPatternSourceSetRewriter.composite; +import static io.papermc.generator.rewriter.registration.RewriterHolder.holder; +import static io.papermc.generator.utils.Formatting.quoted; + +@NullMarked +public final class Rewriters { + + public static void bootstrap(PatternSourceSetRewriter apiSourceSet, PatternSourceSetRewriter serverSourceSet) { + bootstrapApi(apiSourceSet); + bootstrapServer(serverSourceSet); + } + + public static final Consumer API = Rewriters::bootstrapApi; + public static final Consumer SERVER = Rewriters::bootstrapServer; + + private static void bootstrapApi(PatternSourceSetRewriter sourceSet) { + sourceSet + .register("PotionType", PotionType.class, new EnumRegistryRewriter<>(Registries.POTION)) + .register("EntityType", EntityType.class, new EntityTypeRewriter()) + .register("DisplaySlot", DisplaySlot.class, new EnumCloneRewriter<>(net.minecraft.world.scores.DisplaySlot.class) { + @Override + protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.scores.DisplaySlot slot) { + final String name; + if (slot == net.minecraft.world.scores.DisplaySlot.LIST) { + name = "PLAYER_LIST"; + } else { + name = Formatting.formatKeyAsField(slot.getSerializedName()); + } + + return EnumValue.builder(name).argument(quoted(slot.getSerializedName())); + } + }) + .register("SnifferState", Sniffer.State.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.sniffer.Sniffer.State.class)) + .register("PandaGene", Panda.Gene.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Panda.Gene.class) { + @Override + protected EnumValue.Builder rewriteEnumValue(net.minecraft.world.entity.animal.Panda.Gene gene) { + return super.rewriteEnumValue(gene).argument(String.valueOf(gene.isRecessive())); + } + }) + .register("CookingBookCategory", CookingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CookingBookCategory.class)) + .register("CraftingBookCategory", CraftingBookCategory.class, new EnumCloneRewriter<>(net.minecraft.world.item.crafting.CraftingBookCategory.class)) + .register("TropicalFishPattern", TropicalFish.Pattern.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.TropicalFish.Pattern.class)) + .register("BoatStatus", Boat.Status.class, new EnumCloneRewriter<>(net.minecraft.world.entity.vehicle.Boat.Status.class)) + .register("FoxType", Fox.Type.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Fox.Variant.class)) + .register("SalmonVariant", Salmon.Variant.class, new EnumCloneRewriter<>(net.minecraft.world.entity.animal.Salmon.Variant.class)) + .register("ItemUseAnimation", ItemUseAnimation.class, new EnumCloneRewriter<>(net.minecraft.world.item.ItemUseAnimation.class)) + .register("ItemRarity", ItemRarity.class, new EnumCloneRewriter<>(Rarity.class) { + @Override + protected EnumValue.Builder rewriteEnumValue(Rarity rarity) { + return super.rewriteEnumValue(rarity).argument( + "%s.%s".formatted(NamedTextColor.class.getSimpleName(), rarity.color().name()) + ); + } + }) + .register(Material.class, composite( + holder("Blocks", new MaterialRewriter.Blocks()), + //holder("Material#isTransparent", MaterialRewriter.IsTransparent()), + + holder("Items", new MaterialRewriter.Items()) + )) + .register(Statistic.class, composite( + holder("StatisticCustom", new StatisticRewriter.Custom()), + holder("StatisticType", new StatisticRewriter.Type()) + )) + .register(Villager.class, composite( + holder("VillagerType", Villager.Type.class, new RegistryFieldRewriter<>(Registries.VILLAGER_TYPE, "getType")), + holder("VillagerProfession", Villager.Profession.class, new VillagerProfessionRewriter()) + )) + .register("JukeboxSong", JukeboxSong.class, new RegistryFieldRewriter<>(Registries.JUKEBOX_SONG, "get") { + @Override + protected String rewriteFieldName(Holder.Reference reference) { + String keyedName = super.rewriteFieldName(reference); + if (!SourceVersion.isIdentifier(keyedName)) { + // fallback to field names for invalid identifier (happens for 5, 11, 13 etc.) + return RegistryEntries.byRegistryKey(Registries.JUKEBOX_SONG).getFieldNames().get(reference.key()); + } + return keyedName; + } + }) + .register("DamageTypeTags", DamageTypeTags.class, new RegistryTagRewriter<>(Registries.DAMAGE_TYPE, DamageType.class)) + .register("MapCursorType", MapCursor.Type.class, new RegistryFieldRewriter<>(Registries.MAP_DECORATION_TYPE, "getType")) + .register("Structure", Structure.class, new RegistryFieldRewriter<>(Registries.STRUCTURE, "getStructure")) + .register("StructureType", StructureType.class, new RegistryFieldRewriter<>(Registries.STRUCTURE_TYPE, "getStructureType")) + .register("TrimPattern", TrimPattern.class, new RegistryFieldRewriter<>(Registries.TRIM_PATTERN, "getTrimPattern")) + .register("TrimMaterial", TrimMaterial.class, new RegistryFieldRewriter<>(Registries.TRIM_MATERIAL, "getTrimMaterial")) + .register("DamageType", DamageType.class, new RegistryFieldRewriter<>(Registries.DAMAGE_TYPE, "getDamageType")) + .register("GameEvent", GameEvent.class, new RegistryFieldRewriter<>(Registries.GAME_EVENT, "getEvent")) + .register("MusicInstrument", MusicInstrument.class, new RegistryFieldRewriter<>(Registries.INSTRUMENT, "getInstrument")) + .register("WolfVariant", Wolf.Variant.class, new RegistryFieldRewriter<>(Registries.WOLF_VARIANT, "getVariant")) + .register("WolfSoundVariant", Wolf.SoundVariant.class, new RegistryFieldRewriter<>(Registries.WOLF_SOUND_VARIANT, "getSoundVariant")) + .register("CatType", Cat.Type.class, new RegistryFieldRewriter<>(Registries.CAT_VARIANT, "getType")) + .register("FrogVariant", Frog.Variant.class, new RegistryFieldRewriter<>(Registries.FROG_VARIANT, "getVariant")) + .register("PatternType", PatternType.class, new RegistryFieldRewriter<>(Registries.BANNER_PATTERN, "getType")) + .register("Biome", Biome.class, new RegistryFieldRewriter<>(Registries.BIOME, "getBiome")) + .register("Fluid", Fluid.class, new RegistryFieldRewriter<>(Registries.FLUID, "getFluid")) + // .register("Attribute", Attribute.class, new RegistryFieldRewriter<>(Registries.ATTRIBUTE, "getAttribute")) - disable for now (javadocs) + .register("Sound", Sound.class, new RegistryFieldRewriter<>(Registries.SOUND_EVENT, "getSound")) + .register("Art", Art.class, new RegistryFieldRewriter<>(Registries.PAINTING_VARIANT, "getArt")) + .register("ChickenVariant", Chicken.Variant.class, new RegistryFieldRewriter<>(Registries.CHICKEN_VARIANT, "getVariant")) + .register("CowVariant", Cow.Variant.class, new RegistryFieldRewriter<>(Registries.COW_VARIANT, "getVariant")) + .register("PigVariant", Pig.Variant.class, new RegistryFieldRewriter<>(Registries.PIG_VARIANT, "getVariant")) + .register("MemoryKey", MemoryKey.class, new MemoryKeyRewriter()) + // .register("DataComponentTypes", DataComponentTypes.class, new DataComponentTypesRewriter()) - disable for now + // .register("ItemType", ItemType.class, new ItemTypeRewriter()) - disable for now, lynx want the generic type + .register("BlockType", BlockType.class, new BlockTypeRewriter()) + .register("FeatureFlag", FeatureFlag.class, new FeatureFlagRewriter()) + .register("Tag", Tag.class, new TagRewriter()) + .register("MapPalette#colors", MapPalette.class, new MapPaletteRewriter()); + RegistryBootstrapper.bootstrapApi(sourceSet); + } + + private static void bootstrapServer(PatternSourceSetRewriter sourceSet) { + sourceSet + .register("CraftBlockData#MAP", Types.CRAFT_BLOCK_DATA, new CraftBlockDataMapping()) + .register("CraftBlockEntityStates", Types.CRAFT_BLOCK_STATES, new CraftBlockEntityStateMapping()) + .register(Types.CRAFT_STATISTIC, composite( + holder("CraftStatisticCustom", new StatisticRewriter.CraftCustom()), + holder("CraftStatisticType", new StatisticRewriter.CraftType()) + )) + .register(Types.CRAFT_POTION_UTIL, composite( + holder("CraftPotionUtil#upgradeable", new CraftPotionUtilRewriter("strong")), + holder("CraftPotionUtil#extendable", new CraftPotionUtilRewriter("long")) + )) + .register("PaperFeatureFlagProviderImpl#FLAGS", Types.PAPER_FEATURE_FLAG_PROVIDER_IMPL, new PaperFeatureFlagMapping()) + .register("MobGoalHelper#bukkitMap", Types.MOB_GOAL_HELPER, new SearchReplaceRewriter() { + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + for (Map.Entry, Class> entry : MobGoalNames.bukkitMap.entrySet()) { + builder.append(metadata.indent()).append("bukkitMap.put(%s.class, %s.class);".formatted( + entry.getKey().getCanonicalName(), this.importCollector.getShortName(entry.getValue()) + )); + builder.append('\n'); + } + } + }); + RegistryBootstrapper.bootstrapServer(sourceSet); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryBootstrapper.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryBootstrapper.java new file mode 100644 index 000000000..c84fcee51 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryBootstrapper.java @@ -0,0 +1,45 @@ +package io.papermc.generator.registry; + +import io.papermc.generator.rewriter.registration.PatternSourceSetRewriter; +import io.papermc.generator.rewriter.types.Types; +import io.papermc.generator.rewriter.types.registry.PaperRegistriesRewriter; +import io.papermc.generator.rewriter.types.registry.RegistryEventsRewriter; +import io.papermc.generator.types.SourceGenerator; +import io.papermc.generator.types.registry.GeneratedKeyType; +import io.papermc.generator.types.registry.GeneratedTagKeyType; +import io.papermc.paper.registry.event.RegistryEvents; +import java.util.List; +import net.minecraft.core.registries.Registries; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class RegistryBootstrapper { + + private static final String PAPER_REGISTRY_PACKAGE = "io.papermc.paper.registry"; + + public static void bootstrap(List generators) { + // typed/tag keys + RegistryEntries.forEach(entry -> { + generators.add(new GeneratedKeyType<>(PAPER_REGISTRY_PACKAGE + ".keys", entry)); + if (entry.registry().listTags().findAny().isPresent()) { + generators.add(new GeneratedTagKeyType(entry, PAPER_REGISTRY_PACKAGE + ".keys.tags")); + } + }); + + // todo remove once entity type is a registry + generators.add(new GeneratedTagKeyType(RegistryEntries.byRegistryKey(Registries.ENTITY_TYPE), PAPER_REGISTRY_PACKAGE + ".keys.tags")); + } + + public static void bootstrap(PatternSourceSetRewriter apiSourceSet, PatternSourceSetRewriter serverSourceSet) { + bootstrapApi(apiSourceSet); + bootstrapServer(serverSourceSet); + } + + public static void bootstrapApi(PatternSourceSetRewriter sourceSet) { + sourceSet.register("RegistryEvents", RegistryEvents.class, new RegistryEventsRewriter()); + } + + public static void bootstrapServer(PatternSourceSetRewriter sourceSet) { + sourceSet.register("RegistryDefinitions", Types.PAPER_REGISTRIES, new PaperRegistriesRewriter()); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java new file mode 100644 index 000000000..c12cdc0b1 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntries.java @@ -0,0 +1,215 @@ +package io.papermc.generator.registry; + +import io.papermc.generator.utils.ClassHelper; +import io.papermc.paper.datacomponent.DataComponentType; +import io.papermc.paper.datacomponent.DataComponentTypes; +import io.papermc.paper.registry.data.BannerPatternRegistryEntry; +import io.papermc.paper.registry.data.DamageTypeRegistryEntry; +import io.papermc.paper.registry.data.EnchantmentRegistryEntry; +import io.papermc.paper.registry.data.GameEventRegistryEntry; +import io.papermc.paper.registry.data.PaintingVariantRegistryEntry; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import net.minecraft.core.Registry; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.sounds.SoundEvents; +import net.minecraft.world.damagesource.DamageTypes; +import net.minecraft.world.effect.MobEffects; +import net.minecraft.world.entity.ai.attributes.Attributes; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.animal.CatVariants; +import net.minecraft.world.entity.animal.ChickenVariants; +import net.minecraft.world.entity.animal.CowVariants; +import net.minecraft.world.entity.animal.PigVariants; +import net.minecraft.world.entity.animal.frog.FrogVariants; +import net.minecraft.world.entity.animal.wolf.WolfSoundVariants; +import net.minecraft.world.entity.animal.wolf.WolfVariants; +import net.minecraft.world.entity.decoration.PaintingVariants; +import net.minecraft.world.entity.npc.VillagerProfession; +import net.minecraft.world.entity.npc.VillagerType; +import net.minecraft.world.item.Instruments; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.JukeboxSongs; +import net.minecraft.world.item.alchemy.Potions; +import net.minecraft.world.item.enchantment.Enchantments; +import net.minecraft.world.item.equipment.trim.TrimMaterials; +import net.minecraft.world.item.equipment.trim.TrimPatterns; +import net.minecraft.world.level.biome.Biomes; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.entity.BannerPatterns; +import net.minecraft.world.level.levelgen.structure.BuiltinStructures; +import net.minecraft.world.level.material.Fluids; +import net.minecraft.world.level.saveddata.maps.MapDecorationTypes; +import org.bukkit.Art; +import org.bukkit.Fluid; +import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; +import org.bukkit.Keyed; +import org.bukkit.MusicInstrument; +import org.bukkit.Particle; +import org.bukkit.Sound; +import org.bukkit.attribute.Attribute; +import org.bukkit.block.Biome; +import org.bukkit.block.BlockType; +import org.bukkit.block.banner.PatternType; +import org.bukkit.damage.DamageType; +import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Cat; +import org.bukkit.entity.Chicken; +import org.bukkit.entity.Cow; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Frog; +import org.bukkit.entity.Pig; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.memory.MemoryKey; +import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.ItemType; +import org.bukkit.inventory.MenuType; +import org.bukkit.inventory.meta.trim.TrimMaterial; +import org.bukkit.inventory.meta.trim.TrimPattern; +import org.bukkit.map.MapCursor; +import org.bukkit.potion.PotionEffectType; +import org.bukkit.potion.PotionType; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class RegistryEntries { + + // CraftBukkit entry where implementation start by "Craft" + private static RegistryEntry entry(ResourceKey> registryKey, Class holderElementsClass, Class apiClass) { + return entry(registryKey, holderElementsClass, apiClass, "Craft"); + } + + private static RegistryEntry entry(ResourceKey> registryKey, Class holderElementsClass, Class apiClass, String implPrefix) { + String name = io.papermc.typewriter.util.ClassHelper.retrieveFullNestedName(apiClass); + RegistryKeyField registryKeyField = (RegistryKeyField) REGISTRY_KEY_FIELDS.get(registryKey); + String[] classes = name.split("\\."); + if (classes.length == 0) { + return new RegistryEntry<>(registryKey, registryKeyField, holderElementsClass, apiClass, implPrefix.concat(apiClass.getSimpleName())); + } + + String implName = Arrays.stream(classes).map(implPrefix::concat).collect(Collectors.joining(".")); + return new RegistryEntry<>(registryKey, registryKeyField, holderElementsClass, apiClass, implName); + } + + @Deprecated + private static RegistryEntry inconsistentEntry(ResourceKey> registryKey, Class holderElementsClass, Class apiClass, String implClass) { + return new RegistryEntry<>(registryKey, (RegistryKeyField) REGISTRY_KEY_FIELDS.get(registryKey), holderElementsClass, apiClass, implClass); + } + + private static final Map>, RegistryKeyField> REGISTRY_KEY_FIELDS; + static { + Map>, RegistryKeyField> registryKeyFields = new IdentityHashMap<>(); + try { + for (Field field : Registries.class.getDeclaredFields()) { + if (!ResourceKey.class.isAssignableFrom(field.getType())) { + continue; + } + + if (ClassHelper.isStaticConstant(field, Modifier.PUBLIC)) { + Type elementType = ClassHelper.getNestedTypeParameter(field.getGenericType(), ResourceKey.class, Registry.class, null); + if (elementType != null) { + registryKeyFields.put(((ResourceKey>) field.get(null)), new RegistryKeyField<>(ClassHelper.eraseType(elementType), field.getName())); + } + } + } + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + REGISTRY_KEY_FIELDS = Collections.unmodifiableMap(registryKeyFields); + } + + public static final Set> REGISTRY_CLASS_NAME_BASED_ON_API = Set.of( + BlockType.class, + ItemType.class + ); + + public static final List> BUILT_IN = List.of( + entry(Registries.GAME_EVENT, net.minecraft.world.level.gameevent.GameEvent.class, GameEvent.class).apiRegistryBuilder(GameEventRegistryEntry.Builder.class, "PaperGameEventRegistryEntry.PaperBuilder"), + entry(Registries.STRUCTURE_TYPE, net.minecraft.world.level.levelgen.structure.StructureType.class, StructureType.class), + entry(Registries.MOB_EFFECT, MobEffects.class, PotionEffectType.class), + entry(Registries.BLOCK, Blocks.class, BlockType.class), + entry(Registries.ITEM, Items.class, ItemType.class), + entry(Registries.VILLAGER_PROFESSION, VillagerProfession.class, Villager.Profession.class), + entry(Registries.VILLAGER_TYPE, VillagerType.class, Villager.Type.class), + entry(Registries.MAP_DECORATION_TYPE, MapDecorationTypes.class, MapCursor.Type.class), + entry(Registries.MENU, net.minecraft.world.inventory.MenuType.class, MenuType.class), + entry(Registries.ATTRIBUTE, Attributes.class, Attribute.class), + entry(Registries.FLUID, Fluids.class, Fluid.class), + entry(Registries.SOUND_EVENT, SoundEvents.class, Sound.class).allowDirect().apiRegistryField("SOUNDS"), + entry(Registries.DATA_COMPONENT_TYPE, DataComponents.class, DataComponentType.class, "Paper").preload(DataComponentTypes.class).apiAccessName("of") + ); + + public static final List> DATA_DRIVEN = List.of( + entry(Registries.BIOME, Biomes.class, Biome.class).delayed(), + entry(Registries.STRUCTURE, BuiltinStructures.class, Structure.class).delayed(), + entry(Registries.TRIM_MATERIAL, TrimMaterials.class, TrimMaterial.class).allowDirect().delayed(), + entry(Registries.TRIM_PATTERN, TrimPatterns.class, TrimPattern.class).allowDirect().delayed(), + entry(Registries.DAMAGE_TYPE, DamageTypes.class, DamageType.class).apiRegistryBuilder(DamageTypeRegistryEntry.Builder.class, "PaperDamageTypeRegistryEntry.PaperBuilder").delayed(), + entry(Registries.WOLF_VARIANT, WolfVariants.class, Wolf.Variant.class).delayed(), + entry(Registries.WOLF_SOUND_VARIANT, WolfSoundVariants.class, Wolf.SoundVariant.class), + entry(Registries.ENCHANTMENT, Enchantments.class, Enchantment.class).apiRegistryBuilder(EnchantmentRegistryEntry.Builder.class, "PaperEnchantmentRegistryEntry.PaperBuilder").serializationUpdater("ENCHANTMENT_RENAME").delayed(), + entry(Registries.JUKEBOX_SONG, JukeboxSongs.class, JukeboxSong.class).delayed(), + entry(Registries.BANNER_PATTERN, BannerPatterns.class, PatternType.class).allowDirect().apiRegistryBuilder(BannerPatternRegistryEntry.Builder.class, "PaperBannerPatternRegistryEntry.PaperBuilder").delayed(), + entry(Registries.PAINTING_VARIANT, PaintingVariants.class, Art.class).allowDirect().apiRegistryBuilder(PaintingVariantRegistryEntry.Builder.class, "PaperPaintingVariantRegistryEntry.PaperBuilder").apiRegistryField("ART").delayed(), + entry(Registries.INSTRUMENT, Instruments.class, MusicInstrument.class).allowDirect().delayed(), + entry(Registries.CAT_VARIANT, CatVariants.class, Cat.Type.class).delayed(), + entry(Registries.FROG_VARIANT, FrogVariants.class, Frog.Variant.class).delayed(), + entry(Registries.CHICKEN_VARIANT, ChickenVariants.class, Chicken.Variant.class), + entry(Registries.COW_VARIANT, CowVariants.class, Cow.Variant.class), + entry(Registries.PIG_VARIANT, PigVariants.class, Pig.Variant.class) + ); + + public static final List> API_ONLY = List.of( + entry(Registries.ENTITY_TYPE, net.minecraft.world.entity.EntityType.class, EntityType.class), + entry(Registries.PARTICLE_TYPE, ParticleTypes.class, Particle.class), + entry(Registries.POTION, Potions.class, PotionType.class), + entry(Registries.MEMORY_MODULE_TYPE, MemoryModuleType.class, MemoryKey.class) + ); + + public static final Map>, RegistryEntry> BY_REGISTRY_KEY; + static { + Map>, RegistryEntry> byRegistryKey = new IdentityHashMap<>(BUILT_IN.size() + DATA_DRIVEN.size() + API_ONLY.size()); + forEach(entry -> { + byRegistryKey.put(entry.registryKey(), entry); + }, RegistryEntries.BUILT_IN, RegistryEntries.DATA_DRIVEN, RegistryEntries.API_ONLY); + BY_REGISTRY_KEY = Collections.unmodifiableMap(byRegistryKey); + } + + @SuppressWarnings("unchecked") + public static RegistryEntry byRegistryKey(ResourceKey> registryKey) { + return (RegistryEntry) Objects.requireNonNull(BY_REGISTRY_KEY.get(registryKey)); + } + + // real registries + public static void forEach(Consumer> callback) { + forEach(callback, RegistryEntries.BUILT_IN, RegistryEntries.DATA_DRIVEN); + } + + @SafeVarargs + public static void forEach(Consumer> callback, List>... datas) { + for (List> data : datas) { + for (RegistryEntry entry : data) { + callback.accept(entry); + } + } + } + + private RegistryEntries() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntry.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntry.java new file mode 100644 index 000000000..26cbd71ca --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryEntry.java @@ -0,0 +1,214 @@ +package io.papermc.generator.registry; + +import com.google.common.base.Preconditions; +import io.papermc.generator.Main; +import io.papermc.generator.utils.ClassHelper; +import java.lang.constant.ConstantDescs; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import javax.lang.model.SourceVersion; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import org.bukkit.Keyed; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public final class RegistryEntry { + + private final ResourceKey> registryKey; + private final RegistryKeyField registryKeyField; + private final Class elementClass; + private final Class holderElementsClass; + private boolean allowDirect; + + private final Class apiClass; // TODO remove Keyed + private Class preloadClass; + private final String implClass; + + private @Nullable Class apiRegistryBuilder; + private @Nullable String apiRegistryBuilderImpl; + + private @Nullable String fieldRename; + private boolean delayed; + private String apiAccessName = ConstantDescs.INIT_NAME; + private Optional apiRegistryField = Optional.empty(); + + private @Nullable Map, String> fieldNames; + + public RegistryEntry(ResourceKey> registryKey, RegistryKeyField registryKeyField, Class holderElementsClass, Class apiClass, String implClass) { + this.registryKey = registryKey; + this.registryKeyField = registryKeyField; + this.elementClass = registryKeyField.elementClass(); + this.holderElementsClass = holderElementsClass; + this.apiClass = apiClass; + this.preloadClass = apiClass; + this.implClass = implClass; + } + + public ResourceKey> registryKey() { + return this.registryKey; + } + + public Registry registry() { + return Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey); + } + + public String registryKeyField() { + return this.registryKeyField.name(); + } + + public Class apiClass() { + return this.apiClass; + } + + public String implClass() { + return this.implClass; + } + + public RegistryEntry allowDirect() { + this.allowDirect = true; + return this; + } + + public RegistryEntry delayed() { + this.delayed = true; + return this; + } + + public RegistryEntry preload(Class klass) { + this.preloadClass = klass; + return this; + } + + public RegistryEntry apiAccessName(String name) { + Preconditions.checkArgument(SourceVersion.isIdentifier(name) && !SourceVersion.isKeyword(name), "Invalid accessor name"); + this.apiAccessName = name; + return this; + } + + public RegistryEntry serializationUpdater(String fieldName) { + this.fieldRename = fieldName; + return this; + } + + public boolean canAllowDirect() { + return this.allowDirect; + } + + public boolean isDelayed() { + return this.delayed; + } + + public String apiAccessName() { + return this.apiAccessName; + } + + public Class preloadClass() { + return this.preloadClass; + } + + public @Nullable String fieldRename() { + return this.fieldRename; + } + + public @Nullable Class apiRegistryBuilder() { + return this.apiRegistryBuilder; + } + + public @Nullable String apiRegistryBuilderImpl() { + return this.apiRegistryBuilderImpl; + } + + public RegistryEntry apiRegistryBuilder(Class builderClass, String builderImplClass) { + this.apiRegistryBuilder = builderClass; + this.apiRegistryBuilderImpl = builderImplClass; + return this; + } + + public Optional apiRegistryField() { + return this.apiRegistryField; + } + + public RegistryEntry apiRegistryField(String registryField) { + this.apiRegistryField = Optional.of(registryField); + return this; + } + + public String keyClassName() { + if (RegistryEntries.REGISTRY_CLASS_NAME_BASED_ON_API.contains(this.apiClass)) { + return this.apiClass.getSimpleName(); + } + + return this.elementClass.getSimpleName(); + } + + public boolean allowCustomKeys() { + return this.apiRegistryBuilder != null || RegistryEntries.DATA_DRIVEN.contains(this); + } + + private Map, TO> getFields(Map, TO> map, Function transform) { + Registry registry = this.registry(); + try { + for (Field field : this.holderElementsClass.getDeclaredFields()) { + if (!ResourceKey.class.isAssignableFrom(field.getType()) && !Holder.Reference.class.isAssignableFrom(field.getType()) && !this.elementClass.isAssignableFrom(field.getType())) { + continue; + } + + if (ClassHelper.isStaticConstant(field, Modifier.PUBLIC)) { + ResourceKey key = null; + if (this.elementClass.isAssignableFrom(field.getType())) { + key = registry.getResourceKey(this.elementClass.cast(field.get(null))).orElseThrow(); + } else { + if (field.getGenericType() instanceof ParameterizedType complexType && complexType.getActualTypeArguments().length == 1 && + complexType.getActualTypeArguments()[0] == this.elementClass) { + + if (Holder.Reference.class.isAssignableFrom(field.getType())) { + key = ((Holder.Reference) field.get(null)).key(); + } else { + key = (ResourceKey) field.get(null); + } + } + } + if (key != null) { + TO value = transform.apply(field); + if (value != null) { + map.put(key, value); + } + } + } + } + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + return map; + } + + public Map, String> getFieldNames() { + if (this.fieldNames == null) { + this.fieldNames = this.getFields(Field::getName); + } + return this.fieldNames; + } + + public Map, TO> getFields(Function transform) { + return Collections.unmodifiableMap(this.getFields(new IdentityHashMap<>(), transform)); + } + + @Override + public String toString() { + return "RegistryEntry[" + + "registryKey=" + this.registryKey + ", " + + "registryKeyField=" + this.registryKeyField + ", " + + "apiClass=" + this.apiClass + ", " + + "implClass=" + this.implClass + ", " + + ']'; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/registry/RegistryKeyField.java b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryKeyField.java new file mode 100644 index 000000000..7a91f0bd4 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/registry/RegistryKeyField.java @@ -0,0 +1,7 @@ +package io.papermc.generator.registry; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public record RegistryKeyField(Class elementClass, String name) { +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PaperPatternSourceSetRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PaperPatternSourceSetRewriter.java new file mode 100644 index 000000000..08f65d162 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PaperPatternSourceSetRewriter.java @@ -0,0 +1,71 @@ +package io.papermc.generator.rewriter.registration; + +import io.papermc.generator.rewriter.utils.Annotations; +import io.papermc.generator.types.SimpleGenerator; +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.SourceFile; +import io.papermc.typewriter.context.IndentUnit; +import io.papermc.typewriter.context.SourcesMetadata; +import io.papermc.typewriter.registration.SourceSetRewriterImpl; +import io.papermc.typewriter.replace.CompositeRewriter; +import io.papermc.typewriter.replace.ReplaceOptions; +import io.papermc.typewriter.replace.ReplaceOptionsLike; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.io.File; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.SharedConstants; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.VisibleForTesting; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public class PaperPatternSourceSetRewriter extends SourceSetRewriterImpl implements PatternSourceSetRewriter { + + private static final String COMMENT_MARKER_FORMAT = "%s generate - %s"; // {0} = Start|End {1} = pattern + private static final IndentUnit INDENT_UNIT = IndentUnit.parse(SimpleGenerator.INDENT_UNIT); + + public PaperPatternSourceSetRewriter() { + this(Collections.emptySet()); + } + + public PaperPatternSourceSetRewriter(Set classpath) { + super(SourcesMetadata.of(INDENT_UNIT, b -> b.classpath(classpath))); // let the runtime java version since it will always be in sync with what paperweight use + } + + @VisibleForTesting + public SourcesMetadata getMetadata() { + return this.metadata; + } + + private static ReplaceOptionsLike getOptions(String pattern, @Nullable ClassNamed targetClass) { + return ReplaceOptions.between( + COMMENT_MARKER_FORMAT.formatted("Start", pattern), + COMMENT_MARKER_FORMAT.formatted("End", pattern) + ) + .generatedComment(Annotations.annotationStyle(GeneratedFrom.class) + " " + SharedConstants.getCurrentVersion().getId()) + .targetClass(targetClass); + } + + @Override + public PatternSourceSetRewriter register(String pattern, ClassNamed targetClass, SearchReplaceRewriter rewriter) { + return super.register(SourceFile.of(targetClass.topLevel()), rewriter.withOptions(getOptions(pattern, targetClass)).customName(pattern)); + } + + @Override + public PatternSourceSetRewriter register(ClassNamed mainClass, CompositeRewriter rewriter) { + return super.register(SourceFile.of(mainClass), rewriter); + } + + @Contract(value = "_ -> new", pure = true) + public static CompositeRewriter composite(RewriterHolder... holders) { + return CompositeRewriter.bind(Arrays.stream(holders) + .map(holder -> holder.transform(PaperPatternSourceSetRewriter::getOptions)) + .toArray(SearchReplaceRewriter[]::new)); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PatternSourceSetRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PatternSourceSetRewriter.java new file mode 100644 index 000000000..0189efb10 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/PatternSourceSetRewriter.java @@ -0,0 +1,23 @@ +package io.papermc.generator.rewriter.registration; + +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.registration.SourceSetRewriter; +import io.papermc.typewriter.replace.CompositeRewriter; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface PatternSourceSetRewriter extends SourceSetRewriter { + + default PatternSourceSetRewriter register(String pattern, Class targetClass, SearchReplaceRewriter rewriter) { + return register(pattern, new ClassNamed(targetClass), rewriter); + } + + PatternSourceSetRewriter register(String pattern, ClassNamed targetClass, SearchReplaceRewriter rewriter); + + default PatternSourceSetRewriter register(Class mainClass, CompositeRewriter rewriter) { + return this.register(new ClassNamed(mainClass), rewriter); + } + + PatternSourceSetRewriter register(ClassNamed mainClass, CompositeRewriter rewriter); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/RewriterHolder.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/RewriterHolder.java new file mode 100644 index 000000000..0d4809a21 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/registration/RewriterHolder.java @@ -0,0 +1,27 @@ +package io.papermc.generator.rewriter.registration; + +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.replace.ReplaceOptionsLike; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.function.BiFunction; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public record RewriterHolder(String pattern, @Nullable ClassNamed targetClass, SearchReplaceRewriter rewriter) { + + @Contract(value = "_, _, _ -> new", pure = true) + public static RewriterHolder holder(String pattern, @Nullable Class targetClass, SearchReplaceRewriter rewriter) { + return new RewriterHolder(pattern, targetClass == null ? null : new ClassNamed(targetClass), rewriter); + } + + @Contract(value = "_, _ -> new", pure = true) + public static RewriterHolder holder(String pattern, SearchReplaceRewriter rewriter) { + return holder(pattern, null, rewriter); + } + + public SearchReplaceRewriter transform(BiFunction patternMapper) { + return this.rewriter.withOptions(patternMapper.apply(this.pattern, this.targetClass)).customName(this.pattern); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/Types.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/Types.java new file mode 100644 index 000000000..f733d019d --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/Types.java @@ -0,0 +1,28 @@ +package io.papermc.generator.rewriter.types; + +import io.papermc.typewriter.ClassNamed; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Types { + + public static final String BASE_PACKAGE = "org.bukkit.craftbukkit"; + + public static final ClassNamed CRAFT_BLOCK_DATA = ClassNamed.of(BASE_PACKAGE + ".block.data", "CraftBlockData"); + + public static final ClassNamed CRAFT_BLOCK_STATES = ClassNamed.of(BASE_PACKAGE + ".block", "CraftBlockStates"); + + public static final ClassNamed CRAFT_STATISTIC = ClassNamed.of(BASE_PACKAGE, "CraftStatistic"); + + public static final ClassNamed CRAFT_POTION_UTIL = ClassNamed.of(BASE_PACKAGE + ".potion", "CraftPotionUtil"); + + public static final ClassNamed FIELD_RENAME = ClassNamed.of(BASE_PACKAGE + ".legacy", "FieldRename"); + + public static final ClassNamed PAPER_REGISTRIES = ClassNamed.of("io.papermc.paper.registry", "PaperRegistries"); + + public static final ClassNamed PAPER_FEATURE_FLAG_PROVIDER_IMPL = ClassNamed.of("io.papermc.paper.world.flag", "PaperFeatureFlagProviderImpl"); + + public static final ClassNamed PAPER_SIMPLE_REGISTRY = ClassNamed.of("io.papermc.paper.registry", "PaperSimpleRegistry"); + + public static final ClassNamed MOB_GOAL_HELPER = ClassNamed.of("com.destroystokyo.paper.entity.ai", "MobGoalHelper"); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java new file mode 100644 index 000000000..10e6c5782 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/EnumRegistryRewriter.java @@ -0,0 +1,82 @@ +package io.papermc.generator.rewriter.types.registry; + +import com.google.common.base.Suppliers; +import io.papermc.generator.Main; +import io.papermc.generator.rewriter.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.experimental.ExperimentalCollector; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.typewriter.preset.EnumRewriter; +import io.papermc.typewriter.preset.model.EnumValue; +import java.util.Map; +import java.util.function.Supplier; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.flag.FeatureElement; +import net.minecraft.world.flag.FeatureFlags; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import static io.papermc.generator.utils.Formatting.quoted; + +@NullMarked +@ApiStatus.Obsolete +public class EnumRegistryRewriter extends EnumRewriter> { + + private final Supplier> registry; + private final Supplier, SingleFlagHolder>> experimentalKeys; + private final boolean isFilteredRegistry; + private final boolean hasKeyArgument; + + public EnumRegistryRewriter(ResourceKey> registryKey) { + this(registryKey, true); + } + + protected EnumRegistryRewriter(ResourceKey> registryKey, boolean hasKeyArgument) { + this.registry = Suppliers.memoize(() -> Main.REGISTRY_ACCESS.lookupOrThrow(registryKey)); + this.experimentalKeys = Suppliers.memoize(() -> ExperimentalCollector.collectDataDrivenElementIds(this.registry.get())); + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey); + this.hasKeyArgument = hasKeyArgument; + } + + @Override + protected Iterable> getValues() { + return this.registry.get().listElements().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath()))::iterator; + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + EnumValue.Builder value = EnumValue.builder(Formatting.formatKeyAsField(reference.key().location().getPath())); + if (this.hasKeyArgument) { + value.argument(quoted(reference.key().location().getPath())); + } + return value; + } + + @Override + protected void appendEnumValue(Holder.Reference reference, StringBuilder builder, String indent, boolean reachEnd) { + // experimental annotation + SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); + if (requiredFeature != null) { + Annotations.experimentalAnnotations(builder, indent, this.importCollector, requiredFeature); + } + + super.appendEnumValue(reference, builder, indent, reachEnd); + } + + protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { + if (this.isFilteredRegistry) { + // built-in registry + FeatureElement element = (FeatureElement) reference.value(); + if (FeatureFlags.isExperimental(element.requiredFeatures())) { + return SingleFlagHolder.fromSet(element.requiredFeatures()); + } + } else { + // data-driven registry + return this.experimentalKeys.get().get(reference.key()); + } + return null; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java new file mode 100644 index 000000000..ede08c4a0 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/FeatureFlagRewriter.java @@ -0,0 +1,61 @@ +package io.papermc.generator.rewriter.types.registry; + +import com.mojang.logging.LogUtils; +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.SourceFile; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Iterator; +import java.util.Map; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureFlag; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.flag.FeatureFlags; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; +import org.slf4j.Logger; + +import static io.papermc.generator.rewriter.utils.Annotations.annotation; +import static io.papermc.generator.utils.Formatting.quoted; + +@NullMarked +public class FeatureFlagRewriter extends SearchReplaceRewriter { + + private static final Logger LOGGER = LogUtils.getLogger(); + + @Override + public boolean registerFor(SourceFile file) { + try { + org.bukkit.FeatureFlag.class.getDeclaredMethod("create", String.class); + } catch (NoSuchMethodException e) { + LOGGER.error("Fetch method not found, skipping the rewriter for feature flag", e); + return false; + } + + return super.registerFor(file); + } + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + Iterator> flagIterator = FeatureFlags.REGISTRY.names.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().getPath())).iterator(); + while (flagIterator.hasNext()) { + Map.Entry entry = flagIterator.next(); + ResourceLocation name = entry.getKey(); + if (FeatureFlags.isExperimental(FeatureFlagSet.of(entry.getValue()))) { + builder.append(metadata.indent()).append(annotation(ApiStatus.Experimental.class, this.importCollector)).append('\n'); + } + + builder.append(metadata.indent()); + + builder.append(org.bukkit.FeatureFlag.class.getSimpleName()).append(' ').append(Formatting.formatKeyAsField(name.getPath())); + builder.append(" = "); + builder.append("create(%s)".formatted(quoted(name.getPath()))); + builder.append(';'); + + builder.append('\n'); + if (flagIterator.hasNext()) { + builder.append('\n'); + } + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java new file mode 100644 index 000000000..06287f65a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperFeatureFlagMapping.java @@ -0,0 +1,30 @@ +package io.papermc.generator.rewriter.types.registry; + +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Iterator; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureFlags; +import org.bukkit.FeatureFlag; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class PaperFeatureFlagMapping extends SearchReplaceRewriter { + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + Iterator flagIterator = FeatureFlags.REGISTRY.toNames(FeatureFlags.REGISTRY.allFlags()).stream().sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).iterator(); + + while (flagIterator.hasNext()) { + ResourceLocation name = flagIterator.next(); + String keyedName = Formatting.formatKeyAsField(name.getPath()); + builder.append(metadata.indent()); + builder.append("%s.%s, %s.%s".formatted(FeatureFlag.class.getSimpleName(), keyedName, FeatureFlags.class.getSimpleName(), keyedName)); + if (flagIterator.hasNext()) { + builder.append(','); + } + builder.append('\n'); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java new file mode 100644 index 000000000..fa481914f --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/PaperRegistriesRewriter.java @@ -0,0 +1,105 @@ +package io.papermc.generator.rewriter.types.registry; + +import com.google.common.base.CaseFormat; +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.registry.RegistryEntry; +import io.papermc.generator.rewriter.types.Types; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.lang.constant.ConstantDescs; +import java.util.stream.Stream; +import net.minecraft.core.registries.Registries; +import org.bukkit.Keyed; +import org.bukkit.Registry; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class PaperRegistriesRewriter extends SearchReplaceRewriter { + + private void appendEntry(String indent, StringBuilder builder, RegistryEntry entry, boolean canBeDelayed, boolean apiOnly) { + builder.append(indent); + builder.append("start"); + builder.append('('); + builder.append(Registries.class.getSimpleName()).append('.').append(entry.registryKeyField()); + builder.append(", "); + builder.append(RegistryKey.class.getSimpleName()).append('.').append(entry.registryKeyField()); + builder.append(")."); + if (apiOnly) { + builder.append("apiOnly("); + if (entry.apiClass().isEnum()) { + builder.append(this.importCollector.getShortName(Types.PAPER_SIMPLE_REGISTRY)).append("::").append(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, entry.registryKey().location().getPath())); + } else { + builder.append("() -> "); + builder.append(Registry.class.getCanonicalName()).append('.').append(entry.apiRegistryField().orElse(entry.registryKeyField())); + } + builder.append(')'); + } else { + builder.append("craft("); + builder.append(this.importCollector.getShortName(entry.preloadClass())).append(".class"); + builder.append(", "); + + builder.append(this.importCollector.getShortName(this.getImplClassName(entry))).append("::").append(entry.apiAccessName().equals(ConstantDescs.INIT_NAME) ? "new" : entry.apiAccessName()); + + if (entry.canAllowDirect()) { + builder.append(", "); + builder.append(Boolean.TRUE.toString()); + } + builder.append(')'); + + if (entry.fieldRename() != null) { + builder.append(".serializationUpdater(").append(Types.FIELD_RENAME.simpleName()).append('.').append(entry.fieldRename()).append(")"); + } + + if (entry.apiRegistryBuilderImpl() != null) { + builder.append(".writable("); + builder.append(this.importCollector.getShortName(this.classNamedView.findFirst(entry.apiRegistryBuilderImpl()).resolve(this.classResolver))).append("::new"); + builder.append(')'); + } else { + builder.append(".build()"); + } + } + if (canBeDelayed && entry.isDelayed()) { + builder.append(".delayed()"); + } + builder.append(','); + builder.append('\n'); + } + + @Override + public void insert(SearchMetadata metadata, StringBuilder builder) { + builder.append(metadata.indent()).append("// built-in"); + builder.append('\n'); + + for (RegistryEntry entry : RegistryEntries.BUILT_IN) { + appendEntry(metadata.indent(), builder, entry, false, false); + } + + builder.append('\n'); + builder.append(metadata.indent()).append("// data-driven"); + builder.append('\n'); + + for (RegistryEntry entry : RegistryEntries.DATA_DRIVEN) { + appendEntry(metadata.indent(), builder, entry, true, false); + } + + builder.append('\n'); + builder.append(metadata.indent()).append("// api-only"); + builder.append('\n'); + + for (RegistryEntry entry : RegistryEntries.API_ONLY) { + appendEntry(metadata.indent(), builder, entry, false, true); + } + + builder.deleteCharAt(builder.length() - 2); // delete extra comma... + } + + private ClassNamed getImplClassName(RegistryEntry entry) { + try (Stream stream = this.classNamedView.find(entry.implClass())) { + return stream.map(klass -> klass.resolve(this.classResolver)) + .filter(klass -> Keyed.class.isAssignableFrom(klass.knownClass())) // todo check handleable/holderable once keyed is gone + .findFirst().orElseThrow(); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryEventsRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryEventsRewriter.java new file mode 100644 index 000000000..6d289d4d0 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryEventsRewriter.java @@ -0,0 +1,33 @@ +package io.papermc.generator.rewriter.types.registry; + +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.event.RegistryEventProvider; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import org.jspecify.annotations.NullMarked; + +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class RegistryEventsRewriter extends SearchReplaceRewriter { + + @Override + public void insert(SearchMetadata metadata, StringBuilder builder) { + RegistryEntries.forEach(entry -> { + if (entry.apiRegistryBuilder() != null) { + builder.append(metadata.indent()); + builder.append("%s %s %s ".formatted(PUBLIC, STATIC, FINAL)); + builder.append(RegistryEventProvider.class.getSimpleName()); + builder.append("<").append(this.importCollector.getShortName(entry.apiClass())).append(", ").append(this.importCollector.getShortName(entry.apiRegistryBuilder())).append('>'); + builder.append(' '); + builder.append(entry.registryKeyField()); + builder.append(" = "); + builder.append("create(").append(RegistryKey.class.getSimpleName()).append('.').append(entry.registryKeyField()).append(");"); + builder.append('\n'); + } + }); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java new file mode 100644 index 000000000..835c3fd1c --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryFieldRewriter.java @@ -0,0 +1,135 @@ +package io.papermc.generator.rewriter.types.registry; + +import com.google.common.base.Preconditions; +import com.google.common.base.Suppliers; +import com.mojang.logging.LogUtils; +import io.papermc.generator.Main; +import io.papermc.generator.rewriter.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.experimental.ExperimentalCollector; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.SourceFile; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; +import java.util.function.Supplier; +import net.minecraft.core.Holder; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.flag.FeatureElement; +import net.minecraft.world.flag.FeatureFlags; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; + +import static io.papermc.generator.utils.Formatting.quoted; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class RegistryFieldRewriter extends SearchReplaceRewriter { + + private static final Logger LOGGER = LogUtils.getLogger(); + + private final ResourceKey> registryKey; + private final boolean isFilteredRegistry; + private final @Nullable String fetchMethod; + + protected @MonotonicNonNull ClassNamed fieldClass; + private @MonotonicNonNull Supplier, SingleFlagHolder>> experimentalKeys; + + public RegistryFieldRewriter(ResourceKey> registryKey, @Nullable String fetchMethod) { + this.registryKey = registryKey; + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(registryKey); + this.fetchMethod = fetchMethod; + } + + @Override + public boolean registerFor(SourceFile file) { + this.fieldClass = this.options.targetClass().orElse(file.mainClass()); + Preconditions.checkState(this.fieldClass.knownClass() != null, "This rewriter can't run without knowing the field class at runtime!"); + + if (this.fetchMethod != null) { + try { + this.fieldClass.knownClass().getDeclaredMethod(this.fetchMethod, String.class); + } catch (NoSuchMethodException e) { + LOGGER.error("Fetch method not found, skipping the rewriter for registry fields of {}", this.registryKey, e); + return false; + } + } + + return super.registerFor(file); + } + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + boolean isInterface = Objects.requireNonNull(this.fieldClass.knownClass()).isInterface(); + Registry registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey); + this.experimentalKeys = Suppliers.memoize(() -> ExperimentalCollector.collectDataDrivenElementIds(registry)); + Iterator> referenceIterator = registry.listElements().filter(this::canPrintField).sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).iterator(); + + while (referenceIterator.hasNext()) { + Holder.Reference reference = referenceIterator.next(); + + this.rewriteJavadocs(reference, metadata.replacedContent(), metadata.indent(), builder); + + SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); + if (requiredFeature != null) { + Annotations.experimentalAnnotations(builder, metadata.indent(), this.importCollector, requiredFeature); + } + + builder.append(metadata.indent()); + if (!isInterface) { + builder.append("%s %s %s ".formatted(PUBLIC, STATIC, FINAL)); + } + + builder.append(this.rewriteFieldType(reference)).append(' ').append(this.rewriteFieldName(reference)); + builder.append(" = "); + builder.append(this.rewriteFieldValue(reference)); + builder.append(';'); + + builder.append('\n'); + if (referenceIterator.hasNext()) { + builder.append('\n'); + } + } + } + + protected void rewriteJavadocs(Holder.Reference reference, String replacedContent, String indent, StringBuilder builder) { + } + + protected boolean canPrintField(Holder.Reference reference) { + return true; + } + + protected String rewriteFieldType(Holder.Reference reference) { + return this.fieldClass.simpleName(); + } + + protected String rewriteFieldName(Holder.Reference reference) { + return Formatting.formatKeyAsField(reference.key().location().getPath()); + } + + protected String rewriteFieldValue(Holder.Reference reference) { + return "%s(%s)".formatted(this.fetchMethod, quoted(reference.key().location().getPath())); + } + + protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { + if (this.isFilteredRegistry) { + // built-in registry + FeatureElement element = (FeatureElement) reference.value(); + if (FeatureFlags.isExperimental(element.requiredFeatures())) { + return SingleFlagHolder.fromSet(element.requiredFeatures()); + } + } else { + // data-driven registry + return this.experimentalKeys.get().get(reference.key()); + } + return null; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryTagRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryTagRewriter.java new file mode 100644 index 000000000..0e28a8610 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/RegistryTagRewriter.java @@ -0,0 +1,92 @@ +package io.papermc.generator.rewriter.types.registry; + +import com.google.common.base.Preconditions; +import com.mojang.logging.LogUtils; +import io.papermc.generator.Main; +import io.papermc.generator.rewriter.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.SourceFile; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Iterator; +import net.minecraft.core.Registry; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import org.bukkit.Keyed; +import org.bukkit.Tag; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; +import org.slf4j.Logger; + +import static io.papermc.generator.utils.Formatting.quoted; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +@ApiStatus.Obsolete +public class RegistryTagRewriter extends SearchReplaceRewriter { + + private static final Logger LOGGER = LogUtils.getLogger(); + + private final ResourceKey> registryKey; + private final Class apiClass; + private final String fetchMethod = "getTag"; + + public RegistryTagRewriter(ResourceKey> registryKey, Class apiClass) { + this.registryKey = registryKey; + this.apiClass = apiClass; + } + + @Override + public boolean registerFor(SourceFile file) { + ClassNamed holderClass = this.options.targetClass().orElse(file.mainClass()); + Preconditions.checkState(holderClass.knownClass() != null, "This rewriter can't run without knowing the field class at runtime!"); + try { + holderClass.knownClass().getDeclaredMethod(this.fetchMethod, String.class); + } catch (NoSuchMethodException e) { + LOGGER.error("Fetch method not found, skipping the rewriter for registry tag fields of {}", this.registryKey, e); + return false; + } + + return super.registerFor(file); + } + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + Registry registry = Main.REGISTRY_ACCESS.lookupOrThrow(this.registryKey); + Iterator> keyIterator = registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(reference -> reference.location().getPath())).iterator(); + + while (keyIterator.hasNext()) { + TagKey tagKey = keyIterator.next(); + + String featureFlagName = Main.EXPERIMENTAL_TAGS.get(tagKey); + if (featureFlagName != null) { + Annotations.experimentalAnnotations(builder, metadata.indent(), this.importCollector, SingleFlagHolder.fromName(featureFlagName)); + } + + builder.append(metadata.indent()); + builder.append("%s %s %s ".formatted(PUBLIC, STATIC, FINAL)); + + builder.append("%s<%s>".formatted(Tag.class.getSimpleName(), this.apiClass.getSimpleName())).append(' ').append(this.rewriteFieldName(tagKey)); + builder.append(" = "); + builder.append(this.rewriteFieldValue(tagKey)); + builder.append(';'); + + builder.append('\n'); + if (keyIterator.hasNext()) { + builder.append('\n'); + } + } + } + + protected String rewriteFieldName(TagKey tagKey) { + return Formatting.formatKeyAsField(tagKey.location().getPath()); + } + + protected String rewriteFieldValue(TagKey tagKey) { + return "%s(%s)".formatted(this.fetchMethod, quoted(tagKey.location().getPath())); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/TagRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/TagRewriter.java new file mode 100644 index 000000000..fa553ad7c --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/registry/TagRewriter.java @@ -0,0 +1,91 @@ +package io.papermc.generator.rewriter.types.registry; + +import io.papermc.generator.Main; +import io.papermc.generator.rewriter.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Iterator; +import java.util.Locale; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.tags.TagKey; +import org.bukkit.Bukkit; +import org.bukkit.Fluid; +import org.bukkit.GameEvent; +import org.bukkit.Keyed; +import org.bukkit.Material; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.EntityType; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +import static io.papermc.generator.utils.Formatting.quoted; + +@NullMarked +@ApiStatus.Obsolete +public class TagRewriter extends SearchReplaceRewriter { + + public record TagRegistry(String legacyFolderName, Class apiType, ResourceKey> registryKey) { // TODO remove Keyed + } + + private static final TagRegistry[] SUPPORTED_REGISTRIES = { // 1.21 folder name are normalized to registry key but api will stay as is + new TagRegistry("blocks", Material.class, Registries.BLOCK), + new TagRegistry("items", Material.class, Registries.ITEM), + new TagRegistry("fluids", Fluid.class, Registries.FLUID), + new TagRegistry("entity_types", EntityType.class, Registries.ENTITY_TYPE), + new TagRegistry("game_events", GameEvent.class, Registries.GAME_EVENT) + // new TagRegistry("damage_types", DamageType.class, Registries.DAMAGE_TYPE) - separate in DamageTypeTags + }; + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + for (int i = 0, len = SUPPORTED_REGISTRIES.length; i < len; i++) { + final TagRegistry tagRegistry = SUPPORTED_REGISTRIES[i]; + + final ResourceKey> registryKey = tagRegistry.registryKey(); + final Registry registry = Main.REGISTRY_ACCESS.lookupOrThrow(registryKey); + + final String fieldPrefix = Formatting.formatTagFieldPrefix(tagRegistry.legacyFolderName(), registryKey); + final String registryFieldName = "REGISTRY_" + tagRegistry.legacyFolderName().toUpperCase(Locale.ENGLISH); + + if (i != 0) { + builder.append('\n'); // extra line before the registry field + } + + // registry name field + builder.append(metadata.indent()); + builder.append("%s %s = %s;".formatted(String.class.getSimpleName(), registryFieldName, quoted(tagRegistry.legacyFolderName()))); + + builder.append('\n'); + builder.append('\n'); + + Iterator> keyIterator = registry.listTagIds().sorted(Formatting.alphabeticKeyOrder(tagKey -> tagKey.location().getPath())).iterator(); + + while (keyIterator.hasNext()) { + TagKey tagKey = keyIterator.next(); + final String keyPath = tagKey.location().getPath(); + final String fieldName = fieldPrefix + Formatting.formatKeyAsField(keyPath); + + // tag field + String featureFlagName = Main.EXPERIMENTAL_TAGS.get(tagKey); + if (featureFlagName != null) { + Annotations.experimentalAnnotations(builder, metadata.indent(), this.importCollector, SingleFlagHolder.fromName(featureFlagName)); + } + + builder.append(metadata.indent()); + builder.append("%s<%s>".formatted(this.source.mainClass().simpleName(), this.importCollector.getShortName(tagRegistry.apiType()))).append(' ').append(fieldName); + builder.append(" = "); + builder.append("%s.getTag(%s, %s.minecraft(%s), %s.class)".formatted(Bukkit.class.getSimpleName(), registryFieldName, NamespacedKey.class.getSimpleName(), quoted(keyPath), tagRegistry.apiType().getSimpleName())); // assume type is imported properly + builder.append(';'); + + builder.append('\n'); + if (keyIterator.hasNext()) { + builder.append('\n'); + } + } + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/BlockTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/BlockTypeRewriter.java new file mode 100644 index 000000000..9a496c75e --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/BlockTypeRewriter.java @@ -0,0 +1,27 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.typewriter.util.ClassHelper; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.level.block.Block; +import org.bukkit.block.BlockType; +import org.bukkit.block.data.BlockData; + +public class BlockTypeRewriter extends RegistryFieldRewriter { + + public BlockTypeRewriter() { + super(Registries.BLOCK, "getBlockType"); + } + + @Override + protected String rewriteFieldType(Holder.Reference reference) { + Class blockData = BlockStateMapping.getBestSuitedApiClass(reference.value().getClass()); + if (blockData == null) { + blockData = BlockData.class; + } + + return "%s<%s>".formatted(ClassHelper.retrieveFullNestedName(BlockType.Typed.class), this.importCollector.getShortName(blockData)); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockDataMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockDataMapping.java new file mode 100644 index 000000000..2a090056e --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockDataMapping.java @@ -0,0 +1,19 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.rewriter.types.Types; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Comparator; + +public class CraftBlockDataMapping extends SearchReplaceRewriter { + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + BlockStateMapping.MAPPING.entrySet().stream().sorted(Comparator.comparing(entry -> entry.getKey().getCanonicalName())).forEach(entry -> { + builder.append(metadata.indent()); + builder.append("register(%s.class, %s.block.impl.%s::new);".formatted(entry.getKey().getCanonicalName(), Types.BASE_PACKAGE, entry.getValue().implName())); + builder.append('\n'); + }); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java new file mode 100644 index 000000000..2fd4d0c69 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftBlockEntityStateMapping.java @@ -0,0 +1,21 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.utils.BlockEntityMapping; +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import net.minecraft.world.level.block.entity.BlockEntityType; + +public class CraftBlockEntityStateMapping extends SearchReplaceRewriter { + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + BlockEntityMapping.MAPPING.entrySet().stream().sorted(Formatting.alphabeticKeyOrder(entry -> entry.getKey().location().getPath())).forEach(entry -> { + builder.append(metadata.indent()); + builder.append("register(%s.%s, %s.class, %s::new);".formatted( + BlockEntityType.class.getSimpleName(), Formatting.formatKeyAsField(entry.getKey().location().getPath()), + entry.getValue(), entry.getValue())); + builder.append('\n'); + }); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java new file mode 100644 index 000000000..df57fadbc --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/CraftPotionUtilRewriter.java @@ -0,0 +1,32 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.util.Locale; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceLocation; +import org.bukkit.potion.PotionType; + +@Deprecated(forRemoval = true) +public class CraftPotionUtilRewriter extends SearchReplaceRewriter { + + private final String statePrefix; + + public CraftPotionUtilRewriter(String statePrefix) { + this.statePrefix = statePrefix; + } + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + String upperStatePrefix = this.statePrefix.toUpperCase(Locale.ENGLISH); + BuiltInRegistries.POTION.keySet().stream() + .filter(key -> BuiltInRegistries.POTION.containsKey(key.withPath(path -> this.statePrefix + "_" + path))) + .sorted(Formatting.alphabeticKeyOrder(ResourceLocation::getPath)).forEach(key -> { + String keyedName = Formatting.formatKeyAsField(key.getPath()); + builder.append(metadata.indent()); + builder.append(".put(%s.%s, %s.%s_%s)".formatted(PotionType.class.getSimpleName(), keyedName, PotionType.class.getSimpleName(), upperStatePrefix, keyedName)); + builder.append('\n'); + }); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java new file mode 100644 index 000000000..7426838b8 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/EntityTypeRewriter.java @@ -0,0 +1,175 @@ +package io.papermc.generator.rewriter.types.simple; + +import com.google.common.base.CaseFormat; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.rewriter.types.registry.EnumRegistryRewriter; +import io.papermc.generator.types.goal.MobGoalNames; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.preset.model.EnumValue; +import io.papermc.typewriter.util.ClassResolver; +import it.unimi.dsi.fastutil.objects.Object2IntMap; +import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; +import java.lang.reflect.ParameterizedType; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import net.minecraft.Util; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.Mob; + +import static io.papermc.generator.utils.Formatting.quoted; + +public class EntityTypeRewriter extends EnumRegistryRewriter> { + + private static final Map>, Class> ENTITY_GENERIC_TYPES = + RegistryEntries.byRegistryKey(Registries.ENTITY_TYPE).getFields(field -> { + if (field.getGenericType() instanceof ParameterizedType complexType && complexType.getActualTypeArguments().length == 1) { + return (Class) complexType.getActualTypeArguments()[0]; + } + return null; + }); + + private static final Map CLASS_RENAMES = ImmutableMap.builder() + .put("ExperienceBottle", "ThrownExpBottle") + .put("EyeOfEnder", "EnderSignal") + .put("EndCrystal", "EnderCrystal") + .put("FireworkRocket", "Firework") + .put("FishingBobber", "FishHook") + .put("LeashKnot", "LeashHitch") + .put("LightningBolt", "LightningStrike") + .put("Tnt", "TNTPrimed") + .put("ChestMinecart", "StorageMinecart") + .put("CommandBlockMinecart", "CommandMinecart") + .put("TntMinecart", "ExplosiveMinecart") + .put("FurnaceMinecart", "PoweredMinecart") + .buildOrThrow(); + + @Deprecated + private static final Object2IntMap> LEGACY_ID = Util.make(new Object2IntOpenHashMap<>(), map -> { + map.put(EntityType.ITEM, 1); + map.put(EntityType.EXPERIENCE_ORB, 2); + map.put(EntityType.AREA_EFFECT_CLOUD, 3); + map.put(EntityType.ELDER_GUARDIAN, 4); + map.put(EntityType.WITHER_SKELETON, 5); + map.put(EntityType.STRAY, 6); + map.put(EntityType.EGG, 7); + map.put(EntityType.LEASH_KNOT, 8); + map.put(EntityType.PAINTING, 9); + map.put(EntityType.ARROW, 10); + map.put(EntityType.SNOWBALL, 11); + map.put(EntityType.FIREBALL, 12); + map.put(EntityType.SMALL_FIREBALL, 13); + map.put(EntityType.ENDER_PEARL, 14); + map.put(EntityType.EYE_OF_ENDER, 15); + map.put(EntityType.SPLASH_POTION, 16); + map.put(EntityType.EXPERIENCE_BOTTLE, 17); + map.put(EntityType.ITEM_FRAME, 18); + map.put(EntityType.WITHER_SKULL, 19); + map.put(EntityType.TNT, 20); + map.put(EntityType.FALLING_BLOCK, 21); + map.put(EntityType.FIREWORK_ROCKET, 22); + map.put(EntityType.HUSK, 23); + map.put(EntityType.SPECTRAL_ARROW, 24); + map.put(EntityType.SHULKER_BULLET, 25); + map.put(EntityType.DRAGON_FIREBALL, 26); + map.put(EntityType.ZOMBIE_VILLAGER, 27); + map.put(EntityType.SKELETON_HORSE, 28); + map.put(EntityType.ZOMBIE_HORSE, 29); + map.put(EntityType.ARMOR_STAND, 30); + map.put(EntityType.DONKEY, 31); + map.put(EntityType.MULE, 32); + map.put(EntityType.EVOKER_FANGS, 33); + map.put(EntityType.EVOKER, 34); + map.put(EntityType.VEX, 35); + map.put(EntityType.VINDICATOR, 36); + map.put(EntityType.ILLUSIONER, 37); + + map.put(EntityType.COMMAND_BLOCK_MINECART, 40); + map.put(EntityType.MINECART, 42); + map.put(EntityType.CHEST_MINECART, 43); + map.put(EntityType.FURNACE_MINECART, 44); + map.put(EntityType.TNT_MINECART, 45); + map.put(EntityType.HOPPER_MINECART, 46); + map.put(EntityType.SPAWNER_MINECART, 47); + + map.put(EntityType.CREEPER, 50); + map.put(EntityType.SKELETON, 51); + map.put(EntityType.SPIDER, 52); + map.put(EntityType.GIANT, 53); + map.put(EntityType.ZOMBIE, 54); + map.put(EntityType.SLIME, 55); + map.put(EntityType.GHAST, 56); + map.put(EntityType.ZOMBIFIED_PIGLIN, 57); + map.put(EntityType.ENDERMAN, 58); + map.put(EntityType.CAVE_SPIDER, 59); + map.put(EntityType.SILVERFISH, 60); + map.put(EntityType.BLAZE, 61); + map.put(EntityType.MAGMA_CUBE, 62); + map.put(EntityType.ENDER_DRAGON, 63); + map.put(EntityType.WITHER, 64); + map.put(EntityType.BAT, 65); + map.put(EntityType.WITCH, 66); + map.put(EntityType.ENDERMITE, 67); + map.put(EntityType.GUARDIAN, 68); + map.put(EntityType.SHULKER, 69); + + map.put(EntityType.PIG, 90); + map.put(EntityType.SHEEP, 91); + map.put(EntityType.COW, 92); + map.put(EntityType.CHICKEN, 93); + map.put(EntityType.SQUID, 94); + map.put(EntityType.WOLF, 95); + map.put(EntityType.MOOSHROOM, 96); + map.put(EntityType.SNOW_GOLEM, 97); + map.put(EntityType.OCELOT, 98); + map.put(EntityType.IRON_GOLEM, 99); + map.put(EntityType.HORSE, 100); + map.put(EntityType.RABBIT, 101); + map.put(EntityType.POLAR_BEAR, 102); + map.put(EntityType.LLAMA, 103); + map.put(EntityType.LLAMA_SPIT, 104); + map.put(EntityType.PARROT, 105); + + map.put(EntityType.VILLAGER, 120); + + map.put(EntityType.END_CRYSTAL, 200); + }); + + private static final ClassResolver runtime = new ClassResolver(EntityTypeRewriter.class.getClassLoader()); + + public EntityTypeRewriter() { + super(Registries.ENTITY_TYPE, false); + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { + String path = reference.key().location().getPath(); + List arguments = new ArrayList<>(4); + arguments.add(quoted(path)); + arguments.add(toBukkitClass(reference).concat(".class")); + arguments.add(Integer.toString(LEGACY_ID.getOrDefault(reference.value(), -1))); + + if (!reference.value().canSummon()) { + arguments.add(Boolean.FALSE.toString()); + } + return super.rewriteEnumValue(reference).arguments(arguments); + } + + private String toBukkitClass(Holder.Reference> reference) { + Class internalClass = ENTITY_GENERIC_TYPES.get(reference.key()); + if (Mob.class.isAssignableFrom(internalClass)) { + return this.importCollector.getShortName(MobGoalNames.bukkitMap.get((Class) internalClass)); + } + + String className = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, reference.key().location().getPath()); // use the key instead of the internal class name since name match a bit more + ClassNamed resolvedClass = this.classNamedView.findFirst(CLASS_RENAMES.getOrDefault(className, className)).resolve(runtime); + Preconditions.checkArgument(org.bukkit.entity.Entity.class.isAssignableFrom(resolvedClass.knownClass()), "Generic type must be an entity"); + return this.importCollector.getShortName(this.classNamedView.findFirst(CLASS_RENAMES.getOrDefault(className, className)).resolve(runtime)); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/ItemTypeRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/ItemTypeRewriter.java new file mode 100644 index 000000000..232cf5223 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/ItemTypeRewriter.java @@ -0,0 +1,27 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.typewriter.util.ClassHelper; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.Items; +import org.bukkit.inventory.ItemType; +import org.bukkit.inventory.meta.ItemMeta; + +@Deprecated // bad generic +public class ItemTypeRewriter extends RegistryFieldRewriter { + + public ItemTypeRewriter() { + super(Registries.ITEM, "getItemType"); + } + + @Override + protected String rewriteFieldType(Holder.Reference reference) { + if (reference.value().equals(Items.AIR)) { + return super.rewriteFieldType(reference); + } + + return "%s<%s>".formatted(ClassHelper.retrieveFullNestedName(ItemType.Typed.class), ItemMeta.class.getSimpleName()); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MapPaletteRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MapPaletteRewriter.java new file mode 100644 index 000000000..18f490238 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MapPaletteRewriter.java @@ -0,0 +1,41 @@ +package io.papermc.generator.rewriter.types.simple; + +import com.mojang.logging.LogUtils; +import io.papermc.typewriter.replace.SearchMetadata; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import java.awt.Color; +import net.minecraft.world.level.material.MapColor; +import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; + +public class MapPaletteRewriter extends SearchReplaceRewriter { + + private static final Logger LOGGER = LogUtils.getLogger(); + private static final boolean UPDATING = Boolean.getBoolean("paper.updatingMinecraft"); + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + int count = 0; + for (@Nullable MapColor mapColor : MapColor.MATERIAL_COLORS) { + if (mapColor == null) { + continue; + } + + for (MapColor.Brightness brightness : MapColor.Brightness.values()) { + builder.append(metadata.indent()); + Color color = new Color(mapColor.calculateARGBColor(brightness), true); + if (color.getAlpha() != 0xFF) { + builder.append("new %s(0x%08X, true),".formatted(color.getClass().getSimpleName(), color.getRGB())); + } else { + builder.append("new %s(0x%06X),".formatted(color.getClass().getSimpleName(), color.getRGB() & 0x00FFFFFF)); + } + builder.append('\n'); + count++; + } + } + + if (UPDATING) { + LOGGER.warn("There are {} map colors, check CraftMapView#render for possible change and update md5 hash in CraftMapColorCache", count); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java new file mode 100644 index 000000000..9c17c66f7 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MaterialRewriter.java @@ -0,0 +1,104 @@ +package io.papermc.generator.rewriter.types.simple; + +import io.papermc.generator.rewriter.types.registry.EnumRegistryRewriter; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.preset.model.EnumValue; +import java.util.Optional; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.WallSignBlock; +import org.bukkit.block.data.BlockData; + +import static io.papermc.generator.utils.Formatting.asCode; + +@Deprecated(forRemoval = true) +public class MaterialRewriter { + + // blocks + + public static class Blocks extends EnumRegistryRewriter { + + public Blocks() { + super(Registries.BLOCK, false); + } + + @Override + protected Iterable> getValues() { + return BuiltInRegistries.BLOCK.listElements().filter(reference -> !reference.value().equals(net.minecraft.world.level.block.Blocks.AIR)) + .sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath()))::iterator; + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + EnumValue.Builder value = super.rewriteEnumValue(reference); + Block block = reference.value(); + if (BlockStateMapping.MAPPING.containsKey(block.getClass())) { + // some block can also be represented as item in that enum + // doing a double job + Optional equivalentItem = BuiltInRegistries.ITEM.getOptional(reference.key().location()); + + if (equivalentItem.isEmpty() && block instanceof WallSignBlock) { + // wall sign block stack size is 16 for some reason like the sign item? + // but that rule doesn't work for the wall hanging sign block?? + equivalentItem = Optional.of(block.asItem()); + } + + Class blockData = BlockStateMapping.getBestSuitedApiClass(block.getClass()); + if (blockData == null) { + blockData = BlockData.class; + } + if (equivalentItem.isPresent() && equivalentItem.get().getDefaultMaxStackSize() != Item.DEFAULT_MAX_STACK_SIZE) { + return value.arguments(Integer.toString(-1), Integer.toString(equivalentItem.get().getDefaultMaxStackSize()), this.importCollector.getShortName(blockData).concat(".class")); + } + return value.arguments(Integer.toString(-1), this.importCollector.getShortName(blockData).concat(".class")); + } + return value.argument(Integer.toString(-1)); // id not needed for non legacy material + } + } + + /* todo test is broken + public static class IsTransparent extends SwitchCaseRewriter { + + public IsTransparent() { + super(false); + } + + @Override + protected Iterable getCases() { + return BuiltInRegistries.BLOCK.holders().filter(reference -> reference.value().defaultBlockState().useShapeForLightOcclusion()) + .map(reference -> reference.key().location().getPath().toUpperCase(Locale.ENGLISH)).sorted(Formatting.ALPHABETIC_KEY_ORDER)::iterator; + } + }*/ + + // items + + public static class Items extends EnumRegistryRewriter { + + public Items() { + super(Registries.ITEM, false); + } + + @Override + protected Iterable> getValues() { + return BuiltInRegistries.ITEM.listElements().filter(reference -> BuiltInRegistries.BLOCK.getOptional(reference.key().location()).isEmpty() || reference.value().equals(net.minecraft.world.item.Items.AIR)) + .sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath()))::iterator; + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + EnumValue.Builder value = super.rewriteEnumValue(reference); + Item item = reference.value(); + int maxStackSize = item.getDefaultMaxStackSize(); + if (maxStackSize != Item.DEFAULT_MAX_STACK_SIZE) { + return value.arguments(asCode(-1, maxStackSize)); + } + + return value.argument(Integer.toString(-1)); // id not needed for non legacy material + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java new file mode 100644 index 000000000..08e321aab --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/MemoryKeyRewriter.java @@ -0,0 +1,116 @@ +package io.papermc.generator.rewriter.types.simple; + +import com.google.gson.internal.Primitives; +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.generator.utils.ClassHelper; +import java.lang.reflect.ParameterizedType; +import java.util.Map; +import java.util.Set; +import net.minecraft.core.BlockPos; +import net.minecraft.core.GlobalPos; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.util.Unit; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.ai.behavior.PositionTracker; +import net.minecraft.world.entity.ai.memory.MemoryModuleType; +import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities; +import net.minecraft.world.entity.ai.memory.WalkTarget; +import net.minecraft.world.level.pathfinder.Path; +import net.minecraft.world.phys.Vec3; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; + +import static io.papermc.generator.utils.Formatting.quoted; + +@Deprecated +public class MemoryKeyRewriter extends RegistryFieldRewriter> { + + private static final Map>, Class> MEMORY_GENERIC_TYPES = RegistryEntries.byRegistryKey(Registries.MEMORY_MODULE_TYPE).getFields(field -> { + if (field.getGenericType() instanceof ParameterizedType complexType && complexType.getActualTypeArguments().length == 1) { + return ClassHelper.eraseType(complexType.getActualTypeArguments()[0]); + } + return null; + }); + + public MemoryKeyRewriter() { + super(Registries.MEMORY_MODULE_TYPE, null); + } + + // this api is not implemented and is not backed by a proper registry + private static final Set> IGNORED_TYPES = Set.of( + NearestVisibleLivingEntities.class, + WalkTarget.class, + PositionTracker.class, + Path.class, + DamageSource.class, + Vec3.class, + BlockPos.class, + Unit.class, + Void.class + ); + + private static final Set> IGNORED_SUB_TYPES = Set.of( + Iterable.class, + Map.class, + Entity.class + ); + + private static final Map, Class> API_BRIDGE = Map.of( + GlobalPos.class, Location.class + ); + + private static final Map FIELD_RENAMES = Map.of( + "LIKED_NOTEBLOCK", "LIKED_NOTEBLOCK_POSITION" + ); + + @Override + protected boolean canPrintField(Holder.Reference> reference) { + Class memoryType = MEMORY_GENERIC_TYPES.get(reference.key()); + if (IGNORED_TYPES.contains(memoryType)) { + return false; + } + for (Class subType : IGNORED_SUB_TYPES) { + if (subType.isAssignableFrom(memoryType)) { + return false; + } + } + + return true; + } + + private @MonotonicNonNull Class apiMemoryType; + + @Override + protected String rewriteFieldType(Holder.Reference> reference) { + Class memoryType = MEMORY_GENERIC_TYPES.get(reference.key()); + + if (!Primitives.isWrapperType(memoryType) && API_BRIDGE.containsKey(memoryType)) { + this.apiMemoryType = API_BRIDGE.get(memoryType); + } else { + this.apiMemoryType = memoryType; + } + + return "%s<%s>".formatted(this.fieldClass.simpleName(), this.importCollector.getShortName(this.apiMemoryType)); + } + + @Override + protected String rewriteFieldName(Holder.Reference> reference) { + String keyedName = super.rewriteFieldName(reference); + return FIELD_RENAMES.getOrDefault(keyedName, keyedName); + } + + @Override + protected String rewriteFieldValue(Holder.Reference> reference) { + return "new %s<>(%s.minecraft(%s), %s.class)".formatted( + this.fieldClass.simpleName(), + NamespacedKey.class.getSimpleName(), + quoted(reference.key().location().getPath()), + this.apiMemoryType.getSimpleName() // assume the type is already import (see above in rewriteFieldType) + ); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java new file mode 100644 index 000000000..fe67513b1 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/StatisticRewriter.java @@ -0,0 +1,170 @@ +package io.papermc.generator.rewriter.types.simple; + +import com.google.common.collect.ImmutableMap; +import io.papermc.generator.rewriter.types.registry.EnumRegistryRewriter; +import io.papermc.generator.utils.ClassHelper; +import io.papermc.generator.utils.Formatting; +import io.papermc.typewriter.preset.model.EnumValue; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Map; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.stats.StatType; +import net.minecraft.stats.Stats; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import org.bukkit.Statistic; + +import static io.papermc.generator.utils.Formatting.quoted; + +@Deprecated(forRemoval = true) +public class StatisticRewriter { + + private static final Map FIELD_RENAMES = ImmutableMap.builder() + .put("DROP", "DROP_COUNT") + .put("DROPPED", "DROP") + .put("PICKED_UP", "PICKUP") + .put("PLAY_TIME", "PLAY_ONE_MINUTE") + .put("CROUCH_TIME", "SNEAK_TIME") + .put("MINED", "MINE_BLOCK") + .put("USED", "USE_ITEM") + .put("BROKEN", "BREAK_ITEM") + .put("CRAFTED", "CRAFT_ITEM") + .put("KILLED", "KILL_ENTITY") + .put("KILLED_BY", "ENTITY_KILLED_BY") + .put("EAT_CAKE_SLICE", "CAKE_SLICES_EATEN") + .put("FILL_CAULDRON", "CAULDRON_FILLED") + .put("USE_CAULDRON", "CAULDRON_USED") + .put("CLEAN_ARMOR", "ARMOR_CLEANED") + .put("CLEAN_BANNER", "BANNER_CLEANED") + .put("INTERACT_WITH_BREWINGSTAND", "BREWINGSTAND_INTERACTION") + .put("INTERACT_WITH_BEACON", "BEACON_INTERACTION") + .put("INSPECT_DROPPER", "DROPPER_INSPECTED") + .put("INSPECT_HOPPER", "HOPPER_INSPECTED") + .put("INSPECT_DISPENSER", "DISPENSER_INSPECTED") + .put("PLAY_NOTEBLOCK", "NOTEBLOCK_PLAYED") + .put("TUNE_NOTEBLOCK", "NOTEBLOCK_TUNED") + .put("POT_FLOWER", "FLOWER_POTTED") + .put("TRIGGER_TRAPPED_CHEST", "TRAPPED_CHEST_TRIGGERED") + .put("OPEN_ENDERCHEST", "ENDERCHEST_OPENED") + .put("ENCHANT_ITEM", "ITEM_ENCHANTED") + .put("PLAY_RECORD", "RECORD_PLAYED") + .put("INTERACT_WITH_FURNACE", "FURNACE_INTERACTION") + .put("INTERACT_WITH_CRAFTING_TABLE", "CRAFTING_TABLE_INTERACTION") + .put("OPEN_CHEST", "CHEST_OPENED") + .put("OPEN_SHULKER_BOX", "SHULKER_BOX_OPENED") + .buildOrThrow(); + + public static class Custom extends EnumRegistryRewriter { + + public Custom() { + super(Registries.CUSTOM_STAT, false); + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + return super.rewriteEnumValue(reference).rename(name -> FIELD_RENAMES.getOrDefault(name, name)); + } + } + + public static class CraftCustom extends EnumRegistryRewriter { + + private static final Map INTERNAL_FIELD_RENAMES = Map.of( + "SNEAK_TIME", "CROUCH_TIME" + ); + + public CraftCustom() { + super(Registries.CUSTOM_STAT, false); + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference reference) { + String keyedName = Formatting.formatKeyAsField(reference.key().location().getPath()); + + return super.rewriteEnumValue(reference) + .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) + .argument("%s.%s".formatted(Stats.class.getSimpleName(), INTERNAL_FIELD_RENAMES.getOrDefault(keyedName, keyedName))); + } + } + + public static class Type extends EnumRegistryRewriter> { + + private static final Map, String> TYPE_MAPPING = Map.of( + Item.class, "ITEM", + Block.class, "BLOCK", + EntityType.class, "ENTITY" + ); + + private static final Map, Class> FIELD_GENERIC_TYPE; + + static { + final Map, Class> map = new IdentityHashMap<>(); + + try { + for (Field field : Stats.class.getDeclaredFields()) { + if (field.getType() != StatType.class) { + continue; + } + + if (ClassHelper.isStaticConstant(field, Modifier.PUBLIC)) { + java.lang.reflect.Type genericType = ((ParameterizedType) field.getGenericType()).getActualTypeArguments()[0]; + map.put((StatType) field.get(null), ClassHelper.eraseType(genericType)); + } + } + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + FIELD_GENERIC_TYPE = Collections.unmodifiableMap(map); + } + + public Type() { + super(Registries.STAT_TYPE, false); + } + + @Override + protected Iterable>> getValues() { + return BuiltInRegistries.STAT_TYPE.listElements().filter(reference -> reference.value() != Stats.CUSTOM) + .sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath()))::iterator; + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { + Class genericType = FIELD_GENERIC_TYPE.get(reference.value()); + if (!TYPE_MAPPING.containsKey(genericType)) { + throw new IllegalStateException("Unable to translate stat type generic " + genericType.getCanonicalName() + " into the api!"); + } + + return super.rewriteEnumValue(reference) + .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) + .argument("%s.%s".formatted(Statistic.Type.class.getSimpleName(), TYPE_MAPPING.get(genericType))); // find a more direct way? + + } + } + + public static class CraftType extends EnumRegistryRewriter> { + + public CraftType() { + super(Registries.STAT_TYPE, false); + } + + @Override + protected Iterable>> getValues() { + return BuiltInRegistries.STAT_TYPE.listElements().filter(reference -> reference.value() != Stats.CUSTOM) + .sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath()))::iterator; + } + + @Override + protected EnumValue.Builder rewriteEnumValue(Holder.Reference> reference) { + return super.rewriteEnumValue(reference) + .rename(name -> FIELD_RENAMES.getOrDefault(name, name)) + .argument("%s.withDefaultNamespace(%s)".formatted(ResourceLocation.class.getSimpleName(), quoted(reference.key().location().getPath()))); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/package-info.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/package-info.java new file mode 100644 index 000000000..fbb169e21 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/package-info.java @@ -0,0 +1,4 @@ +@NullMarked +package io.papermc.generator.rewriter.types.simple; + +import org.jspecify.annotations.NullMarked; diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java new file mode 100644 index 000000000..4a1f3fab4 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/DataComponentTypesRewriter.java @@ -0,0 +1,261 @@ +package io.papermc.generator.rewriter.types.simple.trial; + +import com.google.gson.internal.Primitives; +import com.mojang.serialization.Codec; +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.generator.utils.ClassHelper; +import io.papermc.paper.datacomponent.item.BlockItemDataProperties; +import io.papermc.paper.datacomponent.item.ItemAdventurePredicate; +import io.papermc.paper.datacomponent.item.ItemArmorTrim; +import io.papermc.typewriter.ClassNamed; +import io.papermc.typewriter.parser.Lexer; +import io.papermc.typewriter.parser.sequence.SequenceTokens; +import io.papermc.typewriter.parser.sequence.TokenTaskBuilder; +import io.papermc.typewriter.parser.token.CharSequenceBlockToken; +import io.papermc.typewriter.parser.token.CharSequenceToken; +import io.papermc.typewriter.parser.token.TokenType; +import io.papermc.typewriter.replace.SearchMetadata; +import java.lang.annotation.Annotation; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.core.component.DataComponentType; +import net.minecraft.core.component.DataComponents; +import net.minecraft.core.registries.Registries; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.ExtraCodecs; +import net.minecraft.util.Unit; +import net.minecraft.world.item.AdventureModePredicate; +import net.minecraft.world.item.Instrument; +import net.minecraft.world.item.Rarity; +import net.minecraft.world.item.component.BlockItemStateProperties; +import net.minecraft.world.item.component.FireworkExplosion; +import net.minecraft.world.item.crafting.Recipe; +import net.minecraft.world.item.equipment.trim.ArmorTrim; +import org.bukkit.FireworkEffect; +import org.bukkit.MusicInstrument; +import org.bukkit.inventory.ItemRarity; +import org.checkerframework.checker.index.qual.NonNegative; +import org.checkerframework.checker.index.qual.Positive; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.jspecify.annotations.Nullable; + +import static io.papermc.generator.utils.Formatting.quoted; + +public class DataComponentTypesRewriter extends RegistryFieldRewriter> { + + public DataComponentTypesRewriter() { + super(Registries.DATA_COMPONENT_TYPE, null); + } + + private static final Set FORMAT_TOKENS = EnumSet.of( + TokenType.COMMENT, + TokenType.SINGLE_COMMENT + ); + + private @MonotonicNonNull Map javadocsPerConstant; + + private Map parseConstantJavadocs(String content) { + Map map = new HashMap<>(); + + Lexer lex = new Lexer(content.toCharArray()); + lex.checkMarkdownDocComments = !this.sourcesMetadata.canSkipMarkdownDocComments(); + SequenceTokens.wrap(lex, FORMAT_TOKENS) + .group(action -> { + ProtoConstant constant = new ProtoConstant(); + action + .map(TokenType.JAVADOC, token -> { + constant.javadocs(((CharSequenceBlockToken) token)); + }, TokenTaskBuilder::asOptional) + .skip(TokenType.PUBLIC).skip(TokenType.STATIC).skip(TokenType.FINAL) + .skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC)) + .skipClosure(TokenType.LT, TokenType.GT, true, TokenTaskBuilder::asOptional) // skip generic + .map(TokenType.IDENTIFIER, token -> { + constant.name(((CharSequenceToken) token).value()); + }) + .skip(TokenType.IDENTIFIER) + .skipClosure(TokenType.LPAREN, TokenType.RPAREN, true) + .map(TokenType.SECO, $ -> { + if (constant.isComplete()) { + map.put(constant.name(), constant.javadocs()); + } + }); + }, TokenTaskBuilder::asRepeatable) + .executeOrThrow(); + + return map; + } + + private static final Set> UNSUPPORTED_TYPES = Set.of( + DataComponents.CUSTOM_DATA, + DataComponents.CREATIVE_SLOT_LOCK, + DataComponents.DEBUG_STICK_STATE, + DataComponents.ENTITY_DATA, + DataComponents.BUCKET_ENTITY_DATA, + DataComponents.BLOCK_ENTITY_DATA, + DataComponents.BEES, + DataComponents.LOCK + ); + + private static final Map>, Type> COMPONENT_GENERIC_TYPES = RegistryEntries.byRegistryKey(Registries.DATA_COMPONENT_TYPE).getFields(field -> { + if (field.getGenericType() instanceof ParameterizedType complexType && complexType.getActualTypeArguments().length == 1) { + return complexType.getActualTypeArguments()[0]; + } + return null; + }); + + private static final Map, Class> API_BRIDGE = Map.of( + Component.class, net.kyori.adventure.text.Component.class, + ResourceLocation.class, Key.class, + Instrument.class, MusicInstrument.class, + FireworkExplosion.class, FireworkEffect.class, + Rarity.class, ItemRarity.class, + ArmorTrim.class, ItemArmorTrim.class, + // renames + BlockItemStateProperties.class, BlockItemDataProperties.class, + AdventureModePredicate.class, ItemAdventurePredicate.class + ); + + @Deprecated + private static final Map FIELD_RENAMES = Map.of( + "BLOCK_STATE", "BLOCK_DATA" + ); + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + this.javadocsPerConstant = parseConstantJavadocs(metadata.replacedContent()); + super.insert(metadata, builder); + } + + @Override + protected boolean canPrintField(Holder.Reference> reference) { + return !UNSUPPORTED_TYPES.contains(reference.value()); + } + + @Override + protected void rewriteJavadocs(Holder.Reference> reference, String replacedContent, String indent, StringBuilder builder) { + String constantName = this.rewriteFieldName(reference); + if (this.javadocsPerConstant.containsKey(constantName)) { + CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName); + builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n'); + } + } + + private boolean isValued; + + private Class handleParameterizedType(Type type) { + if (type instanceof ParameterizedType complexType) { + Type[] args = complexType.getActualTypeArguments(); + if (args.length != 1) { + throw new UnsupportedOperationException("Unsupported type " + complexType); + } + + Class baseClass = ClassHelper.eraseType(complexType); + if (baseClass == Holder.class) { + return ClassHelper.eraseType(args[0]); + } + if (baseClass == ResourceKey.class) { + Class componentClass = ClassHelper.eraseType(args[0]); + if (componentClass == Recipe.class) { + return ResourceLocation.class; // special case recipe registry is not really a thing + } + } + } + + throw new UnsupportedOperationException("Unsupported type " + type); + } + + @Override + protected String rewriteFieldType(Holder.Reference> reference) { + Type componentType = COMPONENT_GENERIC_TYPES.get(reference.key()); + this.isValued = componentType != Unit.class; + if (this.isValued) { + Class componentClass = null; + UnaryOperator tryToWrap = UnaryOperator.identity(); + if (!reference.value().isTransient()) { + final Class annotation = getEquivalentAnnotation(reference.value().codecOrThrow()); + if (annotation != null) { + tryToWrap = value -> "@%s %s".formatted(this.importCollector.getShortName(annotation), value); + } + } + + if (componentType instanceof Class clazz) { + componentClass = clazz; + } else if (componentType instanceof ParameterizedType complexType) { + Type[] args = complexType.getActualTypeArguments(); + if (args.length != 1) { + throw new UnsupportedOperationException("Unsupported type " + componentType); + } + + Class baseClass = ClassHelper.eraseType(complexType); + if (baseClass == List.class) { + tryToWrap = value -> "%s<%s>".formatted(this.importCollector.getShortName(List.class), value); + componentClass = this.handleParameterizedType(args[0]); + } else { + componentClass = this.handleParameterizedType(complexType); + } + } + + if (componentClass == null) { + throw new UnsupportedOperationException("Unsupported type " + componentType); + } + + Class apiComponentClass = null; + if (Primitives.isWrapperType(componentClass)) { + apiComponentClass = componentClass; + } else if (API_BRIDGE.containsKey(componentClass)) { + apiComponentClass = API_BRIDGE.get(componentClass); + } + + final ClassNamed finalClass; + if (apiComponentClass == null) { + finalClass = this.classNamedView.tryFindFirst(io.papermc.typewriter.util.ClassHelper.retrieveFullNestedName(componentClass)).orElse(null); + } else { + finalClass = new ClassNamed(apiComponentClass); + } + return "%s.%s<%s>".formatted( + io.papermc.paper.datacomponent.DataComponentType.class.getSimpleName(), + io.papermc.paper.datacomponent.DataComponentType.Valued.class.getSimpleName(), + tryToWrap.apply(Optional.ofNullable(finalClass).map(this.importCollector::getShortName).orElse(componentClass.getSimpleName())) + ); + } else { + return "%s.%s".formatted( + io.papermc.paper.datacomponent.DataComponentType.class.getSimpleName(), + io.papermc.paper.datacomponent.DataComponentType.NonValued.class.getSimpleName() + ); + } + } + + private @Nullable Class getEquivalentAnnotation(Codec codec) { + Class annotation = null; // int range maybe? + if (codec == ExtraCodecs.POSITIVE_INT || codec == ExtraCodecs.POSITIVE_FLOAT) { + annotation = Positive.class; + } else if (codec == ExtraCodecs.NON_NEGATIVE_INT || codec == ExtraCodecs.NON_NEGATIVE_FLOAT) { + annotation = NonNegative.class; + } + return annotation; + } + + @Override + protected String rewriteFieldName(Holder.Reference> reference) { + String keyedName = super.rewriteFieldName(reference); + return FIELD_RENAMES.getOrDefault(keyedName, keyedName); + } + + @Override + protected String rewriteFieldValue(Holder.Reference> reference) { + return "%s(%s)".formatted(this.isValued ? "valued" : "unvalued", quoted(reference.key().location().getPath())); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ProtoConstant.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ProtoConstant.java new file mode 100644 index 000000000..c370f0c81 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/ProtoConstant.java @@ -0,0 +1,30 @@ +package io.papermc.generator.rewriter.types.simple.trial; + +import io.papermc.typewriter.parser.token.CharSequenceBlockToken; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; + +class ProtoConstant { + + private @MonotonicNonNull String name; + private @MonotonicNonNull CharSequenceBlockToken token; + + public void name(String name) { + this.name = name; + } + + public void javadocs(CharSequenceBlockToken token) { + this.token = token; + } + + public String name() { + return this.name; + } + + public CharSequenceBlockToken javadocs() { + return this.token; + } + + public boolean isComplete() { + return this.name != null && this.token != null; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java new file mode 100644 index 000000000..52884792a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/VillagerProfessionRewriter.java @@ -0,0 +1,101 @@ +package io.papermc.generator.rewriter.types.simple.trial; + +import io.papermc.generator.rewriter.types.registry.RegistryFieldRewriter; +import io.papermc.typewriter.parser.Lexer; +import io.papermc.typewriter.parser.sequence.SequenceTokens; +import io.papermc.typewriter.parser.sequence.TokenTaskBuilder; +import io.papermc.typewriter.parser.token.CharSequenceBlockToken; +import io.papermc.typewriter.parser.token.CharSequenceToken; +import io.papermc.typewriter.parser.token.TokenType; +import io.papermc.typewriter.replace.SearchMetadata; +import java.util.EnumSet; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; +import net.minecraft.core.Holder; +import net.minecraft.core.registries.Registries; +import net.minecraft.world.entity.npc.VillagerProfession; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; + +public class VillagerProfessionRewriter extends RegistryFieldRewriter { + + public VillagerProfessionRewriter() { + super(Registries.VILLAGER_PROFESSION, "getProfession"); + } + + private static final Set FORMAT_TOKENS = EnumSet.of( + TokenType.COMMENT, + TokenType.SINGLE_COMMENT + ); + + private @MonotonicNonNull Map javadocsPerConstant; + + private Map parseConstantJavadocs(String content) { + Map map = new HashMap<>(); + + Lexer lex = new Lexer(content.toCharArray()); + lex.checkMarkdownDocComments = !this.sourcesMetadata.canSkipMarkdownDocComments(); + SequenceTokens.wrap(lex, FORMAT_TOKENS) + .group(action -> { + ProtoConstant constant = new ProtoConstant(); + action + .map(TokenType.JAVADOC, token -> { + constant.javadocs(((CharSequenceBlockToken) token)); + }, TokenTaskBuilder::asOptional) + .skipQualifiedName(Predicate.isEqual(TokenType.JAVADOC)) + .map(TokenType.IDENTIFIER, token -> { + constant.name(((CharSequenceToken) token).value()); + }) + .skip(TokenType.IDENTIFIER) + .skipClosure(TokenType.LPAREN, TokenType.RPAREN, true) + .map(TokenType.SECO, $ -> { + if (constant.isComplete()) { + map.put(constant.name(), constant.javadocs()); + } + }); + }, TokenTaskBuilder::asRepeatable) + .executeOrThrow(); + /* + for enums: + Set endMarkers = Set.of(TokenType.CO, TokenType.SECO); // move to static + SequenceTokens.wrap(lex, FORMAT_TOKENS) + .group(action -> { + ProtoConstant constant = new ProtoConstant(); + action + .map(TokenType.JAVADOC, token -> { + constant.javadocs(((CharSequenceBlockToken) token).value()); + }, TokenTaskBuilder::asOptional) + .map(TokenType.IDENTIFIER, token -> { + constant.name(((CharSequenceToken) token).value()); + }) + .skipClosure(TokenType.LPAREN, TokenType.RPAREN, true) + .skipClosure(TokenType.LSCOPE, TokenType.RSCOPE, true) + .map(endMarkers::contains, $ -> { + // this part will probably fail for the last entry for enum without end (,;) + if (constant.isComplete()) { + map.put(constant.name(), constant.javadocs()); + } + }); + }, TokenTaskBuilder::asRepeatable) + .executeOrThrow(); + */ + + return map; + } + + @Override + protected void insert(SearchMetadata metadata, StringBuilder builder) { + this.javadocsPerConstant = parseConstantJavadocs(metadata.replacedContent()); + super.insert(metadata, builder); + } + + @Override + protected void rewriteJavadocs(Holder.Reference reference, String replacedContent, String indent, StringBuilder builder) { + String constantName = this.rewriteFieldName(reference); + if (this.javadocsPerConstant.containsKey(constantName)) { + CharSequenceBlockToken token = this.javadocsPerConstant.get(constantName); + builder.append(indent).append(replacedContent, token.pos(), token.endPos()).append('\n'); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/package-info.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/package-info.java new file mode 100644 index 000000000..7f71a4035 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/types/simple/trial/package-info.java @@ -0,0 +1,6 @@ +@ApiStatus.Experimental +@NullMarked +package io.papermc.generator.rewriter.types.simple.trial; + +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/Annotations.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/Annotations.java new file mode 100644 index 000000000..a2e58656e --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/Annotations.java @@ -0,0 +1,48 @@ +package io.papermc.generator.rewriter.utils; + +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.typewriter.context.ImportCollector; +import io.papermc.typewriter.util.ClassHelper; +import java.lang.annotation.Annotation; +import org.bukkit.MinecraftExperimental; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Annotations { + + public static String annotation(Class clazz, ImportCollector collector) { + return "@%s".formatted(collector.getShortName(clazz)); + } + + public static String annotationStyle(Class clazz) { + return "@%s".formatted(ClassHelper.retrieveFullNestedName(clazz)); + } + + public static String annotation(Class clazz, ImportCollector collector, String param, String value) { + String annotation = annotation(clazz, collector); + if (value.isEmpty()) { + return annotation; + } + return "%s(%s = %s)".formatted(annotation, param, value); + } + + public static String annotation(Class clazz, ImportCollector collector, String value) { + String annotation = annotation(clazz, collector); + if (value.isEmpty()) { + return annotation; + } + return "%s(%s)".formatted(annotation, value); + } + + public static void experimentalAnnotations(StringBuilder builder, String indent, ImportCollector importCollector, SingleFlagHolder requiredFeature) { + builder.append(indent).append(annotation(MinecraftExperimental.class, importCollector, "%s.%s".formatted( + importCollector.getShortName(MinecraftExperimental.Requires.class, false), requiredFeature.asAnnotationMember().name() + ))).append('\n'); + + builder.append(indent).append(annotation(ApiStatus.Experimental.class, importCollector)).append('\n'); + } + + private Annotations() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/ScanOldGeneratedSourceCode.java b/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/ScanOldGeneratedSourceCode.java new file mode 100644 index 000000000..3185a35dc --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/rewriter/utils/ScanOldGeneratedSourceCode.java @@ -0,0 +1,110 @@ +package io.papermc.generator.rewriter.utils; + +import io.papermc.generator.Main; +import io.papermc.generator.Rewriters; +import io.papermc.generator.rewriter.registration.PaperPatternSourceSetRewriter; +import io.papermc.paper.generated.GeneratedFrom; +import io.papermc.typewriter.SourceFile; +import io.papermc.typewriter.SourceRewriter; +import io.papermc.typewriter.context.FileMetadata; +import io.papermc.typewriter.context.IndentUnit; +import io.papermc.typewriter.parser.StringReader; +import io.papermc.typewriter.replace.CommentMarker; +import io.papermc.typewriter.replace.SearchReplaceRewriter; +import io.papermc.typewriter.replace.SearchReplaceRewriterBase; +import net.minecraft.SharedConstants; +import java.io.IOException; +import java.io.LineNumberReader; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import static io.papermc.typewriter.replace.CommentMarker.EMPTY_MARKER; + +public class ScanOldGeneratedSourceCode { + + private static final String CURRENT_VERSION; + + static { + Main.bootStrap(false); + CURRENT_VERSION = SharedConstants.getCurrentVersion().getId(); + } + + public static void main(String[] args) throws IOException { + PaperPatternSourceSetRewriter apiSourceSet = new PaperPatternSourceSetRewriter(); + PaperPatternSourceSetRewriter serverSourceSet = new PaperPatternSourceSetRewriter(); + + Rewriters.bootstrap(apiSourceSet, serverSourceSet); + + checkOutdated(apiSourceSet, Path.of(args[0], "src/main/java")); + checkOutdated(serverSourceSet, Path.of(args[1], "src/main/java")); + } + + private static void checkOutdated(PaperPatternSourceSetRewriter sourceSetRewriter, Path sourceSet) throws IOException { + IndentUnit globalIndentUnit = sourceSetRewriter.getMetadata().indentUnit(); + for (Map.Entry entry : sourceSetRewriter.getRewriters().entrySet()) { + SourceRewriter rewriter = entry.getValue(); + if (!(rewriter instanceof SearchReplaceRewriterBase srt) || + srt.getRewriters().stream().noneMatch(SearchReplaceRewriter::hasGeneratedComment)) { + continue; + } + + SourceFile file = entry.getKey(); + IndentUnit indentUnit = file.metadata().flatMap(FileMetadata::indentUnit).orElse(globalIndentUnit); + Set rewriters = new HashSet<>(srt.getRewriters()); + try (LineNumberReader reader = new LineNumberReader(Files.newBufferedReader(sourceSet.resolve(file.path()), StandardCharsets.UTF_8))) { + while (true) { + String line = reader.readLine(); + if (line == null) { + break; + } + if (line.isEmpty()) { + continue; + } + + CommentMarker marker = srt.searchStartMarker(new StringReader(line), indentUnit, rewriters); + if (marker != EMPTY_MARKER) { + int startIndentSize = marker.indentSize(); + if (startIndentSize % indentUnit.size() != 0) { + continue; + } + + String nextLine = reader.readLine(); + if (nextLine == null) { + break; + } + if (nextLine.isEmpty()) { + continue; + } + + StringReader nextLineIterator = new StringReader(nextLine); + int indentSize = nextLineIterator.skipChars(indentUnit.character()); + if (indentSize != startIndentSize) { + continue; + } + + String generatedComment = "// %s ".formatted(Annotations.annotationStyle(GeneratedFrom.class)); + if (nextLineIterator.trySkipString(generatedComment) && nextLineIterator.canRead()) { + String generatedVersion = nextLineIterator.getRemaining(); + if (!CURRENT_VERSION.equals(generatedVersion)) { + throw new AssertionError( + "Code at line %d in %s is marked as being generated in version %s when the current version is %s".formatted( + reader.getLineNumber(), file.mainClass().canonicalName(), generatedVersion, CURRENT_VERSION) + ); + } + + if (!marker.owner().getOptions().multipleOperation()) { + if (rewriters.remove(marker.owner()) && rewriters.isEmpty()) { + break; + } + } + } + } + } + } + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/OverriddenClassGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/OverriddenClassGenerator.java new file mode 100644 index 000000000..027cbf061 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/OverriddenClassGenerator.java @@ -0,0 +1,50 @@ +package io.papermc.generator.types; + +import com.mojang.logging.LogUtils; +import com.squareup.javapoet.MethodSpec; +import io.papermc.generator.utils.Annotations; +import java.util.Arrays; +import org.jspecify.annotations.NullMarked; +import org.slf4j.Logger; + +import static javax.lang.model.element.Modifier.PUBLIC; + +@NullMarked +public abstract class OverriddenClassGenerator extends SimpleGenerator { + + private static final Logger LOGGER = LogUtils.getLogger(); + + protected final Class baseClass; + protected boolean printWarningOnMissingOverride; + + protected OverriddenClassGenerator(Class baseClass, String className, String packageName) { + super(className, packageName); + this.baseClass = baseClass; + } + + public Class getBaseClass() { + return this.baseClass; + } + + public MethodSpec.Builder createMethod(String name, Class... parameterTypes) { + MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(name) + .addModifiers(PUBLIC); + if (methodExists(name, parameterTypes)) { + methodBuilder.addAnnotation(Annotations.OVERRIDE); + } else { + if (this.printWarningOnMissingOverride) { + LOGGER.warn("Method {}#{}{} didn't override a known api method!", this.className, name, Arrays.toString(parameterTypes)); + } + } + return methodBuilder; + } + + protected boolean methodExists(String name, Class... parameterTypes) { + try { + this.baseClass.getMethod(name, parameterTypes); + return true; + } catch (NoSuchMethodException e) { + return false; + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/SimpleEnumGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/SimpleEnumGenerator.java new file mode 100644 index 000000000..282a30568 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/SimpleEnumGenerator.java @@ -0,0 +1,30 @@ +package io.papermc.generator.types; + +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.utils.Annotations; +import javax.lang.model.element.Modifier; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class SimpleEnumGenerator> extends SimpleGenerator { + + private final Class enumClass; + + public SimpleEnumGenerator(Class enumClass, String packageName) { + super(enumClass.getSimpleName(), packageName); + this.enumClass = enumClass; + } + + @Override + protected TypeSpec getTypeSpec() { + TypeSpec.Builder typeBuilder = TypeSpec.enumBuilder(this.enumClass.getSimpleName()) + .addModifiers(Modifier.PUBLIC) + .addAnnotations(Annotations.CLASS_HEADER); + + for (T enumValue : this.enumClass.getEnumConstants()) { + typeBuilder.addEnumConstant(enumValue.name()); + } + + return typeBuilder.build(); + } +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java similarity index 78% rename from paper-api-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java rename to paper-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java index 3608b449f..c4476d50a 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/SimpleGenerator.java @@ -2,13 +2,16 @@ package io.papermc.generator.types; import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.TypeSpec; - import java.io.IOException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; +import org.jspecify.annotations.NullMarked; +@NullMarked public abstract class SimpleGenerator implements SourceGenerator { + public static final String INDENT_UNIT = " "; + protected final String className; protected final String packageName; @@ -19,14 +22,15 @@ public abstract class SimpleGenerator implements SourceGenerator { protected abstract TypeSpec getTypeSpec(); - protected abstract JavaFile.Builder file(JavaFile.Builder builder); + protected JavaFile.Builder file(JavaFile.Builder builder) { + return builder; + } @Override public void writeToFile(Path parent) throws IOException { - JavaFile.Builder builder = JavaFile.builder(this.packageName, this.getTypeSpec()); this.file(builder) - .indent(" ") + .indent(INDENT_UNIT) .skipJavaLangImports(true); builder.build().writeTo(parent, StandardCharsets.UTF_8); diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java similarity index 76% rename from paper-api-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java rename to paper-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java index 2d550fa42..434b7b482 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/SourceGenerator.java @@ -2,7 +2,9 @@ package io.papermc.generator.types; import java.io.IOException; import java.nio.file.Path; +import org.jspecify.annotations.NullMarked; +@NullMarked public interface SourceGenerator { void writeToFile(Path parent) throws IOException; diff --git a/paper-generator/src/main/java/io/papermc/generator/types/Types.java b/paper-generator/src/main/java/io/papermc/generator/types/Types.java new file mode 100644 index 000000000..84b52e794 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/Types.java @@ -0,0 +1,14 @@ +package io.papermc.generator.types; + +import com.squareup.javapoet.ClassName; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Types { + + public static final String BASE_PACKAGE = "org.bukkit.craftbukkit"; + + public static final ClassName CRAFT_BLOCK_DATA = ClassName.get(BASE_PACKAGE + ".block.data", "CraftBlockData"); + + public static final ClassName CRAFT_BLOCK = ClassName.get(BASE_PACKAGE + ".block", "CraftBlock"); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataBootstrapper.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataBootstrapper.java new file mode 100644 index 000000000..fbdd1f3f2 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataBootstrapper.java @@ -0,0 +1,23 @@ +package io.papermc.generator.types.craftblockdata; + +import com.google.common.base.Preconditions; +import io.papermc.generator.types.SourceGenerator; +import io.papermc.generator.utils.BlockStateMapping; +import java.util.List; +import java.util.Map; +import net.minecraft.world.level.block.Block; +import org.bukkit.block.data.BlockData; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class CraftBlockDataBootstrapper { + + public static void bootstrap(List generators) { + for (Map.Entry, BlockStateMapping.BlockData> entry : BlockStateMapping.MAPPING.entrySet()) { + Class api = BlockStateMapping.getBestSuitedApiClass(entry.getValue()); + Preconditions.checkState(api != null, "Unknown custom BlockData api class for " + entry.getKey().getCanonicalName()); + + generators.add(new CraftBlockDataGenerator<>(entry.getKey(), entry.getValue(), api)); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataGenerator.java new file mode 100644 index 000000000..9097b0c2d --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/CraftBlockDataGenerator.java @@ -0,0 +1,243 @@ +package io.papermc.generator.types.craftblockdata; + +import com.google.common.base.CaseFormat; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import com.mojang.datafixers.util.Either; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.OverriddenClassGenerator; +import io.papermc.generator.types.Types; +import io.papermc.generator.types.craftblockdata.property.PropertyMaker; +import io.papermc.generator.types.craftblockdata.property.PropertyWriter; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.converter.Converters; +import io.papermc.generator.types.craftblockdata.property.holder.DataPropertyMaker; +import io.papermc.generator.types.craftblockdata.property.holder.VirtualField; +import io.papermc.generator.types.craftblockdata.property.holder.converter.DataConverter; +import io.papermc.generator.types.craftblockdata.property.holder.converter.DataConverters; +import io.papermc.generator.utils.Annotations; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.generator.utils.CommonVariable; +import io.papermc.generator.utils.NamingManager; +import it.unimi.dsi.fastutil.Pair; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Map; +import java.util.function.BiConsumer; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.ChiseledBookShelfBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.Property; +import org.bukkit.Axis; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.Rail; +import org.jspecify.annotations.NullMarked; + +import static io.papermc.generator.utils.NamingManager.keywordGet; +import static io.papermc.generator.utils.NamingManager.keywordGetSet; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class CraftBlockDataGenerator extends OverriddenClassGenerator { + + private final Class blockClass; + private final BlockStateMapping.BlockData blockData; + + protected CraftBlockDataGenerator(Class blockClass, BlockStateMapping.BlockData blockData, Class baseClass) { + super(baseClass, blockData.implName(), Types.BASE_PACKAGE + ".block.impl"); + this.blockClass = blockClass; + this.blockData = blockData; + this.printWarningOnMissingOverride = true; + } + + // default keywords: get/set + // for single boolean property: get = is + // for indexed boolean property: get = has + private static final Map, NamingManager.AccessKeyword> FLUENT_KEYWORD = ImmutableMap., NamingManager.AccessKeyword>builder() + .put(BlockStateProperties.ATTACH_FACE, keywordGetSet("getAttached", "setAttached")) // todo remove this once switch methods are gone + .put(BlockStateProperties.EYE, keywordGet("has")) + .put(BlockStateProperties.BERRIES, keywordGet("has")) // spigot method rename + // data holder keywords is only needed for the first property they hold + .put(ChiseledBookShelfBlock.SLOT_OCCUPIED_PROPERTIES.getFirst(), keywordGet("is")) + .buildOrThrow(); + + private static final Map, BiConsumer> SETTER_PRECONDITIONS = Map.of( + BlockStateProperties.FACING, (param, method) -> { + method.addStatement("$T.checkArgument($N.isCartesian(), $S)", Preconditions.class, param, "Invalid face, only cartesian face are allowed for this property!"); + }, + BlockStateProperties.HORIZONTAL_FACING, (param, method) -> { + method.addStatement("$1T.checkArgument($2N.isCartesian() && $2N.getModY() == 0, $3S)", Preconditions.class, param, "Invalid face, only cartesian horizontal face are allowed for this property!"); + }, + BlockStateProperties.FACING_HOPPER, (param, method) -> { + method.addStatement("$1T.checkArgument($2N.isCartesian() && $2N != $3T.UP, $4S)", Preconditions.class, param, BlockFace.class, "Invalid face, only cartesian face (excluding UP) are allowed for this property!"); + }, + BlockStateProperties.VERTICAL_DIRECTION, (param, method) -> { + method.addStatement("$T.checkArgument($N.getModY() != 0, $S)", Preconditions.class, param, "Invalid face, only vertical face are allowed for this property!"); + }, + BlockStateProperties.ROTATION_16, (param, method) -> { + method.addStatement("$1T.checkArgument($2N != $3T.SELF && $2N.getModY() == 0, $4S)", Preconditions.class, param, BlockFace.class, "Invalid face, only horizontal face are allowed for this property!"); + }, + BlockStateProperties.HORIZONTAL_AXIS, (param, method) -> { + method.addStatement("$1T.checkArgument($2N == $3T.X || $2N == $3T.Z, $4S)", Preconditions.class, param, Axis.class, "Invalid axis, only horizontal axis are allowed for this property!"); + }, + BlockStateProperties.RAIL_SHAPE_STRAIGHT, (param, method) -> { + method.addStatement("$1T.checkArgument($2N != $3T.NORTH_EAST && $2N != $3T.NORTH_WEST && $2N != $3T.SOUTH_EAST && $2N != $3T.SOUTH_WEST, $4S)", Preconditions.class, param, Rail.Shape.class, "Invalid rail shape, only straight rail are allowed for this property!"); + } + ); + + private TypeSpec.Builder propertyHolder() { + TypeSpec.Builder typeBuilder = TypeSpec.classBuilder(this.className) + .addModifiers(PUBLIC) + .addAnnotation(Annotations.GENERATED_FROM) + .superclass(Types.CRAFT_BLOCK_DATA) + .addSuperinterface(this.baseClass); + + ParameterSpec parameter = ParameterSpec.builder(BlockState.class, "state").build(); + MethodSpec constructor = MethodSpec.constructorBuilder() + .addModifiers(PUBLIC) + .addParameter(parameter) + .addStatement("super($N)", parameter) + .build(); + + typeBuilder.addMethod(constructor); + return typeBuilder; + } + + @Override + protected TypeSpec getTypeSpec() { + TypeSpec.Builder typeBuilder = this.propertyHolder(); + + for (Property property : this.blockData.properties()) { + Pair, String> fieldName = PropertyWriter.referenceFieldFromVar(this.blockClass, property, this.blockData.propertyFields()); + + PropertyMaker propertyMaker = PropertyMaker.make(property); + + final String varName; + if (this.blockData.propertyFields().containsKey(property)) { + // get the name from the local class or fallback to the generic BlockStateProperties constant name if not found + varName = this.blockData.propertyFields().get(property).getName(); + } else { + varName = fieldName.right(); + } + + FieldSpec.Builder fieldBuilder = FieldSpec.builder(propertyMaker.getPropertyType(), varName, PRIVATE, STATIC, FINAL) + .initializer("$T.$L", fieldName.left(), fieldName.right()); + FieldSpec field = fieldBuilder.build(); + + typeBuilder.addField(field); + + ConverterBase converter = Converters.getOrDefault(property, propertyMaker); + Class apiClass = converter.getApiType(); + + NamingManager.AccessKeyword accessKeyword = null; + if (apiClass == Boolean.TYPE) { + accessKeyword = keywordGet("is"); + } + accessKeyword = FLUENT_KEYWORD.getOrDefault(property, accessKeyword); + NamingManager propertyNaming = new NamingManager(accessKeyword, CaseFormat.LOWER_UNDERSCORE, property.getName()); + + // get + { + MethodSpec.Builder methodBuilder = createMethod(propertyNaming.simpleGetterName(name -> !name.startsWith("is_") && !name.startsWith("has_"))); + converter.convertGetter(methodBuilder, field); + methodBuilder.returns(apiClass); + + typeBuilder.addMethod(methodBuilder.build()); + } + + // set + { + String paramName = propertyNaming.paramName(apiClass); + ParameterSpec parameter = ParameterSpec.builder(apiClass, paramName, FINAL).build(); + + MethodSpec.Builder methodBuilder = createMethod(propertyNaming.simpleSetterName(name -> !name.startsWith("is_")), apiClass).addParameter(parameter); + if (!apiClass.isPrimitive()) { + methodBuilder.addStatement("$T.checkArgument($N != null, $S)", Preconditions.class, parameter, "%s cannot be null!".formatted(paramName)); + } + if (SETTER_PRECONDITIONS.containsKey(property)) { + SETTER_PRECONDITIONS.get(property).accept(parameter, methodBuilder); + } + converter.convertSetter(methodBuilder, field, parameter); + + typeBuilder.addMethod(methodBuilder.build()); + } + + // extra + propertyMaker.addExtras(typeBuilder, field, this, propertyNaming); + } + + for (Map.Entry, Collection>> complexFields : this.blockData.complexPropertyFields().asMap().entrySet()) { + Either fieldData = complexFields.getKey(); + Collection> properties = complexFields.getValue(); + Property firstProperty = properties.iterator().next(); + + PropertyMaker propertyMaker = PropertyMaker.make(firstProperty); + ConverterBase propertyConverter = Converters.getOrDefault(firstProperty, propertyMaker); + + DataPropertyMaker dataPropertyMaker = DataPropertyMaker.make(properties, this.blockClass, fieldData); + + FieldSpec field = dataPropertyMaker.getOrCreateField(this.blockData.propertyFields()).build(); + typeBuilder.addField(field); + + DataConverter converter = DataConverters.getOrThrow(dataPropertyMaker.getType()); + Class apiClass = propertyConverter.getApiType(); + + NamingManager.AccessKeyword accessKeyword = null; + if (apiClass == Boolean.TYPE) { + accessKeyword = NamingManager.keywordGet("has"); + } + accessKeyword = FLUENT_KEYWORD.getOrDefault(firstProperty, accessKeyword); + NamingManager baseNaming = new NamingManager(accessKeyword, CaseFormat.UPPER_UNDERSCORE, dataPropertyMaker.getBaseName()); + + ParameterSpec indexParameter = ParameterSpec.builder(dataPropertyMaker.getIndexClass(), dataPropertyMaker.getIndexClass() == Integer.TYPE ? CommonVariable.INDEX : baseNaming.paramName(dataPropertyMaker.getIndexClass()), FINAL).build(); + + // get + { + MethodSpec.Builder methodBuilder = createMethod(baseNaming.simpleGetterName(name -> true), dataPropertyMaker.getIndexClass()) + .addParameter(indexParameter); + if (!dataPropertyMaker.getIndexClass().isPrimitive()) { + methodBuilder.addStatement("$T.checkArgument($N != null, $S)", Preconditions.class, indexParameter, "%s cannot be null!".formatted(indexParameter.name)); + } + converter.convertGetter(propertyConverter, methodBuilder, field, indexParameter); + methodBuilder.returns(apiClass); + + typeBuilder.addMethod(methodBuilder.build()); + } + + // set + { + String paramName = baseNaming.paramName(apiClass); + ParameterSpec parameter = ParameterSpec.builder(apiClass, paramName, FINAL).build(); + + MethodSpec.Builder methodBuilder = createMethod(baseNaming.simpleSetterName(name -> true), dataPropertyMaker.getIndexClass(), apiClass) + .addParameter(indexParameter) + .addParameter(parameter); + if (!dataPropertyMaker.getIndexClass().isPrimitive()) { + methodBuilder.addStatement("$T.checkArgument($N != null, $S)", Preconditions.class, indexParameter, "%s cannot be null!".formatted(indexParameter.name)); + } + if (!apiClass.isPrimitive()) { + methodBuilder.addStatement("$T.checkArgument($N != null, $S)", Preconditions.class, parameter, "%s cannot be null!".formatted(paramName)); + } + if (SETTER_PRECONDITIONS.containsKey(firstProperty)) { + SETTER_PRECONDITIONS.get(firstProperty).accept(parameter, methodBuilder); + } + converter.convertSetter(propertyConverter, methodBuilder, field, indexParameter, parameter); + + typeBuilder.addMethod(methodBuilder.build()); + } + + // extra + dataPropertyMaker.addExtras(typeBuilder, field, indexParameter, propertyConverter, this, baseNaming); + } + + return typeBuilder.build(); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/EnumPropertyWriter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/EnumPropertyWriter.java new file mode 100644 index 000000000..9c38001d0 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/EnumPropertyWriter.java @@ -0,0 +1,46 @@ +package io.papermc.generator.types.craftblockdata.property; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import io.papermc.generator.utils.BlockStateMapping; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class EnumPropertyWriter & StringRepresentable> extends PropertyWriter { + + protected EnumPropertyWriter(EnumProperty property) { + super(property); + } + + @Override + public TypeName getPropertyType() { + if (this.property.getClass() == EnumProperty.class) { // exact match + return ParameterizedTypeName.get(this.property.getClass(), this.property.getValueClass()); + } + return super.getPropertyType(); + } + + @Override + protected Class processApiType() { + Class apiClass = this.property.getValueClass(); + apiClass = BlockStateMapping.ENUM_BRIDGE.get(apiClass); + if (apiClass == null) { + throw new IllegalStateException("Unknown enum type for " + this.property); + } + return apiClass; + } + + @Override + public void convertGetter(MethodSpec.Builder method, FieldSpec field) { + method.addStatement("return " + this.rawGetExprent().formatted("$N"), field, this.getApiType()); + } + + @Override + public String rawGetExprent() { + return "this.get(%s, $T.class)"; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/IntegerPropertyWriter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/IntegerPropertyWriter.java new file mode 100644 index 000000000..5d5fb8c8b --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/IntegerPropertyWriter.java @@ -0,0 +1,44 @@ +package io.papermc.generator.types.craftblockdata.property; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.Converters; +import io.papermc.generator.utils.NamingManager; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class IntegerPropertyWriter extends PropertyWriter { + + protected IntegerPropertyWriter(IntegerProperty property) { + super(property); + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, CraftBlockDataGenerator generator, NamingManager naming) { + if (Converters.has(this.property)) { + return; + } + + IntegerProperty property = (IntegerProperty) this.property; + + if (property.min != 0 || property.getName().equals(BlockStateProperties.LEVEL.getName())) { // special case (levelled: composter) + MethodSpec.Builder methodBuilder = generator.createMethod(naming.getterName(name -> true).pre("Minimum").concat()); + methodBuilder.addStatement("return $N.min", field); + methodBuilder.returns(this.getApiType()); + + builder.addMethod(methodBuilder.build()); + } + + { + MethodSpec.Builder methodBuilder = generator.createMethod(naming.getterName(name -> true).pre("Maximum").concat()); + methodBuilder.addStatement("return $N.max", field); + methodBuilder.returns(this.getApiType()); + + builder.addMethod(methodBuilder.build()); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyMaker.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyMaker.java new file mode 100644 index 000000000..0560e19f0 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyMaker.java @@ -0,0 +1,25 @@ +package io.papermc.generator.types.craftblockdata.property; + +import com.squareup.javapoet.TypeName; +import io.papermc.generator.types.craftblockdata.property.appender.AppenderBase; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface PropertyMaker extends ConverterBase, AppenderBase { + + TypeName getPropertyType(); + + static > PropertyMaker make(Property property) { + if (property instanceof IntegerProperty intProperty) { + return new IntegerPropertyWriter(intProperty); + } + if (property instanceof EnumProperty enumProperty) { + return new EnumPropertyWriter<>(enumProperty); + } + return new PropertyWriter<>(property); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyWriter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyWriter.java new file mode 100644 index 000000000..60c93f27a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/PropertyWriter.java @@ -0,0 +1,88 @@ +package io.papermc.generator.types.craftblockdata.property; + +import com.google.common.base.Suppliers; +import com.google.common.primitives.Primitives; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.TypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.appender.PropertyAppenders; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.generator.utils.NamingManager; +import it.unimi.dsi.fastutil.Pair; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Map; +import java.util.function.Supplier; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class PropertyWriter> implements PropertyMaker { + + protected final Property property; + private final Supplier> apiClassSupplier; + + protected PropertyWriter(Property property) { + this.property = property; + this.apiClassSupplier = Suppliers.memoize(this::processApiType); + } + + @Override + public TypeName getPropertyType() { + return TypeName.get(this.property.getClass()); + } + + protected Class processApiType() { + Class apiClass = this.property.getValueClass(); + if (Primitives.isWrapperType(apiClass)) { + apiClass = Primitives.unwrap(apiClass); + } + return apiClass; + } + + @Override + public Class getApiType() { + return this.apiClassSupplier.get(); + } + + @Override + public String rawSetExprent() { + return "this.set(%s, $N)"; + } + + @Override + public String rawGetExprent() { + return "this.get(%s)"; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, CraftBlockDataGenerator generator, NamingManager naming) { + PropertyAppenders.ifPresent(this.property, appender -> appender.addExtras(builder, field, generator, naming)); + } + + public static Pair, String> referenceField(Class from, Property property, Map, Field> fields) { + Class fieldAccess = from; + Field field = fields.get(property); + if (field == null || !Modifier.isPublic(field.getModifiers())) { + fieldAccess = BlockStateProperties.class; + field = BlockStateMapping.FALLBACK_GENERIC_FIELDS.get(property); + } + return Pair.of(fieldAccess, field.getName()); + } + + public static Pair, String> referenceFieldFromVar(Class from, Property property, Map, Field> fields) { + Class fieldAccess = from; + Field field = fields.get(property); + Field genericField = BlockStateMapping.FALLBACK_GENERIC_FIELDS.get(property); + if (field == null || !Modifier.isPublic(field.getModifiers()) || !genericField.getType().equals(field.getType())) { + // field type can differ from BlockStateProperties constants (that's the case for the shulker box (#FACING) and the vault (#STATE)) ref: 1.20.5 + // in that case fallback to the more accurate type to avoid compile error + fieldAccess = BlockStateProperties.class; + field = genericField; + } + return Pair.of(fieldAccess, field.getName()); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/AppenderBase.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/AppenderBase.java new file mode 100644 index 000000000..b1e149e75 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/AppenderBase.java @@ -0,0 +1,13 @@ +package io.papermc.generator.types.craftblockdata.property.appender; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.utils.NamingManager; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface AppenderBase { + + void addExtras(TypeSpec.Builder builder, FieldSpec field, CraftBlockDataGenerator generator, NamingManager naming); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/EnumValuesAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/EnumValuesAppender.java new file mode 100644 index 000000000..0898c3747 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/EnumValuesAppender.java @@ -0,0 +1,45 @@ +package io.papermc.generator.types.craftblockdata.property.appender; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.utils.NamingManager; +import java.util.Set; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class EnumValuesAppender & StringRepresentable, A extends Enum> implements PropertyAppender { + + private final EnumProperty property; + private final Class apiType; + private final String methodName; + + public EnumValuesAppender(EnumProperty property, Class apiType, String methodName) { + this.property = property; + this.apiType = apiType; + this.methodName = methodName; + } + + @Override + public EnumProperty getProperty() { + return this.property; + } + + @Override + public Class getApiType() { + return this.apiType; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, CraftBlockDataGenerator generator, NamingManager naming) { + MethodSpec.Builder methodBuilder = generator.createMethod(this.methodName); + methodBuilder.addStatement("return this.getValues($N, $T.class)", field, this.apiType); + methodBuilder.returns(ParameterizedTypeName.get(Set.class, this.apiType)); + + builder.addMethod(methodBuilder.build()); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppender.java new file mode 100644 index 000000000..63bc0dbd2 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppender.java @@ -0,0 +1,12 @@ +package io.papermc.generator.types.craftblockdata.property.appender; + +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface PropertyAppender, A> extends AppenderBase { + + Property getProperty(); + + Class getApiType(); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppenders.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppenders.java new file mode 100644 index 000000000..9ddfe158c --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/appender/PropertyAppenders.java @@ -0,0 +1,33 @@ +package io.papermc.generator.types.craftblockdata.property.appender; + +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.Property; +import org.bukkit.Axis; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Rail; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class PropertyAppenders { + + private static final Map, AppenderBase> APPENDERS = Stream.of( + new EnumValuesAppender<>(BlockStateProperties.AXIS, Axis.class, "getAxes"), + new EnumValuesAppender<>(BlockStateProperties.HORIZONTAL_AXIS, Axis.class, "getAxes"), + new EnumValuesAppender<>(BlockStateProperties.FACING, BlockFace.class, "getFaces"), + new EnumValuesAppender<>(BlockStateProperties.HORIZONTAL_FACING, BlockFace.class, "getFaces"), + new EnumValuesAppender<>(BlockStateProperties.FACING_HOPPER, BlockFace.class, "getFaces"), + new EnumValuesAppender<>(BlockStateProperties.RAIL_SHAPE, Rail.Shape.class, "getShapes"), + new EnumValuesAppender<>(BlockStateProperties.RAIL_SHAPE_STRAIGHT, Rail.Shape.class, "getShapes"), + new EnumValuesAppender<>(BlockStateProperties.VERTICAL_DIRECTION, BlockFace.class, "getVerticalDirections") + ).collect(Collectors.toUnmodifiableMap(PropertyAppender::getProperty, key -> key)); + + public static void ifPresent(Property property, Consumer callback) { + if (APPENDERS.containsKey(property)) { + callback.accept(APPENDERS.get(property)); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converter.java new file mode 100644 index 000000000..f4c3205c8 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converter.java @@ -0,0 +1,13 @@ +package io.papermc.generator.types.craftblockdata.property.converter; + +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface Converter, A> extends ConverterBase { + + Property getProperty(); + + @Override + Class getApiType(); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/ConverterBase.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/ConverterBase.java new file mode 100644 index 000000000..cbe2e0f59 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/ConverterBase.java @@ -0,0 +1,24 @@ +package io.papermc.generator.types.craftblockdata.property.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface ConverterBase { + + Class getApiType(); + + default void convertSetter(MethodSpec.Builder method, FieldSpec field, ParameterSpec parameter) { + method.addStatement(this.rawSetExprent().formatted("$N"), field, parameter); + } + + String rawSetExprent(); // this go on two layers which can be hard to follow refactor? + + default void convertGetter(MethodSpec.Builder method, FieldSpec field) { + method.addStatement("return " + this.rawGetExprent().formatted("$N"), field); + } + + String rawGetExprent(); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converters.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converters.java new file mode 100644 index 000000000..ee2f8d3d5 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/Converters.java @@ -0,0 +1,25 @@ +package io.papermc.generator.types.craftblockdata.property.converter; + +import io.papermc.generator.types.craftblockdata.property.PropertyMaker; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Converters { + + private static final Map, ConverterBase> CONVERTERS = Stream.of( + new RotationConverter(), + new NoteConverter() + ).collect(Collectors.toUnmodifiableMap(Converter::getProperty, key -> key)); + + public static ConverterBase getOrDefault(Property property, PropertyMaker maker) { + return CONVERTERS.getOrDefault(property, maker); + } + + public static boolean has(Property property) { + return CONVERTERS.containsKey(property); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/NoteConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/NoteConverter.java new file mode 100644 index 000000000..91189dd6a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/NoteConverter.java @@ -0,0 +1,37 @@ +package io.papermc.generator.types.craftblockdata.property.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.Property; +import org.bukkit.Note; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class NoteConverter implements Converter { + + @Override + public Property getProperty() { + return BlockStateProperties.NOTE; + } + + @Override + public Class getApiType() { + return Note.class; + } + + @Override + public String rawSetExprent() { + return "this.set(%s, (int) $N.getId())"; + } + + @Override + public void convertGetter(MethodSpec.Builder method, FieldSpec field) { + method.addStatement("return " + this.rawGetExprent().formatted("$N"), this.getApiType(), field); + } + + @Override + public String rawGetExprent() { + return "new $T(this.get(%s))"; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/RotationConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/RotationConverter.java new file mode 100644 index 000000000..7726efd33 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/converter/RotationConverter.java @@ -0,0 +1,45 @@ +package io.papermc.generator.types.craftblockdata.property.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.util.Vector; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class RotationConverter implements Converter { + + private static final String DIRECTION_VAR = "dir"; + private static final String ANGLE_VAR = "angle"; + + @Override + public Property getProperty() { + return BlockStateProperties.ROTATION_16; + } + + @Override + public Class getApiType() { + return BlockFace.class; + } + + @Override + public void convertSetter(MethodSpec.Builder method, FieldSpec field, ParameterSpec parameter) { + method.addStatement("$T $L = $N.getDirection()", Vector.class, DIRECTION_VAR, parameter); + method.addStatement("$1T $2L = ($1T) -$3T.toDegrees($3T.atan2($4L.getX(), $4L.getZ()))", Float.TYPE, ANGLE_VAR, Math.class, DIRECTION_VAR); + method.addStatement(this.rawSetExprent().formatted("$N", ANGLE_VAR), field, RotationSegment.class); + } + + @Override + public String rawSetExprent() { + return "this.set(%s, $T.convertToSegment(%s))"; + } + + @Override + public String rawGetExprent() { + return "CraftBlockData.ROTATION_CYCLE[this.get(%s)]"; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataHolderType.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataHolderType.java new file mode 100644 index 000000000..86a70923c --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataHolderType.java @@ -0,0 +1,7 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +public enum DataHolderType { + MAP, + LIST, + ARRAY +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyMaker.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyMaker.java new file mode 100644 index 000000000..117b2cd8a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyMaker.java @@ -0,0 +1,31 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +import com.mojang.datafixers.util.Either; +import com.squareup.javapoet.FieldSpec; +import io.papermc.generator.types.craftblockdata.property.holder.appender.DataAppender; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Map; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface DataPropertyMaker extends DataAppender { + + FieldSpec.Builder getOrCreateField(Map, Field> fields); + + Class getIndexClass(); + + @Override + DataHolderType getType(); + + String getBaseName(); + + static DataPropertyMaker make(Collection> properties, Class blockClass, Either fieldData) { + return fieldData.map( + field -> new DataPropertyWriter(field, properties, blockClass), + virtualField -> new VirtualDataPropertyWriter(virtualField, properties, blockClass) + ); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriter.java new file mode 100644 index 000000000..6b94183df --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriter.java @@ -0,0 +1,164 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.Types; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.appender.DataAppenders; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.generator.utils.ClassHelper; +import io.papermc.generator.utils.CommonVariable; +import io.papermc.generator.utils.NamingManager; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.ChiseledBookShelfBlock; +import net.minecraft.world.level.block.MossyCarpetBlock; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.state.properties.Property; +import org.bukkit.block.BlockFace; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.jspecify.annotations.NullMarked; + +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class DataPropertyWriter extends DataPropertyWriterBase { + + private record FieldKey(Class blockClass, String fieldName) { + } + + private static FieldKey key(Class blockClass, String fieldName) { + return new FieldKey(blockClass, fieldName); + } + + private static final Map FIELD_TO_BASE_NAME = Map.of( + "PROPERTY_BY_DIRECTION", "FACE" + ); + + private static final Map FIELD_TO_BASE_NAME_SPECIFICS = Map.of( + key(ChiseledBookShelfBlock.class, "SLOT_OCCUPIED_PROPERTIES"), "SLOT_OCCUPIED", + key(MossyCarpetBlock.class, "PROPERTY_BY_DIRECTION"), "HEIGHT", + key(WallBlock.class, "PROPERTY_BY_DIRECTION"), "HEIGHT" + ); + + protected final Field field; + protected @MonotonicNonNull DataHolderType type; + protected @MonotonicNonNull Class indexClass, internalIndexClass; + protected @MonotonicNonNull TypeName fieldType; + + protected DataPropertyWriter(Field field, Collection> properties, Class blockClass) { + super(properties, blockClass); + this.field = field; + this.computeTypes(field); + } + + protected void computeTypes(Field field) { + this.fieldType = TypeName.get(field.getGenericType()); + + if (field.getType().isArray()) { + this.type = DataHolderType.ARRAY; + this.indexClass = Integer.TYPE; + } else if (List.class.isAssignableFrom(field.getType())) { + this.type = DataHolderType.LIST; + this.indexClass = Integer.TYPE; + } else if (Map.class.isAssignableFrom(field.getType()) && field.getGenericType() instanceof ParameterizedType complexType) { + this.type = DataHolderType.MAP; + this.internalIndexClass = ClassHelper.eraseType(complexType.getActualTypeArguments()[0]); + if (this.internalIndexClass.isEnum()) { + this.indexClass = BlockStateMapping.ENUM_BRIDGE.getOrDefault(this.internalIndexClass, (Class>) this.internalIndexClass); + this.fieldType = ParameterizedTypeName.get( + ClassName.get(field.getType()), + ClassName.get(this.indexClass), + ClassName.get(complexType.getActualTypeArguments()[1]) + ); + } else { + this.indexClass = this.internalIndexClass; + } + } else { + throw new IllegalStateException("Don't know how to turn " + field + " into api"); + } + } + + @Override + public FieldSpec.Builder getOrCreateField(Map, Field> fields) { + FieldSpec.Builder fieldBuilder = FieldSpec.builder(this.fieldType, this.field.getName(), PRIVATE, STATIC, FINAL); + if (Modifier.isPublic(this.field.getModifiers())) { + // accessible phew + if (this.type == DataHolderType.MAP && + this.internalIndexClass == Direction.class && this.indexClass == BlockFace.class) { // Direction -> BlockFace + // convert the key manually only this one is needed for now + fieldBuilder.initializer("$[$1T.$2L.entrySet().stream()\n.collect($3T.toMap($4L -> $5T.notchToBlockFace($4L.getKey()), $4L -> $4L.getValue()))$]", + this.blockClass, this.field.getName(), Collectors.class, CommonVariable.MAP_ENTRY, Types.CRAFT_BLOCK); + } else { + fieldBuilder.initializer("$T.$L", this.blockClass, this.field.getName()); + } + } else { + if (this.type == DataHolderType.ARRAY || this.type == DataHolderType.LIST) { + CodeBlock.Builder code = CodeBlock.builder(); + this.createSyntheticCollection(code, this.type == DataHolderType.ARRAY, fields); + fieldBuilder.initializer(code.build()); + } else if (this.type == DataHolderType.MAP) { + CodeBlock.Builder code = CodeBlock.builder(); + this.createSyntheticMap(code, this.indexClass, fields); + fieldBuilder.initializer(code.build()); + } + } + return fieldBuilder; + } + + @Override + public Class getIndexClass() { + return this.indexClass; + } + + @Override + public DataHolderType getType() { + return this.type; + } + + @Override + public String getBaseName() { + String constantName = this.field.getName(); + + FieldKey key = key(this.blockClass, constantName); + if (FIELD_TO_BASE_NAME_SPECIFICS.containsKey(key)) { + return FIELD_TO_BASE_NAME_SPECIFICS.get(key); + } + + if (FIELD_TO_BASE_NAME.containsKey(constantName)) { + return FIELD_TO_BASE_NAME.get(constantName); + } + return stripFieldAccessKeyword(constantName); + } + + private static final List CUSTOM_KEYWORD = List.of("HAS", "IS", "CAN"); + + private String stripFieldAccessKeyword(String name) { + for (String keyword : CUSTOM_KEYWORD) { + if (name.startsWith(keyword + "_")) { + return name.substring(keyword.length() + 1); + } + } + return name; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase childConverter, CraftBlockDataGenerator generator, NamingManager baseNaming) { + DataAppenders.ifPresent(this.type, appender -> appender.addExtras(builder, field, indexParameter, childConverter, generator, baseNaming)); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriterBase.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriterBase.java new file mode 100644 index 000000000..ef6aa9762 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/DataPropertyWriterBase.java @@ -0,0 +1,66 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +import com.squareup.javapoet.CodeBlock; +import io.papermc.generator.types.craftblockdata.property.PropertyWriter; +import io.papermc.generator.utils.Formatting; +import it.unimi.dsi.fastutil.Pair; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.Property; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public abstract class DataPropertyWriterBase implements DataPropertyMaker { + + protected final Collection> properties; + protected final Class blockClass; + + protected DataPropertyWriterBase(Collection> properties, Class blockClass) { + this.properties = properties; + this.blockClass = blockClass; + } + + protected void createSyntheticCollection(CodeBlock.Builder code, boolean isArray, Map, Field> fields) { + if (isArray) { + code.add("{\n"); + } else { + code.add("$T.of(\n", List.class); + } + code.indent(); + Iterator> it = this.properties.iterator(); + while (it.hasNext()) { + Property property = it.next(); + Pair, String> fieldName = PropertyWriter.referenceField(this.blockClass, property, fields); + code.add("$T.$L", fieldName.left(), fieldName.right()); + if (it.hasNext()) { + code.add(","); + } + code.add("\n"); + } + code.unindent().add(isArray ? "}" : ")"); + } + + protected void createSyntheticMap(CodeBlock.Builder code, Class indexClass, Map, Field> fields) { + // assume indexClass is an enum with its values matching the property names + code.add("$T.of(\n", Map.class).indent(); + Iterator> it = this.properties.iterator(); + while (it.hasNext()) { + Property property = it.next(); + String name = Formatting.formatKeyAsField(property.getName()); + Pair, String> fieldName = PropertyWriter.referenceField(this.blockClass, property, fields); + code.add("$T.$L, $T.$L", indexClass, name, fieldName.left(), fieldName.right()); + if (it.hasNext()) { + code.add(","); + } + code.add("\n"); + } + code.unindent().add(")"); + } + + @Override + public abstract Class getIndexClass(); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualDataPropertyWriter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualDataPropertyWriter.java new file mode 100644 index 000000000..d68d36920 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualDataPropertyWriter.java @@ -0,0 +1,99 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +import com.squareup.javapoet.ArrayTypeName; +import com.squareup.javapoet.CodeBlock; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.utils.BlockStateMapping; +import io.papermc.generator.utils.NamingManager; +import java.lang.reflect.Field; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.properties.Property; +import org.checkerframework.checker.nullness.qual.MonotonicNonNull; +import org.jspecify.annotations.NullMarked; + +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class VirtualDataPropertyWriter extends DataPropertyWriterBase { + + private final VirtualField virtualField; + protected @MonotonicNonNull Class indexClass; + protected @MonotonicNonNull TypeName fieldType; + + protected VirtualDataPropertyWriter(VirtualField virtualField, Collection> properties, Class blockClass) { + super(properties, blockClass); + this.virtualField = virtualField; + this.computeTypes(virtualField); + } + + protected void computeTypes(VirtualField virtualField) { + switch (virtualField.holderType()) { + case ARRAY -> { + this.indexClass = Integer.TYPE; + this.fieldType = ArrayTypeName.of(virtualField.valueType()); + } + case LIST -> { + this.indexClass = Integer.TYPE; + this.fieldType = ParameterizedTypeName.get(List.class, virtualField.valueType()); + } + case MAP -> { + if (virtualField.keyClass() != null) { + this.indexClass = virtualField.keyClass(); + } else { + this.indexClass = this.properties.iterator().next().getValueClass(); + if (this.indexClass.isEnum()) { + this.indexClass = BlockStateMapping.ENUM_BRIDGE.getOrDefault(this.indexClass, (Class>) this.indexClass); + } + } + this.fieldType = ParameterizedTypeName.get(Map.class, this.indexClass, virtualField.valueType()); + } + } + } + + @Override + public FieldSpec.Builder getOrCreateField(Map, Field> fields) { + FieldSpec.Builder fieldBuilder = FieldSpec.builder(this.fieldType, this.virtualField.name(), PRIVATE, STATIC, FINAL); + if (this.getType() == DataHolderType.ARRAY || this.getType() == DataHolderType.LIST) { + CodeBlock.Builder code = CodeBlock.builder(); + this.createSyntheticCollection(code, this.getType() == DataHolderType.ARRAY, fields); + fieldBuilder.initializer(code.build()); + } else if (this.getType() == DataHolderType.MAP) { + CodeBlock.Builder code = CodeBlock.builder(); + this.createSyntheticMap(code, this.indexClass, fields); + fieldBuilder.initializer(code.build()); + } + + return fieldBuilder; + } + + @Override + public Class getIndexClass() { + return this.indexClass; + } + + @Override + public DataHolderType getType() { + return this.virtualField.holderType(); + } + + @Override + public String getBaseName() { + return this.virtualField.baseName(); + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase converter, CraftBlockDataGenerator generator, NamingManager baseNaming) { + + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualField.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualField.java new file mode 100644 index 000000000..26245f80d --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/VirtualField.java @@ -0,0 +1,72 @@ +package io.papermc.generator.types.craftblockdata.property.holder; + +import com.google.common.base.Preconditions; +import com.google.common.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import net.minecraft.world.level.block.state.properties.Property; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public record VirtualField( + String name, + Type valueType, + DataHolderType holderType, + String baseName, + @Nullable Class keyClass, + Collection> values +) { + + @Contract(value = "_, _, _, _ -> new", pure = true) + public static >> VirtualField.FieldValue createCollection(String name, TypeToken valueType, boolean isArray, String baseName) { + return new VirtualField.FieldValue<>(name, valueType, isArray ? DataHolderType.ARRAY : DataHolderType.LIST, baseName, null); + } + + @Contract(value = "_, _, _, _ -> new", pure = true) + public static >> VirtualField.FieldValue createCollection(String name, Class valueType, boolean isArray, String baseName) { + return createCollection(name, TypeToken.of(valueType), isArray, baseName); + } + + @Contract(value = "_, _, _, _ -> new", pure = true) + public static >> VirtualField.FieldValue createMap(String name, Class keyClass, TypeToken valueType, String baseName) { + return new VirtualField.FieldValue<>(name, valueType, DataHolderType.MAP, baseName, keyClass); + } + + @Contract(value = "_, _, _, _ -> new", pure = true) + public static >> VirtualField.FieldValue createMap(String name, Class keyClass, Class valueType, String baseName) { + return createMap(name, keyClass, TypeToken.of(valueType), baseName); + } + + public static class FieldValue>> { + + private final String name; + private final DataHolderType holderType; + private final TypeToken valueTypeToken; + private final String baseName; + private final @Nullable Class keyClass; + + private @Nullable Collection values; + + public FieldValue(String name, TypeToken valueTypeToken, DataHolderType holderType, String baseName, @Nullable Class keyClass) { + this.name = name; + this.valueTypeToken = valueTypeToken; + this.holderType = holderType; + this.baseName = baseName; + this.keyClass = keyClass; + } + + @Contract(value = "_ -> this", mutates = "this") + public FieldValue withValues(Collection properties) { + this.values = List.copyOf(properties); + return this; + } + + public VirtualField make() { + Preconditions.checkState(this.values != null && !this.values.isEmpty(), "The field should doesn't have any content"); + return new VirtualField(this.name, this.valueTypeToken.getType(), this.holderType, this.baseName, this.keyClass, this.values); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ArrayAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ArrayAppender.java new file mode 100644 index 000000000..578af077f --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ArrayAppender.java @@ -0,0 +1,54 @@ +package io.papermc.generator.types.craftblockdata.property.holder.appender; + +import com.google.common.collect.ImmutableSet; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import io.papermc.generator.utils.CommonVariable; +import io.papermc.generator.utils.NamingManager; +import java.util.Set; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class ArrayAppender implements DataAppender { + + @Override + public DataHolderType getType() { + return DataHolderType.ARRAY; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase childConverter, CraftBlockDataGenerator generator, NamingManager baseNaming) { + if (childConverter.getApiType() == Boolean.TYPE) { + String collectVarName = baseNaming.getVariableNameWrapper().post("s").concat(); + MethodSpec.Builder methodBuilder = generator.createMethod(baseNaming.getMethodNameWrapper().post("s").concat()); + methodBuilder.addStatement("$T $L = $T.builder()", ParameterizedTypeName.get(ImmutableSet.Builder.class, Integer.class), collectVarName, ImmutableSet.class); + methodBuilder.beginControlFlow("for (int $1L = 0, len = $2N.length; $1L < len; $1L++)", CommonVariable.INDEX, field); + { + methodBuilder.beginControlFlow("if (" + childConverter.rawGetExprent().formatted("$N[$N]") + ")", field, indexParameter); + { + methodBuilder.addStatement("$L.add($L)", collectVarName, CommonVariable.INDEX); + } + methodBuilder.endControlFlow(); + } + methodBuilder.endControlFlow(); + methodBuilder.addStatement("return $L.build()", collectVarName); + methodBuilder.returns(ParameterizedTypeName.get(Set.class, Integer.class)); + + builder.addMethod(methodBuilder.build()); + } + + { + MethodSpec.Builder methodBuilder = generator.createMethod(baseNaming.getMethodNameWrapper().pre("Maximum").post("s").concat()); + methodBuilder.addStatement("return $N.length", field); + methodBuilder.returns(Integer.TYPE); + + builder.addMethod(methodBuilder.build()); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppender.java new file mode 100644 index 000000000..9f97a383a --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppender.java @@ -0,0 +1,18 @@ +package io.papermc.generator.types.craftblockdata.property.holder.appender; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import io.papermc.generator.utils.NamingManager; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface DataAppender { + + DataHolderType getType(); + + void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase converter, CraftBlockDataGenerator generator, NamingManager baseNaming); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppenders.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppenders.java new file mode 100644 index 000000000..fb484ff56 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/DataAppenders.java @@ -0,0 +1,24 @@ +package io.papermc.generator.types.craftblockdata.property.holder.appender; + +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class DataAppenders { + + private static final Map APPENDERS = Stream.of( + new ArrayAppender(), + new ListAppender(), + new MapAppender() + ).collect(Collectors.toUnmodifiableMap(DataAppender::getType, key -> key)); + + public static void ifPresent(DataHolderType type, Consumer callback) { + if (APPENDERS.containsKey(type)) { + callback.accept(APPENDERS.get(type)); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ListAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ListAppender.java new file mode 100644 index 000000000..850e44a33 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/ListAppender.java @@ -0,0 +1,61 @@ +package io.papermc.generator.types.craftblockdata.property.holder.appender; + +import com.google.common.collect.ImmutableSet; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import io.papermc.generator.utils.CommonVariable; +import io.papermc.generator.utils.NamingManager; +import java.util.Map; +import java.util.Set; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class ListAppender implements DataAppender { + + private static final Map METHOD_BASE_RENAMES = Map.of( + "SlotOccupied", "OccupiedSlot" + ); + + @Override + public DataHolderType getType() { + return DataHolderType.LIST; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase childConverter, CraftBlockDataGenerator generator, NamingManager baseNaming) { + NamingManager.NameWrapper methodName = NamingManager.NameWrapper.wrap("get", METHOD_BASE_RENAMES.getOrDefault(baseNaming.getMethodBaseName(), baseNaming.getMethodBaseName())); + + if (childConverter.getApiType() == Boolean.TYPE) { + String collectVarName = baseNaming.getVariableNameWrapper().post("s").concat(); + MethodSpec.Builder methodBuilder = generator.createMethod(methodName.post("s").concat()); + methodBuilder.addStatement("$T $L = $T.builder()", ParameterizedTypeName.get(ImmutableSet.Builder.class, Integer.class), collectVarName, ImmutableSet.class); + methodBuilder.beginControlFlow("for (int $1L = 0, size = $2N.size(); $1L < size; $1L++)", CommonVariable.INDEX, field); + { + methodBuilder.beginControlFlow("if (" + childConverter.rawGetExprent().formatted("$N.get($N)") + ")", field, indexParameter); + { + methodBuilder.addStatement("$L.add($L)", collectVarName, CommonVariable.INDEX); + } + methodBuilder.endControlFlow(); + } + methodBuilder.endControlFlow(); + methodBuilder.addStatement("return $L.build()", collectVarName); + methodBuilder.returns(ParameterizedTypeName.get(Set.class, Integer.class)); + + builder.addMethod(methodBuilder.build()); + } + + { + MethodSpec.Builder methodBuilder = generator.createMethod(methodName.pre("Maximum").post("s").concat()); + methodBuilder.addStatement("return $N.size()", field); + methodBuilder.returns(Integer.TYPE); + + builder.addMethod(methodBuilder.build()); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/MapAppender.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/MapAppender.java new file mode 100644 index 000000000..e643dd231 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/appender/MapAppender.java @@ -0,0 +1,85 @@ +package io.papermc.generator.types.craftblockdata.property.holder.appender; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.squareup.javapoet.ClassName; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.types.craftblockdata.CraftBlockDataGenerator; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import io.papermc.generator.utils.CommonVariable; +import io.papermc.generator.utils.NamingManager; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.block.data.type.RedstoneWire; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class MapAppender implements DataAppender { + + private static final Map INDEX_NAMES = ImmutableMap.builder() + .put(BlockFace.class.getSimpleName(), "Face") + .buildOrThrow(); + + // no real rule here some has some don't mossy carpet and wall could have it + private static final Set> HAS_ALLOWED_METHOD = Set.of( + MultipleFacing.class, + RedstoneWire.class + ); + + private static boolean supportsExtraMethod(Class clazz) { + for (Class supported : HAS_ALLOWED_METHOD) { + if (supported.isAssignableFrom(clazz)) { + return true; + } + } + return false; + } + + @Override + public DataHolderType getType() { + return DataHolderType.MAP; + } + + @Override + public void addExtras(TypeSpec.Builder builder, FieldSpec field, ParameterSpec indexParameter, ConverterBase childConverter, CraftBlockDataGenerator generator, NamingManager baseNaming) { + if (childConverter.getApiType() == Boolean.TYPE) { + String collectVarName = baseNaming.getVariableNameWrapper().post("s").concat(); + MethodSpec.Builder methodBuilder = generator.createMethod(baseNaming.getMethodNameWrapper().post("s").concat()); + methodBuilder.addStatement("$T $L = $T.builder()", ParameterizedTypeName.get(ClassName.get(ImmutableSet.Builder.class), indexParameter.type), collectVarName, ImmutableSet.class); + methodBuilder.beginControlFlow("for ($T $N : $N.entrySet())", ParameterizedTypeName.get(ClassName.get(Map.Entry.class), indexParameter.type, ClassName.get(BooleanProperty.class)), CommonVariable.MAP_ENTRY, field); + { + methodBuilder.beginControlFlow("if (" + childConverter.rawGetExprent().formatted("$L.getValue()") + ")", CommonVariable.MAP_ENTRY); + { + methodBuilder.addStatement("$L.add($N.getKey())", collectVarName, CommonVariable.MAP_ENTRY); + } + methodBuilder.endControlFlow(); + } + methodBuilder.endControlFlow(); + methodBuilder.addStatement("return $L.build()", collectVarName); + methodBuilder.returns(ParameterizedTypeName.get(ClassName.get(Set.class), indexParameter.type)); + + builder.addMethod(methodBuilder.build()); + } + + if (supportsExtraMethod(generator.getBaseClass()) && + indexParameter.type instanceof ClassName className && !className.isPrimitive() && !className.isBoxedPrimitive()) { + NamingManager.NameWrapper indexNaming = NamingManager.NameWrapper.wrap("get", INDEX_NAMES.getOrDefault(className.simpleName(), className.simpleName())); + + MethodSpec.Builder methodBuilder = generator.createMethod(indexNaming.pre("Allowed").post("s").concat()); + methodBuilder.addStatement("return $T.unmodifiableSet($N.keySet())", Collections.class, field); + methodBuilder.returns(ParameterizedTypeName.get(ClassName.get(Set.class), className)); + + builder.addMethod(methodBuilder.build()); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ArrayConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ArrayConverter.java new file mode 100644 index 000000000..a9b943bc0 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ArrayConverter.java @@ -0,0 +1,32 @@ +package io.papermc.generator.types.craftblockdata.property.holder.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import io.papermc.generator.types.craftblockdata.property.EnumPropertyWriter; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class ArrayConverter implements DataConverter { + + @Override + public DataHolderType getType() { + return DataHolderType.ARRAY; + } + + @Override + public void convertSetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter, ParameterSpec parameter) { + method.addStatement(childConverter.rawSetExprent().formatted("$N[$N]"), field, indexParameter, parameter); + } + + @Override + public void convertGetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter) { + if (childConverter instanceof EnumPropertyWriter enumConverter) { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$N[$N]"), field, indexParameter, enumConverter.getApiType()); + } else { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$N[$N]"), field, indexParameter); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverter.java new file mode 100644 index 000000000..596eb31cc --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverter.java @@ -0,0 +1,18 @@ +package io.papermc.generator.types.craftblockdata.property.holder.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface DataConverter { + + DataHolderType getType(); + + void convertSetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter, ParameterSpec parameter); + + void convertGetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverters.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverters.java new file mode 100644 index 000000000..cfe7e37d4 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/DataConverters.java @@ -0,0 +1,25 @@ +package io.papermc.generator.types.craftblockdata.property.holder.converter; + +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class DataConverters { + + private static final Map CONVERTERS = Stream.of( + new ArrayConverter(), + new ListConverter(), + new MapConverter() + ).collect(Collectors.toUnmodifiableMap(DataConverter::getType, key -> key)); + + public static DataConverter getOrThrow(DataHolderType type) { + DataConverter converter = CONVERTERS.get(type); + if (converter == null) { + throw new IllegalStateException("Cannot handle data holder type: " + type); + } + return converter; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ListConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ListConverter.java new file mode 100644 index 000000000..157b51934 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/ListConverter.java @@ -0,0 +1,32 @@ +package io.papermc.generator.types.craftblockdata.property.holder.converter; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import io.papermc.generator.types.craftblockdata.property.EnumPropertyWriter; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class ListConverter implements DataConverter { + + @Override + public DataHolderType getType() { + return DataHolderType.LIST; + } + + @Override + public void convertSetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter, ParameterSpec parameter) { + method.addStatement(childConverter.rawSetExprent().formatted("$N.get($N)"), field, indexParameter, parameter); + } + + @Override + public void convertGetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter) { + if (childConverter instanceof EnumPropertyWriter enumConverter) { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$N.get($N)"), field, indexParameter, enumConverter.getApiType()); + } else { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$N.get($N)"), field, indexParameter); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/MapConverter.java b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/MapConverter.java new file mode 100644 index 000000000..73903ef5f --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/craftblockdata/property/holder/converter/MapConverter.java @@ -0,0 +1,45 @@ +package io.papermc.generator.types.craftblockdata.property.holder.converter; + +import com.google.common.base.Preconditions; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import io.papermc.generator.types.craftblockdata.property.EnumPropertyWriter; +import io.papermc.generator.types.craftblockdata.property.converter.ConverterBase; +import io.papermc.generator.types.craftblockdata.property.holder.DataHolderType; +import java.util.stream.Collectors; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class MapConverter implements DataConverter { + + private static final String PROPERTY_VAR = "property"; + + @Override + public DataHolderType getType() { + return DataHolderType.MAP; + } + + @Override + public void convertSetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter, ParameterSpec parameter) { + method.addStatement("$T $L = $N.get($N)", ((ParameterizedTypeName) field.type).typeArguments.get(1), PROPERTY_VAR, field, indexParameter); + method.addStatement("$T.checkArgument($N != null, $S, $N.keySet().stream().map($T::name).collect($T.joining($S)))", + Preconditions.class, PROPERTY_VAR, "Invalid " + indexParameter.name + ", only %s are allowed!", field, Enum.class, Collectors.class, ", "); + + method.addStatement(childConverter.rawSetExprent().formatted("$L"), PROPERTY_VAR, parameter); + } + + @Override + public void convertGetter(ConverterBase childConverter, MethodSpec.Builder method, FieldSpec field, ParameterSpec indexParameter) { + method.addStatement("$T $L = $N.get($N)", ((ParameterizedTypeName) field.type).typeArguments.get(1), PROPERTY_VAR, field, indexParameter); + method.addStatement("$T.checkArgument($N != null, $S, $N.keySet().stream().map($T::name).collect($T.joining($S)))", + Preconditions.class, PROPERTY_VAR, "Invalid " + indexParameter.name + ", only %s are allowed!", field, Enum.class, Collectors.class, ", "); + + if (childConverter instanceof EnumPropertyWriter enumConverter) { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$L"), PROPERTY_VAR, enumConverter.getApiType()); + } else { + method.addStatement("return " + childConverter.rawGetExprent().formatted("$L"), PROPERTY_VAR); + } + } +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java similarity index 76% rename from paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java rename to paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java index abcc93e61..0740f0d3b 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalGenerator.java @@ -3,7 +3,6 @@ package io.papermc.generator.types.goal; import com.destroystokyo.paper.entity.ai.GoalKey; import com.squareup.javapoet.ClassName; import com.squareup.javapoet.FieldSpec; -import com.squareup.javapoet.JavaFile; import com.squareup.javapoet.MethodSpec; import com.squareup.javapoet.ParameterSpec; import com.squareup.javapoet.ParameterizedTypeName; @@ -16,28 +15,29 @@ import io.papermc.generator.types.SimpleGenerator; import io.papermc.generator.utils.Annotations; import io.papermc.generator.utils.Formatting; import io.papermc.generator.utils.Javadocs; +import io.papermc.typewriter.util.ClassHelper; import java.util.Comparator; import java.util.List; +import java.util.stream.Stream; import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.ai.goal.GoalSelector; import net.minecraft.world.entity.ai.goal.WrappedGoal; import org.bukkit.NamespacedKey; import org.bukkit.entity.Mob; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.framework.qual.DefaultQualifier; -import org.jetbrains.annotations.Nullable; +import org.jspecify.annotations.NullMarked; import static javax.lang.model.element.Modifier.FINAL; import static javax.lang.model.element.Modifier.PRIVATE; import static javax.lang.model.element.Modifier.PUBLIC; import static javax.lang.model.element.Modifier.STATIC; -@DefaultQualifier(NonNull.class) +@NullMarked public class MobGoalGenerator extends SimpleGenerator { - private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("Mob Goals"); + private static final String CLASS_HEADER = Javadocs.getVersionDependentClassHeader("keys", "Mob Goals"); - public MobGoalGenerator(final String keysClassName, final String pkg) { - super(keysClassName, pkg); + public MobGoalGenerator(String className, String packageName) { + super(className, packageName); } @Override @@ -51,9 +51,8 @@ public class MobGoalGenerator extends SimpleGenerator { .addJavadoc(CLASS_HEADER); TypeName mobType = ParameterizedTypeName.get(ClassName.get(Class.class), type); - TypeName keyType = TypeName.get(String.class); - ParameterSpec keyParam = ParameterSpec.builder(keyType, "key", FINAL).build(); + ParameterSpec keyParam = ParameterSpec.builder(String.class, "key", FINAL).build(); ParameterSpec typeParam = ParameterSpec.builder(mobType, "type", FINAL).build(); MethodSpec.Builder createMethod = MethodSpec.methodBuilder("create") .addModifiers(PRIVATE, STATIC) @@ -68,33 +67,25 @@ public class MobGoalGenerator extends SimpleGenerator { classes = scanResult.getSubclasses(Goal.class.getName()).loadClasses(Goal.class); } - List> vanillaNames = classes.stream() + Stream> vanillaGoals = classes.stream() .filter(clazz -> !java.lang.reflect.Modifier.isAbstract(clazz.getModifiers())) + .filter(clazz -> !clazz.isAnonymousClass() || ClassHelper.getTopLevelClass(clazz) != GoalSelector.class) .filter(clazz -> !WrappedGoal.class.equals(clazz)) // TODO - properly fix - .map(goalClass -> MobGoalNames.getKey(goalClass.getName(), goalClass)) - .filter((key) -> !MobGoalNames.isIgnored(key.getNamespacedKey().getKey())) + .map(MobGoalNames::getKey) .sorted(Comparator., String>comparing(o -> o.getEntityClass().getSimpleName()) .thenComparing(vanillaGoalKey -> vanillaGoalKey.getNamespacedKey().getKey()) - ) - .toList(); + ); - - for (final GoalKey goalKey : vanillaNames) { - TypeName typedKey = ParameterizedTypeName.get(GoalKey.class, goalKey.getEntityClass()); - NamespacedKey key = goalKey.getNamespacedKey(); - - String keyPath = key.getKey(); + vanillaGoals.forEach(goalKey -> { + String keyPath = goalKey.getNamespacedKey().getKey(); String fieldName = Formatting.formatKeyAsField(keyPath); + + TypeName typedKey = ParameterizedTypeName.get(GoalKey.class, goalKey.getEntityClass()); FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKey, fieldName, PUBLIC, STATIC, FINAL) .initializer("$N($S, $T.class)", createMethod.build(), keyPath, goalKey.getEntityClass()); typeBuilder.addField(fieldBuilder.build()); - } + }); return typeBuilder.addMethod(createMethod.build()).build(); } - - @Override - protected JavaFile.Builder file(JavaFile.Builder builder) { - return builder; - } } diff --git a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java similarity index 50% rename from paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java rename to paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java index 047b9af5f..46f5f48c8 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java +++ b/paper-generator/src/main/java/io/papermc/generator/types/goal/MobGoalNames.java @@ -2,140 +2,32 @@ package io.papermc.generator.types.goal; import com.destroystokyo.paper.entity.RangedEntity; import com.destroystokyo.paper.entity.ai.GoalKey; -import com.google.common.collect.BiMap; -import com.google.common.collect.HashBiMap; -import net.minecraft.world.entity.FlyingMob; -import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ambient.AmbientCreature; -import net.minecraft.world.entity.animal.AbstractFish; -import net.minecraft.world.entity.animal.AbstractGolem; -import net.minecraft.world.entity.animal.AbstractSchoolingFish; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Pufferfish; -import net.minecraft.world.entity.animal.ShoulderRidingEntity; -import net.minecraft.world.entity.animal.SnowGolem; -import net.minecraft.world.entity.animal.WaterAnimal; -import net.minecraft.world.entity.animal.horse.AbstractChestedHorse; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.monster.AbstractIllager; -import net.minecraft.world.entity.monster.EnderMan; -import net.minecraft.world.entity.monster.PatrollingMonster; -import net.minecraft.world.entity.monster.RangedAttackMob; -import net.minecraft.world.entity.monster.SpellcasterIllager; -import net.minecraft.world.entity.monster.ZombifiedPiglin; -import net.minecraft.world.entity.monster.piglin.AbstractPiglin; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.AbstractHorse; -import org.bukkit.entity.AbstractSkeleton; -import org.bukkit.entity.AbstractVillager; -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Ambient; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Bee; -import org.bukkit.entity.Blaze; -import org.bukkit.entity.Cat; -import org.bukkit.entity.CaveSpider; -import org.bukkit.entity.ChestedHorse; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Cod; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Dolphin; -import org.bukkit.entity.Donkey; -import org.bukkit.entity.Drowned; -import org.bukkit.entity.ElderGuardian; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Enderman; -import org.bukkit.entity.Endermite; -import org.bukkit.entity.Evoker; -import org.bukkit.entity.Fish; -import org.bukkit.entity.Flying; -import org.bukkit.entity.Fox; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Golem; -import org.bukkit.entity.Guardian; -import org.bukkit.entity.Hoglin; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Husk; -import org.bukkit.entity.Illager; -import org.bukkit.entity.Illusioner; -import org.bukkit.entity.IronGolem; -import org.bukkit.entity.Llama; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Mob; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Mule; -import org.bukkit.entity.MushroomCow; -import org.bukkit.entity.Ocelot; -import org.bukkit.entity.Panda; -import org.bukkit.entity.Parrot; -import org.bukkit.entity.Phantom; -import org.bukkit.entity.Pig; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Piglin; -import org.bukkit.entity.PiglinAbstract; -import org.bukkit.entity.PiglinBrute; -import org.bukkit.entity.Pillager; -import org.bukkit.entity.PolarBear; -import org.bukkit.entity.PufferFish; -import org.bukkit.entity.Rabbit; -import org.bukkit.entity.Raider; -import org.bukkit.entity.Ravager; -import org.bukkit.entity.Salmon; -import org.bukkit.entity.Sheep; -import org.bukkit.entity.Shulker; -import org.bukkit.entity.Silverfish; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.SkeletonHorse; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Snowman; -import org.bukkit.entity.Spellcaster; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Squid; -import org.bukkit.entity.Stray; -import org.bukkit.entity.Strider; -import org.bukkit.entity.Tameable; -import org.bukkit.entity.TraderLlama; -import org.bukkit.entity.TropicalFish; -import org.bukkit.entity.Turtle; -import org.bukkit.entity.Vex; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Vindicator; -import org.bukkit.entity.WanderingTrader; -import org.bukkit.entity.WaterMob; -import org.bukkit.entity.Witch; -import org.bukkit.entity.Wither; -import org.bukkit.entity.WitherSkeleton; -import org.bukkit.entity.Wolf; -import org.bukkit.entity.Zoglin; -import org.bukkit.entity.Zombie; -import org.bukkit.entity.ZombieHorse; -import org.bukkit.entity.ZombieVillager; - +import com.google.common.base.CaseFormat; +import io.papermc.generator.utils.Formatting; +import io.papermc.paper.entity.SchoolableFish; import java.lang.reflect.Constructor; import java.util.HashMap; -import java.util.HashSet; -import java.util.Locale; +import java.util.LinkedHashMap; import java.util.Map; -import java.util.Set; +import net.minecraft.world.entity.ai.goal.Goal; +import net.minecraft.world.entity.monster.RangedAttackMob; +import org.apache.commons.lang3.math.NumberUtils; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.*; +import org.jspecify.annotations.NullMarked; -public class MobGoalNames { +@NullMarked +public final class MobGoalNames { // todo sync with MobGoalHelper ideally this should not be duplicated private static final Map, Class> entityClassCache = new HashMap<>(); - public static final Map, Class> bukkitMap = new HashMap<>(); - + public static final Map, Class> bukkitMap = new LinkedHashMap<>(); static { // bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class); bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class); - bukkitMap.put(AmbientCreature.class, Ambient.class); - bukkitMap.put(Animal.class, Animals.class); + bukkitMap.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); + bukkitMap.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); bukkitMap.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); bukkitMap.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); @@ -144,56 +36,56 @@ public class MobGoalNames { bukkitMap.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); bukkitMap.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); bukkitMap.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); - bukkitMap.put(PathfinderMob.class, Creature.class); + bukkitMap.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); bukkitMap.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); bukkitMap.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); bukkitMap.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); bukkitMap.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); - bukkitMap.put(EnderMan.class, Enderman.class); + bukkitMap.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - bukkitMap.put(AbstractFish.class, Fish.class); - bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class); - bukkitMap.put(FlyingMob.class, Flying.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); + bukkitMap.put(net.minecraft.world.entity.FlyingMob.class, Flying.class); bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); bukkitMap.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - bukkitMap.put(AbstractGolem.class, Golem.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); bukkitMap.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); bukkitMap.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - bukkitMap.put(AbstractChestedHorse.class, ChestedHorse.class); + bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); bukkitMap.put(net.minecraft.world.entity.animal.camel.Camel.class, org.bukkit.entity.Camel.class); - bukkitMap.put(AbstractIllager.class, Illager.class); + bukkitMap.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); bukkitMap.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - bukkitMap.put(SpellcasterIllager.class, Spellcaster.class); + bukkitMap.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); bukkitMap.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); bukkitMap.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); bukkitMap.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); - bukkitMap.put(PatrollingMonster.class, Raider.class); // close enough + bukkitMap.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); // close enough bukkitMap.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); bukkitMap.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); bukkitMap.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); bukkitMap.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - bukkitMap.put(ShoulderRidingEntity.class, Parrot.class); // close enough + bukkitMap.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); // close enough bukkitMap.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); bukkitMap.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - bukkitMap.put(ZombifiedPiglin.class, PigZombie.class); + bukkitMap.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); bukkitMap.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); bukkitMap.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - bukkitMap.put(Pufferfish.class, PufferFish.class); + bukkitMap.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); bukkitMap.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); bukkitMap.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); bukkitMap.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); bukkitMap.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); - bukkitMap.put(net.minecraft.world.entity.animal.Sheep.class, Sheep.class); + bukkitMap.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); bukkitMap.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); bukkitMap.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); bukkitMap.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); @@ -201,10 +93,10 @@ public class MobGoalNames { bukkitMap.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); bukkitMap.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); bukkitMap.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); - bukkitMap.put(SnowGolem.class, Snowman.class); + bukkitMap.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class); bukkitMap.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); bukkitMap.put(net.minecraft.world.entity.animal.Squid.class, Squid.class); - bukkitMap.put(TamableAnimal.class, Tameable.class); + bukkitMap.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); bukkitMap.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); bukkitMap.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); bukkitMap.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); @@ -212,108 +104,86 @@ public class MobGoalNames { bukkitMap.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); bukkitMap.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); bukkitMap.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - bukkitMap.put(WaterAnimal.class, WaterMob.class); + bukkitMap.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); bukkitMap.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); - bukkitMap.put(WitherBoss.class, Wither.class); - bukkitMap.put(net.minecraft.world.entity.animal.Wolf.class, Wolf.class); + bukkitMap.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); + bukkitMap.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); bukkitMap.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); bukkitMap.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); bukkitMap.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); bukkitMap.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); bukkitMap.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); - bukkitMap.put(AbstractPiglin.class, PiglinAbstract.class); + bukkitMap.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class); - bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class); - bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class); - bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, org.bukkit.entity.Frog.class); - bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, org.bukkit.entity.Tadpole.class); - bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, org.bukkit.entity.Warden.class); - bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, org.bukkit.entity.Allay.class); - bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, org.bukkit.entity.Sniffer.class); - bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, org.bukkit.entity.Breeze.class); - bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class); - bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class); - bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, org.bukkit.entity.Creaking.class); - bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, org.bukkit.entity.Squid.class); // close enough + bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); + bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); + bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); + bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, Tadpole.class); + bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, Warden.class); + bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, Allay.class); + bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); + bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); + bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); + bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); + bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); // close enough + bukkitMap.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); // } - private static final BiMap deobfuscationMap = HashBiMap.create(); - static final Set ignored = new HashSet<>(); + private static final Map deobfuscationMap = new HashMap<>(); static { + // TODO these kinda should be checked on each release, in case obfuscation changes deobfuscationMap.put("abstract_skeleton_1", "abstract_skeleton_melee"); - - ignored.add("goal_selector_1"); - ignored.add("goal_selector_2"); - ignored.add("selector_1"); - ignored.add("selector_2"); - ignored.add("wrapped"); } - public static String getUsableName(String name) { - final String original = name; - name = name.substring(name.lastIndexOf(".") + 1); - boolean flag = false; + private static String getPathName(String name) { + String pathName = name.substring(name.lastIndexOf('.') + 1); + boolean needDeobfMap = false; + // inner classes - if (name.contains("$")) { - String cut = name.substring(name.indexOf("$") + 1); - if (cut.length() <= 2) { - name = name.replace("Entity", ""); - name = name.replace("$", "_"); - flag = true; - } else { - // mapped, wooo - name = cut; + int firstInnerDelimiter = pathName.indexOf('$'); + if (firstInnerDelimiter != -1) { + String innerClassName = pathName.substring(firstInnerDelimiter + 1); + for (String nestedClass : innerClassName.split("\\$")) { + if (NumberUtils.isDigits(nestedClass)) { + needDeobfMap = true; + break; + } } + if (!needDeobfMap) { + pathName = innerClassName; + } + pathName = pathName.replace('$', '_'); + // mapped, wooo! } - name = name.replace("PathfinderGoal", ""); - name = name.replace("TargetGoal", ""); - name = name.replace("Goal", ""); - StringBuilder sb = new StringBuilder(); - for (char c : name.toCharArray()) { - if (c >= 'A' && c <= 'Z') { - sb.append("_"); - sb.append(Character.toLowerCase(c)); - } else { - sb.append(c); - } - } - name = sb.toString(); - name = name.replaceFirst("_", ""); + pathName = Formatting.stripWordOfCamelCaseName(pathName, "TargetGoal", true); // replace last? reverse search? + pathName = Formatting.stripWordOfCamelCaseName(pathName, "Goal", true); + pathName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, pathName); - if (flag && !deobfuscationMap.containsKey(name.toLowerCase(Locale.ROOT)) && !ignored.contains(name)) { - System.out.println("need to map " + original + " (" + name.toLowerCase(Locale.ROOT) + ")"); + if (needDeobfMap && !deobfuscationMap.containsKey(pathName)) { + System.err.println("need to map " + name + " (" + pathName + ")"); } // did we rename this key? - return deobfuscationMap.getOrDefault(name, name); + return deobfuscationMap.getOrDefault(pathName, pathName); } - public static boolean isIgnored(String name) { - return ignored.contains(name); - } - - - public static GoalKey getKey(String clazzName, Class goalClass) { - String name = getUsableName(clazzName); - if (MobGoalNames.isIgnored(name)) { - //noinspection unchecked - return (GoalKey) GoalKey.of(Mob.class, NamespacedKey.minecraft(name)); - } + public static GoalKey getKey(Class goalClass) { + String name = getPathName(goalClass.getName()); return GoalKey.of(getEntity(goalClass), NamespacedKey.minecraft(name)); } - public static Class getEntity(Class goalClass) { + private static Class getEntity(Class goalClass) { //noinspection unchecked return (Class) entityClassCache.computeIfAbsent(goalClass, key -> { for (Constructor ctor : key.getDeclaredConstructors()) { - for (int i = 0; i < ctor.getParameterCount(); i++) { - Class param = ctor.getParameterTypes()[i]; + for (Class param : ctor.getParameterTypes()) { if (net.minecraft.world.entity.Mob.class.isAssignableFrom(param)) { //noinspection unchecked return toBukkitClass((Class) param); @@ -322,11 +192,11 @@ public class MobGoalNames { } } } - throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return EntityInsentient? + throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return Mob? }); } - public static Class toBukkitClass(Class nmsClass) { + private static Class toBukkitClass(Class nmsClass) { Class bukkitClass = bukkitMap.get(nmsClass); if (bukkitClass == null) { throw new RuntimeException("Can't figure out applicable bukkit entity for nms entity " + nmsClass); // maybe just return Mob? diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java new file mode 100644 index 000000000..7dd3af4d3 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedKeyType.java @@ -0,0 +1,133 @@ +package io.papermc.generator.types.registry; + +import com.google.common.base.Suppliers; +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.JavaFile; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.registry.RegistryEntry; +import io.papermc.generator.types.SimpleGenerator; +import io.papermc.generator.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.Javadocs; +import io.papermc.generator.utils.experimental.ExperimentalCollector; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.TypedKey; +import java.util.Map; +import java.util.function.Supplier; +import javax.lang.model.SourceVersion; +import net.kyori.adventure.key.Key; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.flag.FeatureElement; +import net.minecraft.world.flag.FeatureFlags; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +import static com.squareup.javapoet.TypeSpec.classBuilder; +import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; +import static io.papermc.generator.utils.Annotations.experimentalAnnotations; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class GeneratedKeyType extends SimpleGenerator { + + private final RegistryEntry entry; + private final Supplier, SingleFlagHolder>> experimentalKeys; + private final boolean isFilteredRegistry; + + public GeneratedKeyType(String packageName, RegistryEntry entry) { + super(entry.keyClassName().concat("Keys"), packageName); + this.entry = entry; + this.experimentalKeys = Suppliers.memoize(() -> ExperimentalCollector.collectDataDrivenElementIds(entry.registry())); + this.isFilteredRegistry = FeatureElement.FILTERED_REGISTRIES.contains(entry.registryKey()); + } + + private MethodSpec.Builder createMethod(TypeName returnType) { + boolean publicCreateKeyMethod = this.entry.allowCustomKeys(); + + ParameterSpec keyParam = ParameterSpec.builder(Key.class, "key", FINAL).build(); + MethodSpec.Builder create = MethodSpec.methodBuilder("create") + .addModifiers(publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) + .addParameter(keyParam) + .addCode("return $T.create($T.$L, $N);", TypedKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) + .returns(returnType); + if (publicCreateKeyMethod) { + create.addJavadoc(Javadocs.CREATE_TYPED_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + } + return create; + } + + private TypeSpec.Builder keyHolderType() { + return classBuilder(this.className) + .addModifiers(PUBLIC, FINAL) + .addJavadoc(Javadocs.getVersionDependentClassHeader("keys", "{@link $T#$L}"), RegistryKey.class, this.entry.registryKeyField()) + .addAnnotations(Annotations.CLASS_HEADER) + .addMethod(MethodSpec.constructorBuilder() + .addModifiers(PRIVATE) + .build() + ); + } + + @Override + protected TypeSpec getTypeSpec() { + TypeName typedKeyType = ParameterizedTypeName.get(TypedKey.class, this.entry.apiClass()); + + TypeSpec.Builder typeBuilder = this.keyHolderType(); + MethodSpec.Builder createMethod = this.createMethod(typedKeyType); + + boolean allExperimental = true; + for (Holder.Reference reference : this.entry.registry().listElements().sorted(Formatting.alphabeticKeyOrder(reference -> reference.key().location().getPath())).toList()) { + ResourceKey key = reference.key(); + String keyPath = key.location().getPath(); + String fieldName = Formatting.formatKeyAsField(keyPath); + if (!SourceVersion.isIdentifier(fieldName) && this.entry.getFieldNames().containsKey(key)) { + fieldName = this.entry.getFieldNames().get(key); + } + + FieldSpec.Builder fieldBuilder = FieldSpec.builder(typedKeyType, fieldName, PUBLIC, STATIC, FINAL) + .initializer("$N(key($S))", createMethod.build(), keyPath) + .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), key.location().toString()); + + SingleFlagHolder requiredFeature = this.getRequiredFeature(reference); + if (requiredFeature != null) { + fieldBuilder.addAnnotations(experimentalAnnotations(requiredFeature)); + } else { + allExperimental = false; + } + typeBuilder.addField(fieldBuilder.build()); + } + + if (allExperimental) { + typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); + createMethod.addAnnotation(EXPERIMENTAL_API_ANNOTATION); + } + return typeBuilder.addMethod(createMethod.build()).build(); + } + + @Override + protected JavaFile.Builder file(JavaFile.Builder builder) { + return builder.addStaticImport(Key.class, "key"); + } + + protected @Nullable SingleFlagHolder getRequiredFeature(Holder.Reference reference) { + if (this.isFilteredRegistry) { + // built-in registry + FeatureElement element = (FeatureElement) reference.value(); + if (FeatureFlags.isExperimental(element.requiredFeatures())) { + return SingleFlagHolder.fromSet(element.requiredFeatures()); + } + } else { + // data-driven registry + return this.experimentalKeys.get().get(reference.key()); + } + return null; + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java new file mode 100644 index 000000000..e1c5cb71f --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/types/registry/GeneratedTagKeyType.java @@ -0,0 +1,103 @@ +package io.papermc.generator.types.registry; + +import com.squareup.javapoet.FieldSpec; +import com.squareup.javapoet.JavaFile; +import com.squareup.javapoet.MethodSpec; +import com.squareup.javapoet.ParameterSpec; +import com.squareup.javapoet.ParameterizedTypeName; +import com.squareup.javapoet.TypeName; +import com.squareup.javapoet.TypeSpec; +import io.papermc.generator.Main; +import io.papermc.generator.registry.RegistryEntry; +import io.papermc.generator.types.SimpleGenerator; +import io.papermc.generator.utils.Annotations; +import io.papermc.generator.utils.Formatting; +import io.papermc.generator.utils.Javadocs; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.paper.registry.RegistryKey; +import io.papermc.paper.registry.tag.TagKey; +import java.util.concurrent.atomic.AtomicBoolean; +import net.kyori.adventure.key.Key; +import org.jspecify.annotations.NullMarked; + +import static com.squareup.javapoet.TypeSpec.classBuilder; +import static io.papermc.generator.utils.Annotations.EXPERIMENTAL_API_ANNOTATION; +import static io.papermc.generator.utils.Annotations.experimentalAnnotations; +import static javax.lang.model.element.Modifier.FINAL; +import static javax.lang.model.element.Modifier.PRIVATE; +import static javax.lang.model.element.Modifier.PUBLIC; +import static javax.lang.model.element.Modifier.STATIC; + +@NullMarked +public class GeneratedTagKeyType extends SimpleGenerator { + + private final RegistryEntry entry; + + public GeneratedTagKeyType(RegistryEntry entry, String packageName) { + super(entry.keyClassName().concat("TagKeys"), packageName); + this.entry = entry; + } + + private MethodSpec.Builder createMethod(TypeName returnType) { + boolean publicCreateKeyMethod = true; // tag lifecycle event exists + + ParameterSpec keyParam = ParameterSpec.builder(Key.class, "key", FINAL).build(); + MethodSpec.Builder create = MethodSpec.methodBuilder("create") + .addModifiers(publicCreateKeyMethod ? PUBLIC : PRIVATE, STATIC) + .addParameter(keyParam) + .addCode("return $T.create($T.$L, $N);", TagKey.class, RegistryKey.class, this.entry.registryKeyField(), keyParam) + .returns(returnType); + if (publicCreateKeyMethod) { + create.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO remove once not experimental + create.addJavadoc(Javadocs.CREATED_TAG_KEY_JAVADOC, this.entry.apiClass(), this.entry.registryKey().location().toString()); + } + return create; + } + + private TypeSpec.Builder keyHolderType() { + return classBuilder(this.className) + .addModifiers(PUBLIC, FINAL) + .addJavadoc(Javadocs.getVersionDependentClassHeader("tag keys", "{@link $T#$L}"), RegistryKey.class, this.entry.registryKeyField()) + .addAnnotations(Annotations.CLASS_HEADER) + .addMethod(MethodSpec.constructorBuilder() + .addModifiers(PRIVATE) + .build() + ); + } + + @Override + protected TypeSpec getTypeSpec() { + TypeName tagKeyType = ParameterizedTypeName.get(TagKey.class, this.entry.apiClass()); + + TypeSpec.Builder typeBuilder = this.keyHolderType(); + MethodSpec.Builder createMethod = this.createMethod(tagKeyType); + + AtomicBoolean allExperimental = new AtomicBoolean(true); + this.entry.registry().listTagIds().sorted(Formatting.alphabeticKeyOrder(tagKey -> tagKey.location().getPath())).forEach(tagKey -> { + String fieldName = Formatting.formatKeyAsField(tagKey.location().getPath()); + FieldSpec.Builder fieldBuilder = FieldSpec.builder(tagKeyType, fieldName, PUBLIC, STATIC, FINAL) + .initializer("$N(key($S))", createMethod.build(), tagKey.location().getPath()) + .addJavadoc(Javadocs.getVersionDependentField("{@code $L}"), "#" + tagKey.location()); + + String featureFlagName = Main.EXPERIMENTAL_TAGS.get(tagKey); + if (featureFlagName != null) { + fieldBuilder.addAnnotations(experimentalAnnotations(SingleFlagHolder.fromName(featureFlagName))); + } else { + allExperimental.set(false); + } + typeBuilder.addField(fieldBuilder.build()); + }); + if (allExperimental.get()) { + typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); + createMethod.addAnnotation(EXPERIMENTAL_API_ANNOTATION); + } else { + typeBuilder.addAnnotation(EXPERIMENTAL_API_ANNOTATION); // TODO experimental API + } + return typeBuilder.addMethod(createMethod.build()).build(); + } + + @Override + protected JavaFile.Builder file(JavaFile.Builder builder) { + return builder.addStaticImport(Key.class, "key"); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/Annotations.java b/paper-generator/src/main/java/io/papermc/generator/utils/Annotations.java new file mode 100644 index 000000000..47a0781ed --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/Annotations.java @@ -0,0 +1,48 @@ +package io.papermc.generator.utils; + +import com.squareup.javapoet.AnnotationSpec; +import io.papermc.generator.utils.experimental.SingleFlagHolder; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.List; +import net.minecraft.SharedConstants; +import org.bukkit.MinecraftExperimental; +import org.jetbrains.annotations.ApiStatus; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Annotations { + + public static List experimentalAnnotations(SingleFlagHolder requiredFeature) { + AnnotationSpec.Builder builder = AnnotationSpec.builder(MinecraftExperimental.class); + builder.addMember("value", "$T.$L", MinecraftExperimental.Requires.class, requiredFeature.asAnnotationMember().name()); + + return List.of( + AnnotationSpec.builder(ApiStatus.Experimental.class).build(), + builder.build() + ); + } + + public static AnnotationSpec suppressWarnings(String... values) { + AnnotationSpec.Builder builder = AnnotationSpec.builder(SuppressWarnings.class); + for (String value : values) { + builder.addMember("value", "$S", value); + } + return builder.build(); + } + + @ApiStatus.Experimental + public static final AnnotationSpec EXPERIMENTAL_API_ANNOTATION = AnnotationSpec.builder(ApiStatus.Experimental.class).build(); + public static final AnnotationSpec NULL_MARKED = AnnotationSpec.builder(NullMarked.class).build(); + public static final AnnotationSpec OVERRIDE = AnnotationSpec.builder(Override.class).build(); + public static final AnnotationSpec GENERATED_FROM = AnnotationSpec.builder(GeneratedFrom.class) + .addMember("value", "$S", SharedConstants.getCurrentVersion().getId()) + .build(); + public static final Iterable CLASS_HEADER = List.of( + suppressWarnings("unused", "SpellCheckingInspection"), + NULL_MARKED, + GENERATED_FROM + ); + + private Annotations() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java new file mode 100644 index 000000000..d8d7d0f56 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/BlockEntityMapping.java @@ -0,0 +1,37 @@ +package io.papermc.generator.utils; + +import com.google.common.base.CaseFormat; +import com.google.common.collect.ImmutableMap; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Map; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.block.entity.BlockEntityType; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class BlockEntityMapping { + + // if this become painful/too weird like the blockdata just rename the impl directly again + private static final Map RENAMES = ImmutableMap.builder() + .put("CraftFurnace", "CraftFurnaceFurnace") + .put("CraftMobSpawner", "CraftCreatureSpawner") + .put("CraftPiston", "CraftMovingPiston") + .put("CraftTrappedChest", "CraftChest") // not really a rename + .buildOrThrow(); + + public static final Map>, String> MAPPING; + + static { + Map>, String> mapping = new IdentityHashMap<>(); + BuiltInRegistries.BLOCK_ENTITY_TYPE.registryKeySet().forEach(key -> { + String name = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, key.location().getPath()); + String implName = "Craft".concat(name); + + mapping.put(key, RENAMES.getOrDefault(implName, implName)); + }); + + MAPPING = Collections.unmodifiableMap(mapping); + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java b/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java new file mode 100644 index 000000000..6cbb05e88 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/BlockStateMapping.java @@ -0,0 +1,445 @@ +package io.papermc.generator.utils; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.Multimap; +import com.mojang.datafixers.util.Either; +import io.papermc.generator.types.craftblockdata.property.holder.VirtualField; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import net.minecraft.core.Direction; +import net.minecraft.core.FrontAndTop; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.util.StringRepresentable; +import net.minecraft.world.level.block.AbstractFurnaceBlock; +import net.minecraft.world.level.block.BigDripleafStemBlock; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.CommandBlock; +import net.minecraft.world.level.block.IronBarsBlock; +import net.minecraft.world.level.block.MultifaceBlock; +import net.minecraft.world.level.block.NoteBlock; +import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.level.block.StructureBlock; +import net.minecraft.world.level.block.TestBlock; +import net.minecraft.world.level.block.TestInstanceBlock; +import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerState; +import net.minecraft.world.level.block.entity.vault.VaultState; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BambooLeaves; +import net.minecraft.world.level.block.state.properties.BedPart; +import net.minecraft.world.level.block.state.properties.BellAttachType; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.state.properties.ComparatorMode; +import net.minecraft.world.level.block.state.properties.CreakingHeartState; +import net.minecraft.world.level.block.state.properties.DoorHingeSide; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.DripstoneThickness; +import net.minecraft.world.level.block.state.properties.Half; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import net.minecraft.world.level.block.state.properties.PistonType; +import net.minecraft.world.level.block.state.properties.Property; +import net.minecraft.world.level.block.state.properties.RailShape; +import net.minecraft.world.level.block.state.properties.RedstoneSide; +import net.minecraft.world.level.block.state.properties.SculkSensorPhase; +import net.minecraft.world.level.block.state.properties.SlabType; +import net.minecraft.world.level.block.state.properties.StairsShape; +import net.minecraft.world.level.block.state.properties.StructureMode; +import net.minecraft.world.level.block.state.properties.TestBlockMode; +import net.minecraft.world.level.block.state.properties.Tilt; +import net.minecraft.world.level.block.state.properties.WallSide; +import org.bukkit.Axis; +import org.bukkit.Instrument; +import org.bukkit.block.BlockFace; +import org.bukkit.block.Orientation; +import org.bukkit.block.data.Ageable; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.block.data.Bisected; +import org.bukkit.block.data.Brushable; +import org.bukkit.block.data.Directional; +import org.bukkit.block.data.FaceAttachable; +import org.bukkit.block.data.Hangable; +import org.bukkit.block.data.Hatchable; +import org.bukkit.block.data.Levelled; +import org.bukkit.block.data.Lightable; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.block.data.Openable; +import org.bukkit.block.data.Orientable; +import org.bukkit.block.data.Powerable; +import org.bukkit.block.data.Rail; +import org.bukkit.block.data.Rotatable; +import org.bukkit.block.data.Segmentable; +import org.bukkit.block.data.Snowable; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.block.data.type.Bamboo; +import org.bukkit.block.data.type.Bed; +import org.bukkit.block.data.type.Bell; +import org.bukkit.block.data.type.BigDripleaf; +import org.bukkit.block.data.type.Chest; +import org.bukkit.block.data.type.Comparator; +import org.bukkit.block.data.type.CreakingHeart; +import org.bukkit.block.data.type.Door; +import org.bukkit.block.data.type.Dripleaf; +import org.bukkit.block.data.type.Fence; +import org.bukkit.block.data.type.Furnace; +import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.block.data.type.RedstoneRail; +import org.bukkit.block.data.type.RedstoneWire; +import org.bukkit.block.data.type.ResinClump; +import org.bukkit.block.data.type.SculkSensor; +import org.bukkit.block.data.type.Slab; +import org.bukkit.block.data.type.Stairs; +import org.bukkit.block.data.type.Switch; +import org.bukkit.block.data.type.TechnicalPiston; +import org.bukkit.block.data.type.TrialSpawner; +import org.bukkit.block.data.type.Vault; +import org.bukkit.block.data.type.Wall; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public final class BlockStateMapping { + + public record BlockData(String implName, @Nullable Class api, + Collection> properties, Map, Field> propertyFields, + Multimap, Property> complexPropertyFields) { + } + + private static final Map API_RENAMES = ImmutableMap.builder() + .put("SnowLayer", "Snow") + .put("StainedGlassPane", "GlassPane") // weird that this one implements glass pane but not the regular glass pane + .put("CeilingHangingSign", "HangingSign") + .put("RedStoneWire", "RedstoneWire") + .put("TripWire", "Tripwire") + .put("TripWireHook", "TripwireHook") + .put("Tnt", "TNT") + .put("BambooStalk", "Bamboo") + .put("Farm", "Farmland") + .put("ChiseledBookShelf", "ChiseledBookshelf") + .put("UntintedParticleLeaves", "Leaves") + .put("TintedParticleLeaves", "Leaves") + .put("StandingSign", "Sign") + .put("FenceGate", "Gate") + .buildOrThrow(); + + private static final Set> BLOCK_SUFFIX_INTENDED = Set.of( + CommandBlock.class, + StructureBlock.class, + NoteBlock.class, + TestBlock.class, + TestInstanceBlock.class + ); + + // virtual data that doesn't exist as constant in the source but still organized this way in the api + public static final ImmutableMultimap, VirtualField> VIRTUAL_NODES = ImmutableMultimap., VirtualField>builder() + .build(); + + public static final Map, Field> FALLBACK_GENERIC_FIELDS; + + static { + Map, Field> fallbackGenericFields = new HashMap<>(); + fetchProperties(BlockStateProperties.class, (field, property) -> fallbackGenericFields.put(property, field), null); + FALLBACK_GENERIC_FIELDS = Collections.unmodifiableMap(fallbackGenericFields); + } + + public static final Map, BlockData> MAPPING; + + static { + Map, Collection>> specialBlocks = new IdentityHashMap<>(); + for (Block block : BuiltInRegistries.BLOCK) { + if (!block.getStateDefinition().getProperties().isEmpty()) { + specialBlocks.put(block.getClass(), block.getStateDefinition().getProperties()); + } + } + + Map, BlockData> map = new IdentityHashMap<>(); + for (Map.Entry, Collection>> entry : specialBlocks.entrySet()) { + Class specialBlock = entry.getKey(); + + Collection> properties = new ArrayList<>(entry.getValue()); + + Map, Field> propertyFields = new HashMap<>(properties.size()); + Multimap, Property> complexPropertyFields = ArrayListMultimap.create(); + + fetchProperties(specialBlock, (field, property) -> { + if (properties.contains(property)) { + propertyFields.put(property, field); + } + }, (field, property) -> { + if (properties.remove(property)) { // handle those separately and only count if the property was in the state definition + complexPropertyFields.put(Either.left(field), property); + } + }); + + // virtual nodes + if (VIRTUAL_NODES.containsKey(specialBlock)) { + for (VirtualField virtualField : VIRTUAL_NODES.get(specialBlock)) { + for (Property property : virtualField.values()) { + if (properties.remove(property)) { + complexPropertyFields.put(Either.right(virtualField), property); + } else { + throw new IllegalStateException("Unhandled virtual node " + virtualField.name() + " for " + property + " in " + specialBlock.getCanonicalName()); + } + } + } + } + + String apiName = formatApiName(specialBlock); + String implName = "Craft".concat(apiName); // before renames + + apiName = Formatting.stripWordOfCamelCaseName(apiName, "Base", true); + apiName = API_RENAMES.getOrDefault(apiName, apiName); + + Class api = ClassHelper.classOr("org.bukkit.block.data.type." + apiName, null); + if (api == null) { + Class directParent = specialBlock.getSuperclass(); + if (specialBlocks.containsKey(directParent)) { + // if the properties are the same then always consider the parent + // check deeper in the tree? + if (specialBlocks.get(directParent).equals(entry.getValue())) { + String parentApiName = formatApiName(directParent); + parentApiName = Formatting.stripWordOfCamelCaseName(parentApiName, "Base", true); + parentApiName = API_RENAMES.getOrDefault(parentApiName, parentApiName); + api = ClassHelper.classOr("org.bukkit.block.data.type." + parentApiName, api); + } + } + } + if (api == null) { // todo remove this part + if (AbstractFurnaceBlock.class.isAssignableFrom(specialBlock)) { + api = Furnace.class; // for smoker and blast furnace + } else if (specialBlock == BigDripleafStemBlock.class) { + api = Dripleaf.class; + } else if (specialBlock == IronBarsBlock.class) { + api = Fence.class; // for glass pane (regular) and iron bars + } else if (specialBlock == MultifaceBlock.class) { + api = ResinClump.class; + } + } + + map.put(specialBlock, new BlockData(implName, api, properties, propertyFields, complexPropertyFields)); + } + MAPPING = Collections.unmodifiableMap(map); + } + + private static final Map> NAME_TO_DATA = Map.of( + BlockStateProperties.AGE_1.getName(), Ageable.class, + BlockStateProperties.LEVEL.getName(), Levelled.class + ); + + private static final Map, Class> PROPERTY_TO_DATA = ImmutableMap., Class>builder() + // levelled and ageable are done using the property name + .put(BlockStateProperties.POWER, AnaloguePowerable.class) + .put(BlockStateProperties.HALF, Bisected.class) + .put(BlockStateProperties.DOUBLE_BLOCK_HALF, Bisected.class) + .put(BlockStateProperties.DUSTED, Brushable.class) + .put(BlockStateProperties.FACING, Directional.class) + .put(BlockStateProperties.HORIZONTAL_FACING, Directional.class) + .put(BlockStateProperties.ATTACH_FACE, FaceAttachable.class) + .put(BlockStateProperties.HANGING, Hangable.class) + .put(BlockStateProperties.HATCH, Hatchable.class) + .put(BlockStateProperties.LIT, Lightable.class) + // multiple facing is done by matching two or more pipe block properties + .put(BlockStateProperties.OPEN, Openable.class) + .put(BlockStateProperties.HORIZONTAL_AXIS, Orientable.class) + .put(BlockStateProperties.AXIS, Orientable.class) + .put(BlockStateProperties.POWERED, Powerable.class) + .put(BlockStateProperties.RAIL_SHAPE, Rail.class) + .put(BlockStateProperties.RAIL_SHAPE_STRAIGHT, Rail.class) + .put(BlockStateProperties.ROTATION_16, Rotatable.class) + .put(BlockStateProperties.SNOWY, Snowable.class) + .put(BlockStateProperties.WATERLOGGED, Waterlogged.class) + .put(BlockStateProperties.SEGMENT_AMOUNT, Segmentable.class) + .buildOrThrow(); + + private static final Map, Class> MAIN_PROPERTY_TO_DATA = Map.of( + BlockStateProperties.PISTON_TYPE, TechnicalPiston.class, + BlockStateProperties.STAIRS_SHAPE, Stairs.class + ); + + public static final Map>, Class>> ENUM_BRIDGE = ImmutableMap.>, Class>>builder() + .put(DoorHingeSide.class, Door.Hinge.class) + .put(SlabType.class, Slab.Type.class) + .put(StructureMode.class, org.bukkit.block.data.type.StructureBlock.Mode.class) + .put(DripstoneThickness.class, PointedDripstone.Thickness.class) + .put(WallSide.class, Wall.Height.class) + .put(BellAttachType.class, Bell.Attachment.class) + .put(NoteBlockInstrument.class, Instrument.class) + .put(StairsShape.class, Stairs.Shape.class) + .put(Direction.class, BlockFace.class) + .put(ComparatorMode.class, Comparator.Mode.class) + .put(PistonType.class, TechnicalPiston.Type.class) + .put(BedPart.class, Bed.Part.class) + .put(Half.class, Bisected.Half.class) + .put(AttachFace.class, FaceAttachable.AttachedFace.class) + .put(RailShape.class, Rail.Shape.class) + .put(SculkSensorPhase.class, SculkSensor.Phase.class) + .put(DoubleBlockHalf.class, Bisected.Half.class) + .put(Tilt.class, BigDripleaf.Tilt.class) + .put(ChestType.class, Chest.Type.class) + .put(RedstoneSide.class, RedstoneWire.Connection.class) + .put(Direction.Axis.class, Axis.class) + .put(BambooLeaves.class, Bamboo.Leaves.class) + .put(TrialSpawnerState.class, TrialSpawner.State.class) + .put(FrontAndTop.class, Orientation.class) + .put(VaultState.class, Vault.State.class) + .put(CreakingHeartState.class, CreakingHeart.State.class) + .put(TestBlockMode.class, org.bukkit.block.data.type.TestBlock.Mode.class) + .buildOrThrow(); + + public static @Nullable Class getBestSuitedApiClass(Class block) { + if (!MAPPING.containsKey(block)) { + return null; + } + + return getBestSuitedApiClass(MAPPING.get(block)); + } + + public static @Nullable Class getBestSuitedApiClass(BlockData data) { + if (data.api() != null) { + return data.api(); + } + + int pipeProps = 0; + Set> extensions = new LinkedHashSet<>(); + for (Property property : data.properties()) { + if (MAIN_PROPERTY_TO_DATA.containsKey(property)) { + return MAIN_PROPERTY_TO_DATA.get(property); + } + + if (NAME_TO_DATA.containsKey(property.getName())) { + extensions.add(NAME_TO_DATA.get(property.getName())); + continue; + } + + if (PROPERTY_TO_DATA.containsKey(property)) { + extensions.add(PROPERTY_TO_DATA.get(property)); + continue; + } + + if (PipeBlock.PROPERTY_BY_DIRECTION.containsValue(property)) { + pipeProps++; + } + } + + if (!extensions.isEmpty()) { + if (isExactly(extensions, Switch.class)) { + return Switch.class; + } + if (isExactly(extensions, RedstoneRail.class)) { + return RedstoneRail.class; + } + + return extensions.iterator().next(); + } + + for (Property property : data.complexPropertyFields().values()) { + if (PipeBlock.PROPERTY_BY_DIRECTION.containsValue(property)) { + pipeProps++; + } + } + + if (pipeProps >= 2) { + return MultipleFacing.class; + } + return null; + } + + private static boolean isExactly(Set> extensions, Class globClass) { + return extensions.equals(ClassHelper.getAllInterfaces(globClass, org.bukkit.block.data.BlockData.class, new HashSet<>())); + } + + private static String formatApiName(Class specialBlock) { + String apiName = specialBlock.getSimpleName(); + if (!BLOCK_SUFFIX_INTENDED.contains(specialBlock)) { + return apiName.substring(0, apiName.length() - "Block".length()); + } + return apiName; + } + + private static boolean handleComplexType(Field field, BiConsumer> complexCallback) throws IllegalAccessException { + if (field.getType().isArray() && Property.class.isAssignableFrom(field.getType().getComponentType())) { + if (!field.trySetAccessible()) { + return true; + } + + for (Property property : (Property[]) field.get(null)) { + complexCallback.accept(field, property); + } + return true; + } + if (Iterable.class.isAssignableFrom(field.getType()) && field.getGenericType() instanceof ParameterizedType complexType) { + Type[] args = complexType.getActualTypeArguments(); + if (args.length == 1 && Property.class.isAssignableFrom(ClassHelper.eraseType(args[0]))) { + if (!field.trySetAccessible()) { + return true; + } + + for (Property property : (Iterable>) field.get(null)) { + complexCallback.accept(field, property); + } + } + return true; + } + if (Map.class.isAssignableFrom(field.getType()) && field.getGenericType() instanceof ParameterizedType complexType) { + if (!field.trySetAccessible()) { + return true; + } + + Type[] args = complexType.getActualTypeArguments(); + if (args.length == 2 && Property.class.isAssignableFrom(ClassHelper.eraseType(args[1]))) { + for (Property property : ((Map>) field.get(null)).values()) { + complexCallback.accept(field, property); + } + return true; + } + } + return false; + } + + private static void fetchProperties(Class block, BiConsumer> simpleCallback, @Nullable BiConsumer> complexCallback) { + try { + for (Field field : block.getDeclaredFields()) { + if (ClassHelper.isStaticConstant(field, 0)) { + if (complexCallback != null && handleComplexType(field, complexCallback)) { + continue; + } + + if (!Property.class.isAssignableFrom(field.getType())) { + continue; + } + + if (field.trySetAccessible()) { + Property property = ((Property) field.get(null)); + simpleCallback.accept(field, property); + } + } + } + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + + if (block.isInterface()) { + return; + } + + // look deeper + if (block.getSuperclass() != null && block.getSuperclass() != Block.class) { + fetchProperties(block.getSuperclass(), simpleCallback, complexCallback); + } + for (Class ext : block.getInterfaces()) { + fetchProperties(ext, simpleCallback, complexCallback); + } + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/ClassHelper.java b/paper-generator/src/main/java/io/papermc/generator/utils/ClassHelper.java new file mode 100644 index 000000000..51e3df843 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/ClassHelper.java @@ -0,0 +1,72 @@ +package io.papermc.generator.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Set; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public final class ClassHelper { + + public static Set> getAllInterfaces(Class clazz, Class ignored, Set> interfaces) { + Class[] classes = clazz.getInterfaces(); + interfaces.addAll(Arrays.asList(classes)); + for (Class farClass : classes) { + if (farClass == ignored) { + continue; + } + getAllInterfaces(farClass, ignored, interfaces); + } + interfaces.remove(ignored); + return interfaces; + } + + public static @Nullable Type getNestedTypeParameter(Type type, @Nullable Class... classes) { + for (Class clazz : classes) { + if (!(type instanceof ParameterizedType complexType)) { + return null; + } + + Type[] types = complexType.getActualTypeArguments(); + if (types.length != 1) { + return null; + } + + if (clazz == null || eraseType(types[0]) == clazz) { + type = types[0]; + } + } + + return type; + } + + public static Class eraseType(Type type) { + if (type instanceof Class clazz) { + return clazz; + } + if (type instanceof ParameterizedType complexType) { + return eraseType(complexType.getRawType()); + } + throw new UnsupportedOperationException("Don't know how to turn " + type + " into its erased type!"); + } + + public static boolean isStaticConstant(Field field, int extraFlags) { + int flags = extraFlags | Modifier.STATIC | Modifier.FINAL; + return (field.getModifiers() & flags) == flags; + } + + public static @Nullable Class classOr(String className, @Nullable Class defaultClass) { + try { + return (Class) Class.forName(className); + } catch (ClassNotFoundException ignored) { + return defaultClass; + } + } + + private ClassHelper() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/CommonVariable.java b/paper-generator/src/main/java/io/papermc/generator/utils/CommonVariable.java new file mode 100644 index 000000000..55ea8c742 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/CommonVariable.java @@ -0,0 +1,10 @@ +package io.papermc.generator.utils; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class CommonVariable { + + public static final String INDEX = "index"; + public static final String MAP_ENTRY = "entry"; +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/Formatting.java b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java similarity index 50% rename from paper-api-generator/src/main/java/io/papermc/generator/utils/Formatting.java rename to paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java index b703a3245..9974a2a36 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/Formatting.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/Formatting.java @@ -7,13 +7,29 @@ import java.util.Locale; import java.util.OptionalInt; import java.util.function.Function; import java.util.regex.Pattern; +import java.util.stream.IntStream; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; +import org.jspecify.annotations.NullMarked; +@NullMarked public final class Formatting { private static final Pattern ILLEGAL_FIELD_CHARACTERS = Pattern.compile("[.-/]"); public static String formatKeyAsField(String path) { - return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ROOT)).replaceAll("_"); + return ILLEGAL_FIELD_CHARACTERS.matcher(path.toUpperCase(Locale.ENGLISH)).replaceAll("_"); + } + + public static String formatTagFieldPrefix(String name, ResourceKey> registryKey) { + if (registryKey == Registries.BLOCK) { + return ""; + } + if (registryKey == Registries.GAME_EVENT) { + return "GAME_EVENT_"; // Paper doesn't follow the format (should be GAME_EVENTS_) (pre 1.21) + } + return name.toUpperCase(Locale.ENGLISH) + "_"; } public static Optional formatTagKey(String tagDir, String resourcePath) { @@ -25,7 +41,39 @@ public final class Formatting { return Optional.of(resourcePath.substring(tagsIndex + tagDir.length() + 1, dotIndex)); // namespace/tags/registry_key/[tag_key].json } - public static Comparator ALPHABETIC_KEY_ORDER = alphabeticKeyOrder(path -> path); + public static String quoted(String value) { + return "\"" + value + "\""; + } + + public static String[] asCode(int... values) { + return IntStream.of(values).mapToObj(Integer::toString).toArray(String[]::new); + } + + public static String stripWordOfCamelCaseName(String name, String word, boolean onlyOnce) { + String newName = name; + int startIndex = 0; + while (true) { + int baseIndex = newName.indexOf(word, startIndex); + if (baseIndex == -1) { + return newName; + } + + if ((baseIndex > 0 && !Character.isLowerCase(newName.charAt(baseIndex - 1))) || + (baseIndex + word.length() < newName.length() && !Character.isUpperCase(newName.charAt(baseIndex + word.length())))) { + startIndex = baseIndex + word.length(); + continue; + } + + newName = newName.substring(0, baseIndex) + newName.substring(baseIndex + word.length()); + startIndex = baseIndex; + if (onlyOnce) { + break; + } + } + return newName; + } + + public static final Comparator ALPHABETIC_KEY_ORDER = alphabeticKeyOrder(path -> path); public static Comparator alphabeticKeyOrder(Function mapper) { return (o1, o2) -> { diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/Javadocs.java b/paper-generator/src/main/java/io/papermc/generator/utils/Javadocs.java new file mode 100644 index 000000000..4c5244079 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/Javadocs.java @@ -0,0 +1,44 @@ +package io.papermc.generator.utils; + +import org.jspecify.annotations.NullMarked; + +@NullMarked +public final class Javadocs { + + public static String getVersionDependentClassHeader(String objectIdentifier, String headerIdentifier) { + return """ + Vanilla %s for %s. + + @apiNote The fields provided here are a direct representation of + what is available from the vanilla game source. They may be + changed (including removals) on any Minecraft version + bump, so cross-version compatibility is not provided on the + same level as it is on most of the other API. + """.formatted(objectIdentifier, headerIdentifier); + } + + public static String getVersionDependentField(String headerIdentifier) { + return """ + %s + + @apiNote This field is version-dependant and may be removed in future Minecraft versions + """.formatted(headerIdentifier); + } + + public static final String CREATE_TYPED_KEY_JAVADOC = """ + Creates a typed key for {@link $T} in the registry {@code $L}. + + @param key the value's key in the registry + @return a new typed key + """; + + public static final String CREATED_TAG_KEY_JAVADOC = """ + Creates a tag key for {@link $T} in the registry {@code $L}. + + @param key the tag key's key + @return a new tag key + """; + + private Javadocs() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/NamingManager.java b/paper-generator/src/main/java/io/papermc/generator/utils/NamingManager.java new file mode 100644 index 000000000..d5ca379ae --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/NamingManager.java @@ -0,0 +1,141 @@ +package io.papermc.generator.utils; + +import com.google.common.base.CaseFormat; +import java.util.Optional; +import java.util.function.Predicate; +import javax.lang.model.SourceVersion; +import org.jetbrains.annotations.Contract; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; + +@NullMarked +public class NamingManager { + + private final @Nullable AccessKeyword accessKeyword; + private final String baseName; + private final String lowerCamelName, upperCamelName; + + public NamingManager(NamingManager.@Nullable AccessKeyword accessKeyword, CaseFormat format, String baseName) { + this.accessKeyword = accessKeyword; // this is a little bit too restrictive for extra data hmm + this.baseName = baseName; + this.upperCamelName = format.to(CaseFormat.UPPER_CAMEL, baseName); + this.lowerCamelName = format.to(CaseFormat.LOWER_CAMEL, baseName); + } + + public String getVariableName() { + return this.lowerCamelName; + } + + public String getMethodBaseName() { + return this.upperCamelName; + } + + public NameWrapper getMethodNameWrapper() { + return NameWrapper.wrap("get", this.upperCamelName); + } + + public NameWrapper getVariableNameWrapper() { + return NameWrapper.wrap("", this.lowerCamelName); + } + + public NameWrapper getterName(Predicate keywordPredicate) { + return accessName(keywordPredicate, AccessKeyword::get, "get"); + } + + public NameWrapper setterName(Predicate keywordPredicate) { + return accessName(keywordPredicate, AccessKeyword::set, "set"); + } + + public String simpleGetterName(Predicate keywordPredicate) { + return getterName(keywordPredicate).concat(); + } + + public String simpleSetterName(Predicate keywordPredicate) { + return setterName(keywordPredicate).concat(); + } + + private NameWrapper accessName(Predicate keywordPredicate, KeywordFetcher keywordFetcher, String fallbackKeyword) { + final String name; + String accessKeyword; + if (keywordPredicate.test(this.baseName)) { + accessKeyword = Optional.ofNullable(this.accessKeyword).flatMap(keywordFetcher::fetch).orElse(fallbackKeyword); + name = this.upperCamelName; + } else { + accessKeyword = ""; + name = this.lowerCamelName; + } + return NameWrapper.wrap(accessKeyword, name); + } + + public String paramName(Class type) { + final String paramName; + if (type.isPrimitive()) { + paramName = this.lowerCamelName; + } else { + paramName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, type.getSimpleName()); + } + return ensureValidName(paramName); + } + + public static String ensureValidName(String name) { + if (!SourceVersion.isIdentifier(name) || SourceVersion.isKeyword(name)) { + return "_" + name; + } + return name; + } + + public static class NameWrapper { + + private final String keyword; + private final String name; + private String preValue = "", postValue = ""; + + private NameWrapper(String keyword, String name) { + this.keyword = keyword; + this.name = name; + } + + public static NameWrapper wrap(String keyword, String name) { + return new NameWrapper(keyword, name); + } + + @Contract(value = "_ -> this", mutates = "this") + public NameWrapper pre(String value) { + this.preValue = value; + return this; + } + + @Contract(value = "_ -> this", mutates = "this") + public NameWrapper post(String value) { + this.postValue = value; + return this; + } + + public String concat() { + String finalName = this.keyword + this.preValue + this.name + this.postValue; + this.preValue = this.postValue = ""; // reset + return ensureValidName(finalName); + } + } + + @FunctionalInterface + private interface KeywordFetcher { + + Optional fetch(AccessKeyword accessKeyword); + } + + public static AccessKeyword keywordGet(String keyword) { + return new AccessKeyword(Optional.of(keyword), Optional.empty()); + } + + public static AccessKeyword keywordSet(String keyword) { + return new AccessKeyword(Optional.empty(), Optional.of(keyword)); + } + + public static AccessKeyword keywordGetSet(String getter, String setter) { + return new AccessKeyword(Optional.of(getter), Optional.of(setter)); + } + + public record AccessKeyword(Optional get, Optional set) { + } +} diff --git a/paper-api-generator/src/main/java/io/papermc/generator/utils/CollectingContext.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/CollectingContext.java similarity index 51% rename from paper-api-generator/src/main/java/io/papermc/generator/utils/CollectingContext.java rename to paper-generator/src/main/java/io/papermc/generator/utils/experimental/CollectingContext.java index c2fbaa2a0..c360dc6fa 100644 --- a/paper-api-generator/src/main/java/io/papermc/generator/utils/CollectingContext.java +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/CollectingContext.java @@ -1,4 +1,4 @@ -package io.papermc.generator.utils; +package io.papermc.generator.utils.experimental; import com.mojang.serialization.Lifecycle; import io.papermc.generator.Main; @@ -8,21 +8,20 @@ import net.minecraft.core.HolderGetter; import net.minecraft.core.Registry; import net.minecraft.data.worldgen.BootstrapContext; import net.minecraft.resources.ResourceKey; -import org.checkerframework.checker.nullness.qual.NonNull; -import org.checkerframework.framework.qual.DefaultQualifier; +import org.jspecify.annotations.NullMarked; -@DefaultQualifier(NonNull.class) +@NullMarked public record CollectingContext(Set> registered, Registry registry) implements BootstrapContext { @Override - public Holder.Reference register(final ResourceKey resourceKey, final @NonNull T t, final Lifecycle lifecycle) { - this.registered.add(resourceKey); - return Holder.Reference.createStandAlone(this.registry, resourceKey); + public Holder.Reference register(ResourceKey key, T value, Lifecycle lifecycle) { + this.registered.add(key); + return Holder.Reference.createStandAlone(this.registry, key); } @Override - public HolderGetter lookup(final ResourceKey> resourceKey) { - return Main.REGISTRY_ACCESS.lookupOrThrow(resourceKey); + public HolderGetter lookup(ResourceKey> key) { + return Main.REGISTRY_ACCESS.lookupOrThrow(key); } } diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/ExperimentalCollector.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/ExperimentalCollector.java new file mode 100644 index 000000000..5e715d038 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/ExperimentalCollector.java @@ -0,0 +1,132 @@ +package io.papermc.generator.utils.experimental; + +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; +import com.mojang.logging.LogUtils; +import io.papermc.generator.Main; +import io.papermc.generator.utils.Formatting; +import java.util.Collection; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.stream.Collectors; +import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; +import net.minecraft.core.RegistrySetBuilder; +import net.minecraft.core.registries.Registries; +import net.minecraft.data.registries.TradeRebalanceRegistries; +import net.minecraft.data.registries.VanillaRegistries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.packs.PackResources; +import net.minecraft.server.packs.PackType; +import net.minecraft.server.packs.repository.BuiltInPackSource; +import net.minecraft.server.packs.resources.MultiPackResourceManager; +import net.minecraft.tags.TagKey; +import org.jspecify.annotations.NullMarked; +import org.jspecify.annotations.Nullable; +import org.slf4j.Logger; + +@NullMarked +public final class ExperimentalCollector { + + private static final Logger LOGGER = LogUtils.getLogger(); + + private static final Map>, RegistrySetBuilder.RegistryBootstrap> VANILLA_REGISTRY_ENTRIES = VanillaRegistries.BUILDER.entries.stream() + .collect(Collectors.toMap(RegistrySetBuilder.RegistryStub::key, RegistrySetBuilder.RegistryStub::bootstrap)); + + private static final Map EXPERIMENTAL_REGISTRY_FLAGS = Map.of( + // Update for Experimental API + TradeRebalanceRegistries.BUILDER, FlagHolders.TRADE_REBALANCE + ); + + private static final Multimap>, Map.Entry>> EXPERIMENTAL_REGISTRY_ENTRIES; + static { + EXPERIMENTAL_REGISTRY_ENTRIES = HashMultimap.create(); + for (Map.Entry entry : EXPERIMENTAL_REGISTRY_FLAGS.entrySet()) { + for (RegistrySetBuilder.RegistryStub stub : entry.getKey().entries) { + EXPERIMENTAL_REGISTRY_ENTRIES.put(stub.key(), Map.entry(entry.getValue(), stub.bootstrap())); + } + } + } + + @SuppressWarnings("unchecked") + public static Map, SingleFlagHolder> collectDataDrivenElementIds(Registry registry) { + Collection>> experimentalEntries = EXPERIMENTAL_REGISTRY_ENTRIES.get(registry.key()); + if (experimentalEntries.isEmpty()) { + return Collections.emptyMap(); + } + + Map, SingleFlagHolder> result = new IdentityHashMap<>(); + for (Map.Entry> experimentalEntry : experimentalEntries) { + RegistrySetBuilder.RegistryBootstrap experimentalBootstrap = (RegistrySetBuilder.RegistryBootstrap) experimentalEntry.getValue(); + Set> experimental = Collections.newSetFromMap(new IdentityHashMap<>()); + CollectingContext experimentalCollector = new CollectingContext<>(experimental, registry); + experimentalBootstrap.run(experimentalCollector); + result.putAll(experimental.stream().collect(Collectors.toMap(key -> key, key -> experimentalEntry.getKey()))); + } + + RegistrySetBuilder.@Nullable RegistryBootstrap vanillaBootstrap = (RegistrySetBuilder.RegistryBootstrap) VANILLA_REGISTRY_ENTRIES.get(registry.key()); + if (vanillaBootstrap != null) { + Set> vanilla = Collections.newSetFromMap(new IdentityHashMap<>()); + CollectingContext vanillaCollector = new CollectingContext<>(vanilla, registry); + vanillaBootstrap.run(vanillaCollector); + result.keySet().removeAll(vanilla); + } + return result; + } + + // collect all the tags by grabbing the json from the data-packs + // another (probably) way is to hook into the data generator like the typed keys generator + public static Map, String> collectTags(MultiPackResourceManager resourceManager) { + Map, String> result = new IdentityHashMap<>(); + + // collect all vanilla tags + Multimap>, String> vanillaTags = HashMultimap.create(); + PackResources vanillaPack = resourceManager.listPacks() + .filter(packResources -> packResources.packId().equals(BuiltInPackSource.VANILLA_ID)) + .findFirst() + .orElseThrow(); + collectTagsFromPack(vanillaPack, (entry, path) -> vanillaTags.put(entry.key(), path)); + + // then distinct with other data-pack tags to know for sure newly created tags and so experimental one + resourceManager.listPacks().forEach(pack -> { + String packId = pack.packId(); + if (packId.equals(BuiltInPackSource.VANILLA_ID)) return; + + collectTagsFromPack(pack, (entry, path) -> { + if (vanillaTags.get(entry.key()).contains(path)) { + return; + } + + result.put(entry.value().listTagIds() + .filter(tagKey -> tagKey.location().getPath().equals(path)) + .findFirst() + .orElseThrow(), packId); + }); + }); + return Collections.unmodifiableMap(result); + } + + private static void collectTagsFromPack(PackResources pack, BiConsumer, String> output) { + Set namespaces = pack.getNamespaces(PackType.SERVER_DATA); + + for (String namespace : namespaces) { + Main.REGISTRY_ACCESS.registries().forEach(entry -> { + // this is probably expensive but can't find another way around and data-pack loader has similar logic + // the issue is that registry key can have parent/key but tag key can also have parent/key so parsing become a mess + // without having at least one of the two values + String tagDir = Registries.tagsDirPath(entry.key()); + pack.listResources(PackType.SERVER_DATA, namespace, tagDir, (id, supplier) -> { + Formatting.formatTagKey(tagDir, id.getPath()).ifPresentOrElse(path -> output.accept(entry, path), () -> { + LOGGER.warn("Unable to parse the path: {}/{}/{}.json in the data-pack {} into a tag key", namespace, tagDir, id.getPath(), pack.packId()); + }); + }); + }); + } + } + + private ExperimentalCollector() { + } +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolder.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolder.java new file mode 100644 index 000000000..a6c9ad76f --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolder.java @@ -0,0 +1,16 @@ +package io.papermc.generator.utils.experimental; + +import net.minecraft.world.flag.FeatureFlag; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.flag.FeatureFlags; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public interface FlagHolder { + + default FeatureFlagSet flagSet() { + return FeatureFlags.REGISTRY.subset(this.flag()); + } + + FeatureFlag flag(); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java new file mode 100644 index 000000000..1472ebb59 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/FlagHolders.java @@ -0,0 +1,24 @@ +package io.papermc.generator.utils.experimental; + +import java.util.HashMap; +import java.util.Map; +import java.util.stream.Collectors; +import net.minecraft.Util; +import net.minecraft.world.flag.FeatureFlag; +import net.minecraft.world.flag.FeatureFlags; +import org.bukkit.MinecraftExperimental; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public class FlagHolders { + + public static final SingleFlagHolder TRADE_REBALANCE = SingleFlagHolder.fromValue(FeatureFlags.TRADE_REBALANCE); + public static final SingleFlagHolder REDSTONE_EXPERIMENTS = SingleFlagHolder.fromValue(FeatureFlags.REDSTONE_EXPERIMENTS); + public static final SingleFlagHolder MINECART_IMPROVEMENTS = SingleFlagHolder.fromValue(FeatureFlags.MINECART_IMPROVEMENTS); + + static final Map ANNOTATION_EQUIVALENT = Util.make(new HashMap(), map -> { + map.put(TRADE_REBALANCE, MinecraftExperimental.Requires.TRADE_REBALANCE); + map.put(REDSTONE_EXPERIMENTS, MinecraftExperimental.Requires.REDSTONE_EXPERIMENTS); + map.put(MINECART_IMPROVEMENTS, MinecraftExperimental.Requires.MINECART_IMPROVEMENTS); + }).entrySet().stream().collect(Collectors.toMap(entry -> entry.getKey().flag(), Map.Entry::getValue)); +} diff --git a/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java new file mode 100644 index 000000000..497805310 --- /dev/null +++ b/paper-generator/src/main/java/io/papermc/generator/utils/experimental/SingleFlagHolder.java @@ -0,0 +1,49 @@ +package io.papermc.generator.utils.experimental; + +import com.google.common.base.Preconditions; +import com.google.common.collect.HashBiMap; +import java.util.HashMap; +import java.util.Map; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.flag.FeatureFlag; +import net.minecraft.world.flag.FeatureFlagSet; +import net.minecraft.world.flag.FeatureFlags; +import org.bukkit.MinecraftExperimental; +import org.jspecify.annotations.NullMarked; + +@NullMarked +public record SingleFlagHolder(FeatureFlag flag) implements FlagHolder { // todo support multiple flags? + + private static final Map FEATURE_FLAG_CACHE = new HashMap<>(); + private static final Map FEATURE_FLAG_NAME = HashBiMap.create(FeatureFlags.REGISTRY.names).inverse(); + + static SingleFlagHolder fromValue(FeatureFlag flag) { + return new SingleFlagHolder(flag); + } + + public static SingleFlagHolder fromSet(FeatureFlagSet standaloneSet) { + Preconditions.checkArgument(Long.bitCount(standaloneSet.mask) == 1, "Flag set size must be equals to 1."); + + for (FeatureFlag flag : FeatureFlags.REGISTRY.names.values()) { + if (standaloneSet.contains(flag)) { + return fromValue(flag); + } + } + + throw new IllegalStateException(); + } + + public static SingleFlagHolder fromName(String name) { + return fromValue(FEATURE_FLAG_CACHE.computeIfAbsent(name, key -> { + return FeatureFlags.REGISTRY.names.get(ResourceLocation.withDefaultNamespace(key)); + })); + } + + public MinecraftExperimental.Requires asAnnotationMember() { + MinecraftExperimental.Requires annotationMember = FlagHolders.ANNOTATION_EQUIVALENT.get(this.flag); + if (annotationMember == null) { + throw new UnsupportedOperationException("Don't know that feature flag: " + FEATURE_FLAG_NAME.get(this.flag)); + } + return annotationMember; + } +} diff --git a/paper-generator/src/test/java/io/papermc/generator/BlockStatePropertyTest.java b/paper-generator/src/test/java/io/papermc/generator/BlockStatePropertyTest.java new file mode 100644 index 000000000..d0c6c2cfa --- /dev/null +++ b/paper-generator/src/test/java/io/papermc/generator/BlockStatePropertyTest.java @@ -0,0 +1,74 @@ +package io.papermc.generator; + +import io.papermc.generator.utils.BlockStateMapping; +import java.lang.invoke.MethodHandles; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.Collections; +import java.util.HashSet; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import io.papermc.generator.utils.ClassHelper; +import net.minecraft.SharedConstants; +import net.minecraft.server.Bootstrap; +import net.minecraft.world.level.block.ChiseledBookShelfBlock; +import net.minecraft.world.level.block.MossyCarpetBlock; +import net.minecraft.world.level.block.PipeBlock; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class BlockStatePropertyTest { + + private static Set>> ENUM_PROPERTY_VALUES; + + @BeforeAll + public static void getAllProperties() { + // bootstrap + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + Bootstrap.validate(); + + // get all properties + Set>> enumPropertyValues = Collections.newSetFromMap(new IdentityHashMap<>()); + try { + for (Field field : BlockStateProperties.class.getDeclaredFields()) { + if (ClassHelper.isStaticConstant(field, Modifier.PUBLIC)) { + if (!EnumProperty.class.isAssignableFrom(field.getType())) { + continue; + } + + enumPropertyValues.add(((EnumProperty) field.get(null)).getValueClass()); + } + } + ENUM_PROPERTY_VALUES = Collections.unmodifiableSet(enumPropertyValues); + } catch (ReflectiveOperationException ex) { + throw new RuntimeException(ex); + } + } + + @Test + public void testReferences() throws NoSuchFieldException, IllegalAccessException { + // if renamed should change DataPropertyWriter#FIELD_TO_BASE_NAME/FIELD_TO_BASE_NAME_SPECIFICS + MethodHandles.Lookup lookup = MethodHandles.lookup(); + lookup.findStaticVarHandle(ChiseledBookShelfBlock.class, "SLOT_OCCUPIED_PROPERTIES", List.class); + lookup.findStaticVarHandle(PipeBlock.class, "PROPERTY_BY_DIRECTION", Map.class); + MethodHandles.privateLookupIn(MossyCarpetBlock.class, lookup).findStaticVarHandle(MossyCarpetBlock.class, "PROPERTY_BY_DIRECTION", Map.class); + } + + @Test + public void testBridge() { + Set missingApiEquivalents = new HashSet<>(); + for (Class> value : ENUM_PROPERTY_VALUES) { + if (!BlockStateMapping.ENUM_BRIDGE.containsKey(value)) { + missingApiEquivalents.add(value.getCanonicalName()); + } + } + + Assertions.assertTrue(missingApiEquivalents.isEmpty(), () -> "Missing some api equivalent in the block state mapping enum bridge (BlockStateMapping#ENUM_BRIDGE) : " + String.join(", ", missingApiEquivalents)); + } +} diff --git a/paper-api-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java b/paper-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java similarity index 74% rename from paper-api-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java rename to paper-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java index 9bc9f6b40..56052d6b5 100644 --- a/paper-api-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java +++ b/paper-generator/src/test/java/io/papermc/generator/MobGoalConverterTest.java @@ -3,21 +3,21 @@ package io.papermc.generator; import io.github.classgraph.ClassGraph; import io.github.classgraph.ScanResult; import io.papermc.generator.types.goal.MobGoalNames; +import java.util.ArrayList; +import java.util.List; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Mob; import org.junit.jupiter.api.Test; -import java.util.ArrayList; -import java.util.List; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.fail; +import static org.junit.jupiter.api.Assertions.assertTrue; public class MobGoalConverterTest { @Test public void testBukkitMap() { final List> classes; - try (ScanResult scanResult = new ClassGraph().enableAllInfo().whitelistPackages(Entity.class.getPackageName()).scan()) { + try (ScanResult scanResult = new ClassGraph().enableClassInfo().whitelistPackages(Entity.class.getPackageName()).scan()) { classes = scanResult.getSubclasses(Mob.class.getName()).loadClasses(Mob.class); } @@ -30,8 +30,6 @@ public class MobGoalConverterTest { } } - if (!missingClasses.isEmpty()) { - fail("Missing some entity classes in the bukkit map: " + String.join(", ", missingClasses)); - } + assertTrue(missingClasses.isEmpty(), () -> "Missing some entity classes in the bukkit map: " + String.join(", ", missingClasses)); } } diff --git a/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java new file mode 100644 index 000000000..61a264843 --- /dev/null +++ b/paper-generator/src/test/java/io/papermc/generator/RegistryMigrationTest.java @@ -0,0 +1,50 @@ +package io.papermc.generator; + +import io.papermc.generator.registry.RegistryEntries; +import io.papermc.generator.registry.RegistryEntry; +import java.util.HashSet; +import java.util.Set; +import net.minecraft.SharedConstants; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.Bootstrap; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; + +public class RegistryMigrationTest { + + @BeforeAll + public static void setup() { + SharedConstants.tryDetectVersion(); + Bootstrap.bootStrap(); + Bootstrap.validate(); + } + + @Test + public void testBuiltInToDataDriven() { + Set migratedRegistries = new HashSet<>(); + for (RegistryEntry entry : RegistryEntries.BUILT_IN) { + ResourceKey> key = entry.registryKey(); + if (!BuiltInRegistries.REGISTRY.containsKey(key.location())) { + migratedRegistries.add(key.toString()); + } + } + + Assertions.assertTrue(migratedRegistries.isEmpty(), () -> "Some registries have become data-driven: %s".formatted(String.join(", ", migratedRegistries))); + } + + @Test + public void testDataDrivenToBuiltIn() { // shouldn't really happen but just in case + Set migratedRegistries = new HashSet<>(); + for (RegistryEntry entry : RegistryEntries.DATA_DRIVEN) { + ResourceKey> key = entry.registryKey(); + if (BuiltInRegistries.REGISTRY.containsKey(key.location())) { + migratedRegistries.add(key.toString()); + } + } + + Assertions.assertTrue(migratedRegistries.isEmpty(), () -> "Some registries have become built-in: %s".formatted(String.join(", ", migratedRegistries))); + } +} diff --git a/paper-api-generator/wideners.at b/paper-generator/wideners.at similarity index 52% rename from paper-api-generator/wideners.at rename to paper-generator/wideners.at index 6c8ce1529..9e582e37b 100644 --- a/paper-api-generator/wideners.at +++ b/paper-generator/wideners.at @@ -1,6 +1,10 @@ +public net/minecraft/world/level/material/MapColor MATERIAL_COLORS +public net/minecraft/world/level/block/state/properties/IntegerProperty min + # for auto-marking experimental stuff public net/minecraft/core/RegistrySetBuilder entries public net/minecraft/core/RegistrySetBuilder$RegistryStub public net/minecraft/data/registries/VanillaRegistries BUILDER -public net/minecraft/data/registries/WinterDropRegistries BUILDER public net/minecraft/data/registries/TradeRebalanceRegistries BUILDER +public net/minecraft/world/flag/FeatureFlagRegistry names +public net/minecraft/world/flag/FeatureFlagSet mask diff --git a/paper-server/build.gradle.kts b/paper-server/build.gradle.kts index b3a223e15..4911dfaf8 100644 --- a/paper-server/build.gradle.kts +++ b/paper-server/build.gradle.kts @@ -1,29 +1,36 @@ import io.papermc.paperweight.attribute.DevBundleOutput import io.papermc.paperweight.util.* +import io.papermc.paperweight.util.data.FileEntry +import paper.libs.com.google.gson.annotations.SerializedName import java.time.Instant +import kotlin.io.path.readText plugins { `java-library` `maven-publish` + idea id("io.papermc.paperweight.core") } val paperMavenPublicUrl = "https://repo.papermc.io/repository/maven-public/" dependencies { - mache("io.papermc:mache:1.21.4+build.7") + mache("io.papermc:mache:1.21.5+build.1") paperclip("io.papermc:paperclip:3.0.3") testRuntimeOnly("org.junit.platform:junit-platform-launcher") } paperweight { minecraftVersion = providers.gradleProperty("mcVersion") - // macheOldPath = file("F:\\Projects\\PaperTooling\\mache\\versions\\1.21.4\\src\\main\\java") - // gitFilePatches = true + gitFilePatches = false + + //updatingMinecraft { + // oldPaperCommit = "f4f275519f7c1fbe9db173b7144a4fe81440e365" + //} spigot { - buildDataRef = "3edaf46ec1eed4115ce1b18d2846cded42577e42" - packageVersion = "v1_21_R3" // also needs to be updated in MappingEnvironment + buildDataRef = "702e1a0a5072b2c4082371d5228cb30525687efc" + packageVersion = "v1_21_R4" // also needs to be updated in MappingEnvironment } reobfPackagesToFix.addAll( @@ -107,6 +114,10 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { } val alsoShade: Configuration by configurations.creating +val runtimeConfiguration by configurations.consumable("runtimeConfiguration") { + attributes.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) +} + // Configure mockito agent that is needed in newer java versions val mockitoAgent = configurations.register("mockitoAgent") abstract class MockitoAgentProvider : CommandLineArgumentProvider { @@ -124,7 +135,8 @@ dependencies { implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 implementation("net.minecrell:terminalconsoleappender:1.3.0") - implementation("net.kyori:adventure-text-serializer-ansi:4.18.0") // Keep in sync with adventureVersion from Paper-API build file + implementation("io.papermc.adventure:adventure-text-serializer-ansi:4.21.0-mc1215-SNAPSHOT") // Keep in sync with adventureVersion from Paper-API build file // FIXME back to release + runtimeConfiguration(sourceSets.main.map { it.runtimeClasspath }) /* Required to add the missing Log4j2Plugins.dat file from log4j-core @@ -213,13 +225,13 @@ tasks.compileTestJava { options.compilerArgs.add("-parameters") } -val scanJar = tasks.register("scanJarForBadCalls", io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { +val scanJarForBadCalls by tasks.registering(io.papermc.paperweight.tasks.ScanJarForBadCalls::class) { badAnnotations.add("Lio/papermc/paper/annotation/DoNotUse;") jarToScan.set(tasks.jar.flatMap { it.archiveFile }) classpath.from(configurations.compileClasspath) } tasks.check { - dependsOn(scanJar) + dependsOn(scanJarForBadCalls) } // Use TCA for console improvements @@ -250,6 +262,32 @@ tasks.test { jvmArgumentProviders.add(provider) } +val generatedDir: java.nio.file.Path = layout.projectDirectory.dir("src/generated/java").asFile.toPath() +idea { + module { + generatedSourceDirs.add(generatedDir.toFile()) + } +} +sourceSets { + main { + java { + srcDir(generatedDir) + } + } +} + +if (providers.gradleProperty("updatingMinecraft").getOrElse("false").toBoolean()) { + val scanJarForOldGeneratedCode by tasks.registering(io.papermc.paperweight.tasks.ScanJarForOldGeneratedCode::class) { + mcVersion.set(providers.gradleProperty("mcVersion")) + annotation.set("Lio/papermc/paper/generated/GeneratedFrom;") + jarToScan.set(tasks.jar.flatMap { it.archiveFile }) + classpath.from(configurations.compileClasspath) + } + tasks.check { + dependsOn(scanJarForOldGeneratedCode) + } +} + fun TaskContainer.registerRunTask( name: String, block: JavaExec.() -> Unit diff --git a/paper-server/patches/features/0002-Allow-Saving-of-Oversized-Chunks.patch b/paper-server/patches/features/0002-Allow-Saving-of-Oversized-Chunks.patch index 950f46073..b8f3933b6 100644 --- a/paper-server/patches/features/0002-Allow-Saving-of-Oversized-Chunks.patch +++ b/paper-server/patches/features/0002-Allow-Saving-of-Oversized-Chunks.patch @@ -31,7 +31,7 @@ this fix, as the data will remain in the oversized file. Once the server returns to a jar with this fix, the data will be restored. diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index d0854fa02be52f560fc91adeb8495a6bd22f6f74..783a2d80f6197dd0af0dc81909f0353a8ea2ecf4 100644 +index 43d38cf26224919cd53d7479753d658f4ab40dbc..4eb07097986aac67421dd8e6a17cc5436da91187 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java @@ -53,6 +53,7 @@ public class RegionFile implements AutoCloseable { @@ -119,7 +119,7 @@ index d0854fa02be52f560fc91adeb8495a6bd22f6f74..783a2d80f6197dd0af0dc81909f0353a + // Paper end } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 5ac84d6b47e7fdc16e1c09b739829de3d316bf5b..51bf310423013d0ae9d3202d66e36a053a767197 100644 +index 5ac84d6b47e7fdc16e1c09b739829de3d316bf5b..763879cdc389fc4d80135b38aa96a5bec448ae9e 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -47,6 +47,43 @@ public final class RegionFileStorage implements AutoCloseable { @@ -139,10 +139,10 @@ index 5ac84d6b47e7fdc16e1c09b739829de3d316bf5b..51bf310423013d0ae9d3202d66e36a05 + if (oversizedData == null) { + return chunk; + } -+ CompoundTag oversizedLevel = oversizedData.getCompound("Level"); ++ CompoundTag oversizedLevel = oversizedData.getCompoundOrEmpty("Level"); + -+ mergeChunkList(chunk.getCompound("Level"), oversizedLevel, "Entities", "Entities"); -+ mergeChunkList(chunk.getCompound("Level"), oversizedLevel, "TileEntities", "TileEntities"); ++ mergeChunkList(chunk.getCompoundOrEmpty("Level"), oversizedLevel, "Entities", "Entities"); ++ mergeChunkList(chunk.getCompoundOrEmpty("Level"), oversizedLevel, "TileEntities", "TileEntities"); + + return chunk; + } catch (Throwable throwable) { @@ -153,8 +153,8 @@ index 5ac84d6b47e7fdc16e1c09b739829de3d316bf5b..51bf310423013d0ae9d3202d66e36a05 + } + + private static void mergeChunkList(CompoundTag level, CompoundTag oversizedLevel, String key, String oversizedKey) { -+ net.minecraft.nbt.ListTag levelList = level.getList(key, net.minecraft.nbt.Tag.TAG_COMPOUND); -+ net.minecraft.nbt.ListTag oversizedList = oversizedLevel.getList(oversizedKey, net.minecraft.nbt.Tag.TAG_COMPOUND); ++ net.minecraft.nbt.ListTag levelList = level.getListOrEmpty(key); ++ net.minecraft.nbt.ListTag oversizedList = oversizedLevel.getListOrEmpty(oversizedKey); + + if (!oversizedList.isEmpty()) { + levelList.addAll(oversizedList); diff --git a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch index 944456687..4df728683 100644 --- a/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch +++ b/paper-server/patches/features/0003-Entity-Activation-Range-2.0.patch @@ -15,7 +15,7 @@ Adds villagers as separate config diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java new file mode 100644 -index 0000000000000000000000000000000000000000..ade6110cc6adb1263c0359ff7e96e96b959e61f3 +index 0000000000000000000000000000000000000000..2ebee223085fe7926c7f3e555df19ae69f36157e --- /dev/null +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -0,0 +1,318 @@ @@ -32,7 +32,7 @@ index 0000000000000000000000000000000000000000..ade6110cc6adb1263c0359ff7e96e96b +import net.minecraft.world.entity.ai.Brain; +import net.minecraft.world.entity.animal.Animal; +import net.minecraft.world.entity.animal.Bee; -+import net.minecraft.world.entity.animal.Sheep; ++import net.minecraft.world.entity.animal.sheep.Sheep; +import net.minecraft.world.entity.animal.horse.Llama; +import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EndCrystal; @@ -338,7 +338,7 @@ index 0000000000000000000000000000000000000000..ade6110cc6adb1263c0359ff7e96e96b + } +} diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index d95413af04121fe91ca0f3b0c70025b9808acef9..ad665c7535c615d2b03a3e7864be435f933235dd 100644 +index 88b81a5fbc88e6240f86c1e780d80eb4b601df8c..00a5ed09caa2689543bd47bcd93d5a6141d0af46 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableList; @@ -357,19 +357,11 @@ index d95413af04121fe91ca0f3b0c70025b9808acef9..ad665c7535c615d2b03a3e7864be435f import java.io.IOException; import java.io.Writer; import java.nio.file.Path; -@@ -95,7 +93,6 @@ import net.minecraft.world.level.levelgen.structure.StructureStart; - import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; - import net.minecraft.world.level.storage.DimensionDataStorage; - import net.minecraft.world.level.storage.LevelStorageSource; --import net.minecraft.world.phys.Vec3; - import org.apache.commons.lang3.mutable.MutableBoolean; - import org.slf4j.Logger; - diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index f45fb8ddb08d82ce76018b5a5c4fce5b3b319559..12f0dc36c5adcdbd9e1dad5f8512ac184da3960f 100644 +index 156f7ddc2fdc96b762598bad2a2b21f433518dc0..ef201f4add358fbf1818f3b2ec9e75fe2cce4c8b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -551,6 +551,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -544,6 +544,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.pop(); } @@ -377,7 +369,7 @@ index f45fb8ddb08d82ce76018b5a5c4fce5b3b319559..12f0dc36c5adcdbd9e1dad5f8512ac18 this.entityTickList .forEach( entity -> { -@@ -980,12 +981,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -982,12 +983,15 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe entity.totalEntityAge++; // Paper - age-like counter for all entities profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(entity.getType()).toString()); profilerFiller.incrementCounter("tickNonPassenger"); @@ -394,7 +386,7 @@ index f45fb8ddb08d82ce76018b5a5c4fce5b3b319559..12f0dc36c5adcdbd9e1dad5f8512ac18 } // Paper start - log detailed entity tick information } finally { -@@ -996,7 +1000,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -998,7 +1002,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information } @@ -403,7 +395,7 @@ index f45fb8ddb08d82ce76018b5a5c4fce5b3b319559..12f0dc36c5adcdbd9e1dad5f8512ac18 if (passengerEntity.isRemoved() || passengerEntity.getVehicle() != ridingEntity) { passengerEntity.stopRiding(); } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { -@@ -1006,12 +1010,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1008,12 +1012,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push(() -> BuiltInRegistries.ENTITY_TYPE.getKey(passengerEntity.getType()).toString()); profilerFiller.incrementCounter("tickPassenger"); @@ -427,10 +419,10 @@ index f45fb8ddb08d82ce76018b5a5c4fce5b3b319559..12f0dc36c5adcdbd9e1dad5f8512ac18 } } diff --git a/net/minecraft/world/entity/AgeableMob.java b/net/minecraft/world/entity/AgeableMob.java -index a9f01e616ef6b0d74caf57cd68eb371a4fd30fd5..179f4e4b9b1eb57f78bbb2f9fa34b11ea79b7a88 100644 +index f9cfa9dd17bd259cfbc0d96bf48a17556b365d8b..201c6d6e2f5799a7678b16f01c85508bc72e8af5 100644 --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -126,6 +126,23 @@ public abstract class AgeableMob extends PathfinderMob { +@@ -129,6 +129,23 @@ public abstract class AgeableMob extends PathfinderMob { super.onSyncedDataUpdated(key); } @@ -455,10 +447,10 @@ index a9f01e616ef6b0d74caf57cd68eb371a4fd30fd5..179f4e4b9b1eb57f78bbb2f9fa34b11e public void aiStep() { super.aiStep(); diff --git a/net/minecraft/world/entity/AreaEffectCloud.java b/net/minecraft/world/entity/AreaEffectCloud.java -index 24735284fda151414d99faad401d25ba60995f9a..23b342cc31c7e72ade0e1ccad86a9ccf34380f13 100644 +index bf44f6b9c8710e0c9a85d44f6217501abc98a7b1..bfd904e468bbf2cc1a5b3353d3a69ad5087c81ae 100644 --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -128,6 +128,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { +@@ -144,6 +144,16 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { this.duration = duration; } @@ -476,10 +468,10 @@ index 24735284fda151414d99faad401d25ba60995f9a..23b342cc31c7e72ade0e1ccad86a9ccf public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 2facc7ad69bfe28c2f928a026ba5ab37387ab039..6256d7f8f4ee8bd4e3673b4e069af5cc0069c8f2 100644 +index fd0cc1bf9e4425a0924ed77854907deec1a7348e..1c9e5f61d182cf60caa885135abddc879d602c48 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -381,6 +381,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -388,6 +388,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess private final int despawnTime; // Paper - entity despawn time limit public int totalEntityAge; // Paper - age-like counter for all entities public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges @@ -492,10 +484,10 @@ index 2facc7ad69bfe28c2f928a026ba5ab37387ab039..6256d7f8f4ee8bd4e3673b4e069af5cc + public void inactiveTick() { + } + // Paper end - EAR 2 + // CraftBukkit end - public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) { - this.origin = location.toVector(); -@@ -414,6 +423,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + // Paper start +@@ -403,6 +412,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.position = Vec3.ZERO; this.blockPosition = BlockPos.ZERO; this.chunkPosition = ChunkPos.ZERO; @@ -509,16 +501,18 @@ index 2facc7ad69bfe28c2f928a026ba5ab37387ab039..6256d7f8f4ee8bd4e3673b4e069af5cc SynchedEntityData.Builder builder = new SynchedEntityData.Builder(this); builder.define(DATA_SHARED_FLAGS_ID, (byte)0); builder.define(DATA_AIR_SUPPLY_ID, this.getMaxAirSupply()); -@@ -978,6 +994,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -958,6 +974,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { - this.wasOnFire = this.isOnFire(); if (type == MoverType.PISTON) { -+ this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper - EAR 2 -+ this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper - EAR 2 ++ // Paper start - EAR 2 ++ this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); ++ this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); ++ // Paper end - EAR 2 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -991,6 +1009,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -971,6 +991,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.stuckSpeedMultiplier = Vec3.ZERO; this.setDeltaMovement(Vec3.ZERO); } @@ -533,10 +527,10 @@ index 2facc7ad69bfe28c2f928a026ba5ab37387ab039..6256d7f8f4ee8bd4e3673b4e069af5cc movement = this.maybeBackOffFromEdge(movement, type); Vec3 vec3 = this.collide(movement); diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index e0c310d970a687945b6a771b4ecb94044128c33c..4546aca8e2e144ec207653c713fc49f849908827 100644 +index 4123354a660f85905c8c2db1c5377201c2b8267e..7ba7a00b8dee651ca7a3cab5b64b4ae11aa66da9 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3103,6 +3103,14 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3163,6 +3163,14 @@ public abstract class LivingEntity extends Entity implements Attackable { return false; } @@ -552,10 +546,10 @@ index e0c310d970a687945b6a771b4ecb94044128c33c..4546aca8e2e144ec207653c713fc49f8 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index e12b47ca5eeb842bae606c0c7a8e3e4cf7d468a9..e330bf990e4874baed1b21cd8c9b44d66ec5b823 100644 +index 8f5c377540f83911c8d245fb00569f08dbc6a690..73ba442b9d39bc021cd5eb6c1c0f98aed94a5a02 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -215,6 +215,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -203,6 +203,19 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab return this.lookControl; } @@ -651,10 +645,10 @@ index 789fea258d70e60d38271ebb31270562dc7eb3ab..d0ab3db7bbd2942db19f473474371b20 } } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index 8b034b6bda937b25dbb3d09b8293fed6d7dc512c..52a7ed0d991758bad0dcedcb7f97fb15ac6c6d04 100644 +index ea3afc27600cde05a17197b071f14972d2c832e6..6c0ebfb2be4e8b884456a2aa3d5fdc87e45a0e3c 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -124,6 +124,29 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -131,6 +131,29 @@ public class ItemEntity extends Entity implements TraceableEntity { return 0.04; } @@ -685,10 +679,10 @@ index 8b034b6bda937b25dbb3d09b8293fed6d7dc512c..52a7ed0d991758bad0dcedcb7f97fb15 public void tick() { if (this.getItem().isEmpty()) { diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java -index 27568a1604d2dd5d46e836bbc25431929e218aa1..2b83262e4a13eae86df82913ce4f3121e3631a43 100644 +index 94032c60944f161519f0ddee69426cbfe3075170..e0e0d2ea7fc60e3142c675404d152eca60263240 100644 --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -265,11 +265,35 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -268,11 +268,35 @@ public class Villager extends AbstractVillager implements ReputationEventHandler return this.assignProfessionWhenSpawned; } @@ -706,7 +700,7 @@ index 27568a1604d2dd5d46e836bbc25431929e218aa1..2b83262e4a13eae86df82913ce4f3121 + this.customServerAiStep(this.level().getMinecraftWorld(), true); + } + } -+ maybeDecayGossip(); ++ this.maybeDecayGossip(); + super.inactiveTick(); + } + // Paper end - EAR 2 @@ -725,7 +719,7 @@ index 27568a1604d2dd5d46e836bbc25431929e218aa1..2b83262e4a13eae86df82913ce4f3121 profilerFiller.pop(); if (this.assignProfessionWhenSpawned) { this.assignProfessionWhenSpawned = false; -@@ -293,7 +317,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -296,7 +320,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler this.lastTradedPlayer = null; } @@ -734,19 +728,19 @@ index 27568a1604d2dd5d46e836bbc25431929e218aa1..2b83262e4a13eae86df82913ce4f3121 Raid raidAt = level.getRaidAt(this.blockPosition()); if (raidAt != null && raidAt.isActive() && !raidAt.isOver()) { level.broadcastEntityEvent(this, (byte)42); -@@ -303,6 +327,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler - if (this.getVillagerData().getProfession() == VillagerProfession.NONE && this.isTrading()) { +@@ -307,6 +331,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler this.stopTrading(); } -+ if (inactive) return; // Paper - EAR 2 ++ if (inactive) return; // Paper - EAR 2 super.customServerAiStep(level); } + diff --git a/net/minecraft/world/entity/projectile/Arrow.java b/net/minecraft/world/entity/projectile/Arrow.java -index c1e09e701757a300183b62d343ded03033e63aa7..56574f8ef879159edc0114da09300143a2c79a35 100644 +index 1f22f44abb21d1ed9a4870f668779efb8fd9b295..91ead824718eeea2afba3bc0ef619b8a24bb24b9 100644 --- a/net/minecraft/world/entity/projectile/Arrow.java +++ b/net/minecraft/world/entity/projectile/Arrow.java -@@ -66,6 +66,16 @@ public class Arrow extends AbstractArrow { +@@ -70,6 +70,16 @@ public class Arrow extends AbstractArrow { builder.define(ID_EFFECT_COLOR, -1); } @@ -764,10 +758,10 @@ index c1e09e701757a300183b62d343ded03033e63aa7..56574f8ef879159edc0114da09300143 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index a3e4605a81eeaca77cc3a3ab937b75a415d83037..c7ae41b2cbc1eb85a6eb9c16813bd326fb8f49f0 100644 +index dcb7714b2edeab8cfb0358929d07bd04cead26bf..e0e193078e550225e163149638bf9e053c0531f8 100644 --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -102,6 +102,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -109,6 +109,21 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { return super.shouldRender(x, y, z) && !this.isAttachedToEntity(); } @@ -790,10 +784,10 @@ index a3e4605a81eeaca77cc3a3ab937b75a415d83037..c7ae41b2cbc1eb85a6eb9c16813bd326 public void tick() { super.tick(); diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java -index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb9e20d1b7 100644 +index 6162415095b030b4cc47364c56fa66236b3b0535..a56d9cdeb6589a053ffaaf2cd599a98ae0a0989a 100644 --- a/net/minecraft/world/entity/vehicle/MinecartHopper.java +++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -47,6 +47,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -48,6 +48,7 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper if (flag != this.isEnabled()) { this.setEnabled(flag); } @@ -801,7 +795,7 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb } public boolean isEnabled() { -@@ -100,11 +101,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -101,11 +102,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public boolean suckInItems() { if (HopperBlockEntity.suckInItems(this.level(), this)) { @@ -815,7 +809,7 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb return true; } } -@@ -139,4 +142,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +@@ -140,4 +143,11 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper public AbstractContainerMenu createMenu(int id, Inventory playerInventory) { return new HopperMenu(id, playerInventory, this); } @@ -828,27 +822,27 @@ index c553cf0592dfa606dbbb1e6854d3377b9feb5efb..8341e7f01606fca90e69384c16fc19bb + } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 32f184288f6065259c921293922c1b0163df4dc4..0f346faa82b988e86834c38837f6f11bea7f31c6 100644 +index 1aa98e4f70627632d3e676395c28fa0ecca72f56..1f26826b2161cfeb27e5b2060e178b493e9142d9 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -153,6 +153,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public Map capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates +@@ -143,6 +143,12 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + @Nullable public List captureDrops; public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); -+ // Paper start ++ // Paper start - EAR 2 + public int wakeupInactiveRemainingAnimals; + public int wakeupInactiveRemainingFlying; + public int wakeupInactiveRemainingMonsters; + public int wakeupInactiveRemainingVillagers; -+ // Paper end ++ // Paper end - EAR 2 public boolean populating; public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot // Paper start - add paper world config diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index ce880bd45fbda4829d17de8507034b3a39c68cbb..ee2f8e8deb35059824b5730a1442f383dc79f01c 100644 +index f8d10be7a0aa7f66f05126e75187025c040e3494..1669b76800756000a2f620610b3c8c8b6c48dd4a 100644 --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -149,6 +149,10 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -153,6 +153,10 @@ public class PistonMovingBlockEntity extends BlockEntity { } entity.setDeltaMovement(d1, d2, d3); diff --git a/paper-server/patches/features/0004-Anti-Xray.patch b/paper-server/patches/features/0004-Anti-Xray.patch index 2a2def278..16f93f288 100644 --- a/paper-server/patches/features/0004-Anti-Xray.patch +++ b/paper-server/patches/features/0004-Anti-Xray.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Anti-Xray diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 81ff677e970ffbe7ad5381e56852e33cf7a8ea45..184e6c6fe2ba522d0ea0774604839320c4152371 100644 +index b9a838d638571bca1d00a620cedf169a3fa87e9d..329e9562e9c2b25228b04c21ff7353d2d8d6e5f6 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -37,20 +37,25 @@ public final class FeatureHooks { @@ -55,10 +55,10 @@ index d4872b7f4e9591b3b1c67406312905851303f521..cb41460e94161675e2ab43f4b1b5286e } diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 5d1943d37dfad0c12e77179f0866851532d983e9..3aea76690bc3e35758d3bf274777130af17d8a0f 100644 +index 89761bd368d75b8fb84f850fb3f8162fa280e236..272da41db7ce4619a8e459a2f0a2221e42f58a40 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -28,7 +28,13 @@ public class ClientboundLevelChunkPacketData { +@@ -33,13 +33,23 @@ public class ClientboundLevelChunkPacketData { private final byte[] buffer; private final List blockEntitiesData; @@ -69,12 +69,10 @@ index 5d1943d37dfad0c12e77179f0866851532d983e9..3aea76690bc3e35758d3bf274777130a + } + public ClientboundLevelChunkPacketData(LevelChunk levelChunk, io.papermc.paper.antixray.ChunkPacketInfo chunkPacketInfo) { + // Paper end - this.heightmaps = new CompoundTag(); - - for (Entry entry : levelChunk.getHeightmaps()) { -@@ -38,7 +44,11 @@ public class ClientboundLevelChunkPacketData { - } - + this.heightmaps = levelChunk.getHeightmaps() + .stream() + .filter(entry1 -> entry1.getKey().sendToClient()) + .collect(Collectors.toMap(Entry::getKey, entry1 -> (long[])entry1.getValue().getRawData().clone())); this.buffer = new byte[calculateChunkSize(levelChunk)]; - extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), levelChunk); + // Paper start - Anti-Xray - Add chunk packet info @@ -84,8 +82,8 @@ index 5d1943d37dfad0c12e77179f0866851532d983e9..3aea76690bc3e35758d3bf274777130a + extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), levelChunk, chunkPacketInfo); this.blockEntitiesData = Lists.newArrayList(); - for (Entry entryx : levelChunk.getBlockEntities().entrySet()) { -@@ -85,9 +95,17 @@ public class ClientboundLevelChunkPacketData { + for (Entry entry : levelChunk.getBlockEntities().entrySet()) { +@@ -82,9 +92,17 @@ public class ClientboundLevelChunkPacketData { return byteBuf; } @@ -145,10 +143,10 @@ index 3a384175f8e7f204234bbaf3081bdc20c47a0d4b..5699bc15eba92e22433a20cb8326b59f private ClientboundLevelChunkWithLightPacket(RegistryFriendlyByteBuf buffer) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index da8848e2a3e3745949eb2356a049451d30f763a7..192977dd661ee795ada13db895db770293e9b402 100644 +index ef201f4add358fbf1818f3b2ec9e75fe2cce4c8b..fe9b4484d683fe48f435a053c9c90557fdf80e7b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -348,7 +348,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -343,7 +343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe org.bukkit.generator.BiomeProvider biomeProvider // CraftBukkit ) { // CraftBukkit start @@ -156,13 +154,13 @@ index da8848e2a3e3745949eb2356a049451d30f763a7..192977dd661ee795ada13db895db7702 + super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules())), dispatcher); // Paper - create paper world configs; Async-Anti-Xray: Pass executor this.pvpMode = server.isPvpAllowed(); this.levelStorageAccess = levelStorageAccess; - this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()); + this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index 47ed3ad5c0b4753f58e0bafff5e5e70b2f0bb40b..623c069f1fe079e020c6391a3db1a3d95cd3dbf5 100644 +index b5378d6d73b6dab56bf664024f3f82496e9a9487..b604cba2490a747661d6819251bc3b9a1d35c7d4 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -299,6 +299,7 @@ public class ServerPlayerGameMode { - org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelected()); // CraftBukkit +@@ -296,6 +296,7 @@ public class ServerPlayerGameMode { + org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } + this.level.chunkPacketBlockController.onPlayerLeftClickBlock(this, pos, action, face, maxBuildHeight, sequence); // Paper - Anti-Xray @@ -188,10 +186,10 @@ index 342bc843c384761e883de861044f4f8930ae8763..14878690a88fd4de3e2c127086607e6c if (io.papermc.paper.event.packet.PlayerChunkLoadEvent.getHandlerList().getRegisteredListeners().length > 0) { new io.papermc.paper.event.packet.PlayerChunkLoadEvent(new org.bukkit.craftbukkit.CraftChunk(chunk), packetListener.getPlayer().getBukkitEntity()).callEvent(); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 600a08d6b45cb19dbe551cefbf726e68684a0837..ff0315cffdb282fdc0a1ffd15e2954caa76835c9 100644 +index a2a4dbcfb77d44657b3dfbe97cb629de215c29eb..73717609fccd9af12e2cc39824106f49426b581c 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -403,7 +403,7 @@ public abstract class PlayerList { +@@ -407,7 +407,7 @@ public abstract class PlayerList { .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket( new net.minecraft.world.level.chunk.EmptyLevelChunk(serverLevel, player.chunkPosition(), plains), @@ -201,18 +199,18 @@ index 600a08d6b45cb19dbe551cefbf726e68684a0837..ff0315cffdb282fdc0a1ffd15e2954ca } // Paper end - Send empty chunk diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 0f346faa82b988e86834c38837f6f11bea7f31c6..771d6ed6a7c889c09efd4ff6e20298c851eaa79f 100644 +index 1f26826b2161cfeb27e5b2060e178b493e9142d9..63f8b0c47e3321b74f4b6bcbc1e28cd751911198 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -168,6 +168,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } - // Paper end - add paper world config +@@ -132,6 +132,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + private long subTickCount; + // CraftBukkit start + public final io.papermc.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - public static BlockPos lastPhysicsProblem; // Spigot - private org.spigotmc.TickLimiter entityLimiter; - private org.spigotmc.TickLimiter tileLimiter; -@@ -214,7 +215,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + private final CraftWorld world; + public boolean pvpMode; + public org.bukkit.generator.ChunkGenerator generator; +@@ -201,7 +202,8 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl org.bukkit.generator.BiomeProvider biomeProvider, // CraftBukkit org.bukkit.World.Environment env, // CraftBukkit java.util.function.Function, AutoCl + public void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) {} + }); // CraftBukkit end - this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); + this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray } // Paper start - Cancel hit for vanished players -@@ -495,6 +498,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - // CraftBukkit end - - BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag +@@ -483,6 +486,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + snapshot.setFlags(flags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags + } + BlockState blockState = chunkAt.setBlockState(pos, state, flags); + this.chunkPacketBlockController.onBlockChange(this, pos, state, blockState, flags, recursionLeft); // Paper - Anti-Xray - + // CraftBukkit end if (blockState == null) { // CraftBukkit start - remove blockstate if failed (or the same) diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index c82780db7fe5b1557a7802d3111f38099be55ac1..d63d745a0220963a297cfedf1e8983aeb471a045 100644 +index c378f9e226df80ab0d4ebd06ae54ce556d0d94e7..97231db28146df56c727c9765f36277634d59a64 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -114,14 +114,14 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @@ -261,10 +259,10 @@ index c82780db7fe5b1557a7802d3111f38099be55ac1..d63d745a0220963a297cfedf1e8983ae } } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index ce781ba2c8b3f9f051201d3809a9cb041036f93a..cad71ac79fc52225a192aa5c5d07b13c831fc2c1 100644 +index 8fa871512ad52c345f15b1f5fb1baf54bb2ec93b..08e2442f6965cc6eaab67bdf9340a5152c08db2a 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -109,7 +109,7 @@ public class LevelChunk extends ChunkAccess { +@@ -110,7 +110,7 @@ public class LevelChunk extends ChunkAccess { @Nullable LevelChunk.PostLoadProcessor postLoad, @Nullable BlendingData blendingData ) { @@ -274,7 +272,7 @@ index ce781ba2c8b3f9f051201d3809a9cb041036f93a..cad71ac79fc52225a192aa5c5d07b13c this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index b3d600b0d6deaf44f232dfc86e1456c867e1c07f..a7fabde0f32f09d7f7bed65576ce469f069a21fa 100644 +index 2399a0f8839c0925a9923bae87362c2c9a217197..1aa4e39431a93a7789b74a2e3476a3e47605e2cc 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -38,9 +38,15 @@ public class LevelChunkSection { @@ -310,12 +308,12 @@ index b3d600b0d6deaf44f232dfc86e1456c867e1c07f..a7fabde0f32f09d7f7bed65576ce469f - this.biomes.write(buffer); + this.states.write(buffer, chunkPacketInfo, chunkSectionIndex); + this.biomes.write(buffer, null, chunkSectionIndex); -+ // Paper end - Anti-Xray ++ // Paper end - Anti-Xray - Add chunk packet info } public int getSerializedSize() { diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index e8ec28ce3fe13561b45c4654e174776d9d2d7b71..a6028a54c75de068515e95913b21160ab4326985 100644 +index 5a3ed1c2dd22434d96947580c4dff28a95eb8252..1491401ec94038450ea5eeb589fc33a336a3ae55 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -28,6 +28,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -454,7 +452,7 @@ index e8ec28ce3fe13561b45c4654e174776d9d2d7b71..a6028a54c75de068515e95913b21160a this.acquire(); @@ -172,24 +239,35 @@ public class PalettedContainer implements PaletteResize, PalettedContainer data.palette.read(buffer); - buffer.readLongArray(data.storage.getRaw()); + buffer.readFixedSizeLongArray(data.storage.getRaw()); this.data = data; + this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server) } finally { @@ -527,10 +525,10 @@ index e8ec28ce3fe13561b45c4654e174776d9d2d7b71..a6028a54c75de068515e95913b21160a + if (chunkPacketInfo != null) { + chunkPacketInfo.setBits(chunkSectionIndex, this.configuration.bits()); + chunkPacketInfo.setPalette(chunkSectionIndex, this.palette); -+ chunkPacketInfo.setIndex(chunkSectionIndex, buffer.writerIndex() + VarInt.getByteSize(this.storage.getRaw().length)); ++ chunkPacketInfo.setIndex(chunkSectionIndex, buffer.writerIndex()); + } -+ // Paper end - buffer.writeLongArray(this.storage.getRaw()); ++ // Paper end - Anti-Xray - Add chunk packet info + buffer.writeFixedSizeLongArray(this.storage.getRaw()); } diff --git a/net/minecraft/world/level/chunk/PalettedContainerRO.java b/net/minecraft/world/level/chunk/PalettedContainerRO.java @@ -550,7 +548,7 @@ index bfbb1a2bb4abbb369a24f2f01439e9ea3e16794b..8d6ed8be4d93f7d4e6ea80c351020d88 int getSerializedSize(); diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index c7c87bc8df86ceeef3e15a8f23fc252d4cee1984..3b55e7fb27d680204b8621666ae9200870def3eb 100644 +index 8efb5148a22b57ed090fb8fd20dd642223b3fb95..58bc96235f0149ea868da3bc3d20472f96d5f6ec 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java @@ -94,7 +94,7 @@ public record SerializableChunkData( @@ -560,51 +558,46 @@ index c7c87bc8df86ceeef3e15a8f23fc252d4cee1984..3b55e7fb27d680204b8621666ae92008 - Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState() + Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), null // Paper - Anti-Xray ); - private static final Logger LOGGER = LogUtils.getLogger(); - private static final String TAG_UPGRADE_DATA = "UpgradeData"; -@@ -128,6 +128,7 @@ public record SerializableChunkData( + private static final Codec>> BLOCK_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.BLOCK.byNameCodec()).listOf(); + private static final Codec>> FLUID_TICKS_CODEC = SavedTick.codec(BuiltInRegistries.FLUID.byNameCodec()).listOf(); +@@ -130,6 +130,7 @@ public record SerializableChunkData( @Nullable public static SerializableChunkData parse(LevelHeightAccessor levelHeightAccessor, RegistryAccess registries, CompoundTag tag) { + net.minecraft.server.level.ServerLevel serverLevel = (net.minecraft.server.level.ServerLevel) levelHeightAccessor; // Paper - Anti-Xray This is is seemingly only called from ChunkMap, where, we have a server level. We'll fight this later if needed. - if (!tag.contains("Status", 8)) { + if (tag.getString("Status").isEmpty()) { return null; } else { -@@ -212,18 +213,21 @@ public record SerializableChunkData( - Codec>> codec = makeBiomeCodecRW(registry); // CraftBukkit - read/write - - for (int i2 = 0; i2 < list7.size(); i2++) { -- CompoundTag compound2 = list7.getCompound(i2); -+ CompoundTag compound2 = list7.getCompound(i2); final CompoundTag sectionData = compound2; // Paper - Anti-Xray - OBFHELPER - int _byte = compound2.getByte("Y"); - LevelChunkSection levelChunkSection; - if (_byte >= levelHeightAccessor.getMinSectionY() && _byte <= levelHeightAccessor.getMaxSectionY()) { -+ // Paper start - Anti-Xray - Add preset block states -+ BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(serverLevel, chunkPos, _byte); - PalettedContainer palettedContainer; - if (compound2.contains("block_states", 10)) { -- palettedContainer = BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, compound2.getCompound("block_states")) -+ Codec> blockStateCodec = presetBlockStates == null ? BLOCK_STATE_CODEC : PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), presetBlockStates); // Paper - Anti-Xray -+ palettedContainer = blockStateCodec.parse(NbtOps.INSTANCE, sectionData.getCompound("block_states")) // Paper - Anti-Xray - .promotePartial(string -> logErrors(chunkPos, _byte, string)) - .getOrThrow(SerializableChunkData.ChunkReadException::new); - } else { - palettedContainer = new PalettedContainer<>( -- Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES -+ Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, presetBlockStates // Paper - Anti-Xray - ); - } - -@@ -234,7 +238,7 @@ public record SerializableChunkData( - .getOrThrow(SerializableChunkData.ChunkReadException::new); - } else { - palettedContainerRo = new PalettedContainer<>( -- registry.asHolderIdMap(), registry.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES -+ registry.asHolderIdMap(), registry.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null // Paper - Anti-Xray - Add preset biomes - ); - } - -@@ -414,7 +418,7 @@ public record SerializableChunkData( +@@ -190,15 +191,17 @@ public record SerializableChunkData( + int byteOr = compoundTag.getByteOr("Y", (byte)0); + LevelChunkSection levelChunkSection; + if (byteOr >= levelHeightAccessor.getMinSectionY() && byteOr <= levelHeightAccessor.getMaxSectionY()) { ++ final BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(serverLevel, chunkPos, byteOr); // Paper - Anti-Xray - Add preset block states ++ final Codec> blockStateCodec = presetBlockStates == null ? BLOCK_STATE_CODEC : PalettedContainer.codecRW(Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState(), presetBlockStates); // Paper - Anti-Xray + PalettedContainer palettedContainer = compoundTag.getCompound("block_states") + .map( +- compoundTag1 -> BLOCK_STATE_CODEC.parse(NbtOps.INSTANCE, compoundTag1) ++ compoundTag1 -> blockStateCodec.parse(NbtOps.INSTANCE, compoundTag1) // Paper - Anti-Xray + .promotePartial(string -> logErrors(chunkPos, byteOr, string)) + .getOrThrow(SerializableChunkData.ChunkReadException::new) + ) + .orElseGet( + () -> new PalettedContainer<>( +- Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES ++ Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, presetBlockStates // Paper - Anti-Xray - Add preset biomes + ) + ); + PalettedContainer> palettedContainerRo = compoundTag.getCompound("biomes") // CraftBukkit - read/write +@@ -209,7 +212,7 @@ public record SerializableChunkData( + ) + .orElseGet( + () -> new PalettedContainer<>( +- registry.asHolderIdMap(), registry.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES ++ registry.asHolderIdMap(), registry.getOrThrow(Biomes.PLAINS), PalettedContainer.Strategy.SECTION_BIOMES, null // Paper - Anti-Xray - Add preset biomes + ) + ); + levelChunkSection = new LevelChunkSection(palettedContainer, palettedContainerRo); +@@ -382,7 +385,7 @@ public record SerializableChunkData( // CraftBukkit start - read/write private static Codec>> makeBiomeCodecRW(Registry biomeRegistry) { diff --git a/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch index 9011d342f..230782d7a 100644 --- a/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch +++ b/paper-server/patches/features/0005-Use-Velocity-compression-and-cipher-natives.patch @@ -269,7 +269,7 @@ index bc674b08a41d5529fe06c6d3f077051cf4138f73..ea8a894158c44c2e7943dea43ecd8e1f + // Paper end - Use Velocity cipher } diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index ad8f8428b75e37097487cdfbd0db2421ee4cbe37..208efae06c7c44f220d4192219a86ec55c98a2fe 100644 +index 2040b9555c430420a8a8697cc131d42eafb96fa1..4ed9611994c5c8da01fede690197527c5b3a5731 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java @@ -772,11 +772,22 @@ public class Connection extends SimpleChannelInboundHandler> { @@ -336,10 +336,10 @@ index 7de11ba404f0b60e7f7b7c16954811a343688219..bd07e6a5aa1883786d789ea71711a0c0 this.channels .add( diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index bb28453d230921d662ed69c8dd48021f428ef060..6689aeacf50d1498e8d23cce696fb4fecbd1cf39 100644 +index 5d48487568994860c153351ad4c6c33bc8aa5309..7950f4f88d8a83ed5610b7af4e134557d32da3f0 100644 --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -276,11 +276,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -275,11 +275,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, } SecretKey secretKey = packet.getSecretKey(_private); diff --git a/paper-server/patches/features/0006-Optimize-Collision-to-not-load-chunks.patch b/paper-server/patches/features/0006-Optimize-Collision-to-not-load-chunks.patch index 8739390e3..9a76d082d 100644 --- a/paper-server/patches/features/0006-Optimize-Collision-to-not-load-chunks.patch +++ b/paper-server/patches/features/0006-Optimize-Collision-to-not-load-chunks.patch @@ -14,19 +14,19 @@ movement will load only the chunk the player enters anyways and avoids loading massive amounts of surrounding chunks due to large AABB lookups. diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 054ece1d539d69a4b7eec57e681179343c7e75c3..6f35067c64f378e955261e763f2bda9a0a6d0153 100644 +index a8eaccde3ec9ed912cbc6df0b29e9f8136a46578..0f6ca6ef161ac2934ba761a1eca3215290c7262b 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -218,6 +218,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -223,6 +223,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper end - Share random for entities to make them more random - public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + public boolean collisionLoadChunks = false; // Paper private @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntity() { diff --git a/net/minecraft/world/level/BlockCollisions.java b/net/minecraft/world/level/BlockCollisions.java -index fd2c338db43aad070cc32c24891b40599c544ac9..2861ea4b699d403b1245f8be5a62503d366ded65 100644 +index ed6e4f9fd0c7ad1219e66bc1cb4038191dd6edd8..45a20dbb935b12d429153463dba5d6fd3385dd7a 100644 --- a/net/minecraft/world/level/BlockCollisions.java +++ b/net/minecraft/world/level/BlockCollisions.java @@ -80,16 +80,37 @@ public class BlockCollisions extends AbstractIterator { @@ -76,7 +76,7 @@ index fd2c338db43aad070cc32c24891b40599c544ac9..2861ea4b699d403b1245f8be5a62503d && (nextType != 2 || blockState.is(Blocks.MOVING_PISTON))) { VoxelShape collisionShape = this.context.getCollisionShape(blockState, this.collisionGetter, this.pos); diff --git a/net/minecraft/world/level/CollisionGetter.java b/net/minecraft/world/level/CollisionGetter.java -index cb54c3aadd8f3c719d3f7ef1fda4aa517919b7c3..844f76a38884e823a558fe59c421ffd4711f80b4 100644 +index 79af1e4dd1f84580e509ac3e9a77bcd5531c8da6..a031d39854eb049a701f3de9e11c73419883d5ca 100644 --- a/net/minecraft/world/level/CollisionGetter.java +++ b/net/minecraft/world/level/CollisionGetter.java @@ -50,11 +50,13 @@ public interface CollisionGetter extends BlockGetter { diff --git a/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch b/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch index b9255fa09..b697d7380 100644 --- a/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch +++ b/paper-server/patches/features/0008-Optimize-Voxel-Shape-Merging.patch @@ -67,10 +67,10 @@ index 60b56a5086b8aad0fad693f686b89138b3a4c80d..5b079ec43c259368d0eed4e838588071 this.firstIndices = new int[i]; this.secondIndices = new int[i]; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index e1b4c4b53844b0755e0640a05e8782fd9a7700a2..e759221fb54aa510d2d8bbba47e1d794367aec6d 100644 +index fe8361535526d9aabdf80390aa84570c580981aa..e6038bbe8513e434daa9ea10bfa817afef0445db 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -279,9 +279,22 @@ public final class Shapes { +@@ -286,9 +286,22 @@ public final class Shapes { } @VisibleForTesting @@ -94,7 +94,7 @@ index e1b4c4b53844b0755e0640a05e8782fd9a7700a2..e759221fb54aa510d2d8bbba47e1d794 if (list1 instanceof CubePointRange && list2 instanceof CubePointRange) { long l = lcm(i, i1); if (size * l <= 256L) { -@@ -289,14 +302,21 @@ public final class Shapes { +@@ -296,14 +309,21 @@ public final class Shapes { } } diff --git a/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch b/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch index 3ae9000bc..e60614158 100644 --- a/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch +++ b/paper-server/patches/features/0009-Handle-Oversized-block-entities-in-chunks.patch @@ -9,11 +9,11 @@ creating too large of a packet to sed. Co-authored-by: Spottedleaf diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -index 3aea76690bc3e35758d3bf274777130af17d8a0f..9e321ef1c3d5803519b243685f4ee598dc0cf640 100644 +index 272da41db7ce4619a8e459a2f0a2221e42f58a40..526c117e0d53ad527eb610c79cdc46ec16b18c0c 100644 --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -27,6 +27,14 @@ public class ClientboundLevelChunkPacketData { - private final CompoundTag heightmaps; +@@ -32,6 +32,14 @@ public class ClientboundLevelChunkPacketData { + private final Map heightmaps; private final byte[] buffer; private final List blockEntitiesData; + // Paper start - Handle oversized block entities in chunks @@ -27,23 +27,23 @@ index 3aea76690bc3e35758d3bf274777130af17d8a0f..9e321ef1c3d5803519b243685f4ee598 // Paper start - Anti-Xray - Add chunk packet info @Deprecated @io.papermc.paper.annotation.DoNotUse -@@ -50,8 +58,18 @@ public class ClientboundLevelChunkPacketData { +@@ -51,8 +59,18 @@ public class ClientboundLevelChunkPacketData { } extractChunkData(new FriendlyByteBuf(this.getWriteBuffer()), levelChunk, chunkPacketInfo); this.blockEntitiesData = Lists.newArrayList(); + int totalTileEntities = 0; // Paper - Handle oversized block entities in chunks - for (Entry entryx : levelChunk.getBlockEntities().entrySet()) { + for (Entry entry : levelChunk.getBlockEntities().entrySet()) { + // Paper start - Handle oversized block entities in chunks + if (++totalTileEntities > BLOCK_ENTITY_LIMIT) { -+ net.minecraft.network.protocol.Packet packet = entryx.getValue().getUpdatePacket(); ++ net.minecraft.network.protocol.Packet packet = entry.getValue().getUpdatePacket(); + if (packet != null) { + this.extraPackets.add(packet); + continue; + } + } + // Paper end - Handle oversized block entities in chunks - this.blockEntitiesData.add(ClientboundLevelChunkPacketData.BlockEntityInfo.create(entryx.getValue())); + this.blockEntitiesData.add(ClientboundLevelChunkPacketData.BlockEntityInfo.create(entry.getValue())); } } diff --git a/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java b/net/minecraft/network/protocol/game/ClientboundLevelChunkWithLightPacket.java diff --git a/paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch b/paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch index 2423e0adc..9b3063fc3 100644 --- a/paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch +++ b/paper-server/patches/features/0010-optimize-dirt-and-snow-spreading.patch @@ -5,7 +5,7 @@ Subject: [PATCH] optimize dirt and snow spreading diff --git a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java -index 11937aa74efe08bdbd66a619c7a825f91d971afd..722f2b9a24679e0fc67aae2cd27051f96f962efe 100644 +index d1c112a50ca2c16e4a5c91be2cc91c302918a1c7..f8cc3f870d88715386bb4de0da81a74fa04fd216 100644 --- a/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java +++ b/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java @@ -17,8 +17,13 @@ public abstract class SpreadingSnowyDirtBlock extends SnowyDirtBlock { @@ -58,7 +58,7 @@ index 11937aa74efe08bdbd66a619c7a825f91d971afd..722f2b9a24679e0fc67aae2cd27051f9 for (int i = 0; i < 4; i++) { BlockPos blockPos = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); - if (level.getBlockState(blockPos).is(Blocks.DIRT) && canPropagate(blockState, level, blockPos)) { -- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState.setValue(SNOWY, Boolean.valueOf(isSnowySetting(level.getBlockState(blockPos.above()))))); // CraftBukkit +- org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState.setValue(SNOWY, isSnowySetting(level.getBlockState(blockPos.above()))), 3); // CraftBukkit + // Paper start - Perf: optimize dirt and snow spreading + if (pos.getX() == blockPos.getX() && pos.getY() == blockPos.getY() && pos.getZ() == blockPos.getZ()) { + continue; @@ -71,7 +71,7 @@ index 11937aa74efe08bdbd66a619c7a825f91d971afd..722f2b9a24679e0fc67aae2cd27051f9 + access = level.getChunkAt(blockPos); + } + if (access.getBlockState(blockPos).is(Blocks.DIRT) && SpreadingSnowyDirtBlock.canPropagate(access, blockState, level, blockPos)) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, (BlockState) blockState.setValue(SpreadingSnowyDirtBlock.SNOWY, isSnowySetting(access.getBlockState(blockPos.above())))); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState.setValue(SNOWY, isSnowySetting(access.getBlockState(blockPos.above()))), 3); // CraftBukkit + // Paper end - Perf: optimize dirt and snow spreading } } diff --git a/paper-server/patches/features/0011-Optimise-getChunkAt-calls-for-loaded-chunks.patch b/paper-server/patches/features/0011-Optimise-getChunkAt-calls-for-loaded-chunks.patch index 6b1a406c1..0f3b8b1fe 100644 --- a/paper-server/patches/features/0011-Optimise-getChunkAt-calls-for-loaded-chunks.patch +++ b/paper-server/patches/features/0011-Optimise-getChunkAt-calls-for-loaded-chunks.patch @@ -7,10 +7,10 @@ bypass the need to get a player chunk, then get the either, then unwrap it... diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index c3553385074108d686425a7637b8975076d906b9..2f49dbc919f7f5eea9abce6106723c72f5ae45fb 100644 +index 006d8abe66b2d66740b984d8ff7f56a41b9929f7..52104bcd74107bb9a475109230ca85dd2eba5b06 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -218,6 +218,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -224,6 +224,12 @@ public class ServerChunkCache extends ChunkSource { if (Thread.currentThread() != this.mainThread) { return CompletableFuture.supplyAsync(() -> this.getChunk(x, z, chunkStatus, requireChunk), this.mainThreadProcessor).join(); } else { @@ -23,7 +23,7 @@ index c3553385074108d686425a7637b8975076d906b9..2f49dbc919f7f5eea9abce6106723c72 ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.incrementCounter("getChunk"); long packedChunkPos = ChunkPos.asLong(x, z); -@@ -252,30 +258,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -258,30 +264,7 @@ public class ServerChunkCache extends ChunkSource { if (Thread.currentThread() != this.mainThread) { return null; } else { diff --git a/paper-server/patches/features/0012-Optimize-Bit-Operations-by-inlining.patch b/paper-server/patches/features/0012-Optimize-Bit-Operations-by-inlining.patch index 688e72d60..ddf95a92e 100644 --- a/paper-server/patches/features/0012-Optimize-Bit-Operations-by-inlining.patch +++ b/paper-server/patches/features/0012-Optimize-Bit-Operations-by-inlining.patch @@ -84,7 +84,7 @@ index 98f0b1cf19d7a035849a9a2fa25e2be3a4c5a980..a81694a22e94cca6f7110f7d5b205d13 public static long getFlatIndex(long packedPos) { diff --git a/net/minecraft/core/SectionPos.java b/net/minecraft/core/SectionPos.java -index 1780d8e14cea62971da75e4dcc80d1805434037b..ce8c394ea1a7bc5bf5c568c82e6158b19df517d8 100644 +index ce076662d2ffbb570c8c225e9635de490ea535e8..2fb2e3434c0e495ab4d5cb6d2718717cd0a269f2 100644 --- a/net/minecraft/core/SectionPos.java +++ b/net/minecraft/core/SectionPos.java @@ -38,7 +38,7 @@ public class SectionPos extends Vec3i { @@ -167,7 +167,7 @@ index 1780d8e14cea62971da75e4dcc80d1805434037b..ce8c394ea1a7bc5bf5c568c82e6158b1 } public static long getZeroNode(int x, int z) { -@@ -205,15 +210,17 @@ public class SectionPos extends Vec3i { +@@ -209,15 +214,17 @@ public class SectionPos extends Vec3i { return asLong(blockToSectionCoord(blockPos.getX()), blockToSectionCoord(blockPos.getY()), blockToSectionCoord(blockPos.getZ())); } @@ -190,7 +190,7 @@ index 1780d8e14cea62971da75e4dcc80d1805434037b..ce8c394ea1a7bc5bf5c568c82e6158b1 } @Override -@@ -226,16 +233,13 @@ public class SectionPos extends Vec3i { +@@ -230,16 +237,13 @@ public class SectionPos extends Vec3i { } public static Stream cube(SectionPos center, int radius) { diff --git a/paper-server/patches/features/0013-Remove-streams-from-hot-code.patch b/paper-server/patches/features/0013-Remove-streams-from-hot-code.patch index afbe9f1e4..0a4c904ef 100644 --- a/paper-server/patches/features/0013-Remove-streams-from-hot-code.patch +++ b/paper-server/patches/features/0013-Remove-streams-from-hot-code.patch @@ -98,18 +98,27 @@ index c215d97c24e6501e1a48a76fc08bf48ff4dfe462..bd31d1cac0d022a72bd536c41d1ef811 } } diff --git a/net/minecraft/world/entity/ai/gossip/GossipContainer.java b/net/minecraft/world/entity/ai/gossip/GossipContainer.java -index 2c839dc80f451c83135828a97aced1a531004bab..b74a4ce1b629d440681a1f5c026997ccaf1d0373 100644 +index d93ef8d7ff04ffd3d7434ea6e2d476115203215b..425ca1931fb0a5c33ba7aaf4f639409c9fea836f 100644 --- a/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/net/minecraft/world/entity/ai/gossip/GossipContainer.java -@@ -59,8 +59,22 @@ public class GossipContainer { - return this.gossips.entrySet().stream().flatMap(gossip -> gossip.getValue().unpack(gossip.getKey())); +@@ -28,7 +28,7 @@ import net.minecraft.util.VisibleForDebug; + public class GossipContainer { + public static final Codec CODEC = GossipContainer.GossipEntry.CODEC + .listOf() +- .xmap(GossipContainer::new, gossipContainer -> gossipContainer.unpack().toList()); ++ .xmap(GossipContainer::new, gossipContainer -> gossipContainer.decompress()); // Paper - Perf: Remove streams from hot code + public static final int DISCARD_THRESHOLD = 2; + public final Map gossips = new HashMap<>(); + +@@ -65,8 +65,22 @@ public class GossipContainer { + return this.gossips.entrySet().stream().flatMap(entry -> entry.getValue().unpack(entry.getKey())); } + // Paper start - Perf: Remove streams from hot code + private List decompress() { -+ List list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); -+ for (Map.Entry entry : this.gossips.entrySet()) { -+ for (GossipContainer.GossipEntry cur : entry.getValue().decompress(entry.getKey())) { ++ final List list = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(); ++ for (final Map.Entry entry : this.gossips.entrySet()) { ++ for (final GossipContainer.GossipEntry cur : entry.getValue().decompress(entry.getKey())) { + if (cur.weightedValue() != 0) { + list.add(cur); + } @@ -125,16 +134,7 @@ index 2c839dc80f451c83135828a97aced1a531004bab..b74a4ce1b629d440681a1f5c026997cc if (list.isEmpty()) { return Collections.emptyList(); } else { -@@ -145,7 +159,7 @@ public class GossipContainer { - - public T store(DynamicOps ops) { - return GossipContainer.GossipEntry.LIST_CODEC -- .encodeStart(ops, this.unpack().toList()) -+ .encodeStart(ops, this.decompress()) // Paper - Perf: Remove streams from hot code - .resultOrPartial(errorMessage -> LOGGER.warn("Failed to serialize gossips: {}", errorMessage)) - .orElseGet(ops::emptyList); - } -@@ -172,12 +186,23 @@ public class GossipContainer { +@@ -176,12 +190,23 @@ public class GossipContainer { final Object2IntMap entries = new Object2IntOpenHashMap<>(); public int weightedValue(Predicate gossipType) { @@ -194,7 +194,7 @@ index 38873e56e95dc772b184e4271f7af1fb411ac9f8..09fd13e2d958da8326276c4dadf25bf4 } } diff --git a/net/minecraft/world/level/levelgen/Beardifier.java b/net/minecraft/world/level/levelgen/Beardifier.java -index 1a09da5aa1ae047a002d6779326c2a29e47d32b5..131923282c9ecbcb1d7f45a826da907c02bd2716 100644 +index 8bc2dd4fa128fc2f88b974b8712cb0953a024eaa..74d8202b5c9bb2a3ee832be70f95c0b5cbecb460 100644 --- a/net/minecraft/world/level/levelgen/Beardifier.java +++ b/net/minecraft/world/level/levelgen/Beardifier.java @@ -35,9 +35,10 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { @@ -211,7 +211,7 @@ index 1a09da5aa1ae047a002d6779326c2a29e47d32b5..131923282c9ecbcb1d7f45a826da907c TerrainAdjustment terrainAdjustment = structureStart.getStructure().terrainAdaptation(); for (StructurePiece structurePiece : structureStart.getPieces()) { -@@ -65,8 +66,7 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { +@@ -64,8 +65,7 @@ public class Beardifier implements DensityFunctions.BeardifierOrMarker { } } } diff --git a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch b/paper-server/patches/features/0015-Moonrise-optimisation-patches.patch similarity index 94% rename from paper-server/patches/features/0016-Moonrise-optimisation-patches.patch rename to paper-server/patches/features/0015-Moonrise-optimisation-patches.patch index 7dfc137ed..10729a44c 100644 --- a/paper-server/patches/features/0016-Moonrise-optimisation-patches.patch +++ b/paper-server/patches/features/0015-Moonrise-optimisation-patches.patch @@ -297,10 +297,18 @@ index 0000000000000000000000000000000000000000..1b8193587814225c2ef2c5d9e667436e + } +} diff --git a/ca/spottedleaf/moonrise/paper/PaperHooks.java b/ca/spottedleaf/moonrise/paper/PaperHooks.java -index 5577287398db2bb9d21f14409ef580b8ab9ea018..4d344559a20a0c35c181e297e81788c747363ec9 100644 +index 729eb5d052465e4093e9d8c5d4fe8463b2efaca6..b9b774a3ca600cee3d0e967063ea2f72c7ab184f 100644 --- a/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/ca/spottedleaf/moonrise/paper/PaperHooks.java -@@ -268,7 +268,7 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo +@@ -13,6 +13,7 @@ import net.minecraft.server.level.ChunkHolder; + import net.minecraft.server.level.GenerationChunkHolder; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.server.level.ServerPlayer; ++import net.minecraft.server.level.TicketType; + import net.minecraft.world.entity.Entity; + import net.minecraft.world.entity.boss.EnderDragonPart; + import net.minecraft.world.level.BlockGetter; +@@ -231,11 +232,16 @@ public final class PaperHooks extends BaseChunkSystemHooks implements PlatformHo @Override public void postLoadProtoChunk(final ServerLevel world, final ProtoChunk chunk) { @@ -309,17 +317,56 @@ index 5577287398db2bb9d21f14409ef580b8ab9ea018..4d344559a20a0c35c181e297e81788c7 } @Override + public int modifyEntityTrackingRange(final Entity entity, final int currentRange) { + return org.spigotmc.TrackingRange.getEntityTrackingRange(entity, currentRange); + } +-} +\ No newline at end of file ++ ++ @Override ++ public long[] getCounterTypesUncached(final TicketType type) { ++ return type == TicketType.FORCED ? new long[] { ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType.COUNTER_TYPE_FORCED } : it.unimi.dsi.fastutil.longs.LongArrays.EMPTY_ARRAY; ++ } ++} diff --git a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java -index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a96872708755bffe0a 100644 +index 6cfc2bc8d5816304c42d9f23396ec9e65c27bdde..975a2e4ea1f84e81fa3526395b43cb8157a06243 100644 --- a/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java +++ b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java -@@ -23,218 +23,59 @@ import java.util.function.Consumer; +@@ -1,38 +1,24 @@ + package ca.spottedleaf.moonrise.paper.util; + + import ca.spottedleaf.concurrentutil.util.Priority; +-import com.mojang.logging.LogUtils; ++import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; ++import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk; ++import ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader; ++import ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemServerChunkCache; ++import ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel; + import net.minecraft.server.level.ChunkHolder; +-import net.minecraft.server.level.ChunkResult; + import net.minecraft.server.level.FullChunkStatus; + import net.minecraft.server.level.ServerLevel; + import net.minecraft.server.level.ServerPlayer; +-import net.minecraft.server.level.TicketType; +-import net.minecraft.world.level.ChunkPos; ++import net.minecraft.server.level.progress.ChunkProgressListener; + import net.minecraft.world.level.chunk.ChunkAccess; + import net.minecraft.world.level.chunk.LevelChunk; +-import net.minecraft.world.level.chunk.status.ChunkPyramid; + import net.minecraft.world.level.chunk.status.ChunkStatus; +-import net.minecraft.world.level.chunk.status.ChunkStep; +-import org.bukkit.Bukkit; +-import org.slf4j.Logger; +-import java.util.ArrayList; + import java.util.List; +-import java.util.concurrent.CompletableFuture; + import java.util.function.Consumer; public abstract class BaseChunkSystemHooks implements ca.spottedleaf.moonrise.common.util.ChunkSystemHooks { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); -- private static final TicketType CHUNK_LOAD = TicketType.create("chunk_load", Long::compareTo); +- private static final TicketType CHUNK_LOAD = TicketType.CHUNK_LOAD; - - private long chunkLoadCounter = 0L; - @@ -329,14 +376,13 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - @Override public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run) { -- this.scheduleChunkTask(level, chunkX, chunkZ, run, Priority.NORMAL); -+ scheduleChunkTask(level, chunkX, chunkZ, run, Priority.NORMAL); - } + this.scheduleChunkTask(level, chunkX, chunkZ, run, Priority.NORMAL); +@@ -40,194 +26,47 @@ public abstract class BaseChunkSystemHooks implements ca.spottedleaf.moonrise.co @Override public void scheduleChunkTask(final ServerLevel level, final int chunkX, final int chunkZ, final Runnable run, final Priority priority) { - level.chunkSource.mainThreadProcessor.execute(run); -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkTask(chunkX, chunkZ, run, priority); ++ ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkTask(chunkX, chunkZ, run, priority); } @Override @@ -362,7 +408,7 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - } - } - }); -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, gen, toStatus, addTicket, priority, onComplete); ++ ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, gen, toStatus, addTicket, priority, onComplete); } @Override @@ -376,11 +422,10 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - } - - final int minLevel = 33 + getDistance(toStatus); -- final Long chunkReference = addTicket ? Long.valueOf(++this.chunkLoadCounter) : null; - final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); - - if (addTicket) { -- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); +- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - level.chunkSource.runDistanceManagerUpdates(); - @@ -394,8 +439,8 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); - } finally { - if (addTicket) { -- level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel, chunkPos); -- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); +- level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); +- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - } - }; @@ -423,7 +468,7 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - }, (final Runnable r) -> { - BaseChunkSystemHooks.this.scheduleChunkTask(level, chunkX, chunkZ, r, Priority.HIGHEST); - }); -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); ++ ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleChunkLoad(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); } @Override @@ -444,11 +489,10 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - - final int minLevel = 33 - (toStatus.ordinal() - 1); - final int radius = toStatus.ordinal() - 1; -- final Long chunkReference = addTicket ? Long.valueOf(++this.chunkLoadCounter) : null; - final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); - - if (addTicket) { -- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); +- level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - level.chunkSource.runDistanceManagerUpdates(); - @@ -462,8 +506,8 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); - } finally { - if (addTicket) { -- level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel, chunkPos); -- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); +- level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); +- level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); - } - } - }; @@ -508,47 +552,41 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - }, (final Runnable r) -> { - BaseChunkSystemHooks.this.scheduleChunkTask(level, chunkX, chunkZ, r, Priority.HIGHEST); - }); -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleTickingState(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); ++ ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().scheduleTickingState(chunkX, chunkZ, toStatus, addTicket, priority, onComplete); } @Override public List getVisibleChunkHolders(final ServerLevel level) { - return new ArrayList<>(level.chunkSource.chunkMap.visibleChunkMap.values()); -+ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); ++ return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } @Override public List getUpdatingChunkHolders(final ServerLevel level) { - return new ArrayList<>(level.chunkSource.chunkMap.updatingChunkMap.values()); -+ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); ++ return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.getOldChunkHolders(); } @Override public int getVisibleChunkHolderCount(final ServerLevel level) { - return level.chunkSource.chunkMap.visibleChunkMap.size(); -+ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); ++ return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } @Override public int getUpdatingChunkHolderCount(final ServerLevel level) { - return level.chunkSource.chunkMap.updatingChunkMap.size(); -+ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); ++ return ((ChunkSystemServerLevel)level).moonrise$getChunkTaskScheduler().chunkHolderManager.size(); } @Override - public boolean hasAnyChunkHolders(final ServerLevel level) { -- return this.getUpdatingChunkHolderCount(level) != 0; -+ return getUpdatingChunkHolderCount(level) != 0; - } - - @Override -@@ -244,89 +85,110 @@ public abstract class BaseChunkSystemHooks implements ca.spottedleaf.moonrise.co +@@ -242,89 +81,98 @@ public abstract class BaseChunkSystemHooks implements ca.spottedleaf.moonrise.co @Override public void onChunkHolderDelete(final ServerLevel level, final ChunkHolder holder) { - + // Update progress listener for LevelLoadingScreen -+ final net.minecraft.server.level.progress.ChunkProgressListener progressListener = level.getChunkSource().chunkMap.progressListener; ++ final ChunkProgressListener progressListener = level.getChunkSource().chunkMap.progressListener; + if (progressListener != null) { + this.scheduleChunkTask(level, holder.getPos().x, holder.getPos().z, () -> { + progressListener.onStatusChange(holder.getPos(), null); @@ -559,72 +597,60 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 @Override public void onChunkPreBorder(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) ++ ((ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) + .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, chunk); } @Override public void onChunkBorder(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().add( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().add(chunk); + chunk.loadCallback(); } @Override public void onChunkNotBorder(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().remove( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getLoadedChunks().remove(chunk); + chunk.unloadCallback(); } @Override public void onChunkPostNotBorder(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) ++ ((ChunkSystemServerChunkCache)((ServerLevel)chunk.getLevel()).getChunkSource()) + .moonrise$setFullChunk(chunk.getPos().x, chunk.getPos().z, null); } @Override public void onChunkTicking(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().add( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); -+ if (!((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$isPostProcessingDone()) { ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().add(chunk); ++ if (!((ChunkSystemLevelChunk)chunk).moonrise$isPostProcessingDone()) { + chunk.postProcessGeneration((ServerLevel)chunk.getLevel()); + } + ((ServerLevel)chunk.getLevel()).startTickingChunk(chunk); + ((ServerLevel)chunk.getLevel()).getChunkSource().chunkMap.tickingGenerated.incrementAndGet(); -+ ((ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$markChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration } @Override public void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().remove( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); -+ ((ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$removeChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().remove(chunk); } @Override public void onChunkEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().add( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().add(chunk); ++ ((ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$markChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration } @Override public void onChunkNotEntityTicking(final LevelChunk chunk, final ChunkHolder holder) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().remove( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() -+ ); ++ ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getEntityTickingChunks().remove(chunk); ++ ((ChunkTickServerLevel)(ServerLevel)chunk.getLevel()).moonrise$removeChunkForPlayerTicking(chunk); // Moonrise - chunk tick iteration } @Override @@ -636,7 +662,7 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 @Override public int getSendViewDistance(final ServerPlayer player) { - return this.getViewDistance(player); -+ return ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.getAPISendViewDistance(player); ++ return RegionizedPlayerChunkLoader.getAPISendViewDistance(player); } @Override @@ -646,7 +672,7 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - return Bukkit.getViewDistance(); - } - return level.chunkSource.chunkMap.serverViewDistance; -+ return ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.getAPIViewDistance(player); ++ return RegionizedPlayerChunkLoader.getAPIViewDistance(player); } @Override @@ -656,28 +682,29 @@ index 2a03573a6a6753f1c87dbde26ff5208c827aa13a..ece1261b67033e946dfc20a968727087 - return Bukkit.getSimulationDistance(); - } - return level.chunkSource.chunkMap.distanceManager.simulationDistance; -+ return ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.getAPITickViewDistance(player); ++ return RegionizedPlayerChunkLoader.getAPITickViewDistance(player); } @Override public void addPlayerToDistanceMaps(final ServerLevel world, final ServerPlayer player) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().addPlayer(player); ++ ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().addPlayer(player); } @Override public void removePlayerFromDistanceMaps(final ServerLevel world, final ServerPlayer player) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().removePlayer(player); ++ ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().removePlayer(player); } @Override public void updateMaps(final ServerLevel world, final ServerPlayer player) { - -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().updatePlayer(player); ++ ((ChunkSystemServerLevel)world).moonrise$getPlayerChunkLoader().updatePlayer(player); } - } +-} \ No newline at end of file ++} diff --git a/ca/spottedleaf/moonrise/patches/block_counting/BlockCountingBitStorage.java b/ca/spottedleaf/moonrise/patches/block_counting/BlockCountingBitStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..93bc56daec4526f373c84763b8c7ccb4a30e800b @@ -980,10 +1007,10 @@ index 0000000000000000000000000000000000000000..866f38eb0f379ffbe2888023a7d1c290 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ChunkSystemConverters.java b/ca/spottedleaf/moonrise/patches/chunk_system/ChunkSystemConverters.java new file mode 100644 -index 0000000000000000000000000000000000000000..44bb25554634af2ec0b2e9b3d9231304d5dff034 +index 0000000000000000000000000000000000000000..f3f5a3f04283a130b4e48e6b78732758335629e7 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/ChunkSystemConverters.java -@@ -0,0 +1,39 @@ +@@ -0,0 +1,38 @@ +package ca.spottedleaf.moonrise.patches.chunk_system; + +import ca.spottedleaf.moonrise.common.PlatformHooks; @@ -1005,8 +1032,7 @@ index 0000000000000000000000000000000000000000..44bb25554634af2ec0b2e9b3d9231304 + } + + private static int getDataVersion(final CompoundTag data, final int dfl) { -+ return !data.contains(SharedConstants.DATA_VERSION_TAG, Tag.TAG_ANY_NUMERIC) -+ ? dfl : data.getInt(SharedConstants.DATA_VERSION_TAG); ++ return data.getIntOr(SharedConstants.DATA_VERSION_TAG, dfl); + } + + public static CompoundTag convertPoiCompoundTag(final CompoundTag data, final ServerLevel world) { @@ -2874,7 +2900,7 @@ index 0000000000000000000000000000000000000000..a36ab89f5c37f5f9ab0152f087bb4cf3 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/EntityDataController.java b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/EntityDataController.java new file mode 100644 -index 0000000000000000000000000000000000000000..828c868f68c2a20bf90d0f7ec253fdeb591f15f6 +index 0000000000000000000000000000000000000000..992d19e1b08fa84325e7bb3c3d7d0b9dff4cdd3b --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/io/datacontroller/EntityDataController.java @@ -0,0 +1,73 @@ @@ -2928,7 +2954,7 @@ index 0000000000000000000000000000000000000000..828c868f68c2a20bf90d0f7ec253fdeb + } + + private static void checkPosition(final ChunkPos pos, final CompoundTag nbt) { -+ final ChunkPos nbtPos = nbt == null ? null : EntityStorage.readChunkPos(nbt); ++ final ChunkPos nbtPos = nbt == null ? null : nbt.read("Position", ChunkPos.CODEC).orElse(null); + if (nbtPos != null && !pos.equals(nbtPos)) { + throw new IllegalArgumentException( + "Entity chunk coordinate and serialized data do not have matching coordinates, trying to serialize coordinate " + pos.toString() @@ -3075,13 +3101,14 @@ index 0000000000000000000000000000000000000000..0b58701342d573fa43cdd06681534854 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/ChunkSystemServerLevel.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/ChunkSystemServerLevel.java new file mode 100644 -index 0000000000000000000000000000000000000000..c278f8ef806f0b45c28cc3040c7db052cb51e053 +index 0000000000000000000000000000000000000000..7964905786ed4cf2b31e7b0d74ad7a6bf9c52851 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/ChunkSystemServerLevel.java -@@ -0,0 +1,62 @@ +@@ -0,0 +1,64 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.level; + +import ca.spottedleaf.concurrentutil.util.Priority; ++import ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet; +import ca.spottedleaf.moonrise.common.list.ReferenceList; +import ca.spottedleaf.moonrise.common.misc.NearbyPlayers; +import ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO; @@ -3091,6 +3118,7 @@ index 0000000000000000000000000000000000000000..c278f8ef806f0b45c28cc3040c7db052 +import net.minecraft.server.level.ChunkHolder; +import net.minecraft.server.level.ServerChunkCache; +import net.minecraft.world.level.chunk.ChunkAccess; ++import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.status.ChunkStatus; +import java.util.List; +import java.util.function.Consumer; @@ -3135,11 +3163,11 @@ index 0000000000000000000000000000000000000000..c278f8ef806f0b45c28cc3040c7db052 + + public NearbyPlayers moonrise$getNearbyPlayers(); + -+ public ReferenceList moonrise$getLoadedChunks(); ++ public ReferenceList moonrise$getLoadedChunks(); + -+ public ReferenceList moonrise$getTickingChunks(); ++ public ReferenceList moonrise$getTickingChunks(); + -+ public ReferenceList moonrise$getEntityTickingChunks(); ++ public ReferenceList moonrise$getEntityTickingChunks(); +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkData.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkData.java new file mode 100644 @@ -3252,26 +3280,26 @@ index 0000000000000000000000000000000000000000..aacd543f03b35908011d0c2891e978cc +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkSystemLevelChunk.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkSystemLevelChunk.java new file mode 100644 -index 0000000000000000000000000000000000000000..5b092bca7027e37aeee8f4b852ad896dd0d5febc +index 0000000000000000000000000000000000000000..59cbbf65c9df5c680b803f6dd6436a35f82fe2d8 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/chunk/ChunkSystemLevelChunk.java @@ -0,0 +1,13 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.level.chunk; + -+import net.minecraft.server.level.ServerChunkCache; ++import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder; + +public interface ChunkSystemLevelChunk { + + public boolean moonrise$isPostProcessingDone(); + -+ public ServerChunkCache.ChunkAndHolder moonrise$getChunkAndHolder(); ++ public NewChunkHolder moonrise$getChunkHolder(); + -+ public void moonrise$setChunkAndHolder(final ServerChunkCache.ChunkAndHolder holder); ++ public void moonrise$setChunkHolder(final NewChunkHolder holder); + +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java new file mode 100644 -index 0000000000000000000000000000000000000000..7aea4e343581b977d11af90f9f65eac3532eade1 +index 0000000000000000000000000000000000000000..1c82dcd38f789707e15e8cbec72ef9cdc7efdf56 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -0,0 +1,569 @@ @@ -3353,7 +3381,7 @@ index 0000000000000000000000000000000000000000..7aea4e343581b977d11af90f9f65eac3 + + public static List readEntities(final ServerLevel world, final CompoundTag compoundTag) { + // TODO check this and below on update for format changes -+ return EntityType.loadEntitiesRecursive(compoundTag.getList("Entities", 10), world, EntitySpawnReason.LOAD).collect(ImmutableList.toImmutableList()); ++ return EntityType.loadEntitiesRecursive(compoundTag.getListOrEmpty("Entities"), world, EntitySpawnReason.LOAD).collect(ImmutableList.toImmutableList()); + } + + // Paper start - rewrite chunk system @@ -3361,12 +3389,12 @@ index 0000000000000000000000000000000000000000..7aea4e343581b977d11af90f9f65eac3 + if (from == null) { + return; + } -+ final ListTag entitiesFrom = from.getList("Entities", Tag.TAG_COMPOUND); ++ final ListTag entitiesFrom = from.getListOrEmpty("Entities"); + if (entitiesFrom == null || entitiesFrom.isEmpty()) { + return; + } + -+ final ListTag entitiesInto = into.getList("Entities", Tag.TAG_COMPOUND); ++ final ListTag entitiesInto = into.getListOrEmpty("Entities"); + into.put("Entities", entitiesInto); // this is in case into doesn't have any entities + entitiesInto.addAll(0, entitiesFrom); + } @@ -3389,7 +3417,7 @@ index 0000000000000000000000000000000000000000..7aea4e343581b977d11af90f9f65eac3 + } + final CompoundTag ret = NbtUtils.addCurrentDataVersion(new CompoundTag()); + ret.put("Entities", entitiesTag); -+ EntityStorage.writeChunkPos(ret, chunkPos); ++ ret.store("Position", ChunkPos.CODEC, chunkPos); + + return !force && entitiesTag.isEmpty() ? null : ret; + } @@ -5271,7 +5299,7 @@ index 0000000000000000000000000000000000000000..89b956b8fdf1a0d862a843104511005e +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/poi/PoiChunk.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/poi/PoiChunk.java new file mode 100644 -index 0000000000000000000000000000000000000000..bbf9d6c1c9525d97160806819a57be03eca290f1 +index 0000000000000000000000000000000000000000..8b5eedee7b5876c0981520ec1548f70a935a501f --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/poi/PoiChunk.java @@ -0,0 +1,204 @@ @@ -5436,7 +5464,7 @@ index 0000000000000000000000000000000000000000..bbf9d6c1c9525d97160806819a57be03 + + final RegistryOps registryOps = RegistryOps.create(NbtOps.INSTANCE, world.registryAccess()); + -+ final CompoundTag sections = data.getCompound("Sections"); ++ final CompoundTag sections = data.getCompoundOrEmpty("Sections"); + + if (sections.isEmpty()) { + // nothing to parse @@ -5453,7 +5481,7 @@ index 0000000000000000000000000000000000000000..bbf9d6c1c9525d97160806819a57be03 + continue; + } + -+ final CompoundTag section = sections.getCompound(key); ++ final CompoundTag section = sections.getCompoundOrEmpty(key); + final DataResult deserializeResult = PoiSection.Packed.CODEC.parse(registryOps, section); + final int finalSectionY = sectionY; + final PoiSection.Packed packed = deserializeResult.resultOrPartial((final String description) -> { @@ -5521,10 +5549,10 @@ index 0000000000000000000000000000000000000000..003a857e70ead858e8437e3c1bfaf22f +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java new file mode 100644 -index 0000000000000000000000000000000000000000..dd2509996bfd08e8c3f9f2be042229eac6d7692d +index 0000000000000000000000000000000000000000..02a9ef1694c796584c29430d27f0a09047368835 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/player/RegionizedPlayerChunkLoader.java -@@ -0,0 +1,1092 @@ +@@ -0,0 +1,1089 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.player; + +import ca.spottedleaf.concurrentutil.util.ConcurrentUtil; @@ -5541,6 +5569,7 @@ index 0000000000000000000000000000000000000000..dd2509996bfd08e8c3f9f2be042229ea +import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk; +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager; +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler; ++import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType; +import ca.spottedleaf.moonrise.patches.chunk_system.util.ParallelSearchRadiusIteration; +import com.google.gson.JsonObject; +import it.unimi.dsi.fastutil.longs.Long2ByteOpenHashMap; @@ -5572,11 +5601,8 @@ index 0000000000000000000000000000000000000000..dd2509996bfd08e8c3f9f2be042229ea + +public final class RegionizedPlayerChunkLoader { + -+ public static final TicketType PLAYER_TICKET = TicketType.create("chunk_system:player_ticket", Long::compareTo); -+ public static final TicketType PLAYER_TICKET_DELAYED = TicketType.create("chunk_system:player_ticket_delayed", Long::compareTo, 5 * 20); -+ -+ public static final int MIN_VIEW_DISTANCE = 2; -+ public static final int MAX_VIEW_DISTANCE = 32; ++ public static final TicketType PLAYER_TICKET = ChunkSystemTicketType.create("chunk_system:player_ticket", Long::compareTo); ++ public static final TicketType PLAYER_TICKET_DELAYED = ChunkSystemTicketType.create("chunk_system:player_ticket_delayed", Long::compareTo, 5L * 20L); + + public static final int GENERATED_TICKET_LEVEL = ChunkHolderManager.FULL_LOADED_TICKET_LEVEL; + public static final int LOADED_TICKET_LEVEL = ChunkTaskScheduler.getTicketLevel(ChunkStatus.EMPTY); @@ -6217,8 +6243,7 @@ index 0000000000000000000000000000000000000000..dd2509996bfd08e8c3f9f2be042229ea + } + this.pushDelayedTicketOp( + ChunkHolderManager.TicketOperation.addOp( -+ chunk, -+ PLAYER_TICKET, LOADED_TICKET_LEVEL, this.idBoxed ++ chunk, PLAYER_TICKET, LOADED_TICKET_LEVEL, this.idBoxed + ) + ); + chunks.add(chunk); @@ -6770,10 +6795,10 @@ index 0000000000000000000000000000000000000000..7eafc5b7cba23d8dec92ecc1050afe3f \ No newline at end of file diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccccb250ac7 +index 0000000000000000000000000000000000000000..f473999938840562b1007a789600342e5796a123 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkHolderManager.java -@@ -0,0 +1,1456 @@ +@@ -0,0 +1,1541 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.scheduling; + +import ca.spottedleaf.concurrentutil.lock.ReentrantAreaLock; @@ -6792,10 +6817,12 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.task.ChunkProgressionTask; +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.task.GenericDataLoadTask; +import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket; ++import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType; +import ca.spottedleaf.moonrise.patches.chunk_system.util.ChunkSystemSortedArraySet; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import com.mojang.logging.LogUtils; ++import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ByteLinkedOpenHashMap; +import it.unimi.dsi.fastutil.longs.Long2ByteMap; +import it.unimi.dsi.fastutil.longs.Long2IntMap; @@ -6841,13 +6868,12 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + public static final int ENTITY_TICKING_TICKET_LEVEL = ChunkLevel.ENTITY_TICKING_LEVEL; + public static final int MAX_TICKET_LEVEL = ChunkLevel.MAX_LEVEL; // inclusive + -+ public static final TicketType UNLOAD_COOLDOWN = TicketType.create("unload_cooldown", (u1, u2) -> 0, 5 * 20); ++ public static final TicketType UNLOAD_COOLDOWN = ChunkSystemTicketType.create("chunk_system:unload_cooldown", null, 5L * 20L); + + private static final long NO_TIMEOUT_MARKER = Long.MIN_VALUE; -+ private static final long PROBE_MARKER = Long.MIN_VALUE + 1; + public final ReentrantAreaLock ticketLockArea; + -+ private final ConcurrentLong2ReferenceChainedHashTable>> tickets = new ConcurrentLong2ReferenceChainedHashTable<>(); ++ private final ConcurrentLong2ReferenceChainedHashTable> tickets = new ConcurrentLong2ReferenceChainedHashTable<>(); + private final ConcurrentLong2ReferenceChainedHashTable sectionToChunkToExpireCount = new ConcurrentLong2ReferenceChainedHashTable<>(); + final ChunkUnloadQueue unloadQueue; + @@ -6878,6 +6904,8 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + return Long.compare(coord1, coord2); + }); + ++ private final ConcurrentLong2ReferenceChainedHashTable ticketCounters = new ConcurrentLong2ReferenceChainedHashTable<>(); ++ + public ChunkHolderManager(final ServerLevel world, final ChunkTaskScheduler taskScheduler) { + this.world = world; + this.taskScheduler = taskScheduler; @@ -6939,7 +6967,6 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + return this.chunkHolders.size(); + } + -+ // TODO replace the need for this, specifically: optimise ServerChunkCache#tickChunks + public Iterable getOldChunkHoldersIterable() { + return new Iterable() { + @Override @@ -7187,7 +7214,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + public String getTicketDebugString(final long coordinate) { + final ReentrantAreaLock.Node ticketLock = this.ticketLockArea.lock(CoordinateUtils.getChunkX(coordinate), CoordinateUtils.getChunkZ(coordinate)); + try { -+ final SortedArraySet> tickets = this.tickets.get(coordinate); ++ final SortedArraySet tickets = this.tickets.get(coordinate); + + return tickets != null ? tickets.first().toString() : "no_ticket"; + } finally { @@ -7197,8 +7224,40 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + } + -+ public Long2ObjectOpenHashMap>> getTicketsCopy() { -+ final Long2ObjectOpenHashMap>> ret = new Long2ObjectOpenHashMap<>(); ++ public boolean hasTickets() { ++ return !this.tickets.isEmpty(); ++ } ++ ++ public List getTicketsAt(final int chunkX, final int chunkZ) { ++ final long key = CoordinateUtils.getChunkKey(chunkX, chunkZ); ++ ++ if (!this.tickets.containsKey(key)) { ++ // avoid contending lock ++ return new ArrayList<>(); ++ } ++ ++ final ReentrantAreaLock.Node lock = this.ticketLockArea.lock(chunkX, chunkZ); ++ try { ++ final SortedArraySet tickets = this.tickets.get(key); ++ ++ if (tickets == null) { ++ return new ArrayList<>(); ++ } ++ ++ final List ret = new ArrayList<>(tickets.size()); ++ ++ for (final Ticket ticket : tickets) { ++ ret.add(ticket); ++ } ++ ++ return ret; ++ } finally { ++ this.ticketLockArea.unlock(lock); ++ } ++ } ++ ++ public Long2ObjectOpenHashMap> getTicketsCopy() { ++ final Long2ObjectOpenHashMap> ret = new Long2ObjectOpenHashMap<>(); + final Long2ObjectOpenHashMap sections = new Long2ObjectOpenHashMap<>(); + final int sectionShift = this.taskScheduler.getChunkSystemLockShift(); + for (final PrimitiveIterator.OfLong iterator = this.tickets.keyIterator(); iterator.hasNext();) { @@ -7227,12 +7286,12 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + try { + for (final LongIterator iterator2 = coordinates.iterator(); iterator2.hasNext();) { + final long coord = iterator2.nextLong(); -+ final SortedArraySet> tickets = this.tickets.get(coord); ++ final SortedArraySet tickets = this.tickets.get(coord); + if (tickets == null) { + // removed before we acquired lock + continue; + } -+ ret.put(coord, ((ChunkSystemSortedArraySet>)tickets).moonrise$copy()); ++ ret.put(coord, ((ChunkSystemSortedArraySet)tickets).moonrise$copy()); + } + } finally { + this.ticketLockArea.unlock(ticketLock); @@ -7248,7 +7307,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + final ReentrantAreaLock.Node ticketLock = this.ticketLockArea.lock(x, z); + try { + final long coordinate = CoordinateUtils.getChunkKey(x, z); -+ final SortedArraySet> tickets = this.tickets.get(coordinate); ++ final SortedArraySet tickets = this.tickets.get(coordinate); + + if (tickets == null) { + return java.util.Collections.emptyList(); @@ -7257,7 +7316,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + ret = com.google.common.collect.ImmutableList.builder(); + for (Ticket ticket : tickets) { + if (ticket.getType() == TicketType.PLUGIN_TICKET) { -+ ret.add((org.bukkit.plugin.Plugin)ticket.key); ++ ret.add((org.bukkit.plugin.Plugin)ticket.moonrise$getIdentifier()); + } + } + } finally { @@ -7276,16 +7335,16 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + } + -+ private static int getTicketLevelAt(SortedArraySet> tickets) { ++ private static int getTicketLevelAt(final SortedArraySet tickets) { + return !tickets.isEmpty() ? tickets.first().getTicketLevel() : MAX_TICKET_LEVEL + 1; + } + -+ public boolean addTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, ++ public boolean addTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, + final T identifier) { + return this.addTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); + } + -+ public boolean addTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, ++ public boolean addTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, + final T identifier) { + return this.addTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkX, chunkZ), level, identifier); + } @@ -7326,29 +7385,29 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + + // supposed to return true if the ticket was added and did not replace another + // but, we always return false if the ticket cannot be added -+ public boolean addTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier) { ++ public boolean addTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier) { + return this.addTicketAtLevel(type, chunk, level, identifier, true); + } + -+ boolean addTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier, final boolean lock) { -+ final long removeDelay = type.timeout <= 0 ? NO_TIMEOUT_MARKER : type.timeout; ++ boolean addTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier, final boolean lock) { ++ final long removeDelay = type.timeout() <= 0 ? NO_TIMEOUT_MARKER : type.timeout(); + if (level > MAX_TICKET_LEVEL) { + return false; + } + + final int chunkX = CoordinateUtils.getChunkX(chunk); + final int chunkZ = CoordinateUtils.getChunkZ(chunk); -+ final Ticket ticket = new Ticket<>(type, level, identifier); -+ ((ChunkSystemTicket)(Object)ticket).moonrise$setRemoveDelay(removeDelay); ++ final Ticket ticket = new Ticket(type, level, removeDelay); ++ ((ChunkSystemTicket)(Object)ticket).moonrise$setIdentifier(identifier); + + final ReentrantAreaLock.Node ticketLock = lock ? this.ticketLockArea.lock(chunkX, chunkZ) : null; + try { -+ final SortedArraySet> ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (final long keyInMap) -> { -+ return SortedArraySet.create(4); ++ final SortedArraySet ticketsAtChunk = this.tickets.computeIfAbsent(chunk, (final long keyInMap) -> { ++ return (SortedArraySet)SortedArraySet.create(4); + }); + + final int levelBefore = getTicketLevelAt(ticketsAtChunk); -+ final Ticket current = (Ticket)((ChunkSystemSortedArraySet>)ticketsAtChunk).moonrise$replace(ticket); ++ final Ticket current = (Ticket)((ChunkSystemSortedArraySet)ticketsAtChunk).moonrise$replace(ticket); + final int levelAfter = getTicketLevelAt(ticketsAtChunk); + + if (current != ticket) { @@ -7365,6 +7424,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + if (removeDelay != NO_TIMEOUT_MARKER) { + this.addExpireCount(chunkX, chunkZ); + } ++ this.addTicketCounter(type, chunk); + } + + if (levelBefore != levelAfter) { @@ -7379,36 +7439,85 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + } + -+ public boolean removeTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { ++ private void addTicketCounter(final TicketType type, final long pos) { ++ final long[] counterTypes = ((ChunkSystemTicketType)(Object)type).moonrise$getCounterTypes(); ++ if (counterTypes.length == 0) { ++ return; ++ } ++ ++ synchronized (this.ticketCounters) { ++ for (final long counterType : counterTypes) { ++ final Long2IntOpenHashMap oldCounters = this.ticketCounters.get(counterType); ++ final Long2IntOpenHashMap newCounters = oldCounters == null ? new Long2IntOpenHashMap() : oldCounters.clone(); ++ ++ newCounters.addTo(pos, 1); ++ ++ this.ticketCounters.put(counterType, newCounters); ++ } ++ } ++ } ++ ++ private void removeTicketCounter(final TicketType type, final long pos) { ++ final long[] counterTypes = ((ChunkSystemTicketType)(Object)type).moonrise$getCounterTypes(); ++ if (counterTypes.length == 0) { ++ return; ++ } ++ ++ synchronized (this.ticketCounters) { ++ for (final long counterType : counterTypes) { ++ final Long2IntOpenHashMap oldCounters = this.ticketCounters.get(counterType); ++ final Long2IntOpenHashMap newCounters = oldCounters == null ? new Long2IntOpenHashMap() : oldCounters.clone(); ++ ++ final int currCount = newCounters.get(pos); ++ if (currCount <= 0) { ++ throw new IllegalStateException("Count must be > 0 at this stage"); ++ } ++ if (currCount == 1) { ++ newCounters.remove(pos); ++ } else { ++ newCounters.put(pos, currCount - 1); ++ } ++ ++ this.ticketCounters.put(counterType, newCounters); ++ } ++ } ++ } ++ ++ public Long2IntOpenHashMap getTicketCounters(final long counterType) { ++ return this.ticketCounters.get(counterType); ++ } ++ ++ public boolean removeTicketAtLevel(final TicketType type, final ChunkPos chunkPos, final int level, final T identifier) { + return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkPos), level, identifier); + } + -+ public boolean removeTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, final T identifier) { ++ public boolean removeTicketAtLevel(final TicketType type, final int chunkX, final int chunkZ, final int level, final T identifier) { + return this.removeTicketAtLevel(type, CoordinateUtils.getChunkKey(chunkX, chunkZ), level, identifier); + } + -+ public boolean removeTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier) { ++ public boolean removeTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier) { + return this.removeTicketAtLevel(type, chunk, level, identifier, true); + } + -+ boolean removeTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier, final boolean lock) { ++ boolean removeTicketAtLevel(final TicketType type, final long chunk, final int level, final T identifier, final boolean lock) { + if (level > MAX_TICKET_LEVEL) { + return false; + } + + final int chunkX = CoordinateUtils.getChunkX(chunk); + final int chunkZ = CoordinateUtils.getChunkZ(chunk); -+ final Ticket probe = new Ticket<>(type, level, identifier); ++ final Ticket probe = new Ticket(type, level, 0L); ++ ((ChunkSystemTicket)(Object)probe).moonrise$setIdentifier(identifier); + + final ReentrantAreaLock.Node ticketLock = lock ? this.ticketLockArea.lock(chunkX, chunkZ) : null; + try { -+ final SortedArraySet> ticketsAtChunk = this.tickets.get(chunk); ++ final SortedArraySet ticketsAtChunk = this.tickets.get(chunk); + if (ticketsAtChunk == null) { + return false; + } + + final int oldLevel = getTicketLevelAt(ticketsAtChunk); -+ final Ticket ticket = (Ticket)((ChunkSystemSortedArraySet>)ticketsAtChunk).moonrise$removeAndGet(probe); ++ final Ticket ticket = (Ticket)((ChunkSystemSortedArraySet)ticketsAtChunk).moonrise$removeAndGet(probe); + + if (ticket == null) { + return false; @@ -7417,8 +7526,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + final int newLevel = getTicketLevelAt(ticketsAtChunk); + // we should not change the ticket levels while the target region may be ticking + if (oldLevel != newLevel) { -+ final Ticket unknownTicket = new Ticket<>(TicketType.UNKNOWN, level, new ChunkPos(chunk)); -+ ((ChunkSystemTicket)(Object)unknownTicket).moonrise$setRemoveDelay(Math.max(1, TicketType.UNKNOWN.timeout)); ++ final Ticket unknownTicket = new Ticket(TicketType.UNKNOWN, level); + if (ticketsAtChunk.add(unknownTicket)) { + this.addExpireCount(chunkX, chunkZ); + } else { @@ -7431,6 +7539,8 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + this.removeExpireCount(chunkX, chunkZ); + } + ++ this.removeTicketCounter(type, chunk); ++ + return true; + } finally { + if (ticketLock != null) { @@ -7440,8 +7550,8 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + + // atomic with respect to all add/remove/addandremove ticket calls for the given chunk -+ public void addAndRemoveTickets(final long chunk, final TicketType addType, final int addLevel, final T addIdentifier, -+ final TicketType removeType, final int removeLevel, final V removeIdentifier) { ++ public void addAndRemoveTickets(final long chunk, final TicketType addType, final int addLevel, final T addIdentifier, ++ final TicketType removeType, final int removeLevel, final V removeIdentifier) { + final ReentrantAreaLock.Node ticketLock = this.ticketLockArea.lock(CoordinateUtils.getChunkX(chunk), CoordinateUtils.getChunkZ(chunk)); + try { + this.addTicketAtLevel(addType, chunk, addLevel, addIdentifier, false); @@ -7452,8 +7562,8 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + + // atomic with respect to all add/remove/addandremove ticket calls for the given chunk -+ public boolean addIfRemovedTicket(final long chunk, final TicketType addType, final int addLevel, final T addIdentifier, -+ final TicketType removeType, final int removeLevel, final V removeIdentifier) { ++ public boolean addIfRemovedTicket(final long chunk, final TicketType addType, final int addLevel, final T addIdentifier, ++ final TicketType removeType, final int removeLevel, final V removeIdentifier) { + final ReentrantAreaLock.Node ticketLock = this.ticketLockArea.lock(CoordinateUtils.getChunkX(chunk), CoordinateUtils.getChunkZ(chunk)); + try { + if (this.removeTicketAtLevel(removeType, chunk, removeLevel, removeIdentifier, false)) { @@ -7466,7 +7576,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + } + -+ public void removeAllTicketsFor(final TicketType ticketType, final int ticketLevel, final T ticketIdentifier) { ++ public void removeAllTicketsFor(final TicketType ticketType, final int ticketLevel, final T ticketIdentifier) { + if (ticketLevel > MAX_TICKET_LEVEL) { + return; + } @@ -7512,7 +7622,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + + final int sectionShift = ((ChunkSystemServerLevel)this.world).moonrise$getRegionChunkShift(); + -+ final Predicate> expireNow = (final Ticket ticket) -> { ++ final Predicate expireNow = (final Ticket ticket) -> { + long removeDelay = ((ChunkSystemTicket)(Object)ticket).moonrise$getRemoveDelay(); + if (removeDelay == NO_TIMEOUT_MARKER) { + return false; @@ -7548,7 +7658,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + final long chunkKey = entry.getLongKey(); + final int expireCount = entry.getIntValue(); + -+ final SortedArraySet> tickets = this.tickets.get(chunkKey); ++ final SortedArraySet tickets = this.tickets.get(chunkKey); + final int levelBefore = getTicketLevelAt(tickets); + + final int sizeBefore = tickets.size(); @@ -7966,7 +8076,7 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + this.removeChunkHolder(holder); + } else { + // add cooldown so the next unload check is not immediately next tick -+ this.addTicketAtLevel(UNLOAD_COOLDOWN, CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ), MAX_TICKET_LEVEL, Unit.INSTANCE, false); ++ this.addTicketAtLevel(UNLOAD_COOLDOWN, CoordinateUtils.getChunkKey(holder.chunkX, holder.chunkZ), MAX_TICKET_LEVEL, null, false); + } + } + } finally { @@ -7990,42 +8100,42 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + + public static record TicketOperation ( + TicketOperationType op, long chunkCoord, -+ TicketType ticketType, int ticketLevel, T identifier, -+ TicketType ticketType2, int ticketLevel2, V identifier2 ++ TicketType ticketType, int ticketLevel, T identifier, ++ TicketType ticketType2, int ticketLevel2, V identifier2 + ) { + + private TicketOperation(TicketOperationType op, long chunkCoord, -+ TicketType ticketType, int ticketLevel, T identifier) { ++ TicketType ticketType, int ticketLevel, T identifier) { + this(op, chunkCoord, ticketType, ticketLevel, identifier, null, 0, null); + } + -+ public static TicketOperation addOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation addOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { + return addOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); + } + -+ public static TicketOperation addOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation addOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { + return addOp(CoordinateUtils.getChunkKey(chunkX, chunkZ), type, ticketLevel, identifier); + } + -+ public static TicketOperation addOp(final long chunk, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation addOp(final long chunk, final TicketType type, final int ticketLevel, final T identifier) { + return new TicketOperation<>(TicketOperationType.ADD, chunk, type, ticketLevel, identifier); + } + -+ public static TicketOperation removeOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation removeOp(final ChunkPos chunk, final TicketType type, final int ticketLevel, final T identifier) { + return removeOp(CoordinateUtils.getChunkKey(chunk), type, ticketLevel, identifier); + } + -+ public static TicketOperation removeOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation removeOp(final int chunkX, final int chunkZ, final TicketType type, final int ticketLevel, final T identifier) { + return removeOp(CoordinateUtils.getChunkKey(chunkX, chunkZ), type, ticketLevel, identifier); + } + -+ public static TicketOperation removeOp(final long chunk, final TicketType type, final int ticketLevel, final T identifier) { ++ public static TicketOperation removeOp(final long chunk, final TicketType type, final int ticketLevel, final T identifier) { + return new TicketOperation<>(TicketOperationType.REMOVE, chunk, type, ticketLevel, identifier); + } + + public static TicketOperation addIfRemovedOp(final long chunk, -+ final TicketType addType, final int addLevel, final T addIdentifier, -+ final TicketType removeType, final int removeLevel, final V removeIdentifier) { ++ final TicketType addType, final int addLevel, final T addIdentifier, ++ final TicketType removeType, final int removeLevel, final V removeIdentifier) { + return new TicketOperation<>( + TicketOperationType.ADD_IF_REMOVED, chunk, addType, addLevel, addIdentifier, + removeType, removeLevel, removeIdentifier @@ -8033,8 +8143,8 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + } + + public static TicketOperation addAndRemove(final long chunk, -+ final TicketType addType, final int addLevel, final T addIdentifier, -+ final TicketType removeType, final int removeLevel, final V removeIdentifier) { ++ final TicketType addType, final int addLevel, final T addIdentifier, ++ final TicketType removeType, final int removeLevel, final V removeIdentifier) { + return new TicketOperation<>( + TicketOperationType.ADD_AND_REMOVE, chunk, addType, addLevel, addIdentifier, + removeType, removeLevel, removeIdentifier @@ -8193,11 +8303,11 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + final JsonArray allTicketsJson = new JsonArray(); + ret.add("tickets", allTicketsJson); + -+ for (final Iterator>>> iterator = this.tickets.entryIterator(); ++ for (final Iterator>> iterator = this.tickets.entryIterator(); + iterator.hasNext();) { -+ final ConcurrentLong2ReferenceChainedHashTable.TableEntry>> coordinateTickets = iterator.next(); ++ final ConcurrentLong2ReferenceChainedHashTable.TableEntry> coordinateTickets = iterator.next(); + final long coordinate = coordinateTickets.getKey(); -+ final SortedArraySet> tickets = coordinateTickets.getValue(); ++ final SortedArraySet tickets = coordinateTickets.getValue(); + + final JsonObject coordinateJson = new JsonObject(); + allTicketsJson.add(coordinateJson); @@ -8212,17 +8322,17 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc + // directly over the set using the iterator + // however, it also means we need to null-check the values, and there is a possibility that we _miss_ an + // entry OR iterate over an entry multiple times -+ for (final Object ticketUncasted : ((ChunkSystemSortedArraySet>)tickets).moonrise$copyBackingArray()) { ++ for (final Object ticketUncasted : ((ChunkSystemSortedArraySet)tickets).moonrise$copyBackingArray()) { + if (ticketUncasted == null) { + continue; + } -+ final Ticket ticket = (Ticket)ticketUncasted; ++ final Ticket ticket = (Ticket)ticketUncasted; + final JsonObject ticketSerialized = new JsonObject(); + ticketsSerialized.add(ticketSerialized); + + ticketSerialized.addProperty("type", ticket.getType().toString()); + ticketSerialized.addProperty("level", Integer.valueOf(ticket.getTicketLevel())); -+ ticketSerialized.addProperty("identifier", Objects.toString(ticket.key)); ++ ticketSerialized.addProperty("identifier", Objects.toString(((ChunkSystemTicket)(Object)ticket).moonrise$getIdentifier())); + ticketSerialized.addProperty("remove_tick", Long.valueOf(((ChunkSystemTicket)(Object)ticket).moonrise$getRemoveDelay())); + } + } @@ -8232,10 +8342,10 @@ index 0000000000000000000000000000000000000000..b5817aa8f537593f6d9fc6b612c82ccc +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java new file mode 100644 -index 0000000000000000000000000000000000000000..67532b85073b7978254a0b04caadfe822679e61f +index 0000000000000000000000000000000000000000..8f8268924ac92fca5df8a11e08031fa8416c6e05 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/ChunkTaskScheduler.java -@@ -0,0 +1,1055 @@ +@@ -0,0 +1,1056 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.scheduling; + +import ca.spottedleaf.concurrentutil.executor.PrioritisedExecutor; @@ -8260,6 +8370,7 @@ index 0000000000000000000000000000000000000000..67532b85073b7978254a0b04caadfe82 +import ca.spottedleaf.moonrise.patches.chunk_system.scheduling.task.ChunkUpgradeGenericStatusTask; +import ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer; +import ca.spottedleaf.moonrise.patches.chunk_system.status.ChunkSystemChunkStep; ++import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType; +import ca.spottedleaf.moonrise.patches.chunk_system.util.ParallelSearchRadiusIteration; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; @@ -8311,35 +8422,35 @@ index 0000000000000000000000000000000000000000..67532b85073b7978254a0b04caadfe82 + LOGGER.info("Chunk system is using population gen parallelism: " + useParallelGen); + } + -+ public static final TicketType CHUNK_LOAD = TicketType.create("chunk_system:chunk_load", Long::compareTo); ++ public static final TicketType CHUNK_LOAD = ChunkSystemTicketType.create("chunk_system:chunk_load", Long::compareTo); + private static final AtomicLong CHUNK_LOAD_IDS = new AtomicLong(); + + public static Long getNextChunkLoadId() { + return Long.valueOf(CHUNK_LOAD_IDS.getAndIncrement()); + } + -+ public static final TicketType NON_FULL_CHUNK_LOAD = TicketType.create("chunk_system:non_full_load", Long::compareTo); ++ public static final TicketType NON_FULL_CHUNK_LOAD = ChunkSystemTicketType.create("chunk_system:non_full_load", Long::compareTo); + private static final AtomicLong NON_FULL_CHUNK_LOAD_IDS = new AtomicLong(); + + public static Long getNextNonFullLoadId() { + return Long.valueOf(NON_FULL_CHUNK_LOAD_IDS.getAndIncrement()); + } + -+ public static final TicketType ENTITY_LOAD = TicketType.create("chunk_system:entity_load", Long::compareTo); ++ public static final TicketType ENTITY_LOAD = ChunkSystemTicketType.create("chunk_system:entity_load", Long::compareTo); + private static final AtomicLong ENTITY_LOAD_IDS = new AtomicLong(); + + public static Long getNextEntityLoadId() { + return Long.valueOf(ENTITY_LOAD_IDS.getAndIncrement()); + } + -+ public static final TicketType POI_LOAD = TicketType.create("chunk_system:poi_load", Long::compareTo); ++ public static final TicketType POI_LOAD = ChunkSystemTicketType.create("chunk_system:poi_load", Long::compareTo); + private static final AtomicLong POI_LOAD_IDS = new AtomicLong(); + + public static Long getNextPoiLoadId() { + return Long.valueOf(POI_LOAD_IDS.getAndIncrement()); + } + -+ public static final TicketType CHUNK_RELIGHT = TicketType.create("starlight:chunk_relight", Long::compareTo); ++ public static final TicketType CHUNK_RELIGHT = ChunkSystemTicketType.create("starlight:chunk_relight", Long::compareTo); + private static final AtomicLong CHUNK_RELIGHT_IDS = new AtomicLong(); + + public static Long getNextChunkRelightId() { @@ -13715,7 +13826,7 @@ index 0000000000000000000000000000000000000000..5f4b99d8c5453f8ad2e600a57ea4e7da +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java new file mode 100644 -index 0000000000000000000000000000000000000000..6ab353b0d2465c3680bb3c8d0852ba0f65c00fd2 +index 0000000000000000000000000000000000000000..96ccb8f657d755b2e58a8dd0cda00ca0df4886b2 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/scheduling/task/ChunkFullTask.java @@ -0,0 +1,151 @@ @@ -13791,7 +13902,7 @@ index 0000000000000000000000000000000000000000..6ab353b0d2465c3680bb3c8d0852ba0f + this.chunkHolder.replaceProtoChunk(new ImposterProtoChunk(chunk, false)); + } + -+ ((ChunkSystemLevelChunk)chunk).moonrise$setChunkAndHolder(new ServerChunkCache.ChunkAndHolder(chunk, this.chunkHolder.vanillaChunkHolder)); ++ ((ChunkSystemLevelChunk)chunk).moonrise$setChunkHolder(this.chunkHolder); + + final NewChunkHolder chunkHolder = this.chunkHolder; + @@ -15652,10 +15763,10 @@ index 0000000000000000000000000000000000000000..3bd1b59250dbab15097a64d515999b27 +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java new file mode 100644 -index 0000000000000000000000000000000000000000..786e6ad17cd6216ef0aadaa7cf10044a0c19c933 +index 0000000000000000000000000000000000000000..befc9224948ebd9e32f1b6ad672e51c168db5a31 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicket.java -@@ -0,0 +1,9 @@ +@@ -0,0 +1,13 @@ +package ca.spottedleaf.moonrise.patches.chunk_system.ticket; + +public interface ChunkSystemTicket { @@ -15664,6 +15775,66 @@ index 0000000000000000000000000000000000000000..786e6ad17cd6216ef0aadaa7cf10044a + + public void moonrise$setRemoveDelay(final long removeDelay); + ++ public T moonrise$getIdentifier(); ++ ++ public void moonrise$setIdentifier(final T identifier); ++ ++} +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketStorage.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketStorage.java +new file mode 100644 +index 0000000000000000000000000000000000000000..8942da3b1449eb83bed25f68f43b70caade79527 +--- /dev/null ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketStorage.java +@@ -0,0 +1,11 @@ ++package ca.spottedleaf.moonrise.patches.chunk_system.ticket; ++ ++import net.minecraft.server.level.ChunkMap; ++ ++public interface ChunkSystemTicketStorage { ++ ++ public ChunkMap moonrise$getChunkMap(); ++ ++ public void moonrise$setChunkMap(final ChunkMap chunkMap); ++ ++} +diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketType.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketType.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0c76e48e3d5327b5ebac414e3ea21885973a0435 +--- /dev/null ++++ b/ca/spottedleaf/moonrise/patches/chunk_system/ticket/ChunkSystemTicketType.java +@@ -0,0 +1,33 @@ ++package ca.spottedleaf.moonrise.patches.chunk_system.ticket; ++ ++import net.minecraft.server.level.TicketType; ++import java.util.Comparator; ++ ++public interface ChunkSystemTicketType { ++ ++ public static final long COUNTER_TYPE_FORCED = 0L; ++ // used only by neoforge ++ public static final long COUNTER_TYPER_NATURAL_SPAWNING_FORCED = 1L; ++ ++ public static TicketType create(final String name, final Comparator identifierComparator) { ++ return create(name, identifierComparator, 0L); ++ } ++ ++ public static TicketType create(final String name, final Comparator identifierComparator, final long timeout) { ++ // note: cannot persist unless registered ++ final TicketType ret = new TicketType(timeout, false, TicketType.TicketUse.LOADING_AND_SIMULATION); ++ ++ ((ChunkSystemTicketType)(Object)ret).moonrise$setIdentifierComparator(identifierComparator); ++ ++ return ret; ++ } ++ ++ public long moonrise$getId(); ++ ++ public Comparator moonrise$getIdentifierComparator(); ++ ++ public void moonrise$setIdentifierComparator(final Comparator comparator); ++ ++ public long[] moonrise$getCounterTypes(); ++ +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/ticks/ChunkSystemLevelChunkTicks.java b/ca/spottedleaf/moonrise/patches/chunk_system/ticks/ChunkSystemLevelChunkTicks.java new file mode 100644 @@ -16108,23 +16279,31 @@ index 0000000000000000000000000000000000000000..4b9e2fa963c14f65f15407c1814c543c +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java new file mode 100644 -index 0000000000000000000000000000000000000000..e97e7d276faf055c89207385d3820debffb06463 +index 0000000000000000000000000000000000000000..6d1fe8028739145b11fce98ad62b2f8044299548 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickConstants.java -@@ -0,0 +1,7 @@ +@@ -0,0 +1,15 @@ +package ca.spottedleaf.moonrise.patches.chunk_tick_iteration; + +public final class ChunkTickConstants { + + public static final int PLAYER_SPAWN_TRACK_RANGE = 8; ++ // the smallest distance on x/z is at 45 degrees, we need to subtract 0.5 since this is calculated from chunk center and not chunk perimeter ++ // note: vanilla does not subtract 0.5 but the result is (luckily!) the same ++ public static final int NARROW_SPAWN_TRACK_RANGE = (int)Math.floor(((double)PLAYER_SPAWN_TRACK_RANGE / Math.sqrt(2.0)) - 0.5); ++ static { ++ if (NARROW_SPAWN_TRACK_RANGE < 0) { ++ throw new IllegalStateException(); ++ } ++ } + +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickDistanceManager.java b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickDistanceManager.java new file mode 100644 -index 0000000000000000000000000000000000000000..f28fd0e01e2bdda0daf9d775e514a7253d32d8d0 +index 0000000000000000000000000000000000000000..27f8e6aae986dc7a3c41f4085bfc04a5499501f1 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickDistanceManager.java -@@ -0,0 +1,16 @@ +@@ -0,0 +1,18 @@ +package ca.spottedleaf.moonrise.patches.chunk_tick_iteration; + +import net.minecraft.core.SectionPos; @@ -16140,10 +16319,12 @@ index 0000000000000000000000000000000000000000..f28fd0e01e2bdda0daf9d775e514a725 + final SectionPos oldPos, final SectionPos newPos, + final boolean oldIgnore, final boolean newIgnore); + ++ public boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ); ++ +} diff --git a/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickServerLevel.java b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickServerLevel.java new file mode 100644 -index 0000000000000000000000000000000000000000..6af03fd7807d4c71dbf85028d18dc850978ef429 +index 0000000000000000000000000000000000000000..1414f25ef770b0fe73ea618a450ade2fe79fbb52 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/chunk_tick_iteration/ChunkTickServerLevel.java @@ -0,0 +1,19 @@ @@ -16155,7 +16336,7 @@ index 0000000000000000000000000000000000000000..6af03fd7807d4c71dbf85028d18dc850 + +public interface ChunkTickServerLevel { + -+ public ReferenceList moonrise$getPlayerTickingChunks(); ++ public ReferenceList moonrise$getPlayerTickingChunks(); + + public void moonrise$markChunkForPlayerTicking(final LevelChunk chunk); + @@ -16168,10 +16349,10 @@ index 0000000000000000000000000000000000000000..6af03fd7807d4c71dbf85028d18dc850 +} diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981f35bfb7d +index 0000000000000000000000000000000000000000..a97a2a8492f3858e3b622d26768b4d819c9b47a7 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -@@ -0,0 +1,2183 @@ +@@ -0,0 +1,2185 @@ +package ca.spottedleaf.moonrise.patches.collisions; + +import ca.spottedleaf.moonrise.common.util.WorldUtil; @@ -18178,11 +18359,10 @@ index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981 + VoxelShape blockCollision = ((CollisionBlockState)blockData).moonrise$getConstantContextCollisionShape(); + + if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) { ++ mutablePos.set(blockX, blockY, blockZ); + if (useEntityCollisionShape) { -+ mutablePos.set(blockX, blockY, blockZ); + blockCollision = collisionShape.getCollisionShape(blockData, world, mutablePos); + } else if (blockCollision == null) { -+ mutablePos.set(blockX, blockY, blockZ); + blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); + } + @@ -18194,7 +18374,6 @@ index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981 + } + + if (predicate != null) { -+ mutablePos.set(blockX, blockY, blockZ); + if (!predicate.test(blockData, mutablePos)) { + continue; + } @@ -18220,7 +18399,6 @@ index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981 + } + + if (predicate != null) { -+ mutablePos.set(blockX, blockY, blockZ); + if (!predicate.test(blockData, mutablePos)) { + continue; + } @@ -18300,7 +18478,7 @@ index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981 + private boolean delegated; + + public LazyEntityCollisionContext(final Entity entity) { -+ super(false, 0.0, null, null, entity); ++ super(false, false, 0.0, null, null, entity); + } + + public static boolean useEntityCollisionShape(final Level world, final Entity entity) { @@ -18331,6 +18509,11 @@ index 0000000000000000000000000000000000000000..e04bd54744335fb5398c6e4f7ce8b981 + } + + @Override ++ public boolean isPlacement() { ++ return this.getDelegate().isPlacement(); ++ } ++ ++ @Override + public boolean isAbove(final VoxelShape shape, final BlockPos pos, final boolean defaultValue) { + return this.getDelegate().isAbove(shape, pos, defaultValue); + } @@ -20140,7 +20323,7 @@ index 0000000000000000000000000000000000000000..f9aef289e9a2d6f63c98c72c56ef32b8 +} diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java new file mode 100644 -index 0000000000000000000000000000000000000000..8aeb5fb87f94a35659347a09a638420699b52a6f +index 0000000000000000000000000000000000000000..d570e87097cf1790a0dc5cc4b74c1e46c2dbbe33 --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightEngine.java @@ -0,0 +1,1438 @@ @@ -20328,7 +20511,7 @@ index 0000000000000000000000000000000000000000..8aeb5fb87f94a35659347a09a6384206 + for (int dx = -radius; dx <= radius; ++dx) { + final int cx = centerChunkX + dx; + final int cz = centerChunkZ + dz; -+ final boolean isTwoRadius = Math.max(IntegerUtil.branchlessAbs(dx), IntegerUtil.branchlessAbs(dz)) == 2; ++ final boolean isTwoRadius = Math.max(Math.abs(dx), Math.abs(dz)) == 2; + final ChunkAccess chunk = (ChunkAccess)chunkProvider.getChunkForLighting(cx, cz); + + if (chunk == null) { @@ -21584,10 +21767,10 @@ index 0000000000000000000000000000000000000000..8aeb5fb87f94a35659347a09a6384206 +} diff --git a/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java new file mode 100644 -index 0000000000000000000000000000000000000000..571db5f9bf94745a8afe2cd313e593fb15db5e37 +index 0000000000000000000000000000000000000000..51f4dd4f583dfbd16cb00f1cb4418d1044cecb1c --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/starlight/light/StarLightInterface.java -@@ -0,0 +1,931 @@ +@@ -0,0 +1,930 @@ +package ca.spottedleaf.moonrise.patches.starlight.light; + +import ca.spottedleaf.concurrentutil.collection.MultiThreadedQueue; @@ -21599,6 +21782,7 @@ index 0000000000000000000000000000000000000000..571db5f9bf94745a8afe2cd313e593fb +import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel; +import ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel; +import ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkStatus; ++import ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType; +import ca.spottedleaf.moonrise.patches.starlight.chunk.StarlightChunk; +import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap; +import it.unimi.dsi.fastutil.shorts.ShortCollection; @@ -21629,10 +21813,8 @@ index 0000000000000000000000000000000000000000..571db5f9bf94745a8afe2cd313e593fb + +public final class StarLightInterface { + -+ public static final TicketType CHUNK_WORK_TICKET = TicketType.create("starlight:chunk_work_ticket", Long::compareTo); ++ public static final TicketType CHUNK_WORK_TICKET = ChunkSystemTicketType.create("starlight:chunk_work_ticket", Long::compareTo); + public static final int LIGHT_TICKET_LEVEL = ChunkLevel.byStatus(ChunkStatus.LIGHT); -+ // ticket level = ChunkLevel.byStatus(FullChunkStatus.FULL) - input -+ public static final int REGION_LIGHT_TICKET_LEVEL = ChunkLevel.byStatus(FullChunkStatus.FULL) - LIGHT_TICKET_LEVEL; + + /** + * Can be {@code null}, indicating the light is all empty. @@ -22575,10 +22757,10 @@ index 0000000000000000000000000000000000000000..40d004afdc6449530f5bb2d7c7638b8e +} diff --git a/ca/spottedleaf/moonrise/patches/starlight/util/SaveUtil.java b/ca/spottedleaf/moonrise/patches/starlight/util/SaveUtil.java new file mode 100644 -index 0000000000000000000000000000000000000000..689ce367164e79e0426eeecb81dbbc521d4bc742 +index 0000000000000000000000000000000000000000..f1f72a051083b61273202cb4e67ecb11f1aecc9d --- /dev/null +++ b/ca/spottedleaf/moonrise/patches/starlight/util/SaveUtil.java -@@ -0,0 +1,189 @@ +@@ -0,0 +1,197 @@ +package ca.spottedleaf.moonrise.patches.starlight.util; + +import ca.spottedleaf.moonrise.common.util.WorldUtil; @@ -22637,15 +22819,18 @@ index 0000000000000000000000000000000000000000..689ce367164e79e0426eeecb81dbbc52 + tag.putBoolean("isLightOn", false); + } + // diff end - store our tag for whether light data is init'd -+ ChunkStatus status = ChunkStatus.byName(tag.getString("Status")); ++ ChunkStatus status = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); + + CompoundTag[] sections = new CompoundTag[maxSection - minSection + 1]; + -+ ListTag sectionsStored = tag.getList("sections", 10); ++ ListTag sectionsStored = tag.getListOrEmpty("sections"); + + for (int i = 0; i < sectionsStored.size(); ++i) { -+ CompoundTag sectionStored = sectionsStored.getCompound(i); -+ int k = sectionStored.getByte("Y"); ++ CompoundTag sectionStored = sectionsStored.getCompound(i).orElse(null); ++ if (sectionStored == null) { ++ continue; ++ } ++ int k = sectionStored.getByteOr("Y", (byte)0); + + // strip light data + sectionStored.remove("BlockLight"); @@ -22728,33 +22913,38 @@ index 0000000000000000000000000000000000000000..689ce367164e79e0426eeecb81dbbc52 + + + // start copy from the original method -+ boolean lit = tag.get("isLightOn") != null && tag.getInt(STARLIGHT_VERSION_TAG) == STARLIGHT_LIGHT_VERSION; ++ boolean lit = tag.get("isLightOn") != null && tag.getIntOr(STARLIGHT_VERSION_TAG, -1) == STARLIGHT_LIGHT_VERSION; + boolean canReadSky = world.dimensionType().hasSkyLight(); -+ ChunkStatus status = ChunkStatus.byName(tag.getString("Status")); ++ ChunkStatus status = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); + if (lit && status.isOrAfter(ChunkStatus.LIGHT)) { // diff - we add the status check here -+ ListTag sections = tag.getList("sections", 10); ++ ListTag sections = tag.getListOrEmpty("sections"); + + for (int i = 0; i < sections.size(); ++i) { -+ CompoundTag sectionData = sections.getCompound(i); -+ int y = sectionData.getByte("Y"); ++ CompoundTag sectionData = sections.getCompound(i).orElse(null); ++ if (sectionData == null) { ++ continue; ++ } ++ int y = sectionData.getByteOr("Y", (byte)0); + -+ if (sectionData.contains("BlockLight", 7)) { ++ final byte[] blockLight = sectionData.getByteArray("BlockLight").orElse(null); ++ if (blockLight != null) { + // this is where our diff is -+ blockNibbles[y - minSection] = new SWMRNibbleArray(sectionData.getByteArray("BlockLight").clone(), sectionData.getInt(BLOCKLIGHT_STATE_TAG)); // clone for data safety ++ blockNibbles[y - minSection] = new SWMRNibbleArray(blockLight.clone(), sectionData.getIntOr(BLOCKLIGHT_STATE_TAG, 0)); // clone for data safety + } else { -+ blockNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getInt(BLOCKLIGHT_STATE_TAG)); ++ blockNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getIntOr(BLOCKLIGHT_STATE_TAG, 0)); + } + + if (canReadSky) { -+ if (sectionData.contains("SkyLight", 7)) { ++ final byte[] skyLight = sectionData.getByteArray("SkyLight").orElse(null); ++ if (skyLight != null) { + // we store under the same key so mod programs editing nbt + // can still read the data, hopefully. + // however, for compatibility we store chunks as unlit so vanilla + // is forced to re-light them if it encounters our data. It's too much of a burden + // to try and maintain compatibility with a broken and inferior skylight management system. -+ skyNibbles[y - minSection] = new SWMRNibbleArray(sectionData.getByteArray("SkyLight").clone(), sectionData.getInt(SKYLIGHT_STATE_TAG)); // clone for data safety ++ skyNibbles[y - minSection] = new SWMRNibbleArray(skyLight.clone(), sectionData.getIntOr(SKYLIGHT_STATE_TAG, 0)); // clone for data safety + } else { -+ skyNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getInt(SKYLIGHT_STATE_TAG)); ++ skyNibbles[y - minSection] = new SWMRNibbleArray(null, sectionData.getIntOr(SKYLIGHT_STATE_TAG, 0)); + } + } + } @@ -22769,7 +22959,7 @@ index 0000000000000000000000000000000000000000..689ce367164e79e0426eeecb81dbbc52 + private SaveUtil() {} +} diff --git a/io/papermc/paper/FeatureHooks.java b/io/papermc/paper/FeatureHooks.java -index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f430aff1ec0 100644 +index 329e9562e9c2b25228b04c21ff7353d2d8d6e5f6..52b981a05ad5aabb7c85dc1e0f1d2b835163bb87 100644 --- a/io/papermc/paper/FeatureHooks.java +++ b/io/papermc/paper/FeatureHooks.java @@ -1,6 +1,9 @@ @@ -22823,7 +23013,7 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 return ObjectSets.unmodifiable(chunks); } -@@ -79,89 +86,30 @@ public final class FeatureHooks { +@@ -79,91 +86,32 @@ public final class FeatureHooks { } public static boolean isSpiderCollidingWithWorldBorder(final Spider spider) { @@ -22892,16 +23082,16 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 public static java.util.Collection getPluginChunkTickets(net.minecraft.server.level.ServerLevel world, int x, int z) { - net.minecraft.server.level.DistanceManager chunkDistanceManager = world.getChunkSource().chunkMap.distanceManager; -- net.minecraft.util.SortedArraySet> tickets = chunkDistanceManager.tickets.get(ChunkPos.asLong(x, z)); +- List tickets = chunkDistanceManager.ticketStorage.tickets.get(ChunkPos.asLong(x, z)); - - if (tickets == null) { - return java.util.Collections.emptyList(); - } - - com.google.common.collect.ImmutableList.Builder ret = com.google.common.collect.ImmutableList.builder(); -- for (net.minecraft.server.level.Ticket ticket : tickets) { +- for (net.minecraft.server.level.Ticket ticket : tickets) { - if (ticket.getType() == net.minecraft.server.level.TicketType.PLUGIN_TICKET) { -- ret.add((org.bukkit.plugin.Plugin) ticket.key); +- ret.add((org.bukkit.plugin.Plugin) ticket.getIdentifier()); - } - } - @@ -22913,11 +23103,14 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 Map> ret = new HashMap<>(); net.minecraft.server.level.DistanceManager chunkDistanceManager = world.getChunkSource().chunkMap.distanceManager; -- for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { -+ for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry>> chunkTickets : chunkDistanceManager.moonrise$getChunkHolderManager().getTicketsCopy().long2ObjectEntrySet()) { // Paper - rewrite chunk system +- for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.ticketStorage.tickets.long2ObjectEntrySet()) { ++ for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.moonrise$getChunkHolderManager().getTicketsCopy().long2ObjectEntrySet()) { // Paper - rewrite chunk system long chunkKey = chunkTickets.getLongKey(); - net.minecraft.util.SortedArraySet> tickets = chunkTickets.getValue(); +- List tickets = chunkTickets.getValue(); ++ net.minecraft.util.SortedArraySet tickets = chunkTickets.getValue(); // Paper - rewrite chunk system + org.bukkit.Chunk chunk = null; + for (net.minecraft.server.level.Ticket ticket : tickets) { @@ -183,15 +131,15 @@ public final class FeatureHooks { } @@ -22937,7 +23130,7 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 } public static void setViewDistance(net.minecraft.server.level.ServerLevel world, int distance) { -@@ -209,31 +157,31 @@ public final class FeatureHooks { +@@ -209,35 +157,31 @@ public final class FeatureHooks { } public static void setSendViewDistance(net.minecraft.server.level.ServerLevel world, int distance) { @@ -22951,7 +23144,11 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 } public static void closeEntityManager(net.minecraft.server.level.ServerLevel world, boolean save) { -- world.entityManager.close(save); +- try { +- world.entityManager.close(save); +- } catch (final java.io.IOException exception) { +- throw new RuntimeException("Failed to close entity manager", exception); +- } + // Paper - rewrite chunk system } @@ -22975,8 +23172,9 @@ index 184e6c6fe2ba522d0ea0774604839320c4152371..460bb584db04b582f3297ae419183f43 + ((ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer)player).moonrise$getViewDistanceHolder().setSendViewDistance(distance); // Paper - rewrite chunk system } - } +-} \ No newline at end of file ++} diff --git a/io/papermc/paper/command/subcommands/ChunkDebugCommand.java b/io/papermc/paper/command/subcommands/ChunkDebugCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..2dca7afbd93cfbb8686f336fcd3b45dd01fba0fc @@ -23399,19 +23597,19 @@ index 0000000000000000000000000000000000000000..8424cf9d4617b4732d44cc460d25b044 + +} diff --git a/net/minecraft/core/Direction.java b/net/minecraft/core/Direction.java -index 3d3eec1db91cb47395f40c4f47aa77164ad42175..216f97207dac88cc1dc3df59c6ee8a62c7614b4a 100644 +index 2028c2a1613b36629dab2c8e36689af329596f09..63fd7b45750430b565d599337d3112cbaa7e7550 100644 --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java @@ -28,7 +28,7 @@ import org.joml.Quaternionf; import org.joml.Vector3f; - import org.joml.Vector4f; + import org.joml.Vector3fc; -public enum Direction implements StringRepresentable { +public enum Direction implements StringRepresentable, ca.spottedleaf.moonrise.patches.collisions.util.CollisionDirection { // Paper - optimise collisions DOWN(0, 1, -1, "down", Direction.AxisDirection.NEGATIVE, Direction.Axis.Y, new Vec3i(0, -1, 0)), UP(1, 0, -1, "up", Direction.AxisDirection.POSITIVE, Direction.Axis.Y, new Vec3i(0, 1, 0)), NORTH(2, 3, 2, "north", Direction.AxisDirection.NEGATIVE, Direction.Axis.Z, new Vec3i(0, 0, -1)), -@@ -62,6 +62,46 @@ public enum Direction implements StringRepresentable { +@@ -67,6 +67,46 @@ public enum Direction implements StringRepresentable { private final int adjY; private final int adjZ; // Paper end - Perf: Inline shift direction fields @@ -23458,7 +23656,7 @@ index 3d3eec1db91cb47395f40c4f47aa77164ad42175..216f97207dac88cc1dc3df59c6ee8a62 private Direction( final int data3d, -@@ -147,14 +187,13 @@ public enum Direction implements StringRepresentable { +@@ -152,14 +192,13 @@ public enum Direction implements StringRepresentable { } public Quaternionf getRotation() { @@ -23480,7 +23678,7 @@ index 3d3eec1db91cb47395f40c4f47aa77164ad42175..216f97207dac88cc1dc3df59c6ee8a62 } public int get3DDataValue() { -@@ -178,7 +217,7 @@ public enum Direction implements StringRepresentable { +@@ -183,7 +222,7 @@ public enum Direction implements StringRepresentable { } public Direction getOpposite() { @@ -23489,7 +23687,7 @@ index 3d3eec1db91cb47395f40c4f47aa77164ad42175..216f97207dac88cc1dc3df59c6ee8a62 } public Direction getClockWise(Direction.Axis axis) { -@@ -600,4 +639,17 @@ public enum Direction implements StringRepresentable { +@@ -626,4 +665,17 @@ public enum Direction implements StringRepresentable { return this.faces.length; } } @@ -23508,10 +23706,10 @@ index 3d3eec1db91cb47395f40c4f47aa77164ad42175..216f97207dac88cc1dc3df59c6ee8a62 + // Paper end - optimise collisions } diff --git a/net/minecraft/core/MappedRegistry.java b/net/minecraft/core/MappedRegistry.java -index 452c358c2cfa0c39e0b09853cd4a9a12c6ced65d..5f752603aa5611ce9d3dd44cc5b70c27ac46a86e 100644 +index a70fc668e1ab7c069bb6ea1500667074ef3f2f91..761e583a56b1c4a605b0cbb04b61c4df60b8b9bb 100644 --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -51,6 +51,19 @@ public class MappedRegistry implements WritableRegistry { +@@ -50,6 +50,19 @@ public class MappedRegistry implements WritableRegistry { return this.getTags(); } @@ -23531,7 +23729,7 @@ index 452c358c2cfa0c39e0b09853cd4a9a12c6ced65d..5f752603aa5611ce9d3dd44cc5b70c27 public MappedRegistry(ResourceKey> key, Lifecycle registryLifecycle) { this(key, registryLifecycle, false); } -@@ -116,6 +129,7 @@ public class MappedRegistry implements WritableRegistry { +@@ -115,6 +128,7 @@ public class MappedRegistry implements WritableRegistry { this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); this.temporaryUnfrozenMap.put(key.location(), value); // Paper - support pre-filling in registry mod API @@ -23540,11 +23738,11 @@ index 452c358c2cfa0c39e0b09853cd4a9a12c6ced65d..5f752603aa5611ce9d3dd44cc5b70c27 } } diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 2b46ca9a2a046063cad422bec00d76107537b091..9aa664537cc37e44db46d5a2a64ae3116938c681 100644 +index 58be6e1d1607a3af5e28f851718b82321f2feb25..9c9b601a3f903bebb0dd1bda0e24745587229727 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -321,6 +321,7 @@ public class Main { - WorldData worldData = worldStem.worldData(); +@@ -324,6 +324,7 @@ public class Main { + levelStorageAccess.saveDataTag(frozen, worldData); */ + Class.forName(net.minecraft.world.entity.npc.VillagerTrades.class.getName()); // Paper - load this sync so it won't fail later async @@ -23552,10 +23750,10 @@ index 2b46ca9a2a046063cad422bec00d76107537b091..9aa664537cc37e44db46d5a2a64ae311 thread1 -> { DedicatedServer dedicatedServer1 = new DedicatedServer( diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 841a41485af62470d833aba578069b19a0bd1e8d..409c1134327bfcc338c3ac5e658a83cc396645d1 100644 +index 91df2a420eeab1bab508b95f0029fae7adb51c58..094ef7f54ad71795a2d8c2a8d03a32bef6ff2164 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -173,7 +173,7 @@ import net.minecraft.world.phys.Vec2; +@@ -172,7 +172,7 @@ import net.minecraft.world.phys.Vec2; import net.minecraft.world.phys.Vec3; import org.slf4j.Logger; @@ -23564,7 +23762,7 @@ index 841a41485af62470d833aba578069b19a0bd1e8d..409c1134327bfcc338c3ac5e658a83cc private static MinecraftServer SERVER; // Paper public static final Logger LOGGER = LogUtils.getLogger(); public static final net.kyori.adventure.text.logger.slf4j.ComponentLogger COMPONENT_LOGGER = net.kyori.adventure.text.logger.slf4j.ComponentLogger.logger(LOGGER.getName()); // Paper -@@ -320,6 +320,77 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop false : this::haveTime); @@ -23729,7 +23934,7 @@ index 841a41485af62470d833aba578069b19a0bd1e8d..409c1134327bfcc338c3ac5e658a83cc this.tickFrame.end(); profilerFiller.popPush("nextTickWait"); this.mayHaveDelayedTasks = true; -@@ -1345,6 +1426,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> UNLOADED_CHUNK_LIST_RESULT = ChunkResult.error("Unloaded chunks found in range"); private static final CompletableFuture>> UNLOADED_CHUNK_LIST_FUTURE = CompletableFuture.completedFuture( UNLOADED_CHUNK_LIST_RESULT -@@ -112,10 +112,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -116,10 +116,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider public static final int MIN_VIEW_DISTANCE = 2; public static final int MAX_VIEW_DISTANCE = 32; public static final int FORCED_TICKET_LEVEL = ChunkLevel.byStatus(FullChunkStatus.ENTITY_TICKING); @@ -24294,7 +24499,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f public final ServerLevel level; private final ThreadedLevelLightEngine lightEngine; private final BlockableEventLoop mainThreadExecutor; -@@ -125,22 +122,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -130,22 +127,18 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final PoiManager poiManager; public final LongSet toDrop = new LongOpenHashSet(); private boolean modified; @@ -24321,7 +24526,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f // CraftBukkit start - recursion-safe executor for Chunk loadCallback() and unloadCallback() public final CallbackExecutor callbackExecutor = new CallbackExecutor(); -@@ -165,9 +158,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -170,9 +163,16 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper start public final ChunkHolder getUnloadingChunkHolder(int chunkX, int chunkZ) { @@ -24339,7 +24544,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f public ChunkMap( ServerLevel level, -@@ -213,10 +213,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -219,10 +219,9 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.progressListener = progressListener; this.chunkStatusListener = chunkStatusListener; ConsecutiveExecutor consecutiveExecutor1 = new ConsecutiveExecutor(dispatcher, "light"); @@ -24350,12 +24555,12 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f - lightChunk, this, this.level.dimensionType().hasSkyLight(), consecutiveExecutor1, this.lightTaskDispatcher + lightChunk, this, this.level.dimensionType().hasSkyLight(), consecutiveExecutor1, null // Paper - rewrite chunk system ); - this.distanceManager = new ChunkMap.DistanceManager(dispatcher, mainThreadExecutor); + this.distanceManager = new ChunkMap.DistanceManager(ticketStorage, dispatcher, mainThreadExecutor); this.overworldDataStorage = overworldDataStorage; -@@ -230,11 +229,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -237,11 +236,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider level ); - this.setServerViewDistance(viewDistance); + this.setServerViewDistance(serverViewDistance); - this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, mainThreadExecutor, this::setChunkUnsaved); + this.worldGenContext = new WorldGenContext(level, generator, structureManager, this.lightEngine, null, this::setChunkUnsaved); // Paper - rewrite chunk system } @@ -24366,7 +24571,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } // Paper start -@@ -264,23 +263,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -263,23 +262,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } boolean isChunkTracked(ServerPlayer player, int x, int z) { @@ -24392,7 +24597,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } protected ThreadedLevelLightEngine getLightEngine() { -@@ -289,21 +276,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -288,21 +275,22 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @Nullable protected ChunkHolder getUpdatingChunkIfPresent(long chunkPos) { @@ -24423,7 +24628,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } public String getChunkDebugData(ChunkPos pos) { -@@ -329,47 +317,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -328,47 +316,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } private CompletableFuture>> getChunkRangeFuture(ChunkHolder chunkHolder, int range, IntFunction statusGetter) { @@ -24472,7 +24677,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } public ReportedException debugFuturesAndCreateReportedException(IllegalStateException exception, String details) { -@@ -401,95 +349,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -400,93 +348,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public CompletableFuture> prepareEntityTickingChunk(ChunkHolder chunk) { @@ -24504,9 +24709,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f - holder.setTicketLevel(newLevel); - } else { - holder = new ChunkHolder(new ChunkPos(chunkPos), newLevel, this.level, this.lightEngine, this::onLevelChange, this); -- // Paper start -- ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, holder); -- // Paper end +- ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, holder); // Paper - } - - this.updatingChunkMap.put(chunkPos, holder); @@ -24577,7 +24780,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } protected void tick(BooleanSupplier hasMoreTime) { -@@ -505,130 +387,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -502,130 +386,28 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public boolean hasWork() { @@ -24715,7 +24918,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } private ChunkAccess handleChunkLoadFailure(Throwable exception, ChunkPos chunkPos) { -@@ -666,108 +446,43 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -663,108 +445,43 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider @Override public GenerationChunkHolder acquireGeneration(long chunkPos) { @@ -24833,7 +25036,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } public int getTickingGenerated() { -@@ -775,125 +490,78 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -772,126 +489,79 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } private boolean saveChunkIfNeeded(ChunkHolder chunk, long gametime) { @@ -24923,8 +25126,8 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f - return false; - } - -- ChunkType chunkTypeFromTag = SerializableChunkData.getChunkTypeFromTag(compoundTag); -- return this.markPosition(chunkPos, chunkTypeFromTag) == 1; +- ChunkType chunkType = SerializableChunkData.getChunkStatusFromTag(compoundTag).getChunkType(); +- return this.markPosition(chunkPos, chunkType) == 1; - } + throw new UnsupportedOperationException(); // Paper - rewrite chunk system } @@ -24970,8 +25173,8 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f private static void dropChunk(ServerPlayer player, ChunkPos chunkPos) { - player.connection.chunkSender.dropChunk(player, chunkPos); + // Paper - rewrite chunk system -+ } -+ + } + + // Paper start - rewrite chunk system + @Override + public CompletableFuture> read(final ChunkPos pos) { @@ -25003,12 +25206,13 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f + @Override + public void flushWorker() { + ca.spottedleaf.moonrise.patches.chunk_system.io.MoonriseRegionFileIO.flush(this.level); - } ++ } + // Paper end - rewrite chunk system - ++ @Nullable public LevelChunk getChunkToSend(long chunkPos) { -@@ -981,7 +649,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(chunkPos); +@@ -977,28 +647,69 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } // CraftBukkit start @@ -25017,25 +25221,89 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f return this.upgradeChunkTag(this.level.getTypeKey(), this.overworldDataStorage, tag, this.generator().getTypeNameForDataFixer(), pos, this.level); // CraftBukkit end } -@@ -991,7 +659,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - while (spawnCandidateChunks.hasNext()) { - long l = spawnCandidateChunks.nextLong(); -- ChunkHolder chunkHolder = this.visibleChunkMap.get(l); -+ ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(l); // Paper - rewrite chunk system - if (chunkHolder != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkHolder.getPos())) { - action.accept(chunkHolder); ++ // Paper start - optimise chunk tick iteration ++ private boolean isChunkNearPlayer(final ChunkMap chunkMap, final ChunkPos chunkPos, final LevelChunk levelChunk) { ++ final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkHolder().holderData; ++ final ca.spottedleaf.moonrise.common.misc.NearbyPlayers.TrackedChunk nearbyPlayers = chunkData.nearbyPlayers; ++ if (nearbyPlayers == null) { ++ return false; ++ } ++ ++ // Note: cannot use narrow on Paper due to custom spawn range ++ ++ final ca.spottedleaf.moonrise.common.list.ReferenceList players = nearbyPlayers.getPlayers(ca.spottedleaf.moonrise.common.misc.NearbyPlayers.NearbyMapType.SPAWN_RANGE); ++ ++ if (players == null) { ++ return false; ++ } ++ ++ final ServerPlayer[] raw = players.getRawDataUnchecked(); ++ final int len = players.size(); ++ ++ Objects.checkFromIndexSize(0, len, raw.length); ++ for (int i = 0; i < len; ++i) { ++ // Paper start - PlayerNaturallySpawnCreaturesEvent ++ com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event = raw[i].playerNaturallySpawnedEvent; ++ if (event == null || event.isCancelled()) { ++ continue; ++ } ++ double blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); ++ if (chunkMap.playerIsCloseEnoughForSpawning(raw[i], chunkPos, blockRange)) { ++ // Paper end - PlayerNaturallySpawnCreaturesEvent ++ return true; ++ } ++ } ++ ++ return false; ++ } ++ // Paper end - optimise chunk tick iteration ++ + void collectSpawningChunks(List output) { +- LongIterator spawnCandidateChunks = this.distanceManager.getSpawnCandidateChunks(); ++ final ca.spottedleaf.moonrise.common.list.ReferenceList tickingChunks = ((ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel)this.level).moonrise$getPlayerTickingChunks(); + +- while (spawnCandidateChunks.hasNext()) { +- ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); +- if (chunkHolder != null) { +- LevelChunk tickingChunk = chunkHolder.getTickingChunk(); +- if (tickingChunk != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkHolder.getPos(), true)) { // Spigot +- output.add(tickingChunk); +- } ++ final LevelChunk[] raw = tickingChunks.getRawDataUnchecked(); ++ final int size = tickingChunks.size(); ++ ++ Objects.checkFromToIndex(0, size, raw.length); ++ for (int i = 0; i < size; ++i) { ++ final LevelChunk levelChunk = raw[i]; ++ ++ if (!this.isChunkNearPlayer((ChunkMap)(Object)this, levelChunk.getPos(), levelChunk)) { ++ continue; } -@@ -1004,7 +672,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider ++ ++ output.add(levelChunk); + } + } + + void forEachBlockTickingChunk(Consumer action) { + this.distanceManager.forEachEntityTickingChunk(chunkPos -> { +- ChunkHolder chunkHolder = this.visibleChunkMap.get(chunkPos); ++ ChunkHolder chunkHolder = this.getVisibleChunkIfPresent(chunkPos); // Paper - rewrite chunk system + if (chunkHolder != null) { + LevelChunk tickingChunk = chunkHolder.getTickingChunk(); + if (tickingChunk != null) { +@@ -1014,8 +725,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos, boolean reducedRange) { -- return this.distanceManager.hasPlayersNearby(chunkPos.toLong()) && this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, reducedRange); +- TriState triState = this.distanceManager.hasPlayersNearby(chunkPos.toLong()); +- return triState == TriState.DEFAULT ? this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, reducedRange) : triState.toBoolean(true); ++ // Paper - chunk tick iteration optimisation - cannot use narrow check due to custom range + return this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, reducedRange); // Paper - chunk tick iteration optimisation // Spigot end } -@@ -1016,7 +684,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1027,7 +738,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private boolean anyPlayerCloseEnoughForSpawningInternal(ChunkPos chunkPos, boolean reducedRange) { double blockRange; // Paper - use from event // Spigot end @@ -25057,7 +25325,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f // Paper start - PlayerNaturallySpawnCreaturesEvent com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent event; blockRange = 16384.0D; -@@ -1032,26 +713,41 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1043,26 +767,41 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } return false; @@ -25066,7 +25334,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f public List getPlayersCloseForSpawning(ChunkPos chunkPos) { - long packedChunkPos = chunkPos.toLong(); -- if (!this.distanceManager.hasPlayersNearby(packedChunkPos)) { +- if (!this.distanceManager.hasPlayersNearby(packedChunkPos).toBoolean(true)) { - return List.of(); - } else { - Builder builder = ImmutableList.builder(); @@ -25079,13 +25347,13 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f + } + + List ret = null; -+ -+ final ServerPlayer[] raw = players.getRawDataUnchecked(); -+ final int len = players.size(); - for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { - if (this.playerIsCloseEnoughForSpawning(serverPlayer, chunkPos, 16384.0D)) { // Spigot - builder.add(serverPlayer); ++ final ServerPlayer[] raw = players.getRawDataUnchecked(); ++ final int len = players.size(); ++ + Objects.checkFromIndexSize(0, len, raw.length); + for (int i = 0; i < len; ++i) { + final ServerPlayer player = raw[i]; @@ -25110,7 +25378,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f if (player.isSpectator()) { return false; } else { -@@ -1072,18 +768,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1091,18 +830,20 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.updatePlayerPos(player); if (!flag) { this.distanceManager.addPlayer(SectionPos.of(player), player); @@ -25133,7 +25401,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } } -@@ -1093,13 +791,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1112,13 +853,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void move(ServerPlayer player) { @@ -25148,7 +25416,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f SectionPos lastSectionPos = player.getLastSectionPos(); SectionPos sectionPos = SectionPos.of(player); -@@ -1108,6 +800,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1127,6 +862,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider boolean flag2 = lastSectionPos.asLong() != sectionPos.asLong(); if (flag2 || flag != flag1) { this.updatePlayerPos(player); @@ -25156,7 +25424,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f if (!flag) { this.distanceManager.removePlayer(lastSectionPos, player); } -@@ -1124,49 +817,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1143,49 +879,29 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.playerMap.unIgnorePlayer(player); } @@ -25217,7 +25485,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } public void addEntity(Entity entity) { -@@ -1190,6 +863,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1209,6 +925,12 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } else { ChunkMap.TrackedEntity trackedEntity = new ChunkMap.TrackedEntity(entity, i, updateInterval, type.trackDeltas()); this.entityMap.put(entity.getId(), trackedEntity); @@ -25230,7 +25498,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f trackedEntity.updatePlayers(this.level.players()); if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, true); -@@ -1219,12 +898,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1238,12 +960,38 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider if (trackedEntity1 != null) { trackedEntity1.broadcastRemoved(); } @@ -25271,24 +25539,24 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f List list = Lists.newArrayList(); List list1 = this.level.players(); -@@ -1302,23 +1007,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1321,23 +1069,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } public void waitForLightBeforeSending(ChunkPos chunkPos, int range) { - int i = range + 1; -- ChunkPos.rangeClosed(chunkPos, i).forEach(pos -> { -- ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(pos.toLong()); +- ChunkPos.rangeClosed(chunkPos, i).forEach(chunkPos1 -> { +- ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(chunkPos1.toLong()); - if (visibleChunkIfPresent != null) { -- visibleChunkIfPresent.addSendDependency(this.lightEngine.waitForPendingTasks(pos.x, pos.z)); +- visibleChunkIfPresent.addSendDependency(this.lightEngine.waitForPendingTasks(chunkPos1.x, chunkPos1.z)); - } - }); + // Paper - rewrite chunk system } -- public class DistanceManager extends net.minecraft.server.level.DistanceManager { // Paper - public -+ public class DistanceManager extends net.minecraft.server.level.DistanceManager implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager { // Paper - public // Paper - rewrite chunk system - protected DistanceManager(final Executor dispatcher, final Executor mainThreadExecutor) { - super(dispatcher, mainThreadExecutor); +- public class DistanceManager extends net.minecraft.server.level.DistanceManager { ++ public class DistanceManager extends net.minecraft.server.level.DistanceManager implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager { // Paper - rewrite chunk system + protected DistanceManager(final TicketStorage ticketStorage, final Executor dispatcher, final Executor mainThreadExecutor) { + super(ticketStorage, dispatcher, mainThreadExecutor); } + // Paper start - rewrite chunk system @@ -25305,7 +25573,7 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f } @Nullable -@@ -1334,13 +1040,96 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1353,13 +1102,96 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -25401,9 +25669,9 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f + // Paper end - optimise entity tracker + public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { - this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this.seenBy); // CraftBukkit + this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper this.entity = entity; -@@ -1431,17 +1220,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1458,17 +1290,24 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } private int getEffectiveRange() { @@ -25437,59 +25705,43 @@ index ad665c7535c615d2b03a3e7864be435f933235dd..3dff97f13586be3b52bbe786852c185f public void updatePlayers(List playersList) { diff --git a/net/minecraft/server/level/DistanceManager.java b/net/minecraft/server/level/DistanceManager.java -index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423faf21c85 100644 +index 342fc6485a6051acf6a936f73f2340014e051257..fd3d0f6cb53bc8b6186f0d86575f21007b2c20ed 100644 --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -34,56 +34,56 @@ import net.minecraft.world.level.ChunkPos; +@@ -30,30 +30,63 @@ import net.minecraft.world.level.TicketStorage; import net.minecraft.world.level.chunk.LevelChunk; import org.slf4j.Logger; -public abstract class DistanceManager { +public abstract class DistanceManager implements ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemDistanceManager, ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickDistanceManager { // Paper - rewrite chunk system // Paper - chunk tick iteration optimisation - static final Logger LOGGER = LogUtils.getLogger(); + private static final Logger LOGGER = LogUtils.getLogger(); static final int PLAYER_TICKET_LEVEL = ChunkLevel.byStatus(FullChunkStatus.ENTITY_TICKING); - private static final int INITIAL_TICKET_LIST_CAPACITY = 4; final Long2ObjectMap> playersPerChunk = new Long2ObjectOpenHashMap<>(); -- public final Long2ObjectOpenHashMap>> tickets = new Long2ObjectOpenHashMap<>(); -- private final DistanceManager.ChunkTicketTracker ticketTracker = new DistanceManager.ChunkTicketTracker(); +- private final LoadingChunkTracker loadingChunkTracker; +- private final SimulationChunkTracker simulationChunkTracker; ++ // Paper - rewrite chunk system + public final TicketStorage ticketStorage; - private final DistanceManager.FixedPlayerDistanceChunkTracker naturalSpawnChunkCounter = new DistanceManager.FixedPlayerDistanceChunkTracker(8); -- private final TickingTracker tickingTicketsTracker = new TickingTracker(); - private final DistanceManager.PlayerTicketTracker playerTicketManager = new DistanceManager.PlayerTicketTracker(32); -- final Set chunksToUpdateFutures = new ReferenceOpenHashSet<>(); +- protected final Set chunksToUpdateFutures = new ReferenceOpenHashSet<>(); - final ThrottlingChunkTaskDispatcher ticketDispatcher; - final LongSet ticketsToRelease = new LongOpenHashSet(); - final Executor mainThreadExecutor; -+ // Paper - rewrite chunk system +- public int simulationDistance = 10; + // Paper - chunk tick iteration optimisation -+ // Paper - rewrite chunk system - private long ticketTickCounter; -- public int simulationDistance = 10; + // Paper - rewrite chunk system - protected DistanceManager(Executor dispatcher, Executor mainThreadExecutor) { + protected DistanceManager(TicketStorage ticketStorage, Executor dispatcher, Executor mainThreadExecutor) { + this.ticketStorage = ticketStorage; +- this.loadingChunkTracker = new LoadingChunkTracker(this, ticketStorage); +- this.simulationChunkTracker = new SimulationChunkTracker(ticketStorage); ++ // Paper - rewrite chunk system TaskScheduler taskScheduler = TaskScheduler.wrapExecutor("player ticket throttler", mainThreadExecutor); - this.ticketDispatcher = new ThrottlingChunkTaskDispatcher(taskScheduler, dispatcher, 4); - this.mainThreadExecutor = mainThreadExecutor; -+ // Paper - rewrite chunk system ++ this.ticketStorage.moonrise$setChunkMap(this.moonrise$getChunkMap()); // Paper - rewrite chunk system } -- protected void purgeStaleTickets() { -- this.ticketTickCounter++; -- ObjectIterator>>> objectIterator = this.tickets.long2ObjectEntrySet().fastIterator(); -- -- while (objectIterator.hasNext()) { -- Entry>> entry = objectIterator.next(); -- Iterator> iterator = entry.getValue().iterator(); -- boolean flag = false; -- -- while (iterator.hasNext()) { -- Ticket ticket = iterator.next(); -- if (ticket.timedOut(this.ticketTickCounter)) { -- iterator.remove(); -- flag = true; -- this.tickingTicketsTracker.removeTicket(entry.getLongKey(), ticket); -- } -- } + // Paper start - rewrite chunk system + @Override + public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager moonrise$getChunkHolderManager() { @@ -25498,21 +25750,18 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 + // Paper end - rewrite chunk system + // Paper start - chunk tick iteration optimisation + private final ca.spottedleaf.moonrise.common.misc.PositionCountingAreaMap spawnChunkTracker = new ca.spottedleaf.moonrise.common.misc.PositionCountingAreaMap<>(); - -- if (flag) { -- this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(entry.getValue()), false); -- } ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range ++ + @Override + public final void moonrise$addPlayer(final ServerPlayer player, final SectionPos pos) { + this.spawnChunkTracker.add(player, pos.x(), pos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range + } - -- if (entry.getValue().isEmpty()) { -- objectIterator.remove(); -- } ++ + @Override + public final void moonrise$removePlayer(final ServerPlayer player, final SectionPos pos) { + this.spawnChunkTracker.remove(player); ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range + } + + @Override @@ -25521,26 +25770,30 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 + final boolean oldIgnore, final boolean newIgnore) { + if (newIgnore) { + this.spawnChunkTracker.remove(player); ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range + } else { + this.spawnChunkTracker.addOrUpdate(player, newPos.x(), newPos.z(), ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickConstants.PLAYER_SPAWN_TRACK_RANGE); - } - } -+ // Paper end - chunk tick iteration optimisation -+ -+ protected void purgeStaleTickets() { -+ this.moonrise$getChunkHolderManager().tick(); // Paper - rewrite chunk system ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range ++ } + } ++ ++ @Override ++ public final boolean moonrise$hasAnyNearbyNarrow(final int chunkX, final int chunkZ) { ++ throw new UnsupportedOperationException(); // Note: Cannot do narrow tracking on Paper due to custom spawn range ++ } ++ ++ // Paper end - chunk tick iteration optimisation + protected abstract boolean isChunkToRemove(long chunkPos); - private static int getTicketLevelAt(SortedArraySet> tickets) { - return !tickets.isEmpty() ? tickets.first().getTicketLevel() : ChunkLevel.MAX_LEVEL + 1; -@@ -98,77 +98,15 @@ public abstract class DistanceManager { + @Nullable +@@ -63,64 +96,15 @@ public abstract class DistanceManager { protected abstract ChunkHolder updateChunkScheduling(long chunkPos, int i, @Nullable ChunkHolder newLevel, int holder); public boolean runAllUpdates(ChunkMap chunkMap) { - this.naturalSpawnChunkCounter.runAllUpdates(); -- this.tickingTicketsTracker.runAllUpdates(); +- this.simulationChunkTracker.runAllUpdates(); - this.playerTicketManager.runAllUpdates(); -- int i = Integer.MAX_VALUE - this.ticketTracker.runDistanceUpdates(Integer.MAX_VALUE); +- int i = Integer.MAX_VALUE - this.loadingChunkTracker.runDistanceUpdates(Integer.MAX_VALUE); - boolean flag = i != 0; - if (flag) { - } @@ -25568,7 +25821,7 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 - - while (longIterator.hasNext()) { - long l = longIterator.nextLong(); -- if (this.getTickets(l).stream().anyMatch(ticket -> ticket.getType() == TicketType.PLAYER)) { +- if (this.ticketStorage.getTickets(l).stream().anyMatch(ticket -> ticket.getType() == TicketType.PLAYER_LOADING)) { - ChunkHolder updatingChunkIfPresent = chunkMap.getUpdatingChunkIfPresent(l); - if (updatingChunkIfPresent == null) { - throw new IllegalStateException(); @@ -25589,118 +25842,25 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 + return this.moonrise$getChunkHolderManager().processTicketUpdates(); // Paper - rewrite chunk system } - void addTicket(long chunkPos, Ticket ticket) { -- SortedArraySet> tickets = this.getTickets(chunkPos); -- int ticketLevelAt = getTicketLevelAt(tickets); -- Ticket ticket1 = tickets.addOrGet(ticket); -- ticket1.setCreatedTick(this.ticketTickCounter); -- if (ticket.getTicketLevel() < ticketLevelAt) { -- this.ticketTracker.update(chunkPos, ticket.getTicketLevel(), true); -- } -+ this.moonrise$getChunkHolderManager().addTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system - } - - void removeTicket(long chunkPos, Ticket ticket) { -- SortedArraySet> tickets = this.getTickets(chunkPos); -- if (tickets.remove(ticket)) { -- } -- -- if (tickets.isEmpty()) { -- this.tickets.remove(chunkPos); -- } -- -- this.ticketTracker.update(chunkPos, getTicketLevelAt(tickets), false); -+ this.moonrise$getChunkHolderManager().removeTicketAtLevel((TicketType)ticket.getType(), chunkPos, ticket.getTicketLevel(), ticket.key); // Paper - rewrite chunk system - } - - public void addTicket(TicketType type, ChunkPos pos, int level, T value) { -@@ -181,68 +119,43 @@ public abstract class DistanceManager { - } - - public void addRegionTicket(TicketType type, ChunkPos pos, int distance, T value) { -- Ticket ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); -- long packedChunkPos = pos.toLong(); -- this.addTicket(packedChunkPos, ticket); // Paper - diff on change above -- this.tickingTicketsTracker.addTicket(packedChunkPos, ticket); -+ this.moonrise$getChunkHolderManager().addTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system - } - - public void removeRegionTicket(TicketType type, ChunkPos pos, int distance, T value) { -- Ticket ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); -- long packedChunkPos = pos.toLong(); -- this.removeTicket(packedChunkPos, ticket); // Paper - diff on change above -- this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket); -+ this.moonrise$getChunkHolderManager().removeTicketAtLevel(type, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); // Paper - rewrite chunk system - } - - // Paper start - public boolean addPluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { -- Ticket ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31 -- final long packedChunkPos = pos.toLong(); -- final Set> tickets = this.getTickets(packedChunkPos); -- if (tickets.contains(ticket)) { -- return false; -- } -- this.addTicket(packedChunkPos, ticket); -- this.tickingTicketsTracker.addTicket(packedChunkPos, ticket); -- return true; -+ return this.moonrise$getChunkHolderManager().addTicketAtLevel(TicketType.PLUGIN_TICKET, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Paper - rewrite chunk system - } - - public boolean removePluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { -- Ticket ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31 -- final long packedChunkPos = pos.toLong(); -- final Set> tickets = this.tickets.get(packedChunkPos); // Don't use getTickets, we don't want to create a new set -- if (tickets == null || !tickets.contains(ticket)) { -- return false; -- } -- this.removeTicket(packedChunkPos, ticket); -- this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket); -- return true; -+ return this.moonrise$getChunkHolderManager().removeTicketAtLevel(TicketType.PLUGIN_TICKET, pos, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Paper - rewrite chunk system - } - // Paper end - - private SortedArraySet> getTickets(long chunkPos) { -- return this.tickets.computeIfAbsent(chunkPos, l -> SortedArraySet.create(4)); -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - - protected void updateChunkForced(ChunkPos pos, boolean add) { -- Ticket ticket = new Ticket<>(TicketType.FORCED, ChunkMap.FORCED_TICKET_LEVEL, pos); -- long packedChunkPos = pos.toLong(); -+ // Paper start - rewrite chunk system - if (add) { -- this.addTicket(packedChunkPos, ticket); -- this.tickingTicketsTracker.addTicket(packedChunkPos, ticket); -+ this.moonrise$getChunkHolderManager().addTicketAtLevel(TicketType.FORCED, pos, ChunkMap.FORCED_TICKET_LEVEL, pos); - } else { -- this.removeTicket(packedChunkPos, ticket); -- this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket); -+ this.moonrise$getChunkHolderManager().removeTicketAtLevel(TicketType.FORCED, pos, ChunkMap.FORCED_TICKET_LEVEL, pos); - } -+ // Paper end - rewrite chunk system - } - public void addPlayer(SectionPos sectionPos, ServerPlayer player) { ChunkPos chunkPos = sectionPos.chunk(); long packedChunkPos = chunkPos.toLong(); this.playersPerChunk.computeIfAbsent(packedChunkPos, l -> new ObjectOpenHashSet<>()).add(player); - this.naturalSpawnChunkCounter.update(packedChunkPos, 0, true); - this.playerTicketManager.update(packedChunkPos, 0, true); -- this.tickingTicketsTracker.addTicket(TicketType.PLAYER, chunkPos, this.getPlayerTicketLevel(), chunkPos); +- this.ticketStorage.addTicket(new Ticket(TicketType.PLAYER_SIMULATION, this.getPlayerTicketLevel()), chunkPos); + // Paper - chunk tick iteration optimisation + // Paper - rewrite chunk system } public void removePlayer(SectionPos sectionPos, ServerPlayer player) { -@@ -254,136 +167,90 @@ public abstract class DistanceManager { +@@ -132,71 +116,79 @@ public abstract class DistanceManager { if (set == null || set.isEmpty()) { // Paper end - some state corruption happens here, don't crash, clean up gracefully this.playersPerChunk.remove(packedChunkPos); - this.naturalSpawnChunkCounter.update(packedChunkPos, Integer.MAX_VALUE, false); - this.playerTicketManager.update(packedChunkPos, Integer.MAX_VALUE, false); -- this.tickingTicketsTracker.removeTicket(TicketType.PLAYER, chunkPos, this.getPlayerTicketLevel(), chunkPos); +- this.ticketStorage.removeTicket(new Ticket(TicketType.PLAYER_SIMULATION, this.getPlayerTicketLevel()), chunkPos); + // Paper - chunk tick iteration optimisation + // Paper - rewrite chunk system } @@ -25712,7 +25872,7 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 } public boolean inEntityTickingRange(long chunkPos) { -- return ChunkLevel.isEntityTicking(this.tickingTicketsTracker.getLevel(chunkPos)); +- return ChunkLevel.isEntityTicking(this.simulationChunkTracker.getLevel(chunkPos)); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().getChunkHolder(chunkPos); + return chunkHolder != null && chunkHolder.isEntityTickingReady(); @@ -25720,17 +25880,19 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 } public boolean inBlockTickingRange(long chunkPos) { -- return ChunkLevel.isBlockTicking(this.tickingTicketsTracker.getLevel(chunkPos)); +- return ChunkLevel.isBlockTicking(this.simulationChunkTracker.getLevel(chunkPos)); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().getChunkHolder(chunkPos); + return chunkHolder != null && chunkHolder.isTickingReady(); + // Paper end - rewrite chunk system } - protected String getTicketDebugString(long chunkPos) { -- SortedArraySet> set = this.tickets.get(chunkPos); -- return set != null && !set.isEmpty() ? set.first().toString() : "no_ticket"; -+ return this.moonrise$getChunkHolderManager().getTicketDebugString(chunkPos); // Paper - rewrite chunk system + public int getChunkLevel(long chunkPos, boolean simulate) { +- return simulate ? this.simulationChunkTracker.getLevel(chunkPos) : this.loadingChunkTracker.getLevel(chunkPos); ++ // Paper start - rewrite chunk system ++ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkHolderManager().getChunkHolder(chunkPos); ++ return chunkHolder == null ? ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager.MAX_TICKET_LEVEL + 1 : chunkHolder.getTicketLevel(); ++ // Paper end - rewrite chunk system } protected void updatePlayerTickets(int viewDistance) { @@ -25741,7 +25903,7 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 public void updateSimulationDistance(int simulationDistance) { - if (simulationDistance != this.simulationDistance) { - this.simulationDistance = simulationDistance; -- this.tickingTicketsTracker.replacePlayerTicketsLevel(this.getPlayerTicketLevel()); +- this.ticketStorage.replaceTicketLevelOfType(this.getPlayerTicketLevel(), TicketType.PLAYER_SIMULATION); - } + // Paper start - rewrite chunk system + // note: vanilla does not clamp to 0, but we do simply because we need a min of 0 @@ -25757,10 +25919,37 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 + return this.spawnChunkTracker.getTotalPositions(); // Paper - chunk tick iteration optimisation } - public boolean hasPlayersNearby(long chunkPos) { + public TriState hasPlayersNearby(long chunkPos) { - this.naturalSpawnChunkCounter.runAllUpdates(); -- return this.naturalSpawnChunkCounter.chunks.containsKey(chunkPos); -+ return this.spawnChunkTracker.hasObjectsNear(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(chunkPos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(chunkPos)); // Paper - chunk tick iteration optimisation +- int level = this.naturalSpawnChunkCounter.getLevel(chunkPos); +- if (level <= NaturalSpawner.INSCRIBED_SQUARE_SPAWN_DISTANCE_CHUNK) { +- return TriState.TRUE; +- } else { +- return level > 8 ? TriState.FALSE : TriState.DEFAULT; +- } ++ // Note: Cannot do narrow tracking on Paper due to custom spawn range // Paper - chunk tick iteration optimisation ++ return this.spawnChunkTracker.hasObjectsNear(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(chunkPos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(chunkPos)) ? net.minecraft.util.TriState.DEFAULT : net.minecraft.util.TriState.FALSE; // Paper - chunk tick iteration optimisation + } + + public void forEachEntityTickingChunk(LongConsumer action) { +- for (Entry entry : Long2ByteMaps.fastIterable(this.simulationChunkTracker.chunks)) { +- byte byteValue = entry.getByteValue(); +- long longKey = entry.getLongKey(); +- if (ChunkLevel.isEntityTicking(byteValue)) { +- action.accept(longKey); +- } ++ // Paper start - rewrite chunk system ++ final ca.spottedleaf.moonrise.common.list.ReferenceList chunks = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.moonrise$getChunkMap().level).moonrise$getEntityTickingChunks(); ++ final LevelChunk[] raw = chunks.getRawDataUnchecked(); ++ final int size = chunks.size(); ++ ++ java.util.Objects.checkFromToIndex(0, size, raw.length); ++ for (int i = 0; i < size; ++i) { ++ final LevelChunk chunk = raw[i]; ++ ++ action.accept(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunk.getPos())); + } ++ // Paper end - rewrite chunk system } public LongIterator getSpawnCandidateChunks() { @@ -25771,106 +25960,11 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 public String getDebugStatus() { - return this.ticketDispatcher.getDebugStatus(); -+ return "No DistanceManager stats available"; // Paper - rewrite chunk system - } - - private void dumpTickets(String filename) { -- try (FileOutputStream fileOutputStream = new FileOutputStream(new File(filename))) { -- for (Entry>> entry : this.tickets.long2ObjectEntrySet()) { -- ChunkPos chunkPos = new ChunkPos(entry.getLongKey()); -- -- for (Ticket ticket : entry.getValue()) { -- fileOutputStream.write( -- (chunkPos.x + "\t" + chunkPos.z + "\t" + ticket.getType() + "\t" + ticket.getTicketLevel() + "\t\n").getBytes(StandardCharsets.UTF_8) -- ); -- } -- } -- } catch (IOException var10) { -- LOGGER.error("Failed to dump tickets to {}", filename, var10); -- } -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - - @VisibleForTesting - TickingTracker tickingTracker() { -- return this.tickingTicketsTracker; -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - - public LongSet getTickingChunks() { -- return this.tickingTicketsTracker.getTickingChunks(); -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - - public void removeTicketsOnClosing() { -- ImmutableSet> set = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve -- ObjectIterator>>> objectIterator = this.tickets.long2ObjectEntrySet().fastIterator(); -- -- while (objectIterator.hasNext()) { -- Entry>> entry = objectIterator.next(); -- Iterator> iterator = entry.getValue().iterator(); -- boolean flag = false; -- -- while (iterator.hasNext()) { -- Ticket ticket = iterator.next(); -- if (!set.contains(ticket.getType())) { -- iterator.remove(); -- flag = true; -- this.tickingTicketsTracker.removeTicket(entry.getLongKey(), ticket); -- } -- } -- -- if (flag) { -- this.ticketTracker.update(entry.getLongKey(), getTicketLevelAt(entry.getValue()), false); -- } -- -- if (entry.getValue().isEmpty()) { -- objectIterator.remove(); -- } -- } -+ // Paper - rewrite chunk system ++ return "N/A"; // Paper - rewrite chunk system } public boolean hasTickets() { -- return !this.tickets.isEmpty(); -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - - // CraftBukkit start - public void removeAllTicketsFor(TicketType ticketType, int ticketLevel, T ticketIdentifier) { -- Ticket target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier); -- -- for (java.util.Iterator>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) { -- Entry>> entry = iterator.next(); -- SortedArraySet> tickets = entry.getValue(); -- if (tickets.remove(target)) { -- // copied from removeTicket -- this.ticketTracker.update(entry.getLongKey(), DistanceManager.getTicketLevelAt(tickets), false); -- -- // can't use entry after it's removed -- if (tickets.isEmpty()) { -- iterator.remove(); -- } -- } -- } -+ this.moonrise$getChunkHolderManager().removeAllTicketsFor(ticketType, ticketLevel, ticketIdentifier); // Paper - rewrite chunk system - } - // CraftBukkit end - -+/* // Paper - rewrite chunk system - class ChunkTicketTracker extends ChunkTracker { - private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1; - -@@ -428,7 +295,7 @@ public abstract class DistanceManager { - public int runDistanceUpdates(int toUpdateCount) { - return this.runUpdates(toUpdateCount); - } -- } -+ }*/ // Paper - rewrite chunk system - - class FixedPlayerDistanceChunkTracker extends ChunkTracker { - protected final Long2ByteMap chunks = new Long2ByteOpenHashMap(); -@@ -487,6 +354,7 @@ public abstract class DistanceManager { +@@ -248,6 +240,7 @@ public abstract class DistanceManager { } } @@ -25878,7 +25972,7 @@ index 8ec20e372570d5eb720cdcdaed9c92946033be9b..5eab6179ce3913cb4e4d424f910ba423 class PlayerTicketTracker extends DistanceManager.FixedPlayerDistanceChunkTracker { private int viewDistance; private final Long2IntMap queueLevels = Long2IntMaps.synchronize(new Long2IntOpenHashMap()); -@@ -563,5 +431,5 @@ public abstract class DistanceManager { +@@ -326,5 +319,5 @@ public abstract class DistanceManager { private boolean haveTicketFor(int level) { return level <= this.viewDistance; } @@ -26218,11 +26312,24 @@ index cb66209c64b855dedf2e4e114a7716da13bc4587..da1366fdc4889d6a3befd43d81a19a81 + // Paper end - rewrite chunk system } } +diff --git a/net/minecraft/server/level/LoadingChunkTracker.java b/net/minecraft/server/level/LoadingChunkTracker.java +index 302841522cf990c38b1493b716048c0f2db40726..7932a6676db7b652d63be5ae4dcf9bcf9ca298e6 100644 +--- a/net/minecraft/server/level/LoadingChunkTracker.java ++++ b/net/minecraft/server/level/LoadingChunkTracker.java +@@ -38,7 +38,7 @@ class LoadingChunkTracker extends ChunkTracker { + if (i != level) { + chunk = this.distanceManager.updateChunkScheduling(chunkPos, level, chunk, i); + if (chunk != null) { +- this.distanceManager.chunksToUpdateFutures.add(chunk); ++ // Paper - rewrite chunk system + } + } + } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28c548ab8d 100644 +index c50a1a01d167696134bd65b2d28db323d81d6ebd..5d63bf024cbcbd2f627c64fee77553c9a512bd15 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -52,7 +52,7 @@ import net.minecraft.world.level.storage.DimensionDataStorage; +@@ -55,7 +55,7 @@ import net.minecraft.world.level.storage.DimensionDataStorage; import net.minecraft.world.level.storage.LevelStorageSource; import org.slf4j.Logger; @@ -26231,7 +26338,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 private static final Logger LOGGER = LogUtils.getLogger(); private final DistanceManager distanceManager; private final ServerLevel level; -@@ -80,6 +80,107 @@ public class ServerChunkCache extends ChunkSource { +@@ -84,6 +84,106 @@ public class ServerChunkCache extends ChunkSource { } long chunkFutureAwaitCounter; // Paper end @@ -26308,38 +26415,37 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 + // Paper end - rewrite chunk system + // Paper start - chunk tick iteration optimisations + private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom shuffleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L); -+ private boolean isChunkNearPlayer(final ChunkMap chunkMap, final ChunkPos chunkPos, final LevelChunk levelChunk) { -+ final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkAndHolder().holder()) -+ .moonrise$getRealChunkHolder().holderData; -+ final ca.spottedleaf.moonrise.common.misc.NearbyPlayers.TrackedChunk nearbyPlayers = chunkData.nearbyPlayers; -+ if (nearbyPlayers == null) { -+ return false; -+ } ++ private void iterateTickingChunksFaster() { ++ final ServerLevel world = this.level; ++ final int randomTickSpeed = world.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); + -+ final ca.spottedleaf.moonrise.common.list.ReferenceList players = nearbyPlayers.getPlayers(ca.spottedleaf.moonrise.common.misc.NearbyPlayers.NearbyMapType.SPAWN_RANGE); ++ // TODO check on update: impl of forEachBlockTickingChunk will only iterate ENTITY ticking chunks! ++ // TODO check on update: consumer just runs tickChunk ++ final ca.spottedleaf.moonrise.common.list.ReferenceList entityTickingChunks = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getEntityTickingChunks(); + -+ if (players == null) { -+ return false; -+ } ++ // note: we can use the backing array here because: ++ // 1. we do not care about new additions ++ // 2. _removes_ are impossible at this stage in the tick ++ final LevelChunk[] raw = entityTickingChunks.getRawDataUnchecked(); ++ final int size = entityTickingChunks.size(); + -+ final ServerPlayer[] raw = players.getRawDataUnchecked(); -+ final int len = players.size(); ++ java.util.Objects.checkFromToIndex(0, size, raw.length); ++ for (int i = 0; i < size; ++i) { ++ world.tickChunk(raw[i], randomTickSpeed); + -+ java.util.Objects.checkFromIndexSize(0, len, raw.length); -+ for (int i = 0; i < len; ++i) { -+ if (chunkMap.playerIsCloseEnoughForSpawning(raw[i], chunkPos, 16384.0D)) { // Spigot (reducedRange = false) -+ return true; ++ // call mid-tick tasks for chunk system ++ if ((i & 7) == 0) { ++ ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.level.getServer()).moonrise$executeMidTickTasks(); ++ continue; + } + } -+ -+ return false; + } + // Paper end - chunk tick iteration optimisations + public ServerChunkCache( ServerLevel level, -@@ -138,13 +239,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -144,13 +244,7 @@ public class ServerChunkCache extends ChunkSource { } // CraftBukkit end // Paper start @@ -26354,7 +26460,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 @Nullable public ChunkAccess getChunkAtImmediately(int x, int z) { -@@ -215,51 +310,42 @@ public class ServerChunkCache extends ChunkSource { +@@ -221,51 +315,42 @@ public class ServerChunkCache extends ChunkSource { @Nullable @Override public ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { @@ -26416,11 +26522,11 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 + final LevelChunk ret = this.fullChunks.get(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); + if (!ca.spottedleaf.moonrise.common.PlatformHooks.get().hasCurrentlyLoadingChunk()) { + return ret; -+ } + } + + if (ret != null || !ca.spottedleaf.moonrise.common.util.TickThread.isTickThread()) { + return ret; - } ++ } + + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.level).moonrise$getChunkTaskScheduler() + .chunkHolderManager.getChunkHolder(chunkX, chunkZ); @@ -26433,7 +26539,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 } private void clearCache() { -@@ -285,54 +371,59 @@ public class ServerChunkCache extends ChunkSource { +@@ -291,54 +376,59 @@ public class ServerChunkCache extends ChunkSource { } private CompletableFuture> getChunkFutureMainThread(int x, int z, ChunkStatus chunkStatus, boolean requireChunk) { @@ -26449,8 +26555,8 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 - currentlyUnloading = (oldChunkState.isOrAfter(FullChunkStatus.FULL) && !currentChunkState.isOrAfter(FullChunkStatus.FULL)); - } - if (requireChunk && !currentlyUnloading) { -- // CraftBukkit end -- this.distanceManager.addTicket(TicketType.UNKNOWN, chunkPos, i, chunkPos); +- // CraftBukkit end +- this.addTicket(new Ticket(TicketType.UNKNOWN, i), chunkPos); - if (this.chunkAbsent(visibleChunkIfPresent, i)) { - ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("chunkLoad"); @@ -26529,10 +26635,10 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 } @Override -@@ -345,28 +436,18 @@ public class ServerChunkCache extends ChunkSource { +@@ -351,28 +441,18 @@ public class ServerChunkCache extends ChunkSource { } - public boolean runDistanceManagerUpdates() { // Paper - public + public boolean runDistanceManagerUpdates() { - boolean flag = this.distanceManager.runAllUpdates(this.chunkMap); - boolean flag1 = this.chunkMap.promoteChunkMap(); - this.chunkMap.runGenerationTasks(); @@ -26564,7 +26670,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 this.chunkMap.saveAllChunks(flush); } -@@ -377,17 +458,15 @@ public class ServerChunkCache extends ChunkSource { +@@ -383,17 +463,15 @@ public class ServerChunkCache extends ChunkSource { } public void close(boolean save) throws IOException { @@ -26585,7 +26691,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 ProfilerFiller gameprofilerfiller = Profiler.get(); gameprofilerfiller.push("purge"); -@@ -411,6 +490,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -417,6 +495,7 @@ public class ServerChunkCache extends ChunkSource { this.runDistanceManagerUpdates(); profilerFiller.popPush("chunks"); if (tickChunks) { @@ -26593,19 +26699,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 this.tickChunks(); this.chunkMap.tick(); } -@@ -435,7 +515,10 @@ public class ServerChunkCache extends ChunkSource { - profilerFiller.push("filteringTickingChunks"); - this.collectTickingChunks(list); - profilerFiller.popPush("shuffleChunks"); -- Util.shuffle(list, this.level.random); -+ // Paper start - chunk tick iteration optimisation -+ this.shuffleRandom.setSeed(this.level.random.nextLong()); -+ Util.shuffle(list, this.shuffleRandom); -+ // Paper end - chunk tick iteration optimisation - this.tickChunks(profilerFiller, l, list); - profilerFiller.pop(); - } finally { -@@ -452,7 +535,7 @@ public class ServerChunkCache extends ChunkSource { +@@ -449,7 +528,7 @@ public class ServerChunkCache extends ChunkSource { profiler.push("broadcast"); for (ChunkHolder chunkHolder : this.chunkHoldersToBroadcast) { @@ -26614,48 +26708,42 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 if (tickingChunk != null) { chunkHolder.broadcastChanges(tickingChunk); } -@@ -463,12 +546,26 @@ public class ServerChunkCache extends ChunkSource { - } +@@ -491,7 +570,10 @@ public class ServerChunkCache extends ChunkSource { + profiler.push("filteringSpawningChunks"); + this.chunkMap.collectSpawningChunks(list); + profiler.popPush("shuffleSpawningChunks"); +- Util.shuffle(list, this.level.random); ++ // Paper start - chunk tick iteration optimisation ++ this.shuffleRandom.setSeed(this.level.random.nextLong()); ++ Util.shuffle(list, this.shuffleRandom); ++ // Paper end - chunk tick iteration optimisation + profiler.popPush("tickSpawningChunks"); - private void collectTickingChunks(List output) { -- this.chunkMap.forEachSpawnCandidateChunk(chunk -> { -- LevelChunk tickingChunk = chunk.getTickingChunk(); -- if (tickingChunk != null && this.level.isNaturalSpawningAllowed(chunk.getPos())) { -- output.add(tickingChunk); -+ // Paper start - chunk tick iteration optimisation -+ final ca.spottedleaf.moonrise.common.list.ReferenceList tickingChunks = -+ ((ca.spottedleaf.moonrise.patches.chunk_tick_iteration.ChunkTickServerLevel)this.level).moonrise$getPlayerTickingChunks(); -+ -+ final ServerChunkCache.ChunkAndHolder[] raw = tickingChunks.getRawDataUnchecked(); -+ final int size = tickingChunks.size(); -+ -+ final ChunkMap chunkMap = this.chunkMap; -+ -+ for (int i = 0; i < size; ++i) { -+ final ServerChunkCache.ChunkAndHolder chunkAndHolder = raw[i]; -+ final LevelChunk levelChunk = chunkAndHolder.chunk(); -+ -+ if (!this.isChunkNearPlayer(chunkMap, levelChunk.getPos(), levelChunk)) { -+ continue; - } -- }); -+ -+ output.add(levelChunk); -+ } -+ // Paper end - chunk tick iteration optimisation - } + for (LevelChunk levelChunk : list) { +@@ -502,7 +584,7 @@ public class ServerChunkCache extends ChunkSource { + } - private void tickChunks(ProfilerFiller profiler, long timeInhabited, List chunks) { -@@ -504,7 +601,7 @@ public class ServerChunkCache extends ChunkSource { - NaturalSpawner.spawnForChunk(this.level, levelChunk, spawnState, filteredSpawningCategories); - } + profiler.popPush("tickTickingChunks"); +- this.chunkMap.forEachBlockTickingChunk(levelChunk1 -> this.level.tickChunk(levelChunk1, _int)); ++ this.iterateTickingChunksFaster(); // Paper - chunk tick iteration optimisations + profiler.pop(); + profiler.popPush("customSpawners"); + if (_boolean) { +@@ -513,22 +595,25 @@ public class ServerChunkCache extends ChunkSource { + private void tickSpawningChunk(LevelChunk chunk, long timeInhabited, List spawnCategories, NaturalSpawner.SpawnState spawnState) { + ChunkPos pos = chunk.getPos(); + chunk.incrementInhabitedTime(timeInhabited); +- if (this.distanceManager.inEntityTickingRange(pos.toLong())) { ++ if (true) { // Paper - rewrite chunk system + this.level.tickThunder(chunk); + } -- if (this.level.shouldTickBlocksAt(pos.toLong())) { -+ if (true) { // Paper - rewrite chunk system - this.level.tickChunk(levelChunk, _int); + if (!spawnCategories.isEmpty()) { +- if (this.level.canSpawnEntitiesInChunk(pos)) { ++ if (this.level.getWorldBorder().isWithinBounds(pos)) { // Paper - rewrite chunk system + NaturalSpawner.spawnForChunk(this.level, chunk, spawnState, spawnCategories); } } -@@ -516,10 +613,13 @@ public class ServerChunkCache extends ChunkSource { } private void getFullChunk(long chunkPos, Consumer fullChunkGetter) { @@ -26672,7 +26760,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 } @Override -@@ -607,6 +707,12 @@ public class ServerChunkCache extends ChunkSource { +@@ -625,6 +710,12 @@ public class ServerChunkCache extends ChunkSource { this.chunkMap.setServerViewDistance(viewDistance); } @@ -26685,16 +26773,7 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 public void setSimulationDistance(int simulationDistance) { this.distanceManager.updateSimulationDistance(simulationDistance); } -@@ -654,7 +760,7 @@ public class ServerChunkCache extends ChunkSource { - } - } - -- record ChunkAndHolder(LevelChunk chunk, ChunkHolder holder) { -+ public record ChunkAndHolder(LevelChunk chunk, ChunkHolder holder) { // Paper - public - } - - public final class MainThreadExecutor extends BlockableEventLoop { -@@ -695,18 +801,14 @@ public class ServerChunkCache extends ChunkSource { +@@ -710,18 +801,14 @@ public class ServerChunkCache extends ChunkSource { @Override public boolean pollTask() { @@ -26719,10 +26798,10 @@ index 2f49dbc919f7f5eea9abce6106723c72f5ae45fb..87d4291a3944f706a694536da6de0f28 } } diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index da793ad12565c36fffb26eb771ff68c76632caf7..db06f966077928419bfe469260f04d7dfda69f28 100644 +index 3f83a589442a80e9c16b5e9cd0f50792defd12bc..0005a1784ccaa00e5d6d67e7be98445150487982 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -91,6 +91,11 @@ public class ServerEntity { +@@ -104,6 +104,11 @@ public class ServerEntity { } public void sendChanges() { @@ -26733,12 +26812,12 @@ index da793ad12565c36fffb26eb771ff68c76632caf7..db06f966077928419bfe469260f04d7d + // Paper end - optimise collisions List passengers = this.entity.getPassengers(); if (!passengers.equals(this.lastPassengers)) { - this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit + List list = this.mountedOrDismounted(passengers).map(Entity::getUUID).toList(); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e831225505 100644 +index fe9b4484d683fe48f435a053c9c90557fdf80e7b..8afe96bfdc37e57129f1bb4af5b6d5cc22c11aee 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -170,7 +170,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; +@@ -166,7 +166,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.ticks.LevelTicks; import org.slf4j.Logger; @@ -26747,7 +26826,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 public static final BlockPos END_SPAWN_POINT = new BlockPos(100, 50, 0); public static final IntProvider RAIN_DELAY = UniformInt.of(12000, 180000); public static final IntProvider RAIN_DURATION = UniformInt.of(12000, 24000); -@@ -185,7 +185,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -181,7 +181,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final net.minecraft.world.level.storage.PrimaryLevelData serverLevelData; // CraftBukkit - type private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(); @@ -26756,7 +26835,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 private final GameEventDispatcher gameEventDispatcher; public boolean noSave; private final SleepStatus sleepStatus; -@@ -256,12 +256,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -253,12 +253,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunksForMoveAsync(AABB axisalignedbb, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26770,7 +26849,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 int minBlockX = Mth.floor(axisalignedbb.minX - 1.0E-7D) - 3; int minBlockZ = Mth.floor(axisalignedbb.minZ - 1.0E-7D) - 3; -@@ -280,32 +275,159 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -277,30 +272,159 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final void loadChunks(int minChunkX, int minChunkZ, int maxChunkX, int maxChunkZ, ca.spottedleaf.concurrentutil.util.Priority priority, java.util.function.Consumer> onLoad) { @@ -26784,7 +26863,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + // Paper start - optimise getPlayerByUUID + @Nullable + @Override -+ public Player getPlayerByUUID(UUID uuid) { ++ public Player getPlayerByUUID(java.util.UUID uuid) { + final Player player = this.getServer().getPlayerList().getPlayer(uuid); + return player != null && player.level() == this ? player : null; + } @@ -26799,16 +26878,18 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + private long lastMidTickFailure; + private long tickedBlocksOrFluids; + private final ca.spottedleaf.moonrise.common.misc.NearbyPlayers nearbyPlayers = new ca.spottedleaf.moonrise.common.misc.NearbyPlayers((ServerLevel)(Object)this); -+ private static final ServerChunkCache.ChunkAndHolder[] EMPTY_CHUNK_AND_HOLDERS = new ServerChunkCache.ChunkAndHolder[0]; -+ private final ca.spottedleaf.moonrise.common.list.ReferenceList loadedChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_CHUNK_AND_HOLDERS); -+ private final ca.spottedleaf.moonrise.common.list.ReferenceList tickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_CHUNK_AND_HOLDERS); -+ private final ca.spottedleaf.moonrise.common.list.ReferenceList entityTickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_CHUNK_AND_HOLDERS); ++ private static final LevelChunk[] EMPTY_LEVEL_CHUNKS = new LevelChunk[0]; ++ private final ca.spottedleaf.moonrise.common.list.ReferenceList loadedChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_LEVEL_CHUNKS); ++ private final ca.spottedleaf.moonrise.common.list.ReferenceList tickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_LEVEL_CHUNKS); ++ private final ca.spottedleaf.moonrise.common.list.ReferenceList entityTickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_LEVEL_CHUNKS); + + @Override + public final LevelChunk moonrise$getFullChunkIfLoaded(final int chunkX, final int chunkZ) { + return this.chunkSource.getChunkNow(chunkX, chunkZ); + } -+ + +- int requiredChunks = (maxChunkX - minChunkX + 1) * (maxChunkZ - minChunkZ + 1); +- int[] loadedChunks = new int[1]; + @Override + public final ChunkAccess moonrise$getAnyChunkIfLoaded(final int chunkX, final int chunkZ) { + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder newChunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkX, chunkZ)); @@ -26818,7 +26899,8 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder.ChunkCompletion lastCompletion = newChunkHolder.getLastChunkCompletion(); + return lastCompletion == null ? null : lastCompletion.chunk(); + } -+ + +- java.util.function.Consumer consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> { + @Override + public final ChunkAccess moonrise$getSpecificChunkIfLoaded(final int chunkX, final int chunkZ, final net.minecraft.world.level.chunk.status.ChunkStatus leastStatus) { + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder newChunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkX, chunkZ); @@ -26907,24 +26989,20 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + final java.util.function.Consumer> onLoad) { + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler chunkTaskScheduler = this.moonrise$getChunkTaskScheduler(); + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkHolderManager chunkHolderManager = chunkTaskScheduler.chunkHolderManager; - -- int requiredChunks = (maxChunkX - minChunkX + 1) * (maxChunkZ - minChunkZ + 1); -- int[] loadedChunks = new int[1]; ++ + final int requiredChunks = (maxChunkX - minChunkX + 1) * (maxChunkZ - minChunkZ + 1); + final java.util.concurrent.atomic.AtomicInteger loadedChunks = new java.util.concurrent.atomic.AtomicInteger(); + final Long holderIdentifier = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.getNextChunkLoadId(); + final int ticketLevel = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.getTicketLevel(chunkStatus); - -- Long holderIdentifier = Long.valueOf(chunkProvider.chunkFutureAwaitCounter++); ++ + final List ret = new ArrayList<>(requiredChunks); - -- java.util.function.Consumer consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> { ++ + final java.util.function.Consumer consumer = (final ChunkAccess chunk) -> { if (chunk != null) { - int ticketLevel = Math.max(33, chunkProvider.chunkMap.getUpdatingChunkIfPresent(chunk.getPos().toLong()).getTicketLevel()); - ret.add(chunk); - ticketLevels.add(ticketLevel); -- chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier); +- chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel); + synchronized (ret) { + ret.add(chunk); + } @@ -26940,13 +27018,13 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 - int ticketLevel = ticketLevels.getInt(i); + final ChunkPos chunkPos = ret.get(i).getPos(); -- chunkProvider.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, ticketLevel, chunkPos); -- chunkProvider.removeTicketAtLevel(TicketType.FUTURE_AWAIT, chunkPos, ticketLevel, holderIdentifier); +- chunkProvider.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, ticketLevel); +- chunkProvider.removeTicketAtLevel(TicketType.FUTURE_AWAIT, chunkPos, ticketLevel); + chunkHolderManager.removeTicketAtLevel(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_LOAD, chunkPos, ticketLevel, holderIdentifier); } } } -@@ -319,16 +441,133 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -314,16 +438,128 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } } @@ -26955,12 +27033,13 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 - // Paper start - optimise getPlayerByUUID - @Nullable @Override -- public Player getPlayerByUUID(UUID uuid) { +- public Player getPlayerByUUID(java.util.UUID uuid) { - final Player player = this.getServer().getPlayerList().getPlayer(uuid); - return player != null && player.level() == this ? player : null; + public final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder moonrise$getViewDistanceHolder() { + return this.viewDistanceHolder; -+ } + } +- // Paper end - optimise getPlayerByUUID + + @Override + public final long moonrise$getLastMidTickFailure() { @@ -26975,21 +27054,20 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + @Override + public final ca.spottedleaf.moonrise.common.misc.NearbyPlayers moonrise$getNearbyPlayers() { + return this.nearbyPlayers; - } -- // Paper end - optimise getPlayerByUUID ++ } + + @Override -+ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getLoadedChunks() { ++ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getLoadedChunks() { + return this.loadedChunks; + } + + @Override -+ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getTickingChunks() { ++ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getTickingChunks() { + return this.tickingChunks; + } + + @Override -+ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getEntityTickingChunks() { ++ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getEntityTickingChunks() { + return this.entityTickingChunks; + } + @@ -27009,12 +27087,11 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + } + // Paper end - rewrite chunk system + // Paper start - chunk tick iteration -+ private static final ServerChunkCache.ChunkAndHolder[] EMPTY_PLAYER_CHUNK_HOLDERS = new ServerChunkCache.ChunkAndHolder[0]; -+ private final ca.spottedleaf.moonrise.common.list.ReferenceList playerTickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_PLAYER_CHUNK_HOLDERS); ++ private final ca.spottedleaf.moonrise.common.list.ReferenceList playerTickingChunks = new ca.spottedleaf.moonrise.common.list.ReferenceList<>(EMPTY_LEVEL_CHUNKS); + private final it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap playerTickingRequests = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); + + @Override -+ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getPlayerTickingChunks() { ++ public final ca.spottedleaf.moonrise.common.list.ReferenceList moonrise$getPlayerTickingChunks() { + return this.playerTickingChunks; + } + @@ -27025,12 +27102,12 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + return; + } + -+ this.playerTickingChunks.add(((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder()); ++ this.playerTickingChunks.add(chunk); + } + + @Override + public final void moonrise$removeChunkForPlayerTicking(final LevelChunk chunk) { -+ this.playerTickingChunks.remove(((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder()); ++ this.playerTickingChunks.remove(chunk); + } + + @Override @@ -27051,9 +27128,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + return; + } + -+ this.playerTickingChunks.add( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)(LevelChunk)chunkHolder.getCurrentChunk()).moonrise$getChunkAndHolder() -+ ); ++ this.playerTickingChunks.add((LevelChunk)chunkHolder.getCurrentChunk()); + } + + @Override @@ -27079,15 +27154,13 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + return; + } + -+ this.playerTickingChunks.remove( -+ ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)(LevelChunk)chunkHolder.getCurrentChunk()).moonrise$getChunkAndHolder() -+ ); ++ this.playerTickingChunks.remove((LevelChunk)chunkHolder.getCurrentChunk()); + } + // Paper end - chunk tick iteration public ServerLevel( MinecraftServer server, -@@ -376,18 +615,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -371,18 +607,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // CraftBukkit end boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); @@ -27107,7 +27180,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 this.chunkSource = new ServerChunkCache( this, levelStorageAccess, -@@ -399,7 +627,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -394,7 +619,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.spigotConfig.simulationDistance, // Spigot flag, progressListener, @@ -27116,10 +27189,10 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 () -> server.overworld().getDataStorage() ); this.chunkSource.getGeneratorState().ensureStructuresGenerated(); -@@ -437,6 +665,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - this.randomSequences = Objects.requireNonNullElseGet( - randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(seed), "random_sequences") - ); +@@ -430,6 +655,20 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + this.sleepStatus = new SleepStatus(); + this.gameEventDispatcher = new GameEventDispatcher(this); + this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); + // Paper start - rewrite chunk system + this.moonrise$setEntityLookup(new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.server.ServerEntityLookup((ServerLevel)(Object)this, ((ServerLevel)(Object)this).new EntityCallbacks())); + this.chunkTaskScheduler = new ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler((ServerLevel)(Object)this); @@ -27137,7 +27210,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit } -@@ -560,8 +802,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -553,8 +792,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.push("checkDespawn"); entity.checkDespawn(); profilerFiller.pop(); @@ -27147,7 +27220,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 Entity vehicle = entity.getVehicle(); if (vehicle != null) { if (!vehicle.isRemoved() && vehicle.hasPassenger(entity)) { -@@ -584,13 +825,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -577,13 +815,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } profilerFiller.push("entityManagement"); @@ -27166,7 +27239,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } protected void tickTime() { -@@ -621,14 +865,67 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -614,7 +855,60 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.players.stream().filter(LivingEntity::isSleeping).collect(Collectors.toList()).forEach(player -> player.stopSleepInBed(false, false)); } @@ -27225,17 +27298,9 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 public void tickChunk(LevelChunk chunk, int randomTickSpeed) { + final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom; // Paper - optimise random ticking ChunkPos pos = chunk.getPos(); - boolean isRaining = this.isRaining(); int minBlockX = pos.getMinBlockX(); int minBlockZ = pos.getMinBlockZ(); - ProfilerFiller profilerFiller = Profiler.get(); - profilerFiller.push("thunder"); -- if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 && this.random.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder -+ if (!this.paperConfig().environment.disableThunder && isRaining && this.isThundering() && this.spigotConfig.thunderChance > 0 && simpleRandom.nextInt(this.spigotConfig.thunderChance) == 0) { // Spigot // Paper - Option to disable thunder // Paper - optimise random ticking - BlockPos blockPos = this.findLightningTargetAround(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); - if (this.isRainingAt(blockPos)) { - DifficultyInstance currentDifficultyAt = this.getCurrentDifficultyAt(blockPos); -@@ -658,7 +955,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -623,7 +917,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow for (int i = 0; i < randomTickSpeed; i++) { @@ -27244,7 +27309,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); } } -@@ -666,33 +963,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -631,33 +925,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe profilerFiller.popPush("tickBlocks"); if (randomTickSpeed > 0) { @@ -27279,7 +27344,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } profilerFiller.pop(); -@@ -946,6 +1217,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -948,6 +1216,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (fluidState.is(fluid)) { fluidState.tick(this, pos, blockState); } @@ -27292,7 +27357,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } private void tickBlock(BlockPos pos, Block block) { -@@ -953,6 +1230,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -955,6 +1229,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (blockState.is(block)) { blockState.tick(this, pos, this.random); } @@ -27305,7 +27370,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } // Paper start - log detailed entity tick information -@@ -1035,6 +1318,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1037,6 +1317,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { @@ -27317,7 +27382,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { org.bukkit.Bukkit.getPluginManager().callEvent(new org.bukkit.event.world.WorldSaveEvent(this.getWorld())); // CraftBukkit -@@ -1047,13 +1335,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1049,13 +1334,18 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe progress.progressStage(Component.translatable("menu.savingChunks")); } @@ -27339,9 +27404,9 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } + // Paper end - add close param - // CraftBukkit start - moved from MinecraftServer.saveChunks - ServerLevel worldserver1 = this; -@@ -1184,7 +1477,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + // CraftBukkit start - moved from MinecraftServer#saveAllChunks + ServerLevel serverLevel1 = this; +@@ -1186,7 +1476,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.removePlayerImmediately((ServerPlayer)entity, Entity.RemovalReason.DISCARDED); } @@ -27350,7 +27415,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } // CraftBukkit start -@@ -1215,7 +1508,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1217,7 +1507,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // CraftBukkit end @@ -27359,7 +27424,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } } -@@ -1226,7 +1519,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1228,7 +1518,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean tryAddFreshEntityWithPassengers(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { // CraftBukkit end @@ -27368,7 +27433,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 return false; } else { this.addFreshEntityWithPassengers(entity, reason); // CraftBukkit -@@ -1961,7 +2254,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1962,7 +2252,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } } @@ -27377,7 +27442,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 bufferedWriter.write(String.format(Locale.ROOT, "block_entity_tickers: %d\n", this.blockEntityTickers.size())); bufferedWriter.write(String.format(Locale.ROOT, "block_ticks: %d\n", this.getBlockTicks().count())); bufferedWriter.write(String.format(Locale.ROOT, "fluid_ticks: %d\n", this.getFluidTicks().count())); -@@ -1979,13 +2272,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1980,13 +2270,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Path path1 = path.resolve("chunks.csv"); try (Writer bufferedWriter2 = Files.newBufferedWriter(path1)) { @@ -27393,7 +27458,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } Path path3 = path.resolve("entities.csv"); -@@ -2094,8 +2387,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2083,8 +2373,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe Locale.ROOT, "players: %s, entities: %s [%s], block_entities: %d [%s], block_ticks: %d, fluid_ticks: %d, chunk_source: %s", this.players.size(), @@ -27404,7 +27469,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 this.blockEntityTickers.size(), getTypeCount(this.blockEntityTickers, TickingBlockEntity::getType), this.getBlockTicks().count(), -@@ -2127,15 +2420,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2116,15 +2406,25 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public LevelEntityGetter getEntities() { org.spigotmc.AsyncCatcher.catchOp("Chunk getEntities call"); // Spigot @@ -27433,7 +27498,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } public void startTickingChunk(LevelChunk chunk) { -@@ -2153,32 +2456,45 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2142,28 +2442,38 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public void close() throws IOException { super.close(); @@ -27452,7 +27517,7 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + return this.moonrise$getAnyChunkIfLoaded(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(chunkPos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(chunkPos)) != null; // Paper - rewrite chunk system } - private boolean isPositionTickingWithEntitiesLoaded(long chunkPos) { + public boolean isPositionTickingWithEntitiesLoaded(long chunkPos) { - return this.areEntitiesLoaded(chunkPos) && this.chunkSource.isPositionTicking(chunkPos); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(chunkPos); @@ -27469,24 +27534,28 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 + // Paper end - rewrite chunk system } - public boolean isNaturalSpawningAllowed(BlockPos pos) { -- return this.entityManager.canPositionTick(pos); -+ // Paper start - rewrite chunk system -+ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(pos)); -+ return chunkHolder != null && chunkHolder.isEntityTickingReady(); -+ // Paper end - rewrite chunk system - } - - public boolean isNaturalSpawningAllowed(ChunkPos chunkPos) { -- return this.entityManager.canPositionTick(chunkPos); + public boolean areEntitiesActuallyLoadedAndTicking(ChunkPos chunkPos) { +- return this.entityManager.isTicking(chunkPos) && this.entityManager.areEntitiesLoaded(chunkPos.toLong()); + // Paper start - rewrite chunk system + final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); + return chunkHolder != null && chunkHolder.isEntityTickingReady(); + // Paper end - rewrite chunk system } + public boolean anyPlayerCloseEnoughForSpawning(BlockPos pos) { +@@ -2175,7 +2485,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + } + + public boolean canSpawnEntitiesInChunk(ChunkPos chunkPos) { +- return this.entityManager.canPositionTick(chunkPos) && this.getWorldBorder().isWithinBounds(chunkPos); ++ // Paper start - rewrite chunk system ++ final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkHolder = this.moonrise$getChunkTaskScheduler().chunkHolderManager.getChunkHolder(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkKey(chunkPos)); ++ return chunkHolder != null && chunkHolder.isEntityTickingReady() && this.getWorldBorder().isWithinBounds(chunkPos); ++ // Paper end - rewrite chunk system + } + @Override -@@ -2232,7 +2548,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2230,7 +2543,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); @@ -27496,10 +27565,10 @@ index d1f235ebd835f58cf0c703c3a64d29825d98e183..080091efc19bc768bb9a660f366c42e8 } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 0bb610f12e3ddda649ecb5ad62ffdc7bfd243223..19428343b37c9b739b3d28984d52e257f85f253f 100644 +index a8c73bdf8fb130eed8922cb537a35cda07e66da5..3e73c69c9db8cbded28a001b20d9989acb11c638 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -178,7 +178,7 @@ import net.minecraft.world.scores.Team; +@@ -187,7 +187,7 @@ import net.minecraft.world.scores.Team; import net.minecraft.world.scores.criteria.ObjectiveCriteria; import org.slf4j.Logger; @@ -27508,9 +27577,9 @@ index 0bb610f12e3ddda649ecb5ad62ffdc7bfd243223..19428343b37c9b739b3d28984d52e257 private static final Logger LOGGER = LogUtils.getLogger(); private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; -@@ -395,6 +395,36 @@ public class ServerPlayer extends Player { +@@ -423,6 +423,36 @@ public class ServerPlayer extends Player { public @Nullable String clientBrandName = null; // Paper - Brand support - public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event + public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; @@ -27546,7 +27615,7 @@ index 0bb610f12e3ddda649ecb5ad62ffdc7bfd243223..19428343b37c9b739b3d28984d52e257 super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile); this.textFilter = server.createTextFilterForPlayer(this); diff --git a/net/minecraft/server/level/ThreadedLevelLightEngine.java b/net/minecraft/server/level/ThreadedLevelLightEngine.java -index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163761498a2 100644 +index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..216c2294f59a9d53613ac249ea63adeaa8a8efa4 100644 --- a/net/minecraft/server/level/ThreadedLevelLightEngine.java +++ b/net/minecraft/server/level/ThreadedLevelLightEngine.java @@ -22,23 +22,134 @@ import net.minecraft.world.level.chunk.LightChunkGetter; @@ -27593,10 +27662,10 @@ index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163 + + final Long ticketId = Long.valueOf(this.chunkWorkCounter.getAndIncrement()); + final ChunkPos pos = new ChunkPos(chunkX, chunkZ); -+ world.getChunkSource().addRegionTicket(ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.REGION_LIGHT_TICKET_LEVEL, ticketId); ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAtLevel(ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.LIGHT_TICKET_LEVEL, ticketId); + + scheduledTask.queueOrRunTask(() -> { -+ world.getChunkSource().removeRegionTicket(ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.REGION_LIGHT_TICKET_LEVEL, ticketId); ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.removeTicketAtLevel(ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.CHUNK_WORK_TICKET, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.LIGHT_TICKET_LEVEL, ticketId); + }); + } + @@ -27612,7 +27681,7 @@ index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163 + final ChunkPos pos = iterator.next(); + + final Long id = ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.getNextChunkRelightId(); -+ world.getChunkSource().addRegionTicket(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_RELIGHT, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.REGION_LIGHT_TICKET_LEVEL, id); ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.addTicketAtLevel(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_RELIGHT, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.LIGHT_TICKET_LEVEL, id); + ticketIds.put(pos, id); + + final ChunkAccess chunk = (ChunkAccess)world.getChunkSource().getChunkForLighting(pos.x, pos.z); @@ -27620,7 +27689,7 @@ index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163 + // cannot relight this chunk + iterator.remove(); + ticketIds.remove(pos); -+ world.getChunkSource().removeRegionTicket(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_RELIGHT, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.REGION_LIGHT_TICKET_LEVEL, id); ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.removeTicketAtLevel(ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_RELIGHT, pos, ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.LIGHT_TICKET_LEVEL, id); + continue; + } + } @@ -27667,9 +27736,9 @@ index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163 + } + + for (final java.util.Map.Entry entry : ticketIds.entrySet()) { -+ world.getChunkSource().removeRegionTicket( ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)world).moonrise$getChunkTaskScheduler().chunkHolderManager.removeTicketAtLevel( + ca.spottedleaf.moonrise.patches.chunk_system.scheduling.ChunkTaskScheduler.CHUNK_RELIGHT, entry.getKey(), -+ ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.REGION_LIGHT_TICKET_LEVEL, entry.getValue() ++ ca.spottedleaf.moonrise.patches.starlight.light.StarLightInterface.LIGHT_TICKET_LEVEL, entry.getValue() + ); + } + } @@ -27879,63 +27948,220 @@ index 11a264ef2f43c2b00741397c9c9ea5393afad6ab..5c9ac44a3b4bc8e047feaf61a94eb163 static enum TaskType { diff --git a/net/minecraft/server/level/Ticket.java b/net/minecraft/server/level/Ticket.java -index e574f217386d677400b4c093d50261045df06d5c..ed8a3d5bd25909ee4648b1ec2ee66878198a1d8a 100644 +index a663c84c756bc59aaddbceda939f552e8a422e60..c3a923b7292e970cbfcde7b9fedcbb6eab02c866 100644 --- a/net/minecraft/server/level/Ticket.java +++ b/net/minecraft/server/level/Ticket.java -@@ -2,13 +2,25 @@ package net.minecraft.server.level; +@@ -7,7 +7,7 @@ import net.minecraft.Util; + import net.minecraft.core.registries.BuiltInRegistries; + import net.minecraft.util.ExtraCodecs; - import java.util.Objects; - --public final class Ticket implements Comparable> { -+public final class Ticket implements Comparable>, ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket { // Paper - rewrite chunk system - private final TicketType type; +-public class Ticket { ++public class Ticket implements Comparable, ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket { // Paper - rewrite chunk system + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec( + instance -> instance.group( + BuiltInRegistries.TICKET_TYPE.byNameCodec().fieldOf("type").forGetter(Ticket::getType), +@@ -20,13 +20,55 @@ public class Ticket { private final int ticketLevel; - public final T key; -- private long createdTick; -+ // Paper start - rewrite chunk system -+ private long removeDelay; + private long ticksLeft; + // Paper start - add identifier +- private Object identifier; ++ private T identifier; // Paper - rewrite chunk system -- protected Ticket(TicketType type, int ticketLevel, T key) { + public Object getIdentifier() { + return this.identifier; + } + // Paper end - add identifier ++ // Paper start - rewrite chunk system + @Override + public final long moonrise$getRemoveDelay() { -+ return this.removeDelay; ++ return this.ticksLeft; ++ } + ++ @Override ++ public final void moonrise$setRemoveDelay(final long removeDelay) { ++ this.ticksLeft = removeDelay; + } + + @Override -+ public final void moonrise$setRemoveDelay(final long removeDelay) { -+ this.removeDelay = removeDelay; ++ public final T moonrise$getIdentifier() { ++ return this.identifier; ++ } ++ ++ @Override ++ public final void moonrise$setIdentifier(final T identifier) { ++ if ((identifier == null) != (((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType)(Object)this.type).moonrise$getIdentifierComparator() == null)) { ++ throw new IllegalStateException("Nullability of identifier should match nullability of comparator"); ++ } ++ this.identifier = identifier; ++ } ++ ++ @Override ++ public final int compareTo(final Ticket ticket) { ++ final int levelCompare = Integer.compare(this.ticketLevel, ticket.ticketLevel); ++ if (levelCompare != 0) { ++ return levelCompare; ++ } ++ ++ final int typeCompare = Long.compare( ++ ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType)(Object)this.type).moonrise$getId(), ++ ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType)(Object)ticket.type).moonrise$getId() ++ ); ++ if (typeCompare != 0) { ++ return typeCompare; ++ } ++ ++ final java.util.Comparator comparator = ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType)(Object)this.type).moonrise$getIdentifierComparator(); ++ return comparator == null ? 0 : comparator.compare(this.identifier, (T)ticket.identifier); + } + // Paper end - rewrite chunk system -+ -+ public Ticket(TicketType type, int ticketLevel, T key) { // Paper - public + + public Ticket(TicketType type, int ticketLevel) { + // Paper start - add identifier +@@ -37,12 +79,12 @@ public class Ticket { + // Paper end - add identifier + } + +- private Ticket(TicketType type, int ticketLevel, long ticksLeft) { ++ public Ticket(TicketType type, int ticketLevel, long ticksLeft) { // Paper - rewrite chunk system - public + // Paper start - add identifier + this(type, ticketLevel, ticksLeft, null); + } + private Ticket(TicketType type, int ticketLevel, long ticksLeft, Object identifier) { +- this.identifier = identifier; ++ this.identifier = (T)identifier; // Paper - rewrite chunk system + // Paper end - add identifier this.type = type; this.ticketLevel = ticketLevel; - this.key = key; -@@ -41,7 +53,7 @@ public final class Ticket implements Comparable> { +@@ -51,17 +93,7 @@ public class Ticket { @Override public String toString() { -- return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] at " + this.createdTick; -+ return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.key + ")] to die in " + this.removeDelay; // Paper - rewrite chunk system +- return this.type.hasTimeout() +- ? "Ticket[" +- + Util.getRegisteredName(BuiltInRegistries.TICKET_TYPE, this.type) +- + " " +- + this.ticketLevel +- + "] with " +- + this.ticksLeft +- + " ticks left ( out of" +- + this.type.timeout() +- + ")" +- : "Ticket[" + Util.getRegisteredName(BuiltInRegistries.TICKET_TYPE, this.type) + " " + this.ticketLevel + "] with no timeout"; ++ return "Ticket[" + this.type + " " + this.ticketLevel + " (" + this.identifier + ")] to die in " + this.ticksLeft; // Paper - rewrite chunk system } - public TicketType getType() { -@@ -53,11 +65,10 @@ public final class Ticket implements Comparable> { + public TicketType getType() { +diff --git a/net/minecraft/server/level/TicketType.java b/net/minecraft/server/level/TicketType.java +index bab5ea53b70041eb413103a481deae0e770b5d8d..f91eed907ffc61a4092aabaa0a1b061c2c453673 100644 +--- a/net/minecraft/server/level/TicketType.java ++++ b/net/minecraft/server/level/TicketType.java +@@ -3,7 +3,40 @@ package net.minecraft.server.level; + import net.minecraft.core.Registry; + import net.minecraft.core.registries.BuiltInRegistries; + +-public record TicketType(long timeout, boolean persist, TicketType.TicketUse use) { ++public final class TicketType implements ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType { // Paper - rewrite chunk system ++ // Paper start - rewrite chunk system ++ private static final java.util.concurrent.atomic.AtomicLong ID_GENERATOR = new java.util.concurrent.atomic.AtomicLong(); ++ private final long id = ID_GENERATOR.getAndIncrement(); ++ private java.util.Comparator identifierComparator; ++ private volatile long[] counterTypes; ++ ++ @Override ++ public final long moonrise$getId() { ++ return this.id; ++ } ++ ++ @Override ++ public final java.util.Comparator moonrise$getIdentifierComparator() { ++ return this.identifierComparator; ++ } ++ ++ @Override ++ public final void moonrise$setIdentifierComparator(final java.util.Comparator comparator) { ++ this.identifierComparator = comparator; ++ } ++ ++ @Override ++ public final long[] moonrise$getCounterTypes() { ++ // need to lazy init this because we cannot check if we are FORCED during construction ++ final long[] types = this.counterTypes; ++ if (types != null) { ++ return types; ++ } ++ ++ return this.counterTypes = ca.spottedleaf.moonrise.common.PlatformHooks.get().getCounterTypesUncached((TicketType)(Object)this); ++ } ++ // Paper end - rewrite chunk system ++ + public static final long NO_TIMEOUT = 0L; + public static final TicketType START = register("start", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); + public static final TicketType DRAGON = register("dragon", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); +@@ -15,7 +48,7 @@ public record TicketType(long timeout, boolean persist, TicketType.TicketUse use + public static final TicketType UNKNOWN = register("unknown", 1L, false, TicketType.TicketUse.LOADING); + public static final TicketType PLUGIN = register("plugin", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // CraftBukkit + public static final TicketType POST_TELEPORT = register("post_teleport", 5L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper +- public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper ++ public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); static { ((TicketType)PLUGIN_TICKET).moonrise$setIdentifierComparator((org.bukkit.plugin.Plugin p1, org.bukkit.plugin.Plugin p2) -> p1.getName().compareTo(p2.getName())); } // Paper // Paper - rewrite chunk system + public static final TicketType FUTURE_AWAIT = register("future_await", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper + public static final TicketType CHUNK_LOAD = register("chunk_load", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING); // Paper - moonrise + +@@ -23,9 +56,52 @@ public record TicketType(long timeout, boolean persist, TicketType.TicketUse use + return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, persist, use)); } - protected void setCreatedTick(long timestamp) { -- this.createdTick = timestamp; -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system ++ // Paper start - rewrite chunk system - convert to class ++ private final long timeout; ++ private final boolean persist; ++ private final net.minecraft.server.level.TicketType.TicketUse use; ++ ++ public TicketType(long timeout, boolean persist, net.minecraft.server.level.TicketType.TicketUse use) { ++ this.timeout = timeout; ++ this.persist = persist; ++ this.use = use; ++ } ++ ++ public boolean persist() { ++ return this.persist; ++ } ++ ++ public net.minecraft.server.level.TicketType.TicketUse use() { ++ return this.use; ++ } ++ ++ @Override ++ public boolean equals(Object obj) { ++ if (obj == this) return true; ++ if (obj == null || obj.getClass() != this.getClass()) return false; ++ var that = (net.minecraft.server.level.TicketType) obj; ++ return this.timeout == that.timeout && ++ this.persist == that.persist && ++ java.util.Objects.equals(this.use, that.use); ++ } ++ ++ @Override ++ public int hashCode() { ++ return java.util.Objects.hash(timeout, persist, use); ++ } ++ ++ @Override ++ public String toString() { ++ return "TicketType[" + ++ "timeout=" + timeout + ", " + ++ "persist=" + persist + ", " + ++ "use=" + use + ']'; ++ } ++ // Paper end - rewrite chunk system - convert to class ++ + // Paper start - chunk-gc config + public static int PLUGIN_TYPE_TIMEOUT = 600; +- @Override ++ // Paper - rewrite chunk system - convert to class + public long timeout() { + return this == PLUGIN ? PLUGIN_TYPE_TIMEOUT : this.timeout; } - - protected boolean timedOut(long currentTime) { -- long timeout = this.type.timeout(); -- return timeout != 0L && currentTime - this.createdTick > timeout; -+ throw new UnsupportedOperationException(); // Paper - rewrite chunk system - } - } diff --git a/net/minecraft/server/level/WorldGenRegion.java b/net/minecraft/server/level/WorldGenRegion.java -index 4eb040006f5d41b47e5ac9df5d9f19c4315d6343..7fa41dea184b01891f45d8e404bc1cba19cf1bcf 100644 +index b30f56fbc1fd17259a1d05dc9155fffcab292ca1..11fed81a4696ba18440e755c3b8a5ca39ed8a6b1 100644 --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java @@ -78,6 +78,36 @@ public class WorldGenRegion implements WorldGenLevel { @@ -27976,10 +28202,10 @@ index 4eb040006f5d41b47e5ac9df5d9f19c4315d6343..7fa41dea184b01891f45d8e404bc1cba this.generatingStep = generatingStep; this.cache = cache; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 7eebb494e38b57e81b4f92f0a96d3a4c610d86df..065f4c810439dde464529b54ae300ecfcb1c2c31 100644 +index 73717609fccd9af12e2cc39824106f49426b581c..72524ff3399a4477dfa3db2f4e79bb14f6519a8b 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1317,7 +1317,7 @@ public abstract class PlayerList { +@@ -1321,7 +1321,7 @@ public abstract class PlayerList { public void setViewDistance(int viewDistance) { this.viewDistance = viewDistance; @@ -27988,7 +28214,7 @@ index 7eebb494e38b57e81b4f92f0a96d3a4c610d86df..065f4c810439dde464529b54ae300ecf for (ServerLevel serverLevel : this.server.getAllLevels()) { if (serverLevel != null) { -@@ -1328,7 +1328,7 @@ public abstract class PlayerList { +@@ -1332,7 +1332,7 @@ public abstract class PlayerList { public void setSimulationDistance(int simulationDistance) { this.simulationDistance = simulationDistance; @@ -28250,12 +28476,12 @@ index 6fb3a3f167d8cbaa78135af0c180b592661e2c1d..e6306a68c8652d4c5d22d5ecb1416f5f InitializationException(String message) { super(message); diff --git a/net/minecraft/util/SortedArraySet.java b/net/minecraft/util/SortedArraySet.java -index 2c6b35b86eed9002016b8228c3195f8033d219ca..339b19e88567be382e550ed54477fabd58d51faa 100644 +index 0b50a8a7ce28742b272ba61d0cf9b7971b4e867d..62c643febe5d642f5741ac2dcec1606a844593be 100644 --- a/net/minecraft/util/SortedArraySet.java +++ b/net/minecraft/util/SortedArraySet.java -@@ -8,12 +8,89 @@ import java.util.Iterator; - import java.util.NoSuchElementException; +@@ -9,12 +9,88 @@ import java.util.NoSuchElementException; import javax.annotation.Nullable; + import net.minecraft.Util; -public class SortedArraySet extends AbstractSet { +public class SortedArraySet extends AbstractSet implements ca.spottedleaf.moonrise.patches.chunk_system.util.ChunkSystemSortedArraySet { // Paper - rewrite chunk system @@ -28276,8 +28502,7 @@ index 2c6b35b86eed9002016b8228c3195f8033d219ca..339b19e88567be382e550ed54477fabd + if (i >= len) { + return false; + } -+ if (!filter.test(backingArray[i])) { -+ ++i; ++ if (!filter.test(backingArray[i++])) { + continue; + } + break; @@ -28285,7 +28510,7 @@ index 2c6b35b86eed9002016b8228c3195f8033d219ca..339b19e88567be382e550ed54477fabd + + // we only want to write back to backingArray if we really need to + -+ int lastIndex = i; // this is where new elements are shifted to ++ int lastIndex = i - 1; // this is where new elements are shifted to + + for (; i < len; ++i) { + final T curr = backingArray[i]; @@ -28372,19 +28597,19 @@ index 8cc5c0716392ba06501542ff5cbe71ee43979e5d..09fd99c9cbd23b5f3c899bfb00c9b896 + // Paper end - block counting } diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718d2467155 100644 +index 24f3fa347c889b4e2b7b2ce69cda0f68e9bbc346..48477efbd01bb1f8987d9a3ae195710e36b7294f 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -135,7 +135,7 @@ import net.minecraft.world.scores.ScoreHolder; +@@ -140,7 +140,7 @@ import net.minecraft.world.scores.ScoreHolder; import net.minecraft.world.scores.Team; - import org.slf4j.Logger; - --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { -+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker + import org.jetbrains.annotations.Contract; +-public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter { ++public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker // CraftBukkit start + private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); private static final int CURRENT_LEVEL = 2; -@@ -146,7 +146,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -151,7 +151,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess // Paper start - Share random for entities to make them more random public static RandomSource SHARED_RANDOM = new RandomRandomSource(); @@ -28403,7 +28628,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 private boolean locked = false; @Override -@@ -159,61 +169,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -164,61 +174,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -28465,8 +28690,8 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 + // Paper - replace random } // Paper end - Share random for entities to make them more random - public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason -@@ -416,6 +372,156 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason +@@ -405,6 +361,156 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.dimensions.makeBoundingBox(x, y, z); } // Paper end @@ -28623,7 +28848,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -1324,35 +1430,77 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1345,35 +1451,77 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return distance; } @@ -28659,7 +28884,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 - Vec3 vec31 = collideWithShapes(new Vec3(vec.x, f1, vec.z), aabb, list); - if (vec31.horizontalDistanceSqr() > vec3.horizontalDistanceSqr()) { - double d = boundingBox.minY - aabb.minY; -- return vec31.add(0.0, -d, 0.0); +- return vec31.subtract(0.0, d, 0.0); - } + final List potentialCollisionsVoxel = new ArrayList<>(); + final List potentialCollisionsBB = new ArrayList<>(); @@ -28725,7 +28950,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 } private static float[] collectCandidateStepUpHeights(AABB box, List colliders, float deltaY, float maxUpStep) { -@@ -2659,23 +2807,110 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2599,21 +2747,110 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public boolean isInWall() { @@ -28741,9 +28966,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 - BlockState blockState = this.level().getBlockState(pos); - return !blockState.isAir() - && blockState.isSuffocating(this.level(), pos) -- && Shapes.joinIsNotEmpty( -- blockState.getCollisionShape(this.level(), pos).move(pos.getX(), pos.getY(), pos.getZ()), Shapes.create(aabb), BooleanOp.AND -- ); +- && Shapes.joinIsNotEmpty(blockState.getCollisionShape(this.level(), pos).move(pos), Shapes.create(aabb), BooleanOp.AND); + } + + final double reducedWith = (double)(this.dimensions.width() * 0.8F); @@ -28849,7 +29072,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 } public InteractionResult interact(Player player, InteractionHand hand) { -@@ -4099,15 +4334,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4061,15 +4298,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public Iterable getIndirectPassengers() { @@ -28875,7 +29098,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 } public int countPlayerPassengers() { -@@ -4245,77 +4482,136 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4212,77 +4451,136 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return Mth.lerp(partialTick, this.yRotO, this.yRot); } @@ -29066,9 +29289,9 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 public boolean touchingUnloadedChunk() { AABB aabb = this.getBoundingBox().inflate(1.0); -@@ -4468,6 +4764,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - this.setPosRaw(x, y, z, false); +@@ -4437,6 +4735,15 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } + public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { + // Paper start - rewrite chunk system + if (this.updatingSectionStatus) { @@ -29082,20 +29305,20 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 if (!checkPosition(this, x, y, z)) { return; } -@@ -4598,6 +4903,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4570,6 +4877,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @Override - public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { + public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause + // Paper start - rewrite chunk system + if (!((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel)this.level).moonrise$getEntityLookup().canRemoveEntity((Entity)(Object)this)) { + LOGGER.warn("Entity " + this + " is currently prevented from being removed from the world since it is processing section status updates", new Throwable()); + return; + } + // Paper end - rewrite chunk system - org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); - // CraftBukkit end + org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers -@@ -4609,7 +4920,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + if (this.removalReason == null) { +@@ -4580,7 +4893,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.stopRiding(); } @@ -29104,7 +29327,7 @@ index 9b3b770f6986dd132da78fdc3626d334166ec52a..b2b61203438bb1fad1ee807729781718 this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); // Paper start - Folia schedulers -@@ -4643,7 +4954,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4614,7 +4927,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public boolean shouldBeSaved() { return (this.removalReason == null || this.removalReason.shouldSave()) && !this.isPassenger() @@ -29320,7 +29543,7 @@ index 7d590dd06cc69c0925d22708425520c38e3cda25..5c5724f5e3ad640f55aecbc1d8f71d1f } diff --git a/net/minecraft/world/entity/ai/village/poi/PoiSection.java b/net/minecraft/world/entity/ai/village/poi/PoiSection.java -index 324cc0686f0f5b1371b2bbea5b8c8fdb1f363006..39cd1e3d8192d7077d6b7864d33933097cc6b986 100644 +index b766b4281aecb3b96e2c263664d81da3425e3653..c3bcb494afe464207e805f8c40b03c700059c64a 100644 --- a/net/minecraft/world/entity/ai/village/poi/PoiSection.java +++ b/net/minecraft/world/entity/ai/village/poi/PoiSection.java @@ -23,13 +23,27 @@ import net.minecraft.core.SectionPos; @@ -29353,10 +29576,10 @@ index 324cc0686f0f5b1371b2bbea5b8c8fdb1f363006..39cd1e3d8192d7077d6b7864d3393309 this(setDirty, true, ImmutableList.of()); } diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 33f6d6862731d22d6d3eeb7cf39a4a42049afae3..a3cc0001a949597e345d7919c3f6109fa4a949ad 100644 +index 75bf15ccd8a12153951f886ed87be9f3bece3133..6f601a0a300bbf01f77d835576d15e25c8ba10b8 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -316,7 +316,7 @@ public class ArmorStand extends LivingEntity { +@@ -245,7 +245,7 @@ public class ArmorStand extends LivingEntity { @Override protected void pushEntities() { if (!this.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return; // Paper - Option to prevent armor stands from doing entity lookups @@ -29502,10 +29725,10 @@ index 300f3ed58109219d97846082941b860585f66fed..892a7c1eb1b321ca6d5ca709142e7fea // Paper start - Affects Spawning API diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b1771d5cb00 100644 +index 63f8b0c47e3321b74f4b6bcbc1e28cd751911198..eb4d03cfdb34243901cfba832d35559d5be9e876 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -79,6 +79,7 @@ import net.minecraft.world.level.storage.LevelData; +@@ -81,6 +81,7 @@ import net.minecraft.world.level.storage.LevelData; import net.minecraft.world.level.storage.WritableLevelData; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; @@ -29513,16 +29736,16 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 import net.minecraft.world.scores.Scoreboard; // CraftBukkit start -@@ -102,7 +103,7 @@ import org.bukkit.entity.SpawnCategory; - import org.bukkit.event.block.BlockPhysicsEvent; +@@ -93,7 +94,7 @@ import org.bukkit.craftbukkit.block.data.CraftBlockData; + import org.bukkit.entity.SpawnCategory; // CraftBukkit end --public abstract class Level implements LevelAccessor, AutoCloseable { -+public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions +-public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable { ++public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemLevel, ca.spottedleaf.moonrise.patches.chunk_system.world.ChunkSystemEntityGetter { // Paper - rewrite chunk system // Paper - optimise collisions public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); public static final ResourceKey NETHER = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("the_nether")); -@@ -127,7 +128,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -118,7 +119,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl public float rainLevel; protected float oThunderLevel; public float thunderLevel; @@ -29531,9 +29754,9 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 @Deprecated private final RandomSource threadSafeRandom = RandomSource.createThreadSafe(); private final Holder dimensionTypeRegistration; -@@ -202,6 +203,629 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -189,6 +190,629 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl - public abstract ResourceKey getTypeKey(); + public abstract ResourceKey getTypeKey(); + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.level.entity.EntityLookup entityLookup; @@ -30161,7 +30384,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 protected Level( WritableLevelData levelData, ResourceKey dimension, -@@ -218,6 +842,15 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -205,6 +829,15 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl io.papermc.paper.configuration.WorldConfiguration> paperWorldConfigCreator, // Paper - create paper world config java.util.concurrent.Executor executor // Paper - Anti-Xray ) { @@ -30177,32 +30400,32 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) levelData).getLevelName()); // Spigot this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config this.generator = gen; -@@ -298,6 +931,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); - this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); +@@ -281,6 +914,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + }); + // CraftBukkit end this.chunkPacketBlockController = this.paperConfig().anticheat.antiXray.enabled ? new io.papermc.paper.antixray.ChunkPacketBlockControllerAntiXray(this, executor) : io.papermc.paper.antixray.ChunkPacketBlockController.NO_OPERATION_INSTANCE; // Paper - Anti-Xray + this.entityLookup = new ca.spottedleaf.moonrise.patches.chunk_system.level.entity.dfl.DefaultEntityLookup(this); // Paper - rewrite chunk system } // Paper start - Cancel hit for vanished players -@@ -567,7 +1201,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); +@@ -555,7 +1189,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + this.setBlocksDirty(pos, blockState, blockState1); } -- if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full - this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); +- if ((flags & 2) != 0 && (!this.isClientSide || (flags & 4) == 0) && (this.isClientSide || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ if ((flags & 2) != 0 && (!this.isClientSide || (flags & 4) == 0) && (this.isClientSide || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.FULL)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement // Paper - rewrite chunk system - change from ticking to full + this.sendBlockUpdated(pos, blockState, state, flags); } -@@ -835,6 +1469,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -820,6 +1454,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl // Spigot start boolean runsNormally = this.tickRateManager().runsNormally(); + int tickedEntities = 0; // Paper - rewrite chunk system var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll toRemove.add(null); // Paper - Fix MC-117075 - for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters -@@ -845,6 +1480,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters +@@ -829,6 +1464,11 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll } else if (runsNormally && this.shouldTickBlocksAt(tickingBlockEntity.getPos())) { tickingBlockEntity.tick(); @@ -30214,7 +30437,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 } } this.blockEntityTickers.removeAll(toRemove); // Paper - Fix MC-117075 -@@ -865,6 +1505,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -849,6 +1489,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD); // Paper end - Prevent block entity and entity crashes } @@ -30222,7 +30445,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 } // Paper start - Option to prevent armor stands from doing entity lookups -@@ -872,7 +1513,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -856,7 +1497,14 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl public boolean noCollision(@Nullable Entity entity, AABB box) { if (entity instanceof net.minecraft.world.entity.decoration.ArmorStand && !entity.level().paperConfig().entities.armorStands.doCollisionEntityLookups) return false; @@ -30238,7 +30461,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 } // Paper end - Option to prevent armor stands from doing entity lookups -@@ -1010,7 +1658,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -994,7 +1642,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl if (this.isOutsideBuildHeight(pos)) { return null; } else { @@ -30247,7 +30470,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 ? null : this.getChunkAt(pos).getBlockEntity(pos, LevelChunk.EntityCreationType.IMMEDIATE); } -@@ -1103,22 +1751,16 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1087,22 +1735,16 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl public List getEntities(@Nullable Entity entity, AABB boundingBox, Predicate predicate) { Profiler.get().incrementCounter("getEntities"); List list = Lists.newArrayList(); @@ -30278,7 +30501,7 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 } @Override -@@ -1132,33 +1774,94 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1116,33 +1758,94 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl this.getEntities(entityTypeTest, bounds, predicate, output, Integer.MAX_VALUE); } @@ -30391,10 +30614,10 @@ index 771d6ed6a7c889c09efd4ff6e20298c851eaa79f..a768f041fd16d253ec4ab5eb75288b17 } + // Paper end - rewrite chunk system - @Nullable - public abstract Entity getEntity(int id); + public List getPushableEntities(Entity entity, AABB boundingBox) { + return this.getEntities(entity, boundingBox, EntitySelector.pushableBy(entity)); diff --git a/net/minecraft/world/level/LevelReader.java b/net/minecraft/world/level/LevelReader.java -index 2709803b9266ff4a2034d83321cd0ba4e30fc0aa..26c8c1e5598daf3550aef05b12218c47bda6618b 100644 +index c59f2c0634e3ebb11b8f6bc09020f951cb602f9b..0842fd6488c8b27d98c4344e1244996b4c0e9912 100644 --- a/net/minecraft/world/level/LevelReader.java +++ b/net/minecraft/world/level/LevelReader.java @@ -22,7 +22,18 @@ import net.minecraft.world.level.dimension.DimensionType; @@ -30418,10 +30641,10 @@ index 2709803b9266ff4a2034d83321cd0ba4e30fc0aa..26c8c1e5598daf3550aef05b12218c47 ChunkAccess getChunk(int x, int z, ChunkStatus chunkStatus, boolean requireChunk); diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddccb66b82e 100644 +index 01083cf32b4b0bd57d1b0ac83eb4e43d9d90fa98..ec4b63a574e7ff2c807c283c9f4b402229864e51 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -63,6 +63,249 @@ public class ServerExplosion implements Explosion { +@@ -60,6 +60,249 @@ public class ServerExplosion implements Explosion { public float yield; // CraftBukkit end public boolean excludeSourceFromDamage = true; // Paper - Allow explosions to damage source @@ -30671,7 +30894,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc public ServerExplosion( ServerLevel level, -@@ -134,63 +377,102 @@ public class ServerExplosion implements Explosion { +@@ -131,63 +374,102 @@ public class ServerExplosion implements Explosion { } private List calculateExplodedPositions() { @@ -30715,7 +30938,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc - if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) { - set.add(blockPos); - // Paper start - prevent headless pistons from forming -- if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(Blocks.MOVING_PISTON)) { +- if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) { - net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos); - if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { - net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); @@ -30790,7 +31013,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc + if (this.fire || !cachedBlock.blockState.isAir()) { + ret.add(cachedBlock.immutablePos); + // Paper start - prevent headless pistons from forming -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) { ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == net.minecraft.world.level.block.Blocks.MOVING_PISTON) { + net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(cachedBlock.immutablePos); // Paper - optimise collisions + if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { + net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); @@ -30821,7 +31044,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc } private void hurtEntities() { -@@ -371,6 +653,14 @@ public class ServerExplosion implements Explosion { +@@ -360,6 +642,14 @@ public class ServerExplosion implements Explosion { return; } // CraftBukkit end @@ -30836,7 +31059,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -384,6 +674,13 @@ public class ServerExplosion implements Explosion { +@@ -373,6 +663,13 @@ public class ServerExplosion implements Explosion { if (this.fire) { this.createFire(list); } @@ -30850,7 +31073,7 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc } private static void addOrAppendStack(List stackCollectors, ItemStack stack, BlockPos pos) { -@@ -474,12 +771,12 @@ public class ServerExplosion implements Explosion { +@@ -462,12 +759,12 @@ public class ServerExplosion implements Explosion { // Paper start - Optimize explosions private float getBlockDensity(Vec3 vec3d, Entity entity) { if (!this.level.paperConfig().environment.optimizeExplosions) { @@ -30865,11 +31088,363 @@ index 155bf7ccff5c1332fceda2598342bb03624608ff..c4485f28def66264846a436cfba7bddc this.level.explosionDensityCache.put(key, blockDensity); } +diff --git a/net/minecraft/world/level/TicketStorage.java b/net/minecraft/world/level/TicketStorage.java +index 03c6e64fc98a42475467b3d42a9af250777c853f..b072dee51b5c189986b1d940b90ffd72c6d67ebd 100644 +--- a/net/minecraft/world/level/TicketStorage.java ++++ b/net/minecraft/world/level/TicketStorage.java +@@ -27,7 +27,7 @@ import net.minecraft.world.level.saveddata.SavedData; + import net.minecraft.world.level.saveddata.SavedDataType; + import org.slf4j.Logger; + +-public class TicketStorage extends SavedData { ++public class TicketStorage extends SavedData implements ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketStorage { // Paper - rewrite chunk system + private static final int INITIAL_TICKET_LIST_CAPACITY = 4; + private static final Logger LOGGER = LogUtils.getLogger(); + private static final Codec> TICKET_ENTRY = Codec.mapPair(ChunkPos.CODEC.fieldOf("chunk_pos"), Ticket.CODEC).codec(); +@@ -36,18 +36,32 @@ public class TicketStorage extends SavedData { + .apply(instance, TicketStorage::fromPacked) + ); + public static final SavedDataType TYPE = new SavedDataType<>("chunks", TicketStorage::new, CODEC, DataFixTypes.SAVED_DATA_FORCED_CHUNKS); +- public final Long2ObjectOpenHashMap> tickets; ++ // Paper - rewrite chunk system + private final Long2ObjectOpenHashMap> deactivatedTickets; +- private LongSet chunksWithForcedTickets = new LongOpenHashSet(); ++ // Paper - rewrite chunk system + @Nullable + private TicketStorage.ChunkUpdated loadingChunkUpdatedListener; + @Nullable + private TicketStorage.ChunkUpdated simulationChunkUpdatedListener; + ++ // Paper start - rewrite chunk system ++ private ChunkMap chunkMap; ++ ++ @Override ++ public final ChunkMap moonrise$getChunkMap() { ++ return this.chunkMap; ++ } ++ ++ @Override ++ public final void moonrise$setChunkMap(final ChunkMap chunkMap) { ++ this.chunkMap = chunkMap; ++ } ++ // Paper end - rewrite chunk system ++ + private TicketStorage(Long2ObjectOpenHashMap> tickets, Long2ObjectOpenHashMap> deactivatedTickets) { +- this.tickets = tickets; ++ // Paper - rewrite chunk system + this.deactivatedTickets = deactivatedTickets; +- this.updateForcedChunks(); ++ // Paper - rewrite chunk system + } + + public TicketStorage() { +@@ -76,8 +90,32 @@ public class TicketStorage extends SavedData { + return list; + } + ++ // Paper start - rewrite chunk system ++ private void redirectRegularTickets(final BiConsumer consumer, final Long2ObjectOpenHashMap> ticketsParam) { ++ if (ticketsParam != null) { ++ throw new IllegalStateException("Bad injection point"); ++ } ++ ++ final Long2ObjectOpenHashMap> tickets = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level) ++ .moonrise$getChunkTaskScheduler().chunkHolderManager.getTicketsCopy(); ++ ++ for (final Iterator>> iterator = tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) { ++ final it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> entry = iterator.next(); ++ ++ final long pos = entry.getLongKey(); ++ final net.minecraft.util.SortedArraySet chunkTickets = entry.getValue(); ++ ++ final ChunkPos chunkPos = new ChunkPos(pos); ++ ++ for (final Ticket ticket : chunkTickets) { ++ consumer.accept(chunkPos, ticket); ++ } ++ } ++ } ++ // Paper end - rewrite chunk system ++ + private void forEachTicket(BiConsumer action) { +- forEachTicket(action, this.tickets); ++ this.redirectRegularTickets(action, null); // Paper - rewrite chunk system + forEachTicket(action, this.deactivatedTickets); + } + +@@ -102,23 +140,26 @@ public class TicketStorage extends SavedData { + } + + public void setLoadingChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated loadingChunkUpdatedListener) { +- this.loadingChunkUpdatedListener = loadingChunkUpdatedListener; ++ // Paper - rewrite chunk system + } + + public void setSimulationChunkUpdatedListener(@Nullable TicketStorage.ChunkUpdated simulationChunkUpdatedListener) { +- this.simulationChunkUpdatedListener = simulationChunkUpdatedListener; ++ // Paper - rewrite chunk system + } + + public boolean hasTickets() { +- return !this.tickets.isEmpty(); ++ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager.hasTickets(); // Paper - rewrite chunk system + } + + public List getTickets(long chunkPos) { +- return this.tickets.getOrDefault(chunkPos, List.of()); ++ // Paper start - rewrite chunk system ++ return ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager ++ .getTicketsAt(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkX(chunkPos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getChunkZ(chunkPos)); ++ // Paper end - rewrite chunk system + } + + private List getOrCreateTickets(long chunkPos) { +- return this.tickets.computeIfAbsent(chunkPos, l -> new ObjectArrayList<>(4)); ++ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + } + + public void addTicketWithRadius(TicketType ticketType, ChunkPos chunkPos, int radius) { +@@ -131,33 +172,14 @@ public class TicketStorage extends SavedData { + } + + public boolean addTicket(long chunkPos, Ticket ticket) { +- List tickets = this.getOrCreateTickets(chunkPos); +- +- for (Ticket ticket1 : tickets) { +- if (isTicketSameTypeAndLevel(ticket, ticket1)) { +- ticket1.resetTicksLeft(); +- this.setDirty(); +- return false; +- } +- } +- +- int ticketLevelAt = getTicketLevelAt(tickets, true); +- int ticketLevelAt1 = getTicketLevelAt(tickets, false); +- tickets.add(ticket); +- if (ticket.getType().doesSimulate() && ticket.getTicketLevel() < ticketLevelAt && this.simulationChunkUpdatedListener != null) { +- this.simulationChunkUpdatedListener.update(chunkPos, ticket.getTicketLevel(), true); +- } +- +- if (ticket.getType().doesLoad() && ticket.getTicketLevel() < ticketLevelAt1 && this.loadingChunkUpdatedListener != null) { +- this.loadingChunkUpdatedListener.update(chunkPos, ticket.getTicketLevel(), true); +- } +- +- if (ticket.getType().equals(TicketType.FORCED)) { +- this.chunksWithForcedTickets.add(chunkPos); +- } ++ // Paper start - rewrite chunk system ++ final boolean ret = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager ++ .addTicketAtLevel(ticket.getType(), chunkPos, ticket.getTicketLevel(), ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket)ticket).moonrise$getIdentifier()); + + this.setDirty(); +- return true; ++ ++ return ret; ++ // Paper end - rewrite chunk system + } + + private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { +@@ -204,49 +226,20 @@ public class TicketStorage extends SavedData { + } + + public boolean removeTicket(long chunkPos, Ticket ticket) { +- List list = this.tickets.get(chunkPos); +- if (list == null) { +- return false; +- } else { +- boolean flag = false; +- Iterator iterator = list.iterator(); +- +- while (iterator.hasNext()) { +- Ticket ticket1 = iterator.next(); +- if (isTicketSameTypeAndLevel(ticket, ticket1)) { +- iterator.remove(); +- flag = true; +- break; +- } +- } ++ // Paper start - rewrite chunk system ++ final boolean ret = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager ++ .removeTicketAtLevel(ticket.getType(), chunkPos, ticket.getTicketLevel(), ((ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicket)ticket).moonrise$getIdentifier()); + +- if (!flag) { +- return false; +- } else { +- if (list.isEmpty()) { +- this.tickets.remove(chunkPos); +- } +- +- if (ticket.getType().doesSimulate() && this.simulationChunkUpdatedListener != null) { +- this.simulationChunkUpdatedListener.update(chunkPos, getTicketLevelAt(list, true), false); +- } +- +- if (ticket.getType().doesLoad() && this.loadingChunkUpdatedListener != null) { +- this.loadingChunkUpdatedListener.update(chunkPos, getTicketLevelAt(list, false), false); +- } +- +- if (ticket.getType().equals(TicketType.FORCED)) { +- this.updateForcedChunks(); +- } +- +- this.setDirty(); +- return true; +- } ++ if (ret) { ++ this.setDirty(); + } ++ ++ return ret; ++ // Paper end - rewrite chunk system + } + + private void updateForcedChunks() { +- this.chunksWithForcedTickets = this.getAllChunksWithTicketThat(ticket -> ticket.getType().equals(TicketType.FORCED)); ++ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + } + + public String getTicketDebugString(long chunkPos, boolean requireSimulation) { +@@ -256,89 +249,20 @@ public class TicketStorage extends SavedData { + } + + public void purgeStaleTickets() { +- this.removeTicketIf(ticket -> { +- ticket.decreaseTicksLeft(); +- return ticket.isTimedOut(); +- }, null); ++ ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler().chunkHolderManager.tick(); // Paper - rewrite chunk system + this.setDirty(); + } + + public void deactivateTicketsOnClosing() { +- this.removeTicketIf(ticket -> ticket.getType() != TicketType.UNKNOWN && ticket.getType() != TicketType.CHUNK_LOAD && ticket.getType() != TicketType.FUTURE_AWAIT, this.deactivatedTickets); ++ // Paper - rewrite chunk system + } + + public void removeTicketIf(Predicate predicate, @Nullable Long2ObjectOpenHashMap> tickets) { +- ObjectIterator>> objectIterator = this.tickets.long2ObjectEntrySet().fastIterator(); +- boolean flag = false; +- +- while (objectIterator.hasNext()) { +- Entry> entry = objectIterator.next(); +- Iterator iterator = entry.getValue().iterator(); +- boolean flag1 = false; +- boolean flag2 = false; +- +- while (iterator.hasNext()) { +- Ticket ticket = iterator.next(); +- if (predicate.test(ticket)) { +- if (tickets != null) { +- List list = tickets.computeIfAbsent(entry.getLongKey(), chunkPos -> new ObjectArrayList<>(entry.getValue().size())); +- list.add(ticket); +- } +- +- iterator.remove(); +- if (ticket.getType().doesLoad()) { +- flag2 = true; +- } +- +- if (ticket.getType().doesSimulate()) { +- flag1 = true; +- } +- +- if (ticket.getType().equals(TicketType.FORCED)) { +- flag = true; +- } +- } +- } +- +- if (flag2 || flag1) { +- if (flag2 && this.loadingChunkUpdatedListener != null) { +- this.loadingChunkUpdatedListener.update(entry.getLongKey(), getTicketLevelAt(entry.getValue(), false), false); +- } +- +- if (flag1 && this.simulationChunkUpdatedListener != null) { +- this.simulationChunkUpdatedListener.update(entry.getLongKey(), getTicketLevelAt(entry.getValue(), true), false); +- } +- +- this.setDirty(); +- if (entry.getValue().isEmpty()) { +- objectIterator.remove(); +- } +- } +- } +- +- if (flag) { +- this.updateForcedChunks(); +- } ++ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + } + + public void replaceTicketLevelOfType(int level, TicketType type) { +- List> list = new ArrayList<>(); +- +- for (Entry> entry : this.tickets.long2ObjectEntrySet()) { +- for (Ticket ticket : entry.getValue()) { +- if (ticket.getType() == type) { +- list.add(Pair.of(ticket, entry.getLongKey())); +- } +- } +- } +- +- for (Pair pair : list) { +- Long _long = pair.getSecond(); +- Ticket ticketx = pair.getFirst(); +- this.removeTicket(_long, ticketx); +- TicketType type1 = ticketx.getType(); +- this.addTicket(_long, new Ticket(type1, level)); +- } ++ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + } + + public boolean updateChunkForced(ChunkPos chunkPos, boolean add) { +@@ -347,22 +271,20 @@ public class TicketStorage extends SavedData { + } + + public LongSet getForceLoadedChunks() { +- return this.chunksWithForcedTickets; +- } +- +- private LongSet getAllChunksWithTicketThat(Predicate predicate) { +- LongOpenHashSet set = new LongOpenHashSet(); ++ // Paper start - rewrite chunk system ++ final it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap forced = ((ca.spottedleaf.moonrise.patches.chunk_system.level.ChunkSystemServerLevel)this.chunkMap.level).moonrise$getChunkTaskScheduler() ++ .chunkHolderManager.getTicketCounters(ca.spottedleaf.moonrise.patches.chunk_system.ticket.ChunkSystemTicketType.COUNTER_TYPE_FORCED); + +- for (Entry> entry : Long2ObjectMaps.fastIterable(this.tickets)) { +- for (Ticket ticket : entry.getValue()) { +- if (predicate.test(ticket)) { +- set.add(entry.getLongKey()); +- break; +- } +- } ++ if (forced == null) { ++ return LongSet.of(); + } + +- return set; ++ return forced.keySet(); ++ // Paper end - rewrite chunk system ++ } ++ ++ private LongSet getAllChunksWithTicketThat(Predicate predicate) { ++ throw new UnsupportedOperationException(); // Paper - rewrite chunk system + } + + @FunctionalInterface +@@ -381,7 +303,7 @@ public class TicketStorage extends SavedData { + } + + public void removeAllPluginRegionTickets(TicketType ticketType, int ticketLevel, org.bukkit.plugin.Plugin ticketIdentifier) { +- removeTicketIf(ticket -> ticket.getType() == ticketType && ticket.getTicketLevel() == ticketLevel && ticket.getIdentifier() == ticketIdentifier, null); ++ this.chunkMap.level.moonrise$getChunkTaskScheduler().chunkHolderManager.removeAllTicketsFor(ticketType, ticketLevel, ticketIdentifier); // Paper - rewrite chunk system + } + // Paper end + } diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java -index 21b9021df95d3611ad17c9fd5f429f97e824ed2f..f44461f92a10cbfdb8fcdbc3a2442e526b9d3d33 100644 +index bb3e37f9674297b2163712d8d98cde191bb6b67d..bad1a03167f7586e5279592adcb43350c9b528cd 100644 --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -117,20 +117,7 @@ public final class Biome { +@@ -118,20 +118,7 @@ public final class Biome { @Deprecated public float getTemperature(BlockPos pos, int seaLevel) { @@ -30906,10 +31481,10 @@ index 8d98cba3830dc5dfb5cae9a6f5fedfffee0d2cd8..73962e79a0f3d892e3155443a1b84508 public interface NoiseBiomeSource { diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index a4eb9a10b6c1351c7341bc031bb9f819e17ff1e5..976de81d65b6494cdad20f4ec5125fceec86f951 100644 +index 95bd1139401d49ddf443a64faca8cd30ca3b1a1d..ae3e6e31171b1bcfba1ae51a0941b52dda270acd 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -259,7 +259,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -305,7 +305,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public static boolean isShapeFullBlock(VoxelShape shape) { @@ -30919,10 +31494,10 @@ index a4eb9a10b6c1351c7341bc031bb9f819e17ff1e5..976de81d65b6494cdad20f4ec5125fce public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) { diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index fa816de449a6077c05fee76835a1625f5b2008ac..5473b4006f7e0266ea11a7b05cef78a113c30d97 100644 +index 1c81dc30aabb354d18290d42dfc419d9b1581fbd..834e27ef2f7b342b074ff9e1e390e02f3ca1c399 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -416,7 +416,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -413,7 +413,7 @@ public abstract class BlockBehaviour implements FeatureElement { return this.properties.destroyTime; } @@ -30931,7 +31506,7 @@ index fa816de449a6077c05fee76835a1625f5b2008ac..5473b4006f7e0266ea11a7b05cef78a1 private static final Direction[] DIRECTIONS = Direction.values(); private static final VoxelShape[] EMPTY_OCCLUSION_SHAPES = Util.make(new VoxelShape[DIRECTIONS.length], shape -> Arrays.fill(shape, Shapes.empty())); private static final VoxelShape[] FULL_BLOCK_OCCLUSION_SHAPES = Util.make( -@@ -455,6 +455,76 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -452,6 +452,76 @@ public abstract class BlockBehaviour implements FeatureElement { private boolean propagatesSkylightDown; private int lightBlock; @@ -31008,7 +31583,7 @@ index fa816de449a6077c05fee76835a1625f5b2008ac..5473b4006f7e0266ea11a7b05cef78a1 protected BlockStateBase(Block owner, Reference2ObjectArrayMap, Comparable> values, MapCodec propertiesCodec) { super(owner, values, propertiesCodec); BlockBehaviour.Properties properties = owner.properties; -@@ -533,6 +603,41 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -530,6 +600,41 @@ public abstract class BlockBehaviour implements FeatureElement { this.propagatesSkylightDown = this.owner.propagatesSkylightDown(this.asState()); this.lightBlock = this.owner.getLightBlock(this.asState()); @@ -31051,7 +31626,7 @@ index fa816de449a6077c05fee76835a1625f5b2008ac..5473b4006f7e0266ea11a7b05cef78a1 public Block getBlock() { diff --git a/net/minecraft/world/level/block/state/StateHolder.java b/net/minecraft/world/level/block/state/StateHolder.java -index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e98b85b1d 100644 +index 7a585970f52ef9cab172bf60c7607551a643c0b3..9b9842462b210b0407279ee8a8e9ccecf3ead005 100644 --- a/net/minecraft/world/level/block/state/StateHolder.java +++ b/net/minecraft/world/level/block/state/StateHolder.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; @@ -31093,7 +31668,7 @@ index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e } public > S cycle(Property property) { -@@ -67,20 +81,21 @@ public abstract class StateHolder { +@@ -77,20 +91,21 @@ public abstract class StateHolder { } public Collection> getProperties() { @@ -31101,7 +31676,7 @@ index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e + return this.optimisedTable.getProperties(); // Paper - optimise blockstate property access } - public > boolean hasProperty(Property property) { + public boolean hasProperty(Property property) { - return this.values.containsKey(property); + return property != null && this.optimisedTable.hasProperty(property); // Paper - optimise blockstate property access } @@ -31122,10 +31697,10 @@ index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e } public > Optional getOptionalValue(Property property) { -@@ -93,22 +108,30 @@ public abstract class StateHolder { +@@ -103,22 +118,30 @@ public abstract class StateHolder { @Nullable - public > T getNullableValue(Property property) { + private > T getNullableValue(Property property) { - Comparable comparable = this.values.get(property); - return comparable == null ? null : property.getValueClass().cast(comparable); + return property == null ? null : this.optimisedTable.get(this.tableIndex, property); // Paper - optimise blockstate property access @@ -31162,7 +31737,7 @@ index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e } private , V extends T> S setValueInternal(Property property, V value, Comparable comparable) { -@@ -125,21 +148,27 @@ public abstract class StateHolder { +@@ -135,21 +158,27 @@ public abstract class StateHolder { } public void populateNeighbours(Map, Comparable>, S> possibleStateMap) { @@ -31203,7 +31778,7 @@ index 2f2dbf02a9732a7e640a6c730d4fc1443e723933..098518383d2c07491e047749ce3a834e } private Map, Comparable> makeNeighbourValues(Property property, Comparable value) { -@@ -149,7 +178,11 @@ public abstract class StateHolder { +@@ -159,7 +188,11 @@ public abstract class StateHolder { } public Map, Comparable> getValues() { @@ -31398,7 +31973,7 @@ index 92350434746f06bbf4a161c6bc42602de7b45220..1c24f38d21da1be9740512981f219924 public Property.Value value(T value) { diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java -index d63d745a0220963a297cfedf1e8983aeb471a045..6d565b52552534ce9cacfc35ad1bf4adcb69eac3 100644 +index 97231db28146df56c727c9765f36277634d59a64..3b7f0d5fe40bdda65ab859a0c22bf0d369dc0f01 100644 --- a/net/minecraft/world/level/chunk/ChunkAccess.java +++ b/net/minecraft/world/level/chunk/ChunkAccess.java @@ -57,7 +57,7 @@ import net.minecraft.world.ticks.SavedTick; @@ -31503,7 +32078,7 @@ index d63d745a0220963a297cfedf1e8983aeb471a045..6d565b52552534ce9cacfc35ad1bf4ad } private void replaceMissingSections(Registry biomeRegistry, LevelChunkSection[] sections) { // Paper - Anti-Xray - make it a non-static method -@@ -442,18 +503,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -448,18 +509,22 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh @Override public Holder getNoiseBiome(int x, int y, int z) { @@ -31537,7 +32112,7 @@ index d63d745a0220963a297cfedf1e8983aeb471a045..6d565b52552534ce9cacfc35ad1bf4ad } // CraftBukkit start public void setBiome(int x, int y, int z, Holder biome) { -@@ -503,12 +568,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh +@@ -509,12 +574,12 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh } public void initializeLightSources() { @@ -31553,7 +32128,7 @@ index d63d745a0220963a297cfedf1e8983aeb471a045..6d565b52552534ce9cacfc35ad1bf4ad public record PackedTicks(List> blocks, List> fluids) { diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java -index b320519578f7e2c52b2116afb247e071b322696e..6ed51cf42b5864194d671b5b56f5b9bdf0291dc0 100644 +index 842f633a1e74ec9e405922bb40469c5d04d8f6e7..857aa6e29b57a0a8eea4d7c14971b9dde59bb0d0 100644 --- a/net/minecraft/world/level/chunk/ChunkGenerator.java +++ b/net/minecraft/world/level/chunk/ChunkGenerator.java @@ -116,7 +116,7 @@ public abstract class ChunkGenerator { @@ -31565,7 +32140,7 @@ index b320519578f7e2c52b2116afb247e071b322696e..6ed51cf42b5864194d671b5b56f5b9bd } public abstract void applyCarvers( -@@ -315,7 +315,7 @@ public abstract class ChunkGenerator { +@@ -314,7 +314,7 @@ public abstract class ChunkGenerator { return Pair.of(placement.getLocatePos(chunkPos), holder); } @@ -31575,7 +32150,7 @@ index b320519578f7e2c52b2116afb247e071b322696e..6ed51cf42b5864194d671b5b56f5b9bd if (startForStructure != null && startForStructure.isValid() && (!skipKnownStructures || tryAddReference(structureManager, startForStructure))) { return Pair.of(placement.getLocatePos(startForStructure.getChunkPos()), holder); diff --git a/net/minecraft/world/level/chunk/EmptyLevelChunk.java b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -index ec128412e4a0d3d21e3b6abea8cd06c03656f00c..07b7e82c7d24f52c0251e09195451841d47883c9 100644 +index d4016e0db6a370f2d1ed8ccae4f11aa85f63d56f..796ca48de2e9b87801646c7e404ef27025e915c7 100644 --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockState; @@ -31654,7 +32229,7 @@ index 7cd5d42e0c28033ee80f18bd0031ed1241fb7aae..718d00a386f32423db9f6d6c95b4a206 this(registry, bits, resizeHandler); values.forEach(this.values::add); diff --git a/net/minecraft/world/level/chunk/ImposterProtoChunk.java b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -index e7c0f4da8508fbca467326f475668d66454d7b77..41856c98d97e7eb0782f8e441b9a269a47ed1914 100644 +index 2ccb56f5befc1a93172e6ab81f93c785222ca6fb..d1331b580b3d27c77244b22a4ad15e719f686c8f 100644 --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java @@ -30,7 +30,7 @@ import net.minecraft.world.level.material.FluidState; @@ -31716,10 +32291,10 @@ index e7c0f4da8508fbca467326f475668d66454d7b77..41856c98d97e7eb0782f8e441b9a269a @Override public BlockEntity getBlockEntity(BlockPos pos) { diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61c6eeacb4 100644 +index 08e2442f6965cc6eaab67bdf9340a5152c08db2a..5d3fc807221392d378fec283bfdefb8747fb8376 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -52,7 +52,7 @@ import net.minecraft.world.ticks.LevelChunkTicks; +@@ -53,7 +53,7 @@ import net.minecraft.world.ticks.LevelChunkTicks; import net.minecraft.world.ticks.TickContainerAccess; import org.slf4j.Logger; @@ -31728,13 +32303,13 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 static final Logger LOGGER = LogUtils.getLogger(); private static final TickingBlockEntity NULL_TICKER = new TickingBlockEntity() { @Override -@@ -93,6 +93,39 @@ public class LevelChunk extends ChunkAccess { +@@ -94,6 +94,39 @@ public class LevelChunk extends ChunkAccess { // Paper start boolean loadedTicketLevel; // Paper end + // Paper start - rewrite chunk system + private boolean postProcessingDone; -+ private net.minecraft.server.level.ServerChunkCache.ChunkAndHolder chunkAndHolder; ++ private ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder chunkAndHolder; + + @Override + public final boolean moonrise$isPostProcessingDone() { @@ -31742,12 +32317,12 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 + } + + @Override -+ public final net.minecraft.server.level.ServerChunkCache.ChunkAndHolder moonrise$getChunkAndHolder() { ++ public final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder moonrise$getChunkHolder() { + return this.chunkAndHolder; + } + + @Override -+ public final void moonrise$setChunkAndHolder(final net.minecraft.server.level.ServerChunkCache.ChunkAndHolder holder) { ++ public final void moonrise$setChunkHolder(final ca.spottedleaf.moonrise.patches.chunk_system.scheduling.NewChunkHolder holder) { + this.chunkAndHolder = holder; + } + // Paper end - rewrite chunk system @@ -31768,7 +32343,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -122,6 +155,14 @@ public class LevelChunk extends ChunkAccess { +@@ -123,6 +156,14 @@ public class LevelChunk extends ChunkAccess { this.postLoad = postLoad; this.blockTicks = blockTicks; this.fluidTicks = fluidTicks; @@ -31783,7 +32358,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 } public LevelChunk(ServerLevel level, ProtoChunk chunk, @Nullable LevelChunk.PostLoadProcessor postLoad) { -@@ -159,13 +200,19 @@ public class LevelChunk extends ChunkAccess { +@@ -160,13 +201,19 @@ public class LevelChunk extends ChunkAccess { } } @@ -31804,7 +32379,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -341,7 +388,7 @@ public class LevelChunk extends ChunkAccess { +@@ -338,7 +385,7 @@ public class LevelChunk extends ChunkAccess { if (LightEngine.hasDifferentLightProperties(blockState, state)) { ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("updateSkyLightSources"); @@ -31813,7 +32388,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 profilerFiller.popPush("queueCheckLight"); this.level.getChunkSource().getLightEngine().checkBlock(pos); profilerFiller.pop(); -@@ -573,11 +620,12 @@ public class LevelChunk extends ChunkAccess { +@@ -581,11 +628,12 @@ public class LevelChunk extends ChunkAccess { // CraftBukkit start public void loadCallback() { @@ -31827,7 +32402,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 if (server != null) { /* * If it's a new world, the first few chunks are generated inside -@@ -586,6 +634,7 @@ public class LevelChunk extends ChunkAccess { +@@ -594,6 +642,7 @@ public class LevelChunk extends ChunkAccess { */ org.bukkit.Chunk bukkitChunk = new org.bukkit.craftbukkit.CraftChunk(this); server.getPluginManager().callEvent(new org.bukkit.event.world.ChunkLoadEvent(bukkitChunk, this.needsDecoration)); @@ -31835,7 +32410,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 if (this.needsDecoration) { this.needsDecoration = false; -@@ -612,13 +661,15 @@ public class LevelChunk extends ChunkAccess { +@@ -620,13 +669,15 @@ public class LevelChunk extends ChunkAccess { } public void unloadCallback() { @@ -31853,7 +32428,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 // Paper start this.loadedTicketLevel = false; // Paper end -@@ -626,8 +677,31 @@ public class LevelChunk extends ChunkAccess { +@@ -634,8 +685,31 @@ public class LevelChunk extends ChunkAccess { @Override public boolean isUnsaved() { @@ -31886,7 +32461,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 // CraftBukkit end public boolean isEmpty() { -@@ -706,6 +780,7 @@ public class LevelChunk extends ChunkAccess { +@@ -710,6 +784,7 @@ public class LevelChunk extends ChunkAccess { this.pendingBlockEntities.clear(); this.upgradeData.upgrade(this); @@ -31895,7 +32470,7 @@ index cad71ac79fc52225a192aa5c5d07b13c831fc2c1..761fdcd4a4e18f45547afd8edff44f61 @Nullable diff --git a/net/minecraft/world/level/chunk/LevelChunkSection.java b/net/minecraft/world/level/chunk/LevelChunkSection.java -index a7fabde0f32f09d7f7bed65576ce469f069a21fa..412e7b1cf8c24f0ddf6d174967bedad576f10aba 100644 +index 1aa4e39431a93a7789b74a2e3476a3e47605e2cc..df717c545472006b99532280c38c1fbef12bcf82 100644 --- a/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/net/minecraft/world/level/chunk/LevelChunkSection.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.Blocks; @@ -32152,7 +32727,7 @@ index b4b973e453a093dcc04a6b7257883aa0065e2a89..a80b2e9dceea423180a9c390d1970317 boolean maybeHas(Predicate filter); diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index a6028a54c75de068515e95913b21160ab4326985..f5da433050fd3060e0335d4002d520ebe8cd691f 100644 +index 1491401ec94038450ea5eeb589fc33a336a3ae55..7da7ce0fd19896593e63edc88b492c02f926bba0 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java @@ -29,7 +29,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer @@ -32262,7 +32837,7 @@ index a6028a54c75de068515e95913b21160ab4326985..f5da433050fd3060e0335d4002d520eb @Override @@ -240,6 +276,7 @@ public class PalettedContainer implements PaletteResize, PalettedContainer - buffer.readLongArray(data.storage.getRaw()); + buffer.readFixedSizeLongArray(data.storage.getRaw()); this.data = data; this.addPresetValues(); // Paper - Anti-Xray - Add preset values (inefficient, but this isn't used by the server) + this.updateData(this.data); // Paper - optimise palette reads @@ -32316,10 +32891,10 @@ index a6028a54c75de068515e95913b21160ab4326985..f5da433050fd3060e0335d4002d520eb for (int i = 0; i < bitStorage.getSize(); i++) { T object = palette.valueFor(bitStorage.get(i)); diff --git a/net/minecraft/world/level/chunk/ProtoChunk.java b/net/minecraft/world/level/chunk/ProtoChunk.java -index 8c333d7f390d823a7c7f303e2f444f52ec16f799..e66239e2da91bd3ddf358d239be796719c0da327 100644 +index 991263ac68d0fb2eeeda28c283ca6f80d5a10af3..13837d5508c34de3ccc49caac0d6c0ba7010d88a 100644 --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -151,7 +151,7 @@ public class ProtoChunk extends ChunkAccess { +@@ -152,7 +152,7 @@ public class ProtoChunk extends ChunkAccess { } if (LightEngine.hasDifferentLightProperties(blockState, state)) { @@ -32396,10 +32971,10 @@ index 9c6f4aa173fa25f9c8a3852d91a4585e069236b6..b14001afe0bf841dac7d0a1d1568fd10 .step(ChunkStatus.FULL, builder -> builder.setTask(ChunkStatusTasks::full)) .build(); diff --git a/net/minecraft/world/level/chunk/status/ChunkStatus.java b/net/minecraft/world/level/chunk/status/ChunkStatus.java -index 7a64b00ff31d1273d0b0b9a3cfd43808c88ef46a..c9d8a1c0a75c34ccd9f5cead02cccd776276f3cb 100644 +index f2aa944dedf917f01d669a703a9b9f4f35af78c2..116efc09663cac3b0f4b8c157e93201e8cc9b7a4 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStatus.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatus.java -@@ -11,7 +11,7 @@ import net.minecraft.resources.ResourceLocation; +@@ -12,7 +12,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.levelgen.Heightmap; import org.jetbrains.annotations.VisibleForTesting; @@ -32408,7 +32983,7 @@ index 7a64b00ff31d1273d0b0b9a3cfd43808c88ef46a..c9d8a1c0a75c34ccd9f5cead02cccd77 public static final int MAX_STRUCTURE_DISTANCE = 8; private static final EnumSet WORLDGEN_HEIGHTMAPS = EnumSet.of(Heightmap.Types.OCEAN_FLOOR_WG, Heightmap.Types.WORLD_SURFACE_WG); public static final EnumSet FINAL_HEIGHTMAPS = EnumSet.of( -@@ -51,8 +51,70 @@ public class ChunkStatus { +@@ -53,8 +53,70 @@ public class ChunkStatus { return list; } @@ -32480,7 +33055,7 @@ index 7a64b00ff31d1273d0b0b9a3cfd43808c88ef46a..c9d8a1c0a75c34ccd9f5cead02cccd77 this.chunkType = chunkType; this.heightmapsAfter = heightmapsAfter; diff --git a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java -index c953bc93de8a42bcc12b7e8f46b3ae804e54964e..2ccbdfdcf81556306e098277ecf119d5fd02138c 100644 +index dc9c612b245275900ae43f7a45e7be755853207c..8129d8a6807b6e770b65ba42441817af09521468 100644 --- a/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java +++ b/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java @@ -182,7 +182,7 @@ public class ChunkStatusTasks { @@ -32496,8 +33071,8 @@ index c953bc93de8a42bcc12b7e8f46b3ae804e54964e..2ccbdfdcf81556306e098277ecf119d5 }, worldGenContext.mainThreadExecutor()); } -- public static void postLoadProtoChunk(ServerLevel level, List entityTags) { // Paper - public -+ public static void postLoadProtoChunk(ServerLevel level, List entityTags, ChunkPos pos) { // Paper - public // Paper - rewrite chunk system - add ChunkPos param +- public static void postLoadProtoChunk(ServerLevel level, List entityTags) { ++ public static void postLoadProtoChunk(ServerLevel level, List entityTags, ChunkPos pos) { // Paper - rewrite chunk system - add ChunkPos param if (!entityTags.isEmpty()) { // CraftBukkit start - these are spawned serialized (DefinedStructure) and we don't call an add event below at the moment due to ordering complexities level.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entityTags, level, EntitySpawnReason.LOAD).filter((entity) -> { @@ -32626,7 +33201,7 @@ index 7a4d299d2ce36982204e30de9278ddfd5b37c3df..b8348976e80578d9eff64eea68c04c60 private final ChunkStatus status; @Nullable diff --git a/net/minecraft/world/level/chunk/storage/ChunkStorage.java b/net/minecraft/world/level/chunk/storage/ChunkStorage.java -index 5ba7f724687401c9ea1756a6491498e03548a257..64343a3f6e6009eed5b392482ec053be8e00ee63 100644 +index 273ba0bdcf2588ea12ecae03b6a566da24a34e2c..258a6b82b10bce1aecc42ddb61cb6732645c1ea0 100644 --- a/net/minecraft/world/level/chunk/storage/ChunkStorage.java +++ b/net/minecraft/world/level/chunk/storage/ChunkStorage.java @@ -22,20 +22,30 @@ import net.minecraft.world.level.chunk.ChunkGenerator; @@ -32665,8 +33240,8 @@ index 5ba7f724687401c9ea1756a6491498e03548a257..64343a3f6e6009eed5b392482ec053be // CraftBukkit start @@ -66,7 +76,9 @@ public class ChunkStorage implements AutoCloseable { - chunkData = ca.spottedleaf.dataconverter.minecraft.MCDataConverter.convertTag(ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.CHUNK, chunkData, version, 1493); // Paper - replace chunk converter - if (chunkData.getCompound("Level").getBoolean("hasLegacyStructureData")) { + chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); + if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { LegacyStructureDataHandler legacyStructureHandler = this.getLegacyStructureHandler(levelKey, storage); + synchronized (legacyStructureHandler) { // Paper - rewrite chunk system chunkData = legacyStructureHandler.updateFromLegacy(chunkData); @@ -32750,27 +33325,8 @@ index 5ba7f724687401c9ea1756a6491498e03548a257..64343a3f6e6009eed5b392482ec053be + return this.storage.info(); // Paper - rewrite chunk system } } -diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java -index c3c9771138cb1712ea429d8c45596220830314eb..da05fb780c55381a7a08ced51d01764a645740b2 100644 ---- a/net/minecraft/world/level/chunk/storage/EntityStorage.java -+++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -71,12 +71,12 @@ public class EntityStorage implements EntityPersistentStorage { - } - } - -- private static ChunkPos readChunkPos(CompoundTag tag) { -+ public static ChunkPos readChunkPos(CompoundTag tag) { // Paper - public - int[] intArray = tag.getIntArray("Position"); - return new ChunkPos(intArray[0], intArray[1]); - } - -- private static void writeChunkPos(CompoundTag tag, ChunkPos pos) { -+ public static void writeChunkPos(CompoundTag tag, ChunkPos pos) { // Paper - public - tag.put("Position", new IntArrayTag(new int[]{pos.x, pos.z})); - } - diff --git a/net/minecraft/world/level/chunk/storage/IOWorker.java b/net/minecraft/world/level/chunk/storage/IOWorker.java -index 889e188e920edb284f04b264bcdd06146f54a4cb..2199a9e2a0141c646d108f2687a27f1d165453c5 100644 +index d0de56609f6f22dded474d7693935180761d2cb5..27e1edbd8d8ffd80c1a3df17bc47f4a6936619f7 100644 --- a/net/minecraft/world/level/chunk/storage/IOWorker.java +++ b/net/minecraft/world/level/chunk/storage/IOWorker.java @@ -30,7 +30,7 @@ public class IOWorker implements ChunkScanAccess, AutoCloseable { @@ -32874,7 +33430,7 @@ index 4eb07097986aac67421dd8e6a17cc5436da91187..984db72272d552c7210bd6f437ea8869 } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 51bf310423013d0ae9d3202d66e36a053a767197..e35bb5534e2fbd2e30154a15ff6d39baa121608f 100644 +index 763879cdc389fc4d80135b38aa96a5bec448ae9e..50bbd8c778bfa9fc9ce93ed09a6fe4dc1f516d51 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -14,7 +14,7 @@ import net.minecraft.nbt.StreamTagVisitor; @@ -33323,38 +33879,47 @@ index 7dc1ffffd9d0fec54dbc254c154ee85ee750174d..778bd73a938c94ecb85ca0f8b686ff4e record PackedChunk(Int2ObjectMap sectionsByY, boolean versionChanged) { diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a550baa6305 100644 +index 58bc96235f0149ea868da3bc3d20472f96d5f6ec..03d1527073cf827fc3e191915fe5f7f064e36c3b 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -148,7 +148,7 @@ public record SerializableChunkData( - UpgradeData upgradeData = tag.contains("UpgradeData", 10) - ? new UpgradeData(tag.getCompound("UpgradeData"), levelHeightAccessor) - : UpgradeData.EMPTY; -- boolean _boolean = tag.getBoolean("isLightOn"); -+ boolean _boolean = chunkStatus.isOrAfter(ChunkStatus.LIGHT) && (tag.get("isLightOn") != null && tag.getInt(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_VERSION_TAG) == ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_LIGHT_VERSION); // Paper - starlight - BlendingData.Packed packed; - if (tag.contains("blending_data", 10)) { - packed = BlendingData.Packed.CODEC.parse(NbtOps.INSTANCE, tag.getCompound("blending_data")).resultOrPartial(LOGGER::error).orElse(null); -@@ -249,7 +249,17 @@ public record SerializableChunkData( +@@ -149,7 +149,7 @@ public record SerializableChunkData( + UpgradeData upgradeData = tag.getCompound("UpgradeData") + .map(compoundTag1 -> new UpgradeData(compoundTag1, levelHeightAccessor)) + .orElse(UpgradeData.EMPTY); +- boolean booleanOr = tag.getBooleanOr("isLightOn", false); ++ boolean booleanOr = chunkStatus.isOrAfter(ChunkStatus.LIGHT) && (tag.get("isLightOn") != null && tag.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_VERSION_TAG, -1) == ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.STARLIGHT_LIGHT_VERSION); // Paper - starlight + BlendingData.Packed packed = tag.read("blending_data", BlendingData.Packed.CODEC).orElse(null); + BelowZeroRetrogen belowZeroRetrogen = tag.read("below_zero_retrogen", BelowZeroRetrogen.CODEC).orElse(null); + long[] longs = tag.getLongArray("carving_mask").orElse(null); +@@ -187,7 +187,7 @@ public record SerializableChunkData( + for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { + Optional compound = listOrEmpty2.getCompound(i2); + if (!compound.isEmpty()) { +- CompoundTag compoundTag = compound.get(); ++ CompoundTag compoundTag = compound.get(); final CompoundTag sectionData = compoundTag; // Paper - OBFHELPER + int byteOr = compoundTag.getByteOr("Y", (byte)0); + LevelChunkSection levelChunkSection; + if (byteOr >= levelHeightAccessor.getMinSectionY() && byteOr <= levelHeightAccessor.getMaxSectionY()) { +@@ -222,7 +222,17 @@ public record SerializableChunkData( - DataLayer dataLayer = compound2.contains("BlockLight", 7) ? new DataLayer(compound2.getByteArray("BlockLight")) : null; - DataLayer dataLayer1 = compound2.contains("SkyLight", 7) ? new DataLayer(compound2.getByteArray("SkyLight")) : null; -- list8.add(new SerializableChunkData.SectionData(_byte, levelChunkSection, dataLayer, dataLayer1)); -+ // Paper start - starlight -+ SerializableChunkData.SectionData serializableChunkData = new SerializableChunkData.SectionData(_byte, levelChunkSection, dataLayer, dataLayer1); -+ if (sectionData.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG, net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setBlockLightState(sectionData.getInt(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG)); -+ } + DataLayer dataLayer = compoundTag.getByteArray("BlockLight").map(DataLayer::new).orElse(null); + DataLayer dataLayer1 = compoundTag.getByteArray("SkyLight").map(DataLayer::new).orElse(null); +- list5.add(new SerializableChunkData.SectionData(byteOr, levelChunkSection, dataLayer, dataLayer1)); ++ // Paper start - starlight ++ SerializableChunkData.SectionData serializableChunkData = new SerializableChunkData.SectionData(byteOr, levelChunkSection, dataLayer, dataLayer1); ++ if (sectionData.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG)) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setBlockLightState(sectionData.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.BLOCKLIGHT_STATE_TAG, 0)); ++ } + -+ if (sectionData.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG, net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setSkyLightState(sectionData.getInt(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG)); -+ } -+ list8.add(serializableChunkData); -+ // Paper end - starlight ++ if (sectionData.contains(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG)) { ++ ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)serializableChunkData).starlight$setSkyLightState(sectionData.getIntOr(ca.spottedleaf.moonrise.patches.starlight.util.SaveUtil.SKYLIGHT_STATE_TAG, 0)); ++ } ++ list5.add(serializableChunkData); ++ // Paper end - starlight + } } - return new SerializableChunkData( -@@ -276,6 +286,59 @@ public record SerializableChunkData( +@@ -250,6 +260,59 @@ public record SerializableChunkData( } } @@ -33414,7 +33979,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 public ProtoChunk read(ServerLevel level, PoiManager poiManager, RegionStorageInfo regionStorageInfo, ChunkPos pos) { if (!Objects.equals(pos, this.chunkPos)) { LOGGER.error("Chunk file at {} is in the wrong location; relocating. (Expected {}, got {})", pos, pos, this.chunkPos); -@@ -294,7 +357,7 @@ public record SerializableChunkData( +@@ -268,7 +331,7 @@ public record SerializableChunkData( SectionPos sectionPos = SectionPos.of(pos, sectionData.y); if (sectionData.chunkSection != null) { levelChunkSections[level.getSectionIndexFromSectionY(sectionData.y)] = sectionData.chunkSection; @@ -33423,7 +33988,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 } boolean flag1 = sectionData.blockLight != null; -@@ -376,7 +439,7 @@ public record SerializableChunkData( +@@ -350,7 +413,7 @@ public record SerializableChunkData( } if (chunkType == ChunkType.LEVELCHUNK) { @@ -33432,7 +33997,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 } else { ProtoChunk protoChunk1 = (ProtoChunk)chunkAccess; -@@ -399,7 +462,7 @@ public record SerializableChunkData( +@@ -366,7 +429,7 @@ public record SerializableChunkData( protoChunk1.setCarvingMask(new CarvingMask(this.carvingMask, chunkAccess.getMinY())); } @@ -33441,7 +34006,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 } } -@@ -427,22 +490,48 @@ public record SerializableChunkData( +@@ -394,22 +457,48 @@ public record SerializableChunkData( throw new IllegalArgumentException("Chunk can't be serialized: " + chunk); } else { ChunkPos pos = chunk.getPos(); @@ -33479,7 +34044,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 + + if (chunkSection == null && blockNibble == null && skyNibble == null) { + continue; -+ } + } + + final SerializableChunkData.SectionData sectionData = new SerializableChunkData.SectionData( + lightSection, chunkSection, @@ -33493,7 +34058,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 + + if (skyNibble != null) { + ((ca.spottedleaf.moonrise.patches.starlight.storage.StarlightSectionData)(Object)sectionData).starlight$setSkyLightState(skyNibble.state); - } ++ } + + sectionsList.add(sectionData); } @@ -33501,7 +34066,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 List list1 = new ArrayList<>(chunk.getBlockEntitiesPos().size()); -@@ -540,7 +629,7 @@ public record SerializableChunkData( +@@ -495,7 +584,7 @@ public record SerializableChunkData( Codec>> codec = makeBiomeCodec(this.biomeRegistry); for (SerializableChunkData.SectionData sectionData : this.sectionData) { @@ -33509,8 +34074,8 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 + CompoundTag compoundTag1 = new CompoundTag(); final CompoundTag sectionNBT = compoundTag1; // Paper - starlight - OBFHELPER LevelChunkSection levelChunkSection = sectionData.chunkSection; if (levelChunkSection != null) { - compoundTag1.put("block_states", BLOCK_STATE_CODEC.encodeStart(NbtOps.INSTANCE, levelChunkSection.getStates()).getOrThrow()); -@@ -555,6 +644,19 @@ public record SerializableChunkData( + compoundTag1.store("block_states", BLOCK_STATE_CODEC, levelChunkSection.getStates()); +@@ -510,6 +599,19 @@ public record SerializableChunkData( compoundTag1.putByteArray("SkyLight", sectionData.skyLight.getData()); } @@ -33530,7 +34095,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 if (!compoundTag1.isEmpty()) { compoundTag1.putByte("Y", (byte)sectionData.y); listTag.add(compoundTag1); -@@ -589,6 +691,14 @@ public record SerializableChunkData( +@@ -544,6 +646,14 @@ public record SerializableChunkData( compoundTag.put("ChunkBukkitValues", this.persistentDataContainer); } // CraftBukkit end @@ -33545,7 +34110,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 return compoundTag; } -@@ -747,6 +857,66 @@ public record SerializableChunkData( +@@ -681,6 +791,66 @@ public record SerializableChunkData( } } @@ -33614,7 +34179,7 @@ index 3b55e7fb27d680204b8621666ae9200870def3eb..879d411775a2fece1d8a970300cb3a55 } } diff --git a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java -index 41ddaceb7485626b1f2ee258c2142eb3114c106e..f883c6400281788982403d0af3ee28613e9a29b1 100644 +index 6be673172548c1382c7402ec4e1ec6ef51f702d3..1d8c151c00ef1192792584b50fe15e102ef46d60 100644 --- a/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java +++ b/net/minecraft/world/level/chunk/storage/SimpleRegionStorage.java @@ -14,7 +14,7 @@ import net.minecraft.util.datafix.DataFixTypes; @@ -33740,10 +34305,10 @@ index 6d61739574155f89511b9adcaf1174841bdc7da7..65728ef17e63d71833677fdcbd5bb907 private ChunkAccess doFill(Blender blender, StructureManager structureManager, RandomState random, ChunkAccess chunk, int minCellY, int cellCountY) { diff --git a/net/minecraft/world/level/levelgen/structure/StructureCheck.java b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -index 06b54c0bec4031689d5c2da5cfea4ef28dbd16bc..f7dc4957b38878ddd3bfc7546be8a4e0af65c807 100644 +index 6a5451440751ad017324e3fec8cfd8efb118511b..48fce0845fb023d6286dac144c285b048d778564 100644 --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -47,8 +47,13 @@ public class StructureCheck { +@@ -48,8 +48,13 @@ public class StructureCheck { private final BiomeSource biomeSource; private final long seed; private final DataFixer fixerUpper; @@ -33759,7 +34324,7 @@ index 06b54c0bec4031689d5c2da5cfea4ef28dbd16bc..f7dc4957b38878ddd3bfc7546be8a4e0 public StructureCheck( ChunkScanAccess storageAccess, -@@ -90,7 +95,7 @@ public class StructureCheck { +@@ -91,7 +96,7 @@ public class StructureCheck { public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); @@ -33768,7 +34333,7 @@ index 06b54c0bec4031689d5c2da5cfea4ef28dbd16bc..f7dc4957b38878ddd3bfc7546be8a4e0 if (map != null) { return this.checkStructureInfo(map, structure, skipKnownStructures); } else { -@@ -100,9 +105,11 @@ public class StructureCheck { +@@ -101,9 +106,11 @@ public class StructureCheck { } else if (!placement.applyAdditionalChunkRestrictions(chunkPos.x, chunkPos.z, this.seed, this.getSaltOverride(structure))) { // Paper - add missing structure seed configs return StructureCheckResult.START_NOT_PRESENT; } else { @@ -33783,7 +34348,7 @@ index 06b54c0bec4031689d5c2da5cfea4ef28dbd16bc..f7dc4957b38878ddd3bfc7546be8a4e0 return !flag ? StructureCheckResult.START_NOT_PRESENT : StructureCheckResult.CHUNK_LOAD_NEEDED; } } -@@ -228,15 +235,25 @@ public class StructureCheck { +@@ -222,15 +229,25 @@ public class StructureCheck { } private void storeFullResults(long chunkPos, Object2IntMap structureChunks) { @@ -34020,7 +34585,7 @@ index ca23af013967b50420ebee178878ea79333de53b..d41b9266625ca6c5e32c5126f35a1f77 public int getLightSectionCount() { diff --git a/net/minecraft/world/level/material/FlowingFluid.java b/net/minecraft/world/level/material/FlowingFluid.java -index 86fd2b831f42bdb5bd045e44b26489d5a8697dd9..e30499bdcd6600e5c9d4a755c1182fb6dff3735f 100644 +index 33fda872d858b3e25636eb999f9559f29855bed6..ace1099a12c762b2e73b71dd3551cf351fedf067 100644 --- a/net/minecraft/world/level/material/FlowingFluid.java +++ b/net/minecraft/world/level/material/FlowingFluid.java @@ -45,6 +45,48 @@ public abstract class FlowingFluid extends Fluid { @@ -34159,7 +34724,7 @@ index 86fd2b831f42bdb5bd045e44b26489d5a8697dd9..e30499bdcd6600e5c9d4a755c1182fb6 public abstract Fluid getFlowing(); public FluidState getFlowing(int level, boolean falling) { -- return this.getFlowing().defaultFluidState().setValue(LEVEL, Integer.valueOf(level)).setValue(FALLING, Boolean.valueOf(falling)); +- return this.getFlowing().defaultFluidState().setValue(LEVEL, level).setValue(FALLING, falling); + // Paper start - fluid method optimisations + final int amount = level; + if (!this.init) { @@ -34173,7 +34738,7 @@ index 86fd2b831f42bdb5bd045e44b26489d5a8697dd9..e30499bdcd6600e5c9d4a755c1182fb6 public abstract Fluid getSource(); public FluidState getSource(boolean falling) { -- return this.getSource().defaultFluidState().setValue(FALLING, Boolean.valueOf(falling)); +- return this.getSource().defaultFluidState().setValue(FALLING, falling); + // Paper start - fluid method optimisations + if (!this.init) { + this.init(); @@ -34184,10 +34749,10 @@ index 86fd2b831f42bdb5bd045e44b26489d5a8697dd9..e30499bdcd6600e5c9d4a755c1182fb6 protected abstract boolean canConvertToSource(ServerLevel level); diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java -index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac560c6ec08 100644 +index 9dda7d19f3f6ca9b402ebe0e4b042ff859b5dcbd..0a5ae623a636923f3bbd3c01974497f39b7c4b62 100644 --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -22,12 +22,30 @@ import net.minecraft.world.level.block.state.properties.Property; +@@ -25,12 +25,30 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.VoxelShape; @@ -34219,7 +34784,7 @@ index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac5 public FluidState(Fluid owner, Reference2ObjectArrayMap, Comparable> values, MapCodec propertiesCodec) { super(owner, values, propertiesCodec); this.isEmpty = owner.isEmpty(); // Paper - Perf: moved from isEmpty() -@@ -38,11 +56,11 @@ public final class FluidState extends StateHolder { +@@ -41,11 +59,11 @@ public final class FluidState extends StateHolder { } public boolean isSource() { @@ -34233,7 +34798,7 @@ index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac5 } public boolean isEmpty() { -@@ -54,11 +72,11 @@ public final class FluidState extends StateHolder { +@@ -57,11 +75,11 @@ public final class FluidState extends StateHolder { } public float getOwnHeight() { @@ -34247,7 +34812,7 @@ index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac5 } public boolean shouldRenderBackwardUpFace(BlockGetter level, BlockPos pos) { -@@ -84,7 +102,7 @@ public final class FluidState extends StateHolder { +@@ -87,7 +105,7 @@ public final class FluidState extends StateHolder { } public boolean isRandomlyTicking() { @@ -34256,7 +34821,7 @@ index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac5 } public void randomTick(ServerLevel level, BlockPos pos, RandomSource random) { -@@ -96,7 +114,12 @@ public final class FluidState extends StateHolder { +@@ -99,7 +117,12 @@ public final class FluidState extends StateHolder { } public BlockState createLegacyBlock() { @@ -34271,10 +34836,10 @@ index d2d71b22666639c003d86a6b6403fcbd2912c5af..481cb46973acb9785fdee5732e98aac5 @Nullable diff --git a/net/minecraft/world/phys/AABB.java b/net/minecraft/world/phys/AABB.java -index 047e1fd078d7f49a2547daeca9eec31306d25dd0..85148858db1fd5e9da8bbdde4b0d84110d80e373 100644 +index f6accdae9fa6c7bd02db92e113eb96fdd2e19d9b..c22acc8889fbb3c9ee698624189c195ee4b5eefb 100644 --- a/net/minecraft/world/phys/AABB.java +++ b/net/minecraft/world/phys/AABB.java -@@ -314,7 +314,7 @@ public class AABB { +@@ -315,7 +315,7 @@ public class AABB { } @Nullable @@ -34284,7 +34849,7 @@ index 047e1fd078d7f49a2547daeca9eec31306d25dd0..85148858db1fd5e9da8bbdde4b0d8411 } diff --git a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java -index adb5f1be35d3a712499076719a1bb819ef52b9a8..39a634e1392239e17818a11750ba869ea7d195ce 100644 +index 4f79538b8127207eae988dfb137d643b7969aafc..31664aeaffd0d891d954a7058e9a49985e23ba02 100644 --- a/net/minecraft/world/phys/shapes/ArrayVoxelShape.java +++ b/net/minecraft/world/phys/shapes/ArrayVoxelShape.java @@ -20,7 +20,7 @@ public class ArrayVoxelShape extends VoxelShape { @@ -34479,10 +35044,10 @@ index f6b6481591e009de80f6b6318d35f193aabb7df3..e9b5069dcd572966b2f5aa220cef30e7 @Override diff --git a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -index 4fc61b329ccb7c9aeb6105dc53d71545a3baea89..309a34f192f7737204ce7a5c3b4004bdd83842f2 100644 +index 8f4c93832c26322c0051043cbd405729075d6e3a..f4efe69ed6c85ea499eefd0bae863ba70ed2d722 100644 --- a/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java +++ b/net/minecraft/world/phys/shapes/DiscreteVoxelShape.java -@@ -3,12 +3,79 @@ package net.minecraft.world.phys.shapes; +@@ -4,12 +4,79 @@ import com.mojang.math.OctahedralGroup; import net.minecraft.core.AxisCycle; import net.minecraft.core.Direction; @@ -34579,10 +35144,10 @@ index ac1488875537421b74f0c491c9b7a40e75539c92..9eb27eb8d6dcaad6ce02f8ce4546acc2 public OffsetDoubleList(DoubleList delegate, double offset) { this.delegate = delegate; diff --git a/net/minecraft/world/phys/shapes/Shapes.java b/net/minecraft/world/phys/shapes/Shapes.java -index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f64460b099b0 100644 +index e6038bbe8513e434daa9ea10bfa817afef0445db..ef3897b88c99bd3f0681ad1747dd77041add821c 100644 --- a/net/minecraft/world/phys/shapes/Shapes.java +++ b/net/minecraft/world/phys/shapes/Shapes.java -@@ -16,9 +16,15 @@ public final class Shapes { +@@ -22,9 +22,15 @@ public final class Shapes { public static final double EPSILON = 1.0E-7; public static final double BIG_EPSILON = 1.0E-6; private static final VoxelShape BLOCK = Util.make(() -> { @@ -34599,9 +35164,9 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 + ); + // Paper end - optimise collisions }); + private static final Vec3 BLOCK_CENTER = new Vec3(0.5, 0.5, 0.5); public static final VoxelShape INFINITY = box( - Double.NEGATIVE_INFINITY, -@@ -43,6 +49,30 @@ public final class Shapes { +@@ -50,6 +56,30 @@ public final class Shapes { return BLOCK; } @@ -34632,7 +35197,7 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 public static VoxelShape box(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { if (!(minX > maxX) && !(minY > maxY) && !(minZ > maxZ)) { return create(minX, minY, minZ, maxX, maxY, maxZ); -@@ -52,39 +82,42 @@ public final class Shapes { +@@ -59,39 +89,42 @@ public final class Shapes { } public static VoxelShape create(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { @@ -34670,10 +35235,7 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 - DoubleArrayList.wrap(new double[]{minX, maxX}), - DoubleArrayList.wrap(new double[]{minY, maxY}), - DoubleArrayList.wrap(new double[]{minZ, maxZ}) -+ minX == 0.0 && maxX == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minX, maxX }), -+ minY == 0.0 && maxY == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minY, maxY }), -+ minZ == 0.0 && maxZ == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minZ, maxZ }) - ); +- ); - } else if (i == 0 && i1 == 0 && i2 == 0) { - return block(); - } else { @@ -34690,7 +35252,10 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 - (int)Math.round(maxX * i3), - (int)Math.round(maxY * i4), - (int)Math.round(maxZ * i5) -- ); ++ minX == 0.0 && maxX == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minX, maxX }), ++ minY == 0.0 && maxY == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minY, maxY }), ++ minZ == 0.0 && maxZ == 1.0 ? ca.spottedleaf.moonrise.patches.collisions.CollisionUtil.ZERO_ONE : DoubleArrayList.wrap(new double[] { minZ, maxZ }) + ); - return new CubeVoxelShape(bitSetDiscreteVoxelShape); } } else { @@ -34701,7 +35266,7 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 } public static VoxelShape create(AABB aabb) { -@@ -120,85 +153,52 @@ public final class Shapes { +@@ -127,85 +160,52 @@ public final class Shapes { } public static VoxelShape or(VoxelShape shape1, VoxelShape... others) { @@ -34824,30 +35389,20 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 } private static boolean joinIsNotEmpty( -@@ -230,52 +230,116 @@ public final class Shapes { +@@ -237,52 +237,113 @@ public final class Shapes { return desiredOffset; } -- public static boolean blockOccudes(VoxelShape shape, VoxelShape adjacentShape, Direction side) { +- public static boolean blockOccludes(VoxelShape shape, VoxelShape adjacentShape, Direction side) { - if (shape == block() && adjacentShape == block()) { + // Paper start - optimise collisions -+ public static boolean blockOccudes(final VoxelShape first, final VoxelShape second, final Direction direction) { -+ final boolean firstBlock = first == BLOCK; -+ final boolean secondBlock = second == BLOCK; -+ -+ if (firstBlock & secondBlock) { ++ public static boolean blockOccludes(final VoxelShape first, final VoxelShape second, final Direction direction) { ++ if (first == BLOCK & second == BLOCK) { return true; - } else if (adjacentShape.isEmpty()) { + } + + if (first.isEmpty() | second.isEmpty()) { -+ return false; -+ } -+ -+ // we optimise getOpposite, so we can use it -+ // secondly, use our cache to retrieve sliced shape -+ final VoxelShape newFirst = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$getFaceShapeClamped(direction); -+ if (newFirst.isEmpty()) { return false; - } else { - Direction.Axis axis = side.getAxis(); @@ -34859,6 +35414,13 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 - && DoubleMath.fuzzyEquals(voxelShape1.min(axis), 0.0, 1.0E-7) - && !joinIsNotEmpty(new SliceShape(voxelShape, axis, voxelShape.shape.getSize(axis) - 1), new SliceShape(voxelShape1, axis, 0), booleanOp); } ++ ++ // we optimise getOpposite, so we can use it ++ // secondly, use our cache to retrieve sliced shape ++ final VoxelShape newFirst = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$getFaceShapeClamped(direction); ++ if (newFirst.isEmpty()) { ++ return false; ++ } + final VoxelShape newSecond = ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$getFaceShapeClamped(direction.getOpposite()); + if (newSecond.isEmpty()) { + return false; @@ -34910,8 +35472,8 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 + public static boolean mergedFaceOccludes(final VoxelShape first, final VoxelShape second, final Direction direction) { + // see if any of the shapes on their own occludes, only if cached + if (((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)first).moonrise$occludesFullBlockIfCached() || ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)second).moonrise$occludesFullBlockIfCached()) { - return true; - } ++ return true; ++ } + + if (first.isEmpty() & second.isEmpty()) { + return false; @@ -34924,8 +35486,8 @@ index e759221fb54aa510d2d8bbba47e1d794367aec6d..5665cfaae4fc9e72b77fd41e16e7f644 + + // see if any of the shapes on their own occludes, only if cached + if (((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)newFirst).moonrise$occludesFullBlockIfCached() || ((ca.spottedleaf.moonrise.patches.collisions.shape.CollisionVoxelShape)newSecond).moonrise$occludesFullBlockIfCached()) { -+ return true; -+ } + return true; + } + + final boolean firstEmpty = newFirst.isEmpty(); + final boolean secondEmpty = newSecond.isEmpty(); @@ -34989,10 +35551,10 @@ index 79f7f04207891dd98cc0b2d93ecb2e07c8baa7b6..7ca12213c10f962ff597a8d51413a17b private static DiscreteVoxelShape makeSlice(DiscreteVoxelShape shape, Direction.Axis axis, int index) { diff --git a/net/minecraft/world/phys/shapes/VoxelShape.java b/net/minecraft/world/phys/shapes/VoxelShape.java -index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36cdac74973 100644 +index 24ef88289162f06c04a6260a08a1665e04c42ebf..08992f072a05e3b3f192459ba433cd70f6b9dd73 100644 --- a/net/minecraft/world/phys/shapes/VoxelShape.java +++ b/net/minecraft/world/phys/shapes/VoxelShape.java -@@ -15,61 +15,546 @@ import net.minecraft.world.phys.AABB; +@@ -16,61 +16,546 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; @@ -35568,7 +36130,7 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c } public VoxelShape move(Vec3 offset) { -@@ -77,20 +562,96 @@ public abstract class VoxelShape { +@@ -82,20 +567,96 @@ public abstract class VoxelShape { } public VoxelShape move(double xOffset, double yOffset, double zOffset) { @@ -35676,7 +36238,7 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c } public void forAllEdges(Shapes.DoubleLineConsumer action) { -@@ -122,9 +683,24 @@ public abstract class VoxelShape { +@@ -127,9 +688,24 @@ public abstract class VoxelShape { } public List toAabbs() { @@ -35704,7 +36266,7 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c } public double min(Direction.Axis axis, double primaryPosition, double secondaryPosition) { -@@ -146,46 +722,92 @@ public abstract class VoxelShape { +@@ -151,46 +727,92 @@ public abstract class VoxelShape { } protected int findIndex(Direction.Axis axis, double position) { @@ -35825,7 +36387,7 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c } public VoxelShape getFaceShape(Direction side) { -@@ -208,19 +830,23 @@ public abstract class VoxelShape { +@@ -213,19 +835,23 @@ public abstract class VoxelShape { } private VoxelShape calculateFace(Direction side) { @@ -35860,7 +36422,7 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c } protected boolean isCubeLike() { -@@ -238,9 +864,30 @@ public abstract class VoxelShape { +@@ -243,9 +869,30 @@ public abstract class VoxelShape { return coords.size() == 2 && DoubleMath.fuzzyEquals(coords.getDouble(0), 0.0, 1.0E-7) && DoubleMath.fuzzyEquals(coords.getDouble(1), 1.0, 1.0E-7); } @@ -35894,19 +36456,19 @@ index 006065c32baf3b1ddc5647196cb9f863c7969064..2c7e70675b62cb753447d2acebf2f36c protected double collideX(AxisCycle movementAxis, AABB collisionBox, double desiredOffset) { if (this.isEmpty()) { diff --git a/net/minecraft/world/ticks/LevelChunkTicks.java b/net/minecraft/world/ticks/LevelChunkTicks.java -index 5b6bd88a5bbbce6cce351938418eba4326e41002..faf45ac459f7c25309d6ef6dce371d484a0dae7b 100644 +index c634d795644be86ad85395ffa39fbac33bf7418b..66d0a6390febe929ef774b0a7813329015bc8cc2 100644 --- a/net/minecraft/world/ticks/LevelChunkTicks.java +++ b/net/minecraft/world/ticks/LevelChunkTicks.java -@@ -17,7 +17,7 @@ import net.minecraft.core.BlockPos; - import net.minecraft.nbt.ListTag; - import net.minecraft.world.level.ChunkPos; +@@ -13,7 +13,7 @@ import java.util.stream.Stream; + import javax.annotation.Nullable; + import net.minecraft.core.BlockPos; -public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess { +public class LevelChunkTicks implements SerializableTickContainer, TickContainerAccess, ca.spottedleaf.moonrise.patches.chunk_system.ticks.ChunkSystemLevelChunkTicks { // Paper - rewrite chunk system private final Queue> tickQueue = new PriorityQueue<>(ScheduledTick.DRAIN_ORDER); @Nullable private List> pendingTicks; -@@ -25,6 +25,30 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -21,6 +21,30 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Nullable private BiConsumer, ScheduledTick> onTickAdded; @@ -35937,7 +36499,7 @@ index 5b6bd88a5bbbce6cce351938418eba4326e41002..faf45ac459f7c25309d6ef6dce371d48 public LevelChunkTicks() { } -@@ -49,7 +73,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -45,7 +69,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon public ScheduledTick poll() { ScheduledTick scheduledTick = this.tickQueue.poll(); if (scheduledTick != null) { @@ -35946,7 +36508,7 @@ index 5b6bd88a5bbbce6cce351938418eba4326e41002..faf45ac459f7c25309d6ef6dce371d48 } return scheduledTick; -@@ -58,7 +82,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -54,7 +78,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon @Override public void schedule(ScheduledTick tick) { if (this.ticksPerPosition.add(tick)) { @@ -35955,7 +36517,7 @@ index 5b6bd88a5bbbce6cce351938418eba4326e41002..faf45ac459f7c25309d6ef6dce371d48 } } -@@ -80,7 +104,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon +@@ -76,7 +100,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon while (iterator.hasNext()) { ScheduledTick scheduledTick = iterator.next(); if (predicate.test(scheduledTick)) { @@ -35964,15 +36526,15 @@ index 5b6bd88a5bbbce6cce351938418eba4326e41002..faf45ac459f7c25309d6ef6dce371d48 this.ticksPerPosition.remove(scheduledTick); } } -@@ -110,6 +134,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - } +@@ -93,6 +117,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon - public ListTag save(long gametime, Function idGetter) { + @Override + public List> pack(long gametime) { + this.lastSaved = gametime; // Paper - rewrite chunk system - ListTag listTag = new ListTag(); - - for (SavedTick savedTick : this.pack(gametime)) { -@@ -121,6 +146,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon + List> list = new ArrayList<>(this.tickQueue.size()); + if (this.pendingTicks != null) { + list.addAll(this.pendingTicks); +@@ -107,6 +132,7 @@ public class LevelChunkTicks implements SerializableTickContainer, TickCon public void unpack(long gameTime) { if (this.pendingTicks != null) { diff --git a/paper-server/patches/features/0017-Fix-entity-tracker-desync-when-new-players-are-added.patch b/paper-server/patches/features/0016-Fix-entity-tracker-desync-when-new-players-are-added.patch similarity index 92% rename from paper-server/patches/features/0017-Fix-entity-tracker-desync-when-new-players-are-added.patch rename to paper-server/patches/features/0016-Fix-entity-tracker-desync-when-new-players-are-added.patch index 4bfb85602..9e490b8a7 100644 --- a/paper-server/patches/features/0017-Fix-entity-tracker-desync-when-new-players-are-added.patch +++ b/paper-server/patches/features/0016-Fix-entity-tracker-desync-when-new-players-are-added.patch @@ -48,10 +48,10 @@ index db31989ebe3d7021cfd2311439e9a00f819b0841..1373977b339405ef59bb3ea03d195285 serverEntity.getLastSentYRot(), entity.getType(), diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 3dff97f13586be3b52bbe786852c185f6753a019..ff6503bf8eb88d1264c3d848a89d0255b4b3ae68 100644 +index 1463c31ba980ab0eb2174e3e891d1423a505e9dc..886340232b58afd59caa6df29e211589a7781070 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1208,6 +1208,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1278,6 +1278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider this.serverEntity.addPairing(player); } // Paper end - entity tracking events @@ -60,10 +60,10 @@ index 3dff97f13586be3b52bbe786852c185f6753a019..ff6503bf8eb88d1264c3d848a89d0255 } else if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index db06f966077928419bfe469260f04d7dfda69f28..0fb253aa55a24b56b17f524b3261c5b75c7d7e59 100644 +index 0005a1784ccaa00e5d6d67e7be98445150487982..257ecbcf7d463eefb951867a5426eaf24e356305 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -90,6 +90,13 @@ public class ServerEntity { +@@ -103,6 +103,13 @@ public class ServerEntity { this.trackedDataValues = entity.getEntityData().getNonDefaultValues(); } @@ -77,7 +77,7 @@ index db06f966077928419bfe469260f04d7dfda69f28..0fb253aa55a24b56b17f524b3261c5b7 public void sendChanges() { // Paper start - optimise collisions if (((ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity)this.entity).moonrise$isHardColliding()) { -@@ -131,7 +138,7 @@ public class ServerEntity { +@@ -136,7 +143,7 @@ public class ServerEntity { this.sendDirtyEntityData(); } @@ -86,7 +86,7 @@ index db06f966077928419bfe469260f04d7dfda69f28..0fb253aa55a24b56b17f524b3261c5b7 byte b = Mth.packDegrees(this.entity.getYRot()); byte b1 = Mth.packDegrees(this.entity.getXRot()); boolean flag = Math.abs(b - this.lastSentYRot) >= 1 || Math.abs(b1 - this.lastSentXRot) >= 1; -@@ -166,7 +173,7 @@ public class ServerEntity { +@@ -171,7 +178,7 @@ public class ServerEntity { long l1 = this.positionCodec.encodeY(vec3); long l2 = this.positionCodec.encodeZ(vec3); boolean flag5 = l < -32768L || l > 32767L || l1 < -32768L || l1 > 32767L || l2 < -32768L || l2 > 32767L; @@ -95,7 +95,7 @@ index db06f966077928419bfe469260f04d7dfda69f28..0fb253aa55a24b56b17f524b3261c5b7 this.wasOnGround = this.entity.onGround(); this.teleportDelay = 0; packet = ClientboundEntityPositionSyncPacket.of(this.entity); -@@ -231,6 +238,7 @@ public class ServerEntity { +@@ -236,6 +243,7 @@ public class ServerEntity { } this.entity.hasImpulse = false; diff --git a/paper-server/patches/features/0018-Eigencraft-redstone-implementation.patch b/paper-server/patches/features/0017-Eigencraft-redstone-implementation.patch similarity index 98% rename from paper-server/patches/features/0018-Eigencraft-redstone-implementation.patch rename to paper-server/patches/features/0017-Eigencraft-redstone-implementation.patch index 9b2677a63..fdb53a27a 100644 --- a/paper-server/patches/features/0018-Eigencraft-redstone-implementation.patch +++ b/paper-server/patches/features/0017-Eigencraft-redstone-implementation.patch @@ -978,10 +978,10 @@ index 0000000000000000000000000000000000000000..ff747a1ecdf3c888bca0d69de4f85dcd + } +} diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d767326d78ea4c 100644 +index cbdf514e190385339476a17c7426c55daec9f2a1..50eceaed6907a596c0c1cd87f5927e07d33a5dbb 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -290,6 +290,60 @@ public class RedStoneWireBlock extends Block { +@@ -265,6 +265,60 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -1042,7 +1042,7 @@ index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d76732 private void updatePowerStrength(Level level, BlockPos pos, BlockState state, @Nullable Orientation orientation, boolean updateShape) { if (useExperimentalEvaluator(level)) { new ExperimentalRedstoneWireEvaluator(this).updatePowerStrength(level, pos, state, orientation, updateShape); -@@ -318,7 +372,7 @@ public class RedStoneWireBlock extends Block { +@@ -293,7 +347,7 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { if (!oldState.is(state.getBlock()) && !level.isClientSide) { @@ -1051,16 +1051,16 @@ index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d76732 for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -337,7 +391,7 @@ public class RedStoneWireBlock extends Block { - level.updateNeighborsAt(pos.relative(direction), this); - } - -- this.updatePowerStrength(level, pos, state, null, false); -+ this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone - this.updateNeighborsOfNeighboringWires(level, pos); +@@ -310,7 +364,7 @@ public class RedStoneWireBlock extends Block { + level.updateNeighborsAt(pos.relative(direction), this); } + +- this.updatePowerStrength(level, pos, state, null, false); ++ this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone + this.updateNeighborsOfNeighboringWires(level, pos); } -@@ -363,7 +417,7 @@ public class RedStoneWireBlock extends Block { + } +@@ -335,7 +389,7 @@ public class RedStoneWireBlock extends Block { if (!level.isClientSide) { if (neighborBlock != this || !useExperimentalEvaluator(level)) { if (state.canSurvive(level, pos)) { @@ -1070,7 +1070,7 @@ index 84e6c986917128d4488afa23d29c689cadb4f55d..f02232ce97779db0d12a5d5da1d76732 dropResources(state, level, pos); level.removeBlock(pos, false); diff --git a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java -index 380fc51a252022195e178daccd8aa53dd1d71a2e..2d77780b6727f82ffc3cb216ca5f2d6483496cfd 100644 +index 3f6f3ca5a5e412e57fad635f52cd152520d6dca2..abcc144a086a45bf4cfa4d1a33e2ae10952e0da2 100644 --- a/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java +++ b/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java @@ -44,7 +44,7 @@ public class DefaultRedstoneWireEvaluator extends RedstoneWireEvaluator { diff --git a/paper-server/patches/features/0019-Add-Alternate-Current-redstone-implementation.patch b/paper-server/patches/features/0018-Add-Alternate-Current-redstone-implementation.patch similarity index 98% rename from paper-server/patches/features/0019-Add-Alternate-Current-redstone-implementation.patch rename to paper-server/patches/features/0018-Add-Alternate-Current-redstone-implementation.patch index e1e8e1cdb..c505fb79b 100644 --- a/paper-server/patches/features/0019-Add-Alternate-Current-redstone-implementation.patch +++ b/paper-server/patches/features/0018-Add-Alternate-Current-redstone-implementation.patch @@ -2326,18 +2326,18 @@ index 0000000000000000000000000000000000000000..298076a0db4e6ee6e4775ac43bf749d9 + } +} diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index a293d1481b5f4a1d18addc3e518486c639223f09..5bf38ab129451e867b638cfbd2d7be59cbf7f38d 100644 +index 8afe96bfdc37e57129f1bb4af5b6d5cc22c11aee..32db2b9e375c12cbf7abab69cc01e8ac2c7c3b6e 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -214,6 +214,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - public final UUID uuid; +@@ -210,6 +210,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + public final java.util.UUID uuid; public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent + private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current) - public LevelChunk getChunkIfLoaded(int x, int z) { - return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately -@@ -2557,6 +2558,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + @Override + public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { +@@ -2552,6 +2553,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.chunkSource.getGenerator().getSeaLevel(); } @@ -2352,12 +2352,12 @@ index a293d1481b5f4a1d18addc3e518486c639223f09..5bf38ab129451e867b638cfbd2d7be59 @Override public void onCreated(Entity entity) { diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index a768f041fd16d253ec4ab5eb75288b1771d5cb00..1dbe7c7c1051c3972105534a07ce50d4cf98fc85 100644 +index eb4d03cfdb34243901cfba832d35559d5be9e876..013ed7dbe2309f562f63e66203179a90566e8115 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -2099,6 +2099,17 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - - public abstract FuelValues fuelValues(); +@@ -2096,6 +2096,17 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl + return 0; + } + // Paper start - optimize redstone (Alternate Current) + public alternate.current.wire.WireHandler getWireHandler() { @@ -2374,10 +2374,10 @@ index a768f041fd16d253ec4ab5eb75288b1771d5cb00..1dbe7c7c1051c3972105534a07ce50d4 NONE("none"), BLOCK("block"), diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b7790ad4d 100644 +index 50eceaed6907a596c0c1cd87f5927e07d33a5dbb..1943a6aad888647953e2d9dbbeedb0bd81c6f9df 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -290,7 +290,7 @@ public class RedStoneWireBlock extends Block { +@@ -265,7 +265,7 @@ public class RedStoneWireBlock extends Block { return state.isFaceSturdy(level, pos, Direction.UP) || state.is(Blocks.HOPPER); } @@ -2386,7 +2386,7 @@ index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b // The bulk of the new functionality is found in RedstoneWireTurbo.java io.papermc.paper.redstone.RedstoneWireTurbo turbo = new io.papermc.paper.redstone.RedstoneWireTurbo(this); -@@ -372,7 +372,13 @@ public class RedStoneWireBlock extends Block { +@@ -347,7 +347,13 @@ public class RedStoneWireBlock extends Block { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { if (!oldState.is(state.getBlock()) && !level.isClientSide) { @@ -2401,22 +2401,22 @@ index f02232ce97779db0d12a5d5da1d767326d78ea4c..12c9d60314c99fb65e640d255a2d0c6b for (Direction direction : Direction.Plane.VERTICAL) { level.updateNeighborsAt(pos.relative(direction), this); -@@ -391,7 +397,13 @@ public class RedStoneWireBlock extends Block { - level.updateNeighborsAt(pos.relative(direction), this); - } - -- this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone -+ // Paper start - optimize redstone - replace call to updatePowerStrength -+ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { -+ level.getWireHandler().onWireRemoved(pos, state); // Alternate Current -+ } else { -+ this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft -+ } -+ // Paper end - optimize redstone - this.updateNeighborsOfNeighboringWires(level, pos); +@@ -364,7 +370,13 @@ public class RedStoneWireBlock extends Block { + level.updateNeighborsAt(pos.relative(direction), this); } + +- this.updateSurroundingRedstone(level, pos, state, null, false); // Paper - Optimize redstone ++ // Paper start - optimize redstone - replace call to updatePowerStrength ++ if (level.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { ++ level.getWireHandler().onWireRemoved(pos, state); // Alternate Current ++ } else { ++ this.updateSurroundingRedstone(level, pos, state, null, false); // Vanilla/Eigencraft ++ } ++ // Paper end - optimize redstone + this.updateNeighborsOfNeighboringWires(level, pos); } -@@ -415,9 +427,15 @@ public class RedStoneWireBlock extends Block { + } +@@ -387,9 +399,15 @@ public class RedStoneWireBlock extends Block { @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { if (!level.isClientSide) { diff --git a/paper-server/patches/features/0020-Improve-exact-choice-recipe-ingredients.patch b/paper-server/patches/features/0019-Improve-exact-choice-recipe-ingredients.patch similarity index 98% rename from paper-server/patches/features/0020-Improve-exact-choice-recipe-ingredients.patch rename to paper-server/patches/features/0019-Improve-exact-choice-recipe-ingredients.patch index 19c90b001..28472a8e3 100644 --- a/paper-server/patches/features/0020-Improve-exact-choice-recipe-ingredients.patch +++ b/paper-server/patches/features/0019-Improve-exact-choice-recipe-ingredients.patch @@ -150,7 +150,7 @@ index 0000000000000000000000000000000000000000..f47c12e9dd6cfa857ca07a764edc22de + } +} diff --git a/net/minecraft/recipebook/ServerPlaceRecipe.java b/net/minecraft/recipebook/ServerPlaceRecipe.java -index 6475509689439636275b06b9eac33f0922d8fcfd..6c398c91909f42e352e80d0781549df9d834a060 100644 +index 6d3e3ec045d5b15a435f7217369968b33e082724..b7a3758af337270737041f84d10eb43784e42279 100644 --- a/net/minecraft/recipebook/ServerPlaceRecipe.java +++ b/net/minecraft/recipebook/ServerPlaceRecipe.java @@ -40,6 +40,7 @@ public class ServerPlaceRecipe> { @@ -204,10 +204,10 @@ index 6475509689439636275b06b9eac33f0922d8fcfd..6c398c91909f42e352e80d0781549df9 int i = this.inventory.findSlotMatchingCraftingIngredient(item, item1); if (i == -1) { diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index 8a29d771046667db22fba166fa5337de1896cd0d..839cbb67d3d38960d9114a4db5bab911b66a573c 100644 +index 24d32c0163d27a7886bd4048d508591b89f714a4..dd406c5becacbc2d05b062726a8af88a1d6faba9 100644 --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -185,12 +185,12 @@ public class Inventory implements Container, Nameable { +@@ -230,12 +230,12 @@ public class Inventory implements Container, Nameable { return !stack.isDamaged() && !stack.isEnchanted() && !stack.has(DataComponents.CUSTOM_NAME); } diff --git a/paper-server/patches/features/0021-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch b/paper-server/patches/features/0020-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch similarity index 98% rename from paper-server/patches/features/0021-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch rename to paper-server/patches/features/0020-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch index ac10e23e4..6f11bc233 100644 --- a/paper-server/patches/features/0021-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch +++ b/paper-server/patches/features/0020-Only-write-chunk-data-to-disk-if-it-serializes-witho.patch @@ -45,7 +45,7 @@ index 984db72272d552c7210bd6f437ea88694ddd2828..dea2823a9d1d69dcb0a4759d8ea9b301 public void close() throws IOException { ByteBuffer byteBuffer = ByteBuffer.wrap(this.buf, 0, this.count); diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index e35bb5534e2fbd2e30154a15ff6d39baa121608f..d263f78fa610ce6f6fb5a0f5e064e3d8335c2199 100644 +index 50bbd8c778bfa9fc9ce93ed09a6fe4dc1f516d51..e9c7e56343238cfce3f4a3c658f2983ca1ef3f0e 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -15,6 +15,7 @@ import net.minecraft.util.ExceptionCollector; diff --git a/paper-server/patches/features/0022-Entity-load-save-limit-per-chunk.patch b/paper-server/patches/features/0021-Entity-load-save-limit-per-chunk.patch similarity index 65% rename from paper-server/patches/features/0022-Entity-load-save-limit-per-chunk.patch rename to paper-server/patches/features/0021-Entity-load-save-limit-per-chunk.patch index 7f3828e1a..85d8aa9cf 100644 --- a/paper-server/patches/features/0022-Entity-load-save-limit-per-chunk.patch +++ b/paper-server/patches/features/0021-Entity-load-save-limit-per-chunk.patch @@ -9,7 +9,7 @@ defaults are only included for certain entites, this allows setting limits for any entity type. diff --git a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java -index 7aea4e343581b977d11af90f9f65eac3532eade1..d21ce54ebb5724c04eadf56a2cde701d5eeb5db2 100644 +index 1c82dcd38f789707e15e8cbec72ef9cdc7efdf56..ba20e87d2105ce53cdaf4049de2388d05fcd1b56 100644 --- a/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java +++ b/ca/spottedleaf/moonrise/patches/chunk_system/level/entity/ChunkEntitySlices.java @@ -104,7 +104,18 @@ public final class ChunkEntitySlices { @@ -32,35 +32,35 @@ index 7aea4e343581b977d11af90f9f65eac3532eade1..d21ce54ebb5724c04eadf56a2cde701d if (entity.save(compoundTag)) { entitiesTag.add(compoundTag); diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 73cdfa5a315ed259b38dfa946a0b7955d9ac9f50..49201d6664656ebe34c84c1c84b5ea4878729062 100644 +index 4c57990c94721dd0973477669e1dadfab5f16404..8af02ed823da098a5592ef195c9fe8ed8f245b53 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1420,9 +1420,20 @@ public class EntityType implements FeatureElement, EntityTypeT - public static Stream loadEntitiesRecursive(final List entityTags, final Level level, final EntitySpawnReason spawnReason) { - final Spliterator spliterator = entityTags.spliterator(); - return StreamSupport.stream(new Spliterator() { -+ final java.util.Map, Integer> loadedEntityCounts = new java.util.HashMap<>(); // Paper - Entity load/save limit per chunk - @Override - public boolean tryAdvance(Consumer consumer) { - return spliterator.tryAdvance(tag -> EntityType.loadEntityRecursive((CompoundTag)tag, level, spawnReason, entity -> { -+ // Paper start - Entity load/save limit per chunk -+ final EntityType entityType = entity.getType(); -+ final int saveLimit = level.paperConfig().chunks.entityPerChunkSaveLimit.getOrDefault(entityType, -1); -+ if (saveLimit > -1) { -+ if (this.loadedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) { -+ return null; -+ } -+ this.loadedEntityCounts.merge(entityType, 1, Integer::sum); -+ } -+ // Paper end - Entity load/save limit per chunk - consumer.accept(entity); - return entity; - })); +@@ -1430,9 +1430,20 @@ public class EntityType implements FeatureElement, EntityTypeT + } + + public static Stream loadEntitiesRecursive(List entityTags, Level level, EntitySpawnReason spawnReason) { ++ final java.util.Map, Integer> loadedEntityCounts = new java.util.HashMap<>(); // Paper - Entity load/save limit per chunk + return entityTags.stream() + .flatMap(tag -> tag.asCompound().stream()) + .mapMulti((compoundTag, consumer) -> loadEntityRecursive(compoundTag, level, spawnReason, entity -> { ++ // Paper start - Entity load/save limit per chunk ++ final EntityType entityType = entity.getType(); ++ final int saveLimit = level.paperConfig().chunks.entityPerChunkSaveLimit.getOrDefault(entityType, -1); ++ if (saveLimit > -1) { ++ if (loadedEntityCounts.getOrDefault(entityType, 0) >= saveLimit) { ++ return null; ++ } ++ loadedEntityCounts.merge(entityType, 1, Integer::sum); ++ } ++ // Paper end - Entity load/save limit per chunk + consumer.accept(entity); + return entity; + })); diff --git a/net/minecraft/world/level/chunk/storage/EntityStorage.java b/net/minecraft/world/level/chunk/storage/EntityStorage.java -index da05fb780c55381a7a08ced51d01764a645740b2..2856206eafddfcbcc1b65408deda40357f43a6f8 100644 +index bcc2a4081fac07c4579c3aabfe4353743f8cd876..f9fb1380be9cbe960127c208c65c19f770e50b6d 100644 --- a/net/minecraft/world/level/chunk/storage/EntityStorage.java +++ b/net/minecraft/world/level/chunk/storage/EntityStorage.java -@@ -93,7 +93,18 @@ public class EntityStorage implements EntityPersistentStorage { +@@ -87,7 +87,18 @@ public class EntityStorage implements EntityPersistentStorage { } } else { ListTag listTag = new ListTag(); diff --git a/paper-server/patches/features/0023-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch b/paper-server/patches/features/0022-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch similarity index 98% rename from paper-server/patches/features/0023-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch rename to paper-server/patches/features/0022-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch index c95c2f25f..1b166b017 100644 --- a/paper-server/patches/features/0023-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch +++ b/paper-server/patches/features/0022-Attempt-to-recalculate-regionfile-header-if-it-is-co.patch @@ -617,7 +617,7 @@ index dea2823a9d1d69dcb0a4759d8ea9b3015ede20dc..0c41177462cca5c4bbab6490e323b953 return byteBuffer; } diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index d263f78fa610ce6f6fb5a0f5e064e3d8335c2199..dad7f94b611cf0fc68b1a3878c458233f6bb6d61 100644 +index e9c7e56343238cfce3f4a3c658f2983ca1ef3f0e..f3ea8b9e8f4510112ec5e41727ebc0cf9ecee195 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -23,6 +23,36 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -686,7 +686,7 @@ index d263f78fa610ce6f6fb5a0f5e064e3d8335c2199..dad7f94b611cf0fc68b1a3878c458233 return var4; diff --git a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java -index 0c739ca5b01ac0ec35a11fd01c5fc65de97c2852..de7deee4b79c969a7797bd57b657a16404c15303 100644 +index 1649119f45d970a9bf1683d676c47ecfc18ad047..cc544f3199cd6af29e50362923d0651705877f16 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileVersion.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileVersion.java @@ -21,7 +21,7 @@ import org.slf4j.Logger; @@ -699,10 +699,10 @@ index 0c739ca5b01ac0ec35a11fd01c5fc65de97c2852..de7deee4b79c969a7797bd57b657a164 public static final RegionFileVersion VERSION_GZIP = register( new RegionFileVersion( diff --git a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -index 879d411775a2fece1d8a970300cb3a550baa6305..6b6aaeca14178b5b709e20ae13552d42217f15c0 100644 +index 03d1527073cf827fc3e191915fe5f7f064e36c3b..749096358fccbd5d1d13801092255c51096eb001 100644 --- a/net/minecraft/world/level/chunk/storage/SerializableChunkData.java +++ b/net/minecraft/world/level/chunk/storage/SerializableChunkData.java -@@ -120,6 +120,18 @@ public record SerializableChunkData( +@@ -122,6 +122,18 @@ public record SerializableChunkData( } } // Paper end - guard against serializing mismatching coordinates @@ -711,17 +711,17 @@ index 879d411775a2fece1d8a970300cb3a550baa6305..6b6aaeca14178b5b709e20ae13552d42 + public static long getLastWorldSaveTime(final CompoundTag chunkData) { + final int dataVersion = ChunkStorage.getVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version -+ final CompoundTag levelData = chunkData.getCompound("Level"); -+ return levelData.getLong("LastUpdate"); ++ final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); ++ return levelData.getLongOr("LastUpdate", 0L); + } else { -+ return chunkData.getLong("LastUpdate"); ++ return chunkData.getLongOr("LastUpdate", 0L); + } + } + // Paper end - Attempt to recalculate regionfile header if it is corrupt // Paper start - Do not let the server load chunks from newer versions private static final int CURRENT_DATA_VERSION = net.minecraft.SharedConstants.getCurrentVersion().getDataVersion().getVersion(); -@@ -604,7 +616,7 @@ public record SerializableChunkData( +@@ -571,7 +583,7 @@ public record SerializableChunkData( compoundTag.putInt("xPos", this.chunkPos.x); compoundTag.putInt("yPos", this.minSectionY); compoundTag.putInt("zPos", this.chunkPos.z); @@ -729,4 +729,4 @@ index 879d411775a2fece1d8a970300cb3a550baa6305..6b6aaeca14178b5b709e20ae13552d42 + compoundTag.putLong("LastUpdate", this.lastUpdateTime); // Paper - Diff on change compoundTag.putLong("InhabitedTime", this.inhabitedTime); compoundTag.putString("Status", BuiltInRegistries.CHUNK_STATUS.getKey(this.chunkStatus).toString()); - if (this.blendingData != null) { + compoundTag.storeNullable("blending_data", BlendingData.Packed.CODEC, this.blendingData); diff --git a/paper-server/patches/features/0024-Incremental-chunk-and-player-saving.patch b/paper-server/patches/features/0023-Incremental-chunk-and-player-saving.patch similarity index 87% rename from paper-server/patches/features/0024-Incremental-chunk-and-player-saving.patch rename to paper-server/patches/features/0023-Incremental-chunk-and-player-saving.patch index 441ccfc6b..4cdfa5a7a 100644 --- a/paper-server/patches/features/0024-Incremental-chunk-and-player-saving.patch +++ b/paper-server/patches/features/0023-Incremental-chunk-and-player-saving.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Incremental chunk and player saving diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 409c1134327bfcc338c3ac5e658a83cc396645d1..cc2d442682496197d29ace79b22e6cf6fb7edf5e 100644 +index 00f7f4356d6bffdd31f58b9d798c755edd9cd3ff..ea85cac4a41075efe8525c40755e7ebac6ca9dea 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -960,7 +960,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop chunks) { +@@ -541,9 +541,18 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + private void tickChunks(ProfilerFiller profiler, long timeInhabited) { profiler.popPush("naturalSpawnCount"); int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount(); - NaturalSpawner.SpawnState spawnState = NaturalSpawner.createState( @@ -77,13 +68,22 @@ index 87d4291a3944f706a694536da6de0f28c548ab8d..5576bf1d1d70ab7a010653d3207909b5 this.lastSpawnState = spawnState; profiler.popPush("spawnAndTick"); boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.players().isEmpty(); // CraftBukkit +@@ -572,7 +581,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + profiler.popPush("shuffleSpawningChunks"); + // Paper start - chunk tick iteration optimisation + this.shuffleRandom.setSeed(this.level.random.nextLong()); +- Util.shuffle(list, this.shuffleRandom); ++ if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled + // Paper end - chunk tick iteration optimisation + profiler.popPush("tickSpawningChunks"); + diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 02fb30a3adf92de0795aee213caf94a228b01ca0..67f6e40216e0be063a3cfb61427f095f7c74d785 100644 +index 8e7ee4dc951eb53ccf65ab71214a0b89bd932ba0..73a450e045eba5dbfc7a4e861e4c614c8f60d6b4 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -375,6 +375,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -403,6 +403,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean queueHealthUpdatePacket; - public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; + public @Nullable net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; // Paper end - cancellable death event + // Paper start - Optional per player mob spawns + public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; @@ -93,10 +93,10 @@ index 02fb30a3adf92de0795aee213caf94a228b01ca0..67f6e40216e0be063a3cfb61427f095f public org.bukkit.craftbukkit.entity.CraftPlayer.TransferCookieConnection transferCookieConnection; public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7efff5a93e03 100644 +index 3a864c568cd66a680760bb4df2cb020e323e9a9d..c710e08ab48075ce7854e56826adb8f0364b025b 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -72,6 +72,14 @@ public final class NaturalSpawner { +@@ -66,6 +66,14 @@ public final class NaturalSpawner { public static NaturalSpawner.SpawnState createState( int spawnableChunkCount, Iterable entities, NaturalSpawner.ChunkGetter chunkGetter, LocalMobCapCalculator calculator ) { @@ -111,7 +111,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff PotentialCalculator potentialCalculator = new PotentialCalculator(); Object2IntOpenHashMap map = new Object2IntOpenHashMap<>(); -@@ -93,11 +101,16 @@ public final class NaturalSpawner { +@@ -87,11 +95,16 @@ public final class NaturalSpawner { potentialCalculator.addCharge(entity.blockPosition(), mobSpawnCost.charge()); } @@ -129,7 +129,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff }); } } -@@ -135,7 +148,7 @@ public final class NaturalSpawner { +@@ -129,7 +142,7 @@ public final class NaturalSpawner { if ((spawnFriendlies || !mobCategory.isFriendly()) && (spawnEnemies || mobCategory.isFriendly()) && (spawnPassives || !mobCategory.isPersistent()) @@ -138,7 +138,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff list.add(mobCategory); // CraftBukkit end } -@@ -149,8 +162,37 @@ public final class NaturalSpawner { +@@ -143,8 +156,37 @@ public final class NaturalSpawner { profilerFiller.push("spawner"); for (MobCategory mobCategory : categories) { @@ -150,8 +150,8 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff + if (level.paperConfig().entities.spawning.perPlayerMobSpawns) { + // Copied from getFilteredSpawningCategories + int limit = mobCategory.getMaxInstancesPerChunk(); -+ SpawnCategory spawnCategory = CraftSpawnCategory.toBukkit(mobCategory); -+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { ++ org.bukkit.entity.SpawnCategory spawnCategory = org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(mobCategory); ++ if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { + limit = level.getWorld().getSpawnLimit(spawnCategory); + } + @@ -178,7 +178,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff } } -@@ -170,9 +212,16 @@ public final class NaturalSpawner { +@@ -164,9 +206,16 @@ public final class NaturalSpawner { public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -196,7 +196,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff } } -@@ -189,6 +238,12 @@ public final class NaturalSpawner { +@@ -183,6 +232,12 @@ public final class NaturalSpawner { NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { @@ -209,7 +209,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); -@@ -252,9 +307,14 @@ public final class NaturalSpawner { +@@ -247,9 +302,14 @@ public final class NaturalSpawner { ++i; ++i3; callback.run(mobForSpawn, chunk); @@ -225,7 +225,7 @@ index 913ea92ace9d610c25bf28f703a3b227044aea63..ef8bacbbb43a9b80281a313ca43b7eff return; } -@@ -565,7 +625,7 @@ public final class NaturalSpawner { +@@ -563,7 +623,7 @@ public final class NaturalSpawner { this.spawnPotential.addCharge(blockPos, d); MobCategory category = type.getCategory(); this.mobCategoryCounts.addTo(category, 1); diff --git a/paper-server/patches/features/0027-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch similarity index 88% rename from paper-server/patches/features/0027-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch rename to paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch index e098cf936..46cd1a1a5 100644 --- a/paper-server/patches/features/0027-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch +++ b/paper-server/patches/features/0026-Improve-cancelling-PreCreatureSpawnEvent-with-per-pl.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Improve cancelling PreCreatureSpawnEvent with per player mob diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 9eed24939fc09f00a9dbce1be2ab9c34d024fd29..b3f498558614243cf633dcd71e3c49c2c55e6e0f 100644 +index 4f4bcc4bbfcc9b191d12d667b8fc1e644a9d5957..0d8aefe8c886eaa4c33cbab53b0ad1c016f0531f 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -255,8 +255,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -262,8 +262,25 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider } } @@ -37,10 +37,10 @@ index 9eed24939fc09f00a9dbce1be2ab9c34d024fd29..b3f498558614243cf633dcd71e3c49c2 // Paper end - Optional per player mob spawns diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 5576bf1d1d70ab7a010653d3207909b5de867e70..6540b2d6a1062d883811ce240c49d30d1925b291 100644 +index f863377a807b672f49f7140688f378eca2cf650b..59e8a5e1b35c81883c9b1ca00c6e55d77584d8cc 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -576,7 +576,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -546,7 +546,17 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled // re-set mob counts for (ServerPlayer player : this.level.players) { @@ -60,10 +60,10 @@ index 5576bf1d1d70ab7a010653d3207909b5de867e70..6540b2d6a1062d883811ce240c49d30d spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true); } else { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 67f6e40216e0be063a3cfb61427f095f7c74d785..3de65c4025be91d938a350c884975cb6edc234d3 100644 +index 73a450e045eba5dbfc7a4e861e4c614c8f60d6b4..105d6b3a40067f9e8ae5bbd9f2872171f73b3d07 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -379,6 +379,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -407,6 +407,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public static final int MOBCATEGORY_TOTAL_ENUMS = net.minecraft.world.entity.MobCategory.values().length; public final int[] mobCounts = new int[MOBCATEGORY_TOTAL_ENUMS]; // Paper end - Optional per player mob spawns @@ -72,10 +72,10 @@ index 67f6e40216e0be063a3cfb61427f095f7c74d785..3de65c4025be91d938a350c884975cb6 public org.bukkit.craftbukkit.entity.CraftPlayer.TransferCookieConnection transferCookieConnection; public String displayName; diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index ef8bacbbb43a9b80281a313ca43b7efff5a93e03..17ce115e887cbbb06ad02ab7ddb488e27342c0e4 100644 +index 17b13baa3465530b11ff918c806c772eb5c39a2c..afd6da5c361e1dcf311a9afe8a7efe2faef2556a 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -285,6 +285,11 @@ public final class NaturalSpawner { +@@ -279,6 +279,11 @@ public final class NaturalSpawner { // Paper start - PreCreatureSpawnEvent PreSpawnStatus doSpawning = isValidSpawnPostitionForType(level, category, structureManager, generator, spawnerData, mutableBlockPos, d2); diff --git a/paper-server/patches/features/0028-Optimize-Hoppers.patch b/paper-server/patches/features/0027-Optimize-Hoppers.patch similarity index 95% rename from paper-server/patches/features/0028-Optimize-Hoppers.patch rename to paper-server/patches/features/0027-Optimize-Hoppers.patch index 3625f8dfc..6aa172b31 100644 --- a/paper-server/patches/features/0028-Optimize-Hoppers.patch +++ b/paper-server/patches/features/0027-Optimize-Hoppers.patch @@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..24a2090e068ad3c0d08705050944abdf + } +} diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index cc2d442682496197d29ace79b22e6cf6fb7edf5e..ae220a732c78ab076261f20b5a54c71d7fceb407 100644 +index ea85cac4a41075efe8525c40755e7ebac6ca9dea..7af29d3dc7b337d74cee5df7cbca35c420643370 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1708,6 +1708,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0; // Paper - BlockPhysicsEvent serverLevel.hasEntityMoveEvent = io.papermc.paper.event.entity.EntityMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Paper - Add EntityMoveEvent serverLevel.updateLagCompensationTick(); // Paper - lag compensation @@ -60,10 +60,10 @@ index cc2d442682496197d29ace79b22e6cf6fb7edf5e..ae220a732c78ab076261f20b5a54c71d /* Drop global time updates if (this.tickCount % 20 == 0) { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index b393be76bead3c66ab0bd8a0e6fd9b9ef81d8e28..76f50437396f8f856381d0fbef52953ef7c263f6 100644 +index 5329dc9259f30011d277336bfc76da18c15d5d81..8391f51b7dd584dd346bda5dccbee900d4fa9c2d 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -827,10 +827,16 @@ public final class ItemStack implements DataComponentHolder { +@@ -832,10 +832,16 @@ public final class ItemStack implements DataComponentHolder { } public ItemStack copy() { @@ -83,18 +83,18 @@ index b393be76bead3c66ab0bd8a0e6fd9b9ef81d8e28..76f50437396f8f856381d0fbef52953e return itemStack; } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index 2ebdf1ad323bb53dfe9eed319e25856b35a1443c..77618757c0e678532dbab814aceed83f7f1cd892 100644 +index 7783ff94e5183737d01c75c521b70b4fbd8c34a6..a1075c26d55cc01219acd94d0138f81aa9d34c48 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -26,6 +26,7 @@ import net.minecraft.world.level.block.state.BlockState; +@@ -33,6 +33,7 @@ import net.minecraft.world.level.block.state.BlockState; import org.slf4j.Logger; public abstract class BlockEntity { + static boolean ignoreBlockEntityUpdates; // Paper - Perf: Optimize Hoppers // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); - public org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; -@@ -196,6 +197,7 @@ public abstract class BlockEntity { + public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; +@@ -202,6 +203,7 @@ public abstract class BlockEntity { public void setChanged() { if (this.level != null) { @@ -103,10 +103,10 @@ index 2ebdf1ad323bb53dfe9eed319e25856b35a1443c..77618757c0e678532dbab814aceed83f } } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78fa880b4cd 100644 +index 9a03934dd4d96184f37b9ff5661eb7bd76150464..15d4f60942c0cc612c1468b4c0fda886867a67cb 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -139,18 +139,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -143,18 +143,56 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } } @@ -166,7 +166,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f } if (flag) { -@@ -174,6 +212,206 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -178,6 +216,206 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen return true; } @@ -373,7 +373,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) { Container attachedContainer = getAttachedContainer(level, pos, blockEntity); if (attachedContainer == null) { -@@ -183,57 +421,60 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -187,57 +425,60 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (isFullContainer(attachedContainer, opposite)) { return false; } else { @@ -485,7 +485,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f } } } -@@ -288,6 +529,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -292,6 +533,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen Container sourceContainer = getSourceContainer(level, hopper, blockPos, blockState); if (sourceContainer != null) { Direction direction = Direction.DOWN; @@ -493,7 +493,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f for (int i : getSlots(sourceContainer, direction)) { if (tryTakeInItemFromSlot(hopper, sourceContainer, i, direction, level)) { // Spigot -@@ -313,55 +555,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -317,55 +559,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private static boolean tryTakeInItemFromSlot(Hopper hopper, Container container, int slot, Direction direction, Level level) { // Spigot ItemStack item = container.getItem(slot); if (!item.isEmpty() && canTakeItemFromContainer(hopper, container, item, slot, direction)) { @@ -601,7 +601,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f } return false; -@@ -370,13 +615,15 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -374,13 +619,15 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean addItem(Container container, ItemEntity item) { boolean flag = false; // CraftBukkit start @@ -618,7 +618,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f ItemStack itemStack = item.getItem().copy(); ItemStack itemStack1 = addItem(null, container, itemStack, null); if (itemStack1.isEmpty()) { -@@ -431,7 +678,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -435,7 +682,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen stack = stack.split(destination.getMaxStackSize()); } // Spigot end @@ -628,7 +628,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f stack = leftover; // Paper - Make hoppers respect inventory max stack size flag = true; } else if (canMergeItems(item, stack)) { -@@ -519,13 +768,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -523,13 +772,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable public static Container getContainerAt(Level level, BlockPos pos) { @@ -650,7 +650,7 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f blockContainer = getEntityContainer(level, x, y, z); } -@@ -551,14 +806,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -555,14 +810,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Nullable private static Container getEntityContainer(Level level, double x, double y, double z) { @@ -669,10 +669,10 @@ index e58a32593e8b42bfc534d13457240860293dd3f4..5cd1326ad5d046c88b2b3449d610a78f @Override diff --git a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -index 73b3ddb120d6b6f89e478960e78bed415baea205..f9c31da81d84033abfc1179fc643bceffe35da17 100644 +index 1c98d003907feb16de8f26377fceedf728afe7fb..eed5f8f912544b79c8ed54dcdc5eeacb6dcfaccd 100644 --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -53,7 +53,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc +@@ -54,7 +54,7 @@ public abstract class RandomizableContainerBlockEntity extends BaseContainerBloc @Override public ItemStack getItem(int index) { diff --git a/paper-server/patches/features/0030-Flush-regionfiles-on-save-configuration-option.patch b/paper-server/patches/features/0028-Flush-regionfiles-on-save-configuration-option.patch similarity index 100% rename from paper-server/patches/features/0030-Flush-regionfiles-on-save-configuration-option.patch rename to paper-server/patches/features/0028-Flush-regionfiles-on-save-configuration-option.patch diff --git a/paper-server/patches/features/0029-Optimise-collision-checking-in-player-move-packet-ha.patch b/paper-server/patches/features/0029-Optimise-collision-checking-in-player-move-packet-ha.patch index 5f5108129..8dce7a440 100644 --- a/paper-server/patches/features/0029-Optimise-collision-checking-in-player-move-packet-ha.patch +++ b/paper-server/patches/features/0029-Optimise-collision-checking-in-player-move-packet-ha.patch @@ -6,27 +6,27 @@ Subject: [PATCH] Optimise collision checking in player move packet handling Move collision logic to just the hasNewCollision call instead of getCubes + hasNewCollision diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 12c83cb084563a4e3f7f357d8b600941544ef2b0..90e582ca30851857add5e2d830e9876667fd1807 100644 +index 5e921c490814be31fc2843327c0e2cc76bda6620..f49a2c18ec20a7181951389066b7d062b48d43fa 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -563,7 +563,7 @@ public class ServerGamePacketListenerImpl +@@ -555,7 +555,7 @@ public class ServerGamePacketListenerImpl return; } - boolean flag = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625)); -+ AABB oldBox = rootVehicle.getBoundingBox(); // Paper - copy from player movement packet ++ final AABB oldBox = rootVehicle.getBoundingBox(); // Paper - copy from player movement packet d3 = d - this.vehicleLastGoodX; // Paper - diff on change, used for checking large move vectors above d4 = d1 - this.vehicleLastGoodY; // Paper - diff on change, used for checking large move vectors above d5 = d2 - this.vehicleLastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -573,6 +573,7 @@ public class ServerGamePacketListenerImpl +@@ -565,6 +565,7 @@ public class ServerGamePacketListenerImpl } rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); -+ boolean didCollide = toX != rootVehicle.getX() || toY != rootVehicle.getY() || toZ != rootVehicle.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be... - double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source ++ final boolean didCollide = toX != rootVehicle.getX() || toY != rootVehicle.getY() || toZ != rootVehicle.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be... + double verticalDelta = d4; // Paper - Decompile fix: lvt reassignment lost d3 = d - rootVehicle.getX(); d4 = d1 - rootVehicle.getY(); -@@ -584,14 +585,22 @@ public class ServerGamePacketListenerImpl +@@ -576,14 +577,22 @@ public class ServerGamePacketListenerImpl d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag2 = false; if (d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot @@ -35,24 +35,24 @@ index 12c83cb084563a4e3f7f357d8b600941544ef2b0..90e582ca30851857add5e2d830e98766 LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7)); } - rootVehicle.absMoveTo(d, d1, d2, f, f1); - this.player.absMoveTo(d, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + rootVehicle.absSnapTo(d, d1, d2, f, f1); + this.player.absSnapTo(d, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit - boolean flag3 = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625)); - if (flag && (flag2 || !flag3)) { + // Paper start - optimise out extra getCubes + boolean teleportBack = flag2; // violating this is always a fail + if (!teleportBack) { + // note: only call after setLocation, or else getBoundingBox is wrong -+ AABB newBox = rootVehicle.getBoundingBox(); ++ final AABB newBox = rootVehicle.getBoundingBox(); + if (didCollide || !oldBox.equals(newBox)) { + teleportBack = this.hasNewCollision(serverLevel, rootVehicle, oldBox, newBox); + } // else: no collision at all detected, why do we care? + } + if (teleportBack) { // Paper end - optimise out extra getCubes - rootVehicle.absMoveTo(x, y, z, f, f1); - this.player.absMoveTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + rootVehicle.absSnapTo(x, y, z, f, f1); + this.player.absSnapTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle)); -@@ -669,9 +678,32 @@ public class ServerGamePacketListenerImpl +@@ -661,9 +670,32 @@ public class ServerGamePacketListenerImpl } private boolean noBlocksAround(Entity entity) { @@ -60,22 +60,22 @@ index 12c83cb084563a4e3f7f357d8b600941544ef2b0..90e582ca30851857add5e2d830e98766 - .getBlockStates(entity.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0)) - .allMatch(BlockBehaviour.BlockStateBase::isAir); + // Paper start - stop using streams, this is already a known fixed problem in Entity#move -+ AABB box = entity.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0); -+ int minX = Mth.floor(box.minX); -+ int minY = Mth.floor(box.minY); -+ int minZ = Mth.floor(box.minZ); -+ int maxX = Mth.floor(box.maxX); -+ int maxY = Mth.floor(box.maxY); -+ int maxZ = Mth.floor(box.maxZ); ++ final AABB box = entity.getBoundingBox().inflate(0.0625).expandTowards(0.0, -0.55, 0.0); ++ final int minX = Mth.floor(box.minX); ++ final int minY = Mth.floor(box.minY); ++ final int minZ = Mth.floor(box.minZ); ++ final int maxX = Mth.floor(box.maxX); ++ final int maxY = Mth.floor(box.maxY); ++ final int maxZ = Mth.floor(box.maxZ); + -+ Level level = entity.level(); -+ BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); ++ final Level level = entity.level(); ++ final BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos(); + + for (int y = minY; y <= maxY; ++y) { + for (int z = minZ; z <= maxZ; ++z) { + for (int x = minX; x <= maxX; ++x) { + pos.set(x, y, z); -+ BlockState blockState = level.getBlockStateIfLoaded(pos); ++ final BlockState blockState = level.getBlockStateIfLoaded(pos); + if (blockState != null && !blockState.isAir()) { + return false; + } @@ -88,43 +88,43 @@ index 12c83cb084563a4e3f7f357d8b600941544ef2b0..90e582ca30851857add5e2d830e98766 } @Override -@@ -1371,7 +1403,7 @@ public class ServerGamePacketListenerImpl +@@ -1430,7 +1462,7 @@ public class ServerGamePacketListenerImpl + } } - } -- AABB boundingBox = this.player.getBoundingBox(); -+ AABB boundingBox = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB - d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above - d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above - d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above -@@ -1410,6 +1442,7 @@ public class ServerGamePacketListenerImpl - boolean flag1 = this.player.verticalCollisionBelow; - this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); - this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move -+ boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be... - // Paper start - prevent position desync - if (this.awaitingPositionFromClient != null) { - return; // ... thanks Mojang for letting move calls teleport across dimensions. -@@ -1442,7 +1475,17 @@ public class ServerGamePacketListenerImpl - } +- AABB boundingBox = this.player.getBoundingBox(); ++ AABB boundingBox = this.player.getBoundingBox(); // Paper - diff on change, should be old AABB + d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above + d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above + d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above +@@ -1469,6 +1501,7 @@ public class ServerGamePacketListenerImpl + boolean flag1 = this.player.verticalCollisionBelow; + this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); + this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move ++ final boolean didCollide = toX != this.player.getX() || toY != this.player.getY() || toZ != this.player.getZ(); // Paper - needed here as the difference in Y can be reset - also note: this is only a guess at whether collisions took place, floating point errors can make this true when it shouldn't be... + // Paper start - prevent position desync + if (this.awaitingPositionFromClient != null) { + return; // ... thanks Mojang for letting move calls teleport across dimensions. +@@ -1501,7 +1534,17 @@ public class ServerGamePacketListenerImpl + } - // Paper start - Add fail move event -- boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && serverLevel.noCollision(this.player, boundingBox) || this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)); -+ // Paper start - optimise out extra getCubes -+ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && movedWrongly; -+ this.player.absMoveTo(d, d1, d2, f, f1); // prevent desync by tping to the set position, dropped for unknown reasons by mojang -+ if (!this.player.noPhysics && !this.player.isSleeping() && !teleportBack) { -+ AABB newBox = this.player.getBoundingBox(); -+ if (didCollide || !boundingBox.equals(newBox)) { -+ // note: only call after setLocation, or else getBoundingBox is wrong -+ teleportBack = this.hasNewCollision(serverLevel, this.player, boundingBox, newBox); -+ } // else: no collision at all detected, why do we care? -+ } -+ // Paper end - optimise out extra getCubes - if (teleportBack) { - io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, - toX, toY, toZ, toYaw, toPitch, false); -@@ -1578,7 +1621,7 @@ public class ServerGamePacketListenerImpl + // Paper start - Add fail move event +- boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && serverLevel.noCollision(this.player, boundingBox) || this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)); ++ // Paper start - optimise out extra getCubes ++ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && movedWrongly; ++ this.player.absSnapTo(d, d1, d2, f, f1); // prevent desync by tping to the set position, dropped for unknown reasons by mojang ++ if (!this.player.noPhysics && !this.player.isSleeping() && !teleportBack) { ++ final AABB newBox = this.player.getBoundingBox(); ++ if (didCollide || !boundingBox.equals(newBox)) { ++ // note: only call after setLocation, or else getBoundingBox is wrong ++ teleportBack = this.hasNewCollision(serverLevel, this.player, boundingBox, newBox); ++ } // else: no collision at all detected, why do we care? ++ } ++ // Paper end - optimise out extra getCubes + if (teleportBack) { + io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, + toX, toY, toZ, toYaw, toPitch, false); +@@ -1638,7 +1681,7 @@ public class ServerGamePacketListenerImpl private boolean updateAwaitingTeleport() { if (this.awaitingPositionFromClient != null) { @@ -133,7 +133,7 @@ index 12c83cb084563a4e3f7f357d8b600941544ef2b0..90e582ca30851857add5e2d830e98766 this.awaitingTeleportTime = this.tickCount; this.teleport( this.awaitingPositionFromClient.x, -@@ -1597,6 +1640,33 @@ public class ServerGamePacketListenerImpl +@@ -1657,6 +1700,33 @@ public class ServerGamePacketListenerImpl } } diff --git a/paper-server/patches/features/0031-Do-not-record-movement-for-vehicles-players-unaffect.patch b/paper-server/patches/features/0031-Do-not-record-movement-for-vehicles-players-unaffect.patch deleted file mode 100644 index 72a1e59c2..000000000 --- a/paper-server/patches/features/0031-Do-not-record-movement-for-vehicles-players-unaffect.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf -Date: Sun, 2 Feb 2025 10:57:48 -0800 -Subject: [PATCH] Do not record movement for vehicles/players unaffected by - blocks - -If the player is not affected by movement through blocks, then -storing the movement would eventually invoke logic to apply effects -caused by moving through such blocks. For example, moving through -a portal in spectator mode and then later switching to creative mode -would portal the player. - -diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 90e582ca30851857add5e2d830e9876667fd1807..c569cdfa4cba4f65892ffd4045c611837049f440 100644 ---- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java -+++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -659,7 +659,7 @@ public class ServerGamePacketListenerImpl - // CraftBukkit end - - this.player.serverLevel().getChunkSource().move(this.player); -- rootVehicle.recordMovementThroughBlocks(new Vec3(x, y, z), rootVehicle.position()); -+ if (!rootVehicle.isSpectator() && rootVehicle.isAffectedByBlocks()) rootVehicle.recordMovementThroughBlocks(new Vec3(x, y, z), rootVehicle.position()); // Paper - Do not record movement for vehicles/players unaffected by blocks - Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); - this.handlePlayerKnownMovement(vec3); - rootVehicle.setOnGroundWithMovement(packet.onGround(), vec3); -@@ -1577,7 +1577,7 @@ public class ServerGamePacketListenerImpl - Vec3 vec3 = new Vec3(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z); - this.player.setOnGroundWithMovement(packet.isOnGround(), packet.horizontalCollision(), vec3); - this.player.doCheckFallDamage(vec3.x, vec3.y, vec3.z, packet.isOnGround()); -- this.player.recordMovementThroughBlocks(new Vec3(x, y, z), this.player.position()); -+ if (!this.player.isSpectator() && this.player.isAffectedByBlocks()) this.player.recordMovementThroughBlocks(new Vec3(x, y, z), this.player.position()); // Paper - Do not record movement for vehicles/players unaffected by blocks - this.handlePlayerKnownMovement(vec3); - if (flag) { - this.player.resetFallDistance(); diff --git a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java.patch b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java.patch index 183594148..3f95b375a 100644 --- a/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java.patch +++ b/paper-server/patches/sources/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/ca/spottedleaf/moonrise/paper/util/BaseChunkSystemHooks.java -@@ -1,0 +_,332 @@ +@@ -1,0 +_,330 @@ +package ca.spottedleaf.moonrise.paper.util; + +import ca.spottedleaf.concurrentutil.util.Priority; @@ -28,7 +28,7 @@ + + private static final Logger LOGGER = LogUtils.getLogger(); + private static final ChunkStep FULL_CHUNK_STEP = ChunkPyramid.GENERATION_PYRAMID.getStepTo(ChunkStatus.FULL); -+ private static final TicketType CHUNK_LOAD = TicketType.create("chunk_load", Long::compareTo); ++ private static final TicketType CHUNK_LOAD = TicketType.CHUNK_LOAD; + + private long chunkLoadCounter = 0L; + @@ -82,11 +82,10 @@ + } + + final int minLevel = 33 + getDistance(toStatus); -+ final Long chunkReference = addTicket ? Long.valueOf(++this.chunkLoadCounter) : null; + final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); + + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); ++ level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + level.chunkSource.runDistanceManagerUpdates(); + @@ -100,8 +99,8 @@ + com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); + } finally { + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel, chunkPos); -+ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); ++ level.chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.UNKNOWN, chunkPos, minLevel); ++ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + } + }; @@ -149,11 +148,10 @@ + + final int minLevel = 33 - (toStatus.ordinal() - 1); + final int radius = toStatus.ordinal() - 1; -+ final Long chunkReference = addTicket ? Long.valueOf(++this.chunkLoadCounter) : null; + final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); + + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); ++ level.chunkSource.addTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + level.chunkSource.runDistanceManagerUpdates(); + @@ -167,8 +165,8 @@ + com.destroystokyo.paper.util.SneakyThrow.sneaky(thr); + } finally { + if (addTicket) { -+ level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel, chunkPos); -+ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel, chunkReference); ++ level.chunkSource.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, minLevel); ++ level.chunkSource.removeTicketAtLevel(CHUNK_LOAD, chunkPos, minLevel); + } + } + }; diff --git a/paper-server/patches/sources/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java.patch b/paper-server/patches/sources/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java.patch index 3d5dbbd31..c57087812 100644 --- a/paper-server/patches/sources/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java.patch +++ b/paper-server/patches/sources/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java.patch @@ -1,6 +1,6 @@ --- a/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java +++ b/com/mojang/authlib/yggdrasil/YggdrasilGameProfileRepository.java -@@ -44,6 +_,7 @@ +@@ -47,6 +_,7 @@ .collect(Collectors.toSet()); final int page = 0; @@ -8,7 +8,7 @@ for (final List request : Iterables.partition(criteria, ENTRIES_PER_PAGE)) { final List normalizedRequest = request.stream().map(YggdrasilGameProfileRepository::normalizeName).toList(); -@@ -75,6 +_,12 @@ +@@ -78,6 +_,12 @@ LOGGER.debug("Couldn't find profile {}", name); callback.onProfileLookupFailed(name, new ProfileNotFoundException("Server did not find the requested profile")); } diff --git a/paper-server/patches/sources/com/mojang/logging/LogUtils.java.patch b/paper-server/patches/sources/com/mojang/logging/LogUtils.java.patch index b05ea2c1e..d9dae21fb 100644 --- a/paper-server/patches/sources/com/mojang/logging/LogUtils.java.patch +++ b/paper-server/patches/sources/com/mojang/logging/LogUtils.java.patch @@ -1,9 +1,10 @@ --- a/com/mojang/logging/LogUtils.java +++ b/com/mojang/logging/LogUtils.java -@@ -61,4 +_,9 @@ +@@ -61,4 +_,10 @@ public static Logger getLogger() { return LoggerFactory.getLogger(STACK_WALKER.getCallerClass()); } ++ + // Paper start + public static Logger getClassLogger() { + return LoggerFactory.getLogger(STACK_WALKER.getCallerClass().getSimpleName()); diff --git a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch index 671c030fa..b699e0d32 100644 --- a/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch +++ b/paper-server/patches/sources/com/mojang/math/OctahedralGroup.java.patch @@ -1,28 +1,34 @@ --- a/com/mojang/math/OctahedralGroup.java +++ b/com/mojang/math/OctahedralGroup.java -@@ -111,6 +_,7 @@ - this.permutation = permutation; - this.transformation = new Matrix3f().scaling(invertX ? -1.0F : 1.0F, invertY ? -1.0F : 1.0F, invertZ ? -1.0F : 1.0F); - this.transformation.mul(permutation.transformation()); -+ this.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields - } +@@ -123,6 +_,12 @@ + } + ); - private BooleanList packInversions() { -@@ -139,7 +_,7 @@ ++ static { ++ for (OctahedralGroup octahedralGroup : values()) { ++ octahedralGroup.initializeRotationDirections(); // Paper - Avoid Lazy Initialization for Enum Fields ++ } ++ } ++ + private OctahedralGroup(final String name, final SymmetricGroup3 permutation, final boolean invertX, final boolean invertY, final boolean invertZ) { + this.name = name; + this.invertX = invertX; +@@ -160,7 +_,7 @@ return this.name; } - public Direction rotate(Direction direction) { + public void initializeRotationDirections() { // Paper - Avoid Lazy Initialization for Enum Fields if (this.rotatedDirections == null) { - this.rotatedDirections = Maps.newEnumMap(Direction.class); - Direction.Axis[] axiss = Direction.Axis.values(); -@@ -154,6 +_,10 @@ - } + this.rotatedDirections = Util.makeEnumMap(Direction.class, direction1 -> { + Direction.Axis axis = direction1.getAxis(); +@@ -171,6 +_,11 @@ + }); } + // Paper start - Avoid Lazy Initialization for Enum Fields + } ++ + public Direction rotate(Direction direction) { + // Paper end - Avoid Lazy Initialization for Enum Fields return this.rotatedDirections.get(direction); diff --git a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch index c86ccb1d6..cdbc56fdd 100644 --- a/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch +++ b/paper-server/patches/sources/io/papermc/paper/FeatureHooks.java.patch @@ -1,6 +1,6 @@ --- /dev/null +++ b/io/papermc/paper/FeatureHooks.java -@@ -1,0 +_,234 @@ +@@ -1,0 +_,238 @@ +package io.papermc.paper; + +import io.papermc.paper.command.PaperSubcommand; @@ -139,16 +139,16 @@ + public static java.util.Collection getPluginChunkTickets(net.minecraft.server.level.ServerLevel world, + int x, int z) { + net.minecraft.server.level.DistanceManager chunkDistanceManager = world.getChunkSource().chunkMap.distanceManager; -+ net.minecraft.util.SortedArraySet> tickets = chunkDistanceManager.tickets.get(ChunkPos.asLong(x, z)); ++ List tickets = chunkDistanceManager.ticketStorage.tickets.get(ChunkPos.asLong(x, z)); + + if (tickets == null) { + return java.util.Collections.emptyList(); + } + + com.google.common.collect.ImmutableList.Builder ret = com.google.common.collect.ImmutableList.builder(); -+ for (net.minecraft.server.level.Ticket ticket : tickets) { ++ for (net.minecraft.server.level.Ticket ticket : tickets) { + if (ticket.getType() == net.minecraft.server.level.TicketType.PLUGIN_TICKET) { -+ ret.add((org.bukkit.plugin.Plugin) ticket.key); ++ ret.add((org.bukkit.plugin.Plugin) ticket.getIdentifier()); + } + } + @@ -159,12 +159,12 @@ + Map> ret = new HashMap<>(); + net.minecraft.server.level.DistanceManager chunkDistanceManager = world.getChunkSource().chunkMap.distanceManager; + -+ for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry>> chunkTickets : chunkDistanceManager.tickets.long2ObjectEntrySet()) { ++ for (it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry> chunkTickets : chunkDistanceManager.ticketStorage.tickets.long2ObjectEntrySet()) { + long chunkKey = chunkTickets.getLongKey(); -+ net.minecraft.util.SortedArraySet> tickets = chunkTickets.getValue(); ++ List tickets = chunkTickets.getValue(); + + org.bukkit.Chunk chunk = null; -+ for (net.minecraft.server.level.Ticket ticket : tickets) { ++ for (net.minecraft.server.level.Ticket ticket : tickets) { + if (ticket.getType() != net.minecraft.server.level.TicketType.PLUGIN_TICKET) { + continue; + } @@ -173,7 +173,7 @@ + chunk = world.getWorld().getChunkAt(ChunkPos.getX(chunkKey), ChunkPos.getZ(chunkKey)); + } + -+ ret.computeIfAbsent((org.bukkit.plugin.Plugin) ticket.key, (key) -> com.google.common.collect.ImmutableList.builder()).add(chunk); ++ ret.computeIfAbsent((org.bukkit.plugin.Plugin) ticket.getIdentifier(), (key) -> com.google.common.collect.ImmutableList.builder()).add(chunk); + } + } + @@ -215,7 +215,11 @@ + } + + public static void closeEntityManager(net.minecraft.server.level.ServerLevel world, boolean save) { -+ world.entityManager.close(save); ++ try { ++ world.entityManager.close(save); ++ } catch (final java.io.IOException exception) { ++ throw new RuntimeException("Failed to close entity manager", exception); ++ } + } + + public static java.util.concurrent.Executor getWorldgenExecutor() { diff --git a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch index 658c5707e..a2a9d43ba 100644 --- a/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch +++ b/paper-server/patches/sources/net/minecraft/ChatFormatting.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/ChatFormatting.java +++ b/net/minecraft/ChatFormatting.java -@@ -112,6 +_,19 @@ +@@ -118,6 +_,19 @@ return friendlyName == null ? null : FORMATTING_BY_NAME.get(cleanName(friendlyName)); } + // Paper start - add method to get by hex value + @Nullable -+ public static ChatFormatting getByHexValue(int i) { ++ public static ChatFormatting getByHexValue(int color) { + for (ChatFormatting value : values()) { -+ if (value.getColor() != null && value.getColor() == i) { ++ if (value.getColor() != null && value.getColor() == color) { + return value; + } + } diff --git a/paper-server/patches/sources/net/minecraft/Util.java.patch b/paper-server/patches/sources/net/minecraft/Util.java.patch index ebf86ad6c..355d8b2d5 100644 --- a/paper-server/patches/sources/net/minecraft/Util.java.patch +++ b/paper-server/patches/sources/net/minecraft/Util.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/Util.java +++ b/net/minecraft/Util.java -@@ -92,9 +_,26 @@ +@@ -93,9 +_,26 @@ private static final int DEFAULT_MAX_THREADS = 255; private static final int DEFAULT_SAFE_FILE_OPERATION_RETRIES = 10; private static final String MAX_THREADS_SYSTEM_PROPERTY = "max.bg.threads"; @@ -28,7 +28,7 @@ private static final DateTimeFormatter FILENAME_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH.mm.ss", Locale.ROOT); public static final int LINEAR_LOOKUP_THRESHOLD = 8; private static final Set ALLOWED_UNTRUSTED_LINK_PROTOCOLS = Set.of("http", "https"); -@@ -113,6 +_,7 @@ +@@ -114,6 +_,7 @@ .findFirst() .orElseThrow(() -> new IllegalStateException("No jar file system provider found")); private static Consumer thePauser = string -> {}; @@ -36,7 +36,7 @@ public static Collector, ?, Map> toMap() { return Collectors.toMap(Entry::getKey, Entry::getValue); -@@ -135,7 +_,7 @@ +@@ -136,7 +_,7 @@ } public static long getNanos() { @@ -45,7 +45,7 @@ } public static long getEpochMillis() { -@@ -146,9 +_,10 @@ +@@ -147,9 +_,10 @@ return FILENAME_DATE_TIME_FORMATTER.format(ZonedDateTime.now()); } @@ -58,7 +58,7 @@ if (i <= 0) { directExecutorService = MoreExecutors.newDirectExecutorService(); } else { -@@ -173,16 +_,30 @@ +@@ -174,16 +_,30 @@ super.onTermination(throwOnTermination); } }; @@ -91,7 +91,7 @@ } private static int getMaxThreads() { -@@ -233,6 +_,21 @@ +@@ -234,6 +_,21 @@ })); } @@ -113,7 +113,7 @@ public static void throwAsRuntime(Throwable throwable) { throw throwable instanceof RuntimeException ? (RuntimeException)throwable : new RuntimeException(throwable); } -@@ -1075,16 +_,7 @@ +@@ -1088,16 +_,7 @@ } public void openUri(URI uri) { diff --git a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch index 488821280..b008af84c 100644 --- a/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/CommandSourceStack.java.patch @@ -18,11 +18,10 @@ public CommandSourceStack( CommandSource source, -@@ -187,6 +_,30 @@ - this.chatMessageChainer +@@ -188,6 +_,30 @@ ); } -+ + + // Paper start - Expose 'with' functions from the CommandSourceStack + @Override + public CommandSourceStack withLocation(org.bukkit.Location location) { @@ -46,9 +45,10 @@ + ); + } + // Paper end - Expose 'with' functions from the CommandSourceStack - ++ public CommandSourceStack withRotation(Vec2 rotation) { return this.rotation.equals(rotation) + ? this @@ -391,9 +_,44 @@ @Override @@ -94,7 +94,7 @@ public Vec3 getPosition() { return this.worldPosition; } -@@ -499,20 +_,25 @@ +@@ -498,20 +_,25 @@ Component component = Component.translatable("chat.type.admin", this.getDisplayName(), message).withStyle(ChatFormatting.GRAY, ChatFormatting.ITALIC); if (this.server.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)) { for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -123,7 +123,7 @@ } } -@@ -523,7 +_,7 @@ +@@ -522,7 +_,7 @@ @Override public Collection getOnlinePlayerNames() { @@ -132,7 +132,7 @@ } @Override -@@ -598,4 +_,16 @@ +@@ -597,4 +_,16 @@ public boolean isSilent() { return this.silent; } diff --git a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch index 119e3eb76..440074ebe 100644 --- a/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch +++ b/paper-server/patches/sources/net/minecraft/commands/Commands.java.patch @@ -127,7 +127,7 @@ StackTraceElement[] stackTrace = var12.getStackTrace(); for (int i = 0; i < Math.min(stackTrace.length, 3); i++) { -@@ -309,18 +_,22 @@ +@@ -308,18 +_,22 @@ } @Nullable @@ -148,12 +148,12 @@ int min = Math.min(var7.getInput().length(), var7.getCursor()); MutableComponent mutableComponent = Component.empty() .withStyle(ChatFormatting.GRAY) -- .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + command))); -+ .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label))); // CraftBukkit // Paper +- .withStyle(style -> style.withClickEvent(new ClickEvent.SuggestCommand("/" + command))); ++ .withStyle(style -> style.withClickEvent(new ClickEvent.SuggestCommand("/" + label))); // CraftBukkit // Paper if (min > 10) { mutableComponent.append(CommonComponents.ELLIPSIS); } -@@ -332,7 +_,17 @@ +@@ -331,7 +_,17 @@ } mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC)); @@ -172,7 +172,7 @@ } return null; -@@ -360,26 +_,120 @@ +@@ -359,26 +_,120 @@ } public void sendCommands(ServerPlayer player) { @@ -297,9 +297,9 @@ + // we want the exact command instance to be used for equality checks + // when assigning serialization ids to each command node - if (argumentBuilder instanceof RequiredArgumentBuilder) { - RequiredArgumentBuilder requiredArgumentBuilder = (RequiredArgumentBuilder)argumentBuilder; -@@ -396,7 +_,7 @@ + if (argumentBuilder instanceof RequiredArgumentBuilder requiredArgumentBuilder + && requiredArgumentBuilder.getSuggestionsProvider() != null) { +@@ -393,7 +_,7 @@ commandNodeToSuggestionNode.put(commandNode, commandNode1); rootSuggestion.addChild(commandNode1); if (!commandNode.getChildren().isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/core/Direction.java.patch b/paper-server/patches/sources/net/minecraft/core/Direction.java.patch index 1859b6bb9..2b097a773 100644 --- a/paper-server/patches/sources/net/minecraft/core/Direction.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Direction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/Direction.java +++ b/net/minecraft/core/Direction.java -@@ -57,6 +_,12 @@ +@@ -62,6 +_,12 @@ .sorted(Comparator.comparingInt(direction -> direction.data2d)) .toArray(Direction[]::new); @@ -13,10 +13,10 @@ private Direction( final int data3d, final int oppositeIndex, -@@ -74,6 +_,11 @@ - this.axisDirection = axisDirection; +@@ -80,6 +_,11 @@ this.normal = normal; this.normalVec3 = Vec3.atLowerCornerOf(normal); + this.normalVec3f = new Vector3f(normal.getX(), normal.getY(), normal.getZ()); + // Paper start - Perf: Inline shift direction fields + this.adjX = normal.getX(); + this.adjY = normal.getY(); @@ -25,7 +25,7 @@ } public static Direction[] orderedByNearest(Entity entity) { -@@ -247,15 +_,15 @@ +@@ -252,15 +_,15 @@ } public int getStepX() { diff --git a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch index 2a92380a2..da03bc092 100644 --- a/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/MappedRegistry.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/MappedRegistry.java +++ b/net/minecraft/core/MappedRegistry.java -@@ -33,17 +_,18 @@ +@@ -32,17 +_,18 @@ public class MappedRegistry implements WritableRegistry { private final ResourceKey> key; private final ObjectList> byId = new ObjectArrayList<>(256); @@ -24,7 +24,7 @@ @Override public Stream> listTags() { -@@ -114,6 +_,7 @@ +@@ -113,6 +_,7 @@ this.toId.put(value, size); this.registrationInfos.put(key, registrationInfo); this.registryLifecycle = this.registryLifecycle.add(registrationInfo.lifecycle()); @@ -32,7 +32,7 @@ return reference; } } -@@ -275,6 +_,7 @@ +@@ -274,6 +_,7 @@ return this; } else { this.frozen = true; @@ -40,7 +40,7 @@ this.byValue.forEach((object, reference) -> reference.bindValue((T)object)); List list = this.byKey .entrySet() -@@ -509,4 +_,13 @@ +@@ -508,4 +_,13 @@ Stream> getTags(); } diff --git a/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch b/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch index 0b17d3ac2..8cfe2a274 100644 --- a/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Rotations.java.patch @@ -1,21 +1,25 @@ --- a/net/minecraft/core/Rotations.java +++ b/net/minecraft/core/Rotations.java -@@ -34,6 +_,18 @@ - this(tag.getFloat(0), tag.getFloat(1), tag.getFloat(2)); - } - -+ // Paper start - faster alternative constructor -+ private Rotations(float x, float y, float z, Void dummy_var) { -+ this.x = x; -+ this.y = y; -+ this.z = z; -+ } -+ +@@ -26,11 +_,22 @@ + buffer.writeFloat(value.z); + } + }; ++ // Paper start - add internal method for skipping validation for plugins ++ private static boolean SKIP_VALIDATION = false; + public static Rotations createWithoutValidityChecks(float x, float y, float z) { -+ return new Rotations(x, y, z, null); ++ SKIP_VALIDATION = true; ++ Rotations rotations = new Rotations(x, y, z); ++ SKIP_VALIDATION = false; ++ return rotations; + } -+ // Paper end - faster alternative constructor -+ - public ListTag save() { - ListTag listTag = new ListTag(); - listTag.add(FloatTag.valueOf(this.x)); ++ // Paper end - add internal method for skipping validation for plugins + + public Rotations(float x, float y, float z) { ++ if (SKIP_VALIDATION) { // Paper - add internal method for skipping validation for plugins + x = !Float.isInfinite(x) && !Float.isNaN(x) ? x % 360.0F : 0.0F; + y = !Float.isInfinite(y) && !Float.isNaN(y) ? y % 360.0F : 0.0F; + z = !Float.isInfinite(z) && !Float.isNaN(z) ? z % 360.0F : 0.0F; ++ } // Paper - add internal method for skipping validation for plugins + this.x = x; + this.y = y; + this.z = z; diff --git a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch index 09caa5158..e2155688d 100644 --- a/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/Vec3i.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/Vec3i.java +++ b/net/minecraft/core/Vec3i.java -@@ -16,9 +_,9 @@ - vec3i -> IntStream.of(vec3i.getX(), vec3i.getY(), vec3i.getZ()) - ); +@@ -22,9 +_,9 @@ + ByteBufCodecs.VAR_INT, Vec3i::getX, ByteBufCodecs.VAR_INT, Vec3i::getY, ByteBufCodecs.VAR_INT, Vec3i::getZ, Vec3i::new + ); public static final Vec3i ZERO = new Vec3i(0, 0, 0); - private int x; - private int y; @@ -13,7 +13,7 @@ public static Codec offsetCodec(int maxOffset) { return CODEC.validate( -@@ -35,12 +_,12 @@ +@@ -41,12 +_,12 @@ } @Override @@ -28,7 +28,7 @@ return (this.getY() + this.getZ() * 31) * 31 + this.getX(); } -@@ -53,15 +_,15 @@ +@@ -59,15 +_,15 @@ } } @@ -47,7 +47,7 @@ return this.z; } -@@ -235,4 +_,10 @@ +@@ -241,4 +_,10 @@ public String toShortString() { return this.getX() + ", " + this.getY() + ", " + this.getZ(); } diff --git a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch index d551548c5..890881533 100644 --- a/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/cauldron/CauldronInteraction.java.patch @@ -122,13 +122,14 @@ ) ); addDefaultInteractions(map3); -@@ -202,15 +_,34 @@ +@@ -202,15 +_,35 @@ Predicate statePredicate, SoundEvent fillSound ) { + // Paper start - add hitDirection + return fillBucket(state, level, pos, player, hand, emptyStack, filledStack, statePredicate, fillSound, null); // Paper - add hitDirection + } ++ + static InteractionResult fillBucket(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack emptyStack, ItemStack filledStack, Predicate statePredicate, SoundEvent fillSound, @javax.annotation.Nullable net.minecraft.core.Direction hitDirection) { + // Paper end - add hitDirection if (!statePredicate.test(state)) { @@ -137,7 +138,7 @@ if (!level.isClientSide) { + // Paper start - fire PlayerBucketFillEvent + if (hitDirection != null) { -+ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((net.minecraft.server.level.ServerLevel) level, player, pos, pos, hitDirection, emptyStack, filledStack.getItem(), hand); ++ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, pos, pos, hitDirection, emptyStack, filledStack.getItem(), hand); + if (event.isCancelled()) { + return InteractionResult.PASS; + } @@ -158,20 +159,21 @@ level.playSound(null, pos, fillSound, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PICKUP, pos); } -@@ -222,12 +_,32 @@ +@@ -222,12 +_,33 @@ static InteractionResult emptyBucket( Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack filledStackl, BlockState state, SoundEvent emptySound ) { + // Paper start - add hitDirection + return emptyBucket(level, pos, player, hand, filledStackl, state, emptySound, null); + } ++ + static InteractionResult emptyBucket(Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack filledStackl, BlockState state, SoundEvent emptySound, @javax.annotation.Nullable net.minecraft.core.Direction hitDirection) { + // Paper end - add hitDirection if (!level.isClientSide) { + // Paper start - fire PlayerBucketEmptyEvent + ItemStack output = new ItemStack(Items.BUCKET); + if (hitDirection != null) { -+ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent((net.minecraft.server.level.ServerLevel) level, player, pos, pos, hitDirection, filledStackl, hand); ++ org.bukkit.event.player.PlayerBucketEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent(level, player, pos, pos, hitDirection, filledStackl, hand); + if (event.isCancelled()) { + return InteractionResult.PASS; + } @@ -193,7 +195,7 @@ level.playSound(null, pos, emptySound, SoundSource.BLOCKS, 1.0F, 1.0F); level.gameEvent(null, GameEvent.FLUID_PLACE, pos); } -@@ -236,7 +_,7 @@ +@@ -236,23 +_,23 @@ } private static InteractionResult fillWaterInteraction( @@ -201,13 +203,8 @@ + BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, ItemStack filledStack, final net.minecraft.core.Direction hitDirection // Paper - add hitDirection ) { return emptyBucket( - level, -@@ -245,20 +_,20 @@ - hand, - filledStack, - Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, Integer.valueOf(3)), -- SoundEvents.BUCKET_EMPTY -+ SoundEvents.BUCKET_EMPTY, hitDirection // Paper - add hitDirection +- level, pos, player, hand, filledStack, Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEvents.BUCKET_EMPTY ++ level, pos, player, hand, filledStack, Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEvents.BUCKET_EMPTY, hitDirection // Paper - add hitDirection ); } @@ -227,10 +224,10 @@ ) { return (InteractionResult)(isUnderWater(level, pos) ? InteractionResult.CONSUME -@@ -269,53 +_,68 @@ +@@ -263,53 +_,68 @@ hand, filledStack, - Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, Integer.valueOf(3)), + Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), - SoundEvents.BUCKET_EMPTY_POWDER_SNOW + SoundEvents.BUCKET_EMPTY_POWDER_SNOW, hitDirection // Paper - add hitDirection )); diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch index 9850a5e8f..855a46776 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponentPatch.java.patch @@ -1,50 +1,50 @@ --- a/net/minecraft/core/component/DataComponentPatch.java +++ b/net/minecraft/core/component/DataComponentPatch.java -@@ -86,6 +_,11 @@ - buffer.writeVarInt(0); - buffer.writeVarInt(0); - } else { -+ // Paper start - data sanitization for items -+ final io.papermc.paper.util.ItemObfuscationSession itemObfuscationSession = value.map.isEmpty() -+ ? null // Avoid thread local lookup of current session if it won't be needed anyway. -+ : io.papermc.paper.util.ItemObfuscationSession.currentSession(); -+ // Paper end - data sanitization for items - int i = 0; - int i1 = 0; +@@ -106,6 +_,11 @@ + buffer.writeVarInt(0); + buffer.writeVarInt(0); + } else { ++ // Paper start - data sanitization for items ++ final io.papermc.paper.util.sanitizer.ItemObfuscationSession itemObfuscationSession = value.map.isEmpty() ++ ? null // Avoid thread local lookup of current session if it won't be needed anyway. ++ : io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession(); ++ // Paper end - data sanitization for items + int i = 0; + int i1 = 0; -@@ -93,7 +_,7 @@ - value.map - )) { - if (entry.getValue().isPresent()) { -- i++; -+ if (!io.papermc.paper.util.ItemComponentSanitizer.shouldDrop(itemObfuscationSession, entry.getKey())) i++; // Paper - data sanitization for items - } else { - i1++; - } -@@ -106,6 +_,7 @@ - value.map - )) { - Optional optional = entryx.getValue(); -+ optional = io.papermc.paper.util.ItemComponentSanitizer.override(itemObfuscationSession, entryx.getKey(), entryx.getValue()); // Paper - data sanitization for items - if (optional.isPresent()) { - DataComponentType dataComponentType = entryx.getKey(); - DataComponentType.STREAM_CODEC.encode(buffer, dataComponentType); -@@ -125,7 +_,13 @@ - } +@@ -113,7 +_,7 @@ + value.map + )) { + if (entry.getValue().isPresent()) { +- i++; ++ if (!io.papermc.paper.util.sanitizer.ItemComponentSanitizer.shouldDrop(itemObfuscationSession, entry.getKey())) i++; // Paper - data sanitization for items + } else { + i1++; + } +@@ -126,6 +_,7 @@ + value.map + )) { + Optional optional = entryx.getValue(); ++ optional = io.papermc.paper.util.sanitizer.ItemComponentSanitizer.override(itemObfuscationSession, entryx.getKey(), entryx.getValue()); // Paper - data sanitization for items + if (optional.isPresent()) { + DataComponentType dataComponentType = entryx.getKey(); + DataComponentType.STREAM_CODEC.encode(buffer, dataComponentType); +@@ -145,7 +_,13 @@ + } - private static void encodeComponent(RegistryFriendlyByteBuf buffer, DataComponentType component, Object value) { -- component.streamCodec().encode(buffer, (T)value); -+ // Paper start - codec errors of random anonymous classes are useless -+ try { -+ component.streamCodec().encode(buffer, (T)value); -+ } catch (final Exception e) { -+ throw new RuntimeException("Error encoding component " + component, e); -+ } -+ // Paper end - codec errors of random anonymous classes are useless - } - }; - private static final String REMOVED_PREFIX = "!"; -@@ -230,6 +_,42 @@ + private void encodeComponent(RegistryFriendlyByteBuf buffer, DataComponentType component, Object value) { +- codecGetter.apply(component).encode(buffer, (T)value); ++ // Paper start - codec errors of random anonymous classes are useless ++ try { ++ codecGetter.apply(component).encode(buffer, (T)value); ++ } catch (final Exception e) { ++ throw new RuntimeException("Error encoding component " + component, e); ++ } ++ // Paper end - codec errors of random anonymous classes are useless + } + }; + } +@@ -249,6 +_,42 @@ Builder() { } diff --git a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch index a1a9d2377..a5d03b55d 100644 --- a/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/component/DataComponents.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/core/component/DataComponents.java +++ b/net/minecraft/core/component/DataComponents.java -@@ -180,10 +_,10 @@ +@@ -203,10 +_,10 @@ "map_post_processing", builder -> builder.networkSynchronized(MapPostProcessing.STREAM_CODEC) ); public static final DataComponentType CHARGED_PROJECTILES = register( - "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(ChargedProjectiles.STREAM_CODEC).cacheEncoding() -+ "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.CHARGED_PROJECTILES).cacheEncoding() // Paper - sanitize charged projectiles ++ "charged_projectiles", builder -> builder.persistent(ChargedProjectiles.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.CHARGED_PROJECTILES).cacheEncoding() // Paper - sanitize charged projectiles ); public static final DataComponentType BUNDLE_CONTENTS = register( - "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(BundleContents.STREAM_CODEC).cacheEncoding() -+ "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.BUNDLE_CONTENTS).cacheEncoding() // Paper - sanitize bundle contents ++ "bundle_contents", builder -> builder.persistent(BundleContents.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.BUNDLE_CONTENTS).cacheEncoding() // Paper - sanitize bundle contents ); public static final DataComponentType POTION_CONTENTS = register( "potion_contents", builder -> builder.persistent(PotionContents.CODEC).networkSynchronized(PotionContents.STREAM_CODEC).cacheEncoding() -@@ -250,7 +_,7 @@ +@@ -286,7 +_,7 @@ "pot_decorations", builder -> builder.persistent(PotDecorations.CODEC).networkSynchronized(PotDecorations.STREAM_CODEC).cacheEncoding() ); public static final DataComponentType CONTAINER = register( - "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(ItemContainerContents.STREAM_CODEC).cacheEncoding() -+ "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(io.papermc.paper.util.OversizedItemComponentSanitizer.CONTAINER).cacheEncoding() // Paper - sanitize container contents ++ "container", builder -> builder.persistent(ItemContainerContents.CODEC).networkSynchronized(io.papermc.paper.util.sanitizer.OversizedItemComponentSanitizer.CONTAINER).cacheEncoding() // Paper - sanitize container contents ); public static final DataComponentType BLOCK_STATE = register( "block_state", builder -> builder.persistent(BlockItemStateProperties.CODEC).networkSynchronized(BlockItemStateProperties.STREAM_CODEC).cacheEncoding() diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch index c40f77ee7..e0aa37968 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java.patch @@ -1,30 +1,27 @@ --- a/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/BoatDispenseItemBehavior.java -@@ -40,13 +_,39 @@ +@@ -40,13 +_,36 @@ d4 = 0.0; } + // CraftBukkit start -+ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink at end and single item in event ++ ItemStack singleItemStack = item.copyWithCount(1); + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(d1, d2 + d4, d3)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // stack.grow(1); // Paper - shrink below + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch index 3533ecd0e..603010595 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java.patch @@ -1,20 +1,11 @@ --- a/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DefaultDispenseItemBehavior.java -@@ -10,23 +_,46 @@ +@@ -9,24 +_,37 @@ + public class DefaultDispenseItemBehavior implements DispenseItemBehavior { private static final int DEFAULT_ACCURACY = 6; - -+ // CraftBukkit start + private Direction direction; // Paper - cache facing direction -+ private boolean dropper; -+ -+ public DefaultDispenseItemBehavior(boolean dropper) { -+ this.dropper = dropper; -+ } -+ -+ public DefaultDispenseItemBehavior() {} -+ // CraftBukkit end -+ + @Override public final ItemStack dispense(BlockSource blockSource, ItemStack item) { + this.direction = blockSource.state().getValue(DispenserBlock.FACING); // Paper - cache facing direction @@ -32,7 +23,7 @@ ItemStack itemStack = item.split(1); - spawnItem(blockSource.level(), itemStack, 6, direction, dispensePosition); + // CraftBukkit start -+ if (!DefaultDispenseItemBehavior.spawnItem(blockSource.level(), itemStack, 6, this.direction, dispensePosition, blockSource, this.dropper)) { ++ if (!DefaultDispenseItemBehavior.spawnItem(blockSource.level(), itemStack, 6, this.direction, dispensePosition, blockSource)) { + item.grow(1); + } + // CraftBukkit end @@ -50,37 +41,35 @@ double d = position.x(); double d1 = position.y(); double d2 = position.z(); -@@ -43,7 +_,45 @@ +@@ -43,7 +_,43 @@ level.random.triangle(0.2, 0.0172275 * speed), level.random.triangle(facing.getStepZ() * d3, 0.0172275 * speed) ); + return itemEntity; // CraftBukkit + } + -+ // CraftBukkit - void -> boolean return, IPosition -> ISourceBlock last argument, dropper -+ public static boolean spawnItem(Level level, ItemStack stack, int speed, Direction facing, Position dispensePosition, BlockSource blockSource, boolean dropper) { ++ // CraftBukkit start - void -> boolean return ++ public static boolean spawnItem(Level level, ItemStack stack, int speed, Direction facing, Position position, BlockSource blockSource) { + if (stack.isEmpty()) return true; -+ ItemEntity itemEntity = DefaultDispenseItemBehavior.prepareItem(level, stack, speed, facing, dispensePosition); ++ ItemEntity itemEntity = DefaultDispenseItemBehavior.prepareItem(level, stack, speed, facing, position); + + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(itemEntity.getDeltaMovement())); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); -+ } ++ level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + + itemEntity.setItem(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); -+ itemEntity.setDeltaMovement(org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getVelocity())); ++ itemEntity.setDeltaMovement(org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getVelocity())); + -+ if (!dropper && !event.getItem().getType().equals(craftItem.getType())) { ++ if (blockSource.state().is(net.minecraft.world.level.block.Blocks.DISPENSER) && !event.getItem().getType().equals(craftItem.getType())) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior.getClass() != DefaultDispenseItemBehavior.class) { + dispenseBehavior.dispense(blockSource, eventStack); + } else { diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch index c4e6ac4f5..2631a4ed0 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/DispenseItemBehavior.java.patch @@ -1,31 +1,28 @@ --- a/net/minecraft/core/dispenser/DispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/DispenseItemBehavior.java -@@ -82,16 +_,48 @@ +@@ -83,16 +_,45 @@ Direction direction = blockSource.state().getValue(DispenserBlock.FACING); EntityType type = ((SpawnEggItem)item.getItem()).getType(blockSource.level().registryAccess(), item); + // CraftBukkit start + ServerLevel serverLevel = blockSource.level(); -+ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink below and single item in event ++ ItemStack singleItemStack = item.copyWithCount(1); + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // item.grow(1); // Paper - shrink below + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; @@ -46,42 +43,40 @@ } - item.shrink(1); -+ if (shrink) item.shrink(1); // Paper - actually handle here ++ if (shrink) item.shrink(1); + // CraftBukkit end blockSource.level().gameEvent(null, GameEvent.ENTITY_PLACE, blockSource.pos()); return item; } -@@ -109,12 +_,40 @@ +@@ -110,12 +_,38 @@ Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); ServerLevel serverLevel = blockSource.level(); + // CraftBukkit start -+ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink below and single item in event ++ ItemStack singleItemStack = item.copyWithCount(1); + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // item.grow(1); // Paper - shrink below + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; + } + } + // CraftBukkit end ++ + final ItemStack newStack = org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()); // Paper - use event itemstack (unwrap is fine here because the stack won't be modified) Consumer consumer = EntityType.appendDefaultStackConfig( - armorStand1 -> armorStand1.setYRot(direction.toYRot()), serverLevel, item, null @@ -90,76 +85,37 @@ ArmorStand armorStand = EntityType.ARMOR_STAND.spawn(serverLevel, consumer, blockPos, EntitySpawnReason.DISPENSER, false, false); if (armorStand != null) { - item.shrink(1); -+ if (shrink) item.shrink(1); // Paper - actually handle here ++ if (shrink) item.shrink(1); // Paper } return item; -@@ -134,7 +_,36 @@ - livingEntity -> livingEntity instanceof Saddleable saddleable && !saddleable.isSaddled() && saddleable.isSaddleable() - ); - if (!entitiesOfClass.isEmpty()) { -- ((Saddleable)entitiesOfClass.get(0)).equipSaddle(item.split(1), SoundSource.BLOCKS); -+ // CraftBukkit start -+ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink below and single item in event -+ ServerLevel world = blockSource.level(); -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); -+ -+ org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), entitiesOfClass.get(0).getBukkitLivingEntity()); -+ if (!DispenserBlock.eventFired) { -+ world.getCraftServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ // item.grow(1); // Paper - shrink below -+ return item; -+ } -+ -+ boolean shrink = true; // Paper -+ if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { // Paper - fix possible StackOverflowError -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ ((Saddleable) entitiesOfClass.get(0)).equipSaddle(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()), SoundSource.BLOCKS); // Paper - track changed items in dispense event -+ // CraftBukkit end -+ if (shrink) item.shrink(1); // Paper - actually handle here - this.setSuccess(true); - return item; - } else { -@@ -156,8 +_,36 @@ +@@ -135,8 +_,35 @@ new AABB(blockPos), abstractChestedHorse1 -> abstractChestedHorse1.isAlive() && !abstractChestedHorse1.hasChest() )) { - if (abstractChestedHorse.isTamed() && abstractChestedHorse.getSlot(499).set(item)) { - item.shrink(1); + if (abstractChestedHorse.isTamed()/* && abstractChestedHorse.getSlot(499).set(item)*/) { -+ ItemStack singleCopy = item.copyWithCount(1); // Paper - shrink below ++ // CraftBukkit start ++ ItemStack singleCopy = item.copyWithCount(1); + ServerLevel world = blockSource.level(); + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleCopy); + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), abstractChestedHorse.getBukkitLivingEntity()); -+ if (!DispenserBlock.eventFired) { -+ world.getCraftServer().getPluginManager().callEvent(event); -+ } ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // stack.grow(1); // Paper - shrink below (this was actually missing and should be here, added it commented out to be consistent) ++ this.setSuccess(false); + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { // Paper - fix possible StackOverflowError ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; + } @@ -171,30 +127,25 @@ this.setSuccess(true); return item; } -@@ -195,8 +_,50 @@ +@@ -174,8 +_,45 @@ DispensibleContainerItem dispensibleContainerItem = (DispensibleContainerItem)item.getItem(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); Level level = blockSource.level(); + // CraftBukkit start -+ int x = blockPos.getX(); -+ int y = blockPos.getY(); -+ int z = blockPos.getZ(); -+ BlockState iblockdata = level.getBlockState(blockPos); ++ BlockState state = level.getBlockState(blockPos); + ItemStack dispensedItem = item; // Paper - track changed item from the dispense event + // Paper start - correctly check if the bucket place will succeed + /* Taken from SolidBucketItem#emptyContents */ -+ boolean willEmptyContentsSolidBucketItem = dispensibleContainerItem instanceof net.minecraft.world.item.SolidBucketItem && level.isInWorldBounds(blockPos) && iblockdata.isAir(); ++ boolean willEmptyContentsSolidBucketItem = dispensibleContainerItem instanceof net.minecraft.world.item.SolidBucketItem && level.isInWorldBounds(blockPos) && state.isAir(); + /* Taken from BucketItem#emptyContents */ -+ boolean willEmptyBucketItem = dispensibleContainerItem instanceof final net.minecraft.world.item.BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (iblockdata.isAir() || iblockdata.canBeReplaced(bucketItem.content) || (iblockdata.getBlock() instanceof net.minecraft.world.level.block.LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, level, blockPos, iblockdata, bucketItem.content))); ++ boolean willEmptyBucketItem = dispensibleContainerItem instanceof final net.minecraft.world.item.BucketItem bucketItem && bucketItem.content instanceof net.minecraft.world.level.material.FlowingFluid && (state.isAir() || state.canBeReplaced(bucketItem.content) || (state.getBlock() instanceof net.minecraft.world.level.block.LiquidBlockContainer liquidBlockContainer && liquidBlockContainer.canPlaceLiquid(null, level, blockPos, state, bucketItem.content))); + if (willEmptyContentsSolidBucketItem || willEmptyBucketItem) { + // Paper end - correctly check if the bucket place will succeed + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(x, y, z)); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); ++ level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return item; @@ -203,7 +154,7 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; @@ -223,7 +174,7 @@ return this.consumeWithRemainder(blockSource, item, new ItemStack(Items.BUCKET)); } else { return this.defaultDispenseItemBehavior.dispense(blockSource, item); -@@ -219,12 +_,37 @@ +@@ -198,12 +_,19 @@ BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = levelAccessor.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { @@ -234,64 +185,27 @@ } else { levelAccessor.gameEvent(null, GameEvent.FLUID_PICKUP, blockPos); Item item1 = itemStack.getItem(); -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(levelAccessor, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); -+ if (!DispenserBlock.eventFired) { -+ levelAccessor.getMinecraftWorld().getCraftServer().getPluginManager().callEvent(event); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ return result; + } -+ -+ if (event.isCancelled()) { -+ return item; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ -+ itemStack = bucketPickup.pickupBlock(null, levelAccessor, blockPos, blockState); // From above -+ // CraftBukkit end ++ // Paper end - Call BlockDispenseEvent ++ itemStack = bucketPickup.pickupBlock(null, levelAccessor, blockPos, blockState); // CraftBukkit - from above return this.consumeWithRemainder(blockSource, item, new ItemStack(item1)); } } else { -@@ -236,17 +_,44 @@ - @Override - protected ItemStack execute(BlockSource blockSource, ItemStack item) { - ServerLevel serverLevel = blockSource.level(); -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item); // Paper - ignore stack size on damageable items -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ return item; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ // CraftBukkit end +@@ -218,15 +_,26 @@ this.setSuccess(true); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); BlockPos blockPos = blockSource.pos().relative(direction); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ this.setSuccess(false); ++ return result; ++ } ++ // Paper end - Call BlockDispenseEvent BlockState blockState = serverLevel.getBlockState(blockPos); if (BaseFireBlock.canBePlacedAt(serverLevel, blockPos, direction)) { - serverLevel.setBlockAndUpdate(blockPos, BaseFireBlock.getState(serverLevel, blockPos)); @@ -303,42 +217,26 @@ + } + // CraftBukkit end } else if (CampfireBlock.canLight(blockState) || CandleBlock.canLight(blockState) || CandleCakeBlock.canLight(blockState)) { - serverLevel.setBlockAndUpdate(blockPos, blockState.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); + serverLevel.setBlockAndUpdate(blockPos, blockState.setValue(BlockStateProperties.LIT, true)); serverLevel.gameEvent(null, GameEvent.BLOCK_CHANGE, blockPos); -- } else if (blockState.getBlock() instanceof TntBlock) { -+ } else if (blockState.getBlock() instanceof TntBlock && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(serverLevel, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, blockSource.pos())) { // CraftBukkit - TNTPrimeEvent - TntBlock.explode(serverLevel, blockPos); - serverLevel.removeBlock(blockPos, false); - } else { -@@ -266,11 +_,62 @@ + } else if (blockState.getBlock() instanceof TntBlock) { +- if (TntBlock.prime(serverLevel, blockPos)) { ++ if (TntBlock.prime(serverLevel, blockPos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(serverLevel, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.DISPENSER, null, blockSource.pos()))) { // CraftBukkit - TNTPrimeEvent + serverLevel.removeBlock(blockPos, false); + } else { + this.setSuccess(false); +@@ -248,11 +_,46 @@ this.setSuccess(true); Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); -+ // CraftBukkit start -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ this.setSuccess(false); ++ return result; + } -+ -+ if (event.isCancelled()) { -+ return item; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ -+ level.captureTreeGeneration = true; -+ // CraftBukkit end ++ // Paper end - Call BlockDispenseEvent ++ level.captureTreeGeneration = true; // CraftBukkit if (!BoneMealItem.growCrop(item, level, blockPos) && !BoneMealItem.growWaterPlant(item, level, blockPos, null)) { this.setSuccess(false); } else if (!level.isClientSide) { @@ -346,26 +244,27 @@ } + // CraftBukkit start + level.captureTreeGeneration = false; -+ if (level.capturedBlockStates.size() > 0) { ++ if (!level.capturedBlockStates.isEmpty()) { + org.bukkit.TreeType treeType = net.minecraft.world.level.block.SaplingBlock.treeType; + net.minecraft.world.level.block.SaplingBlock.treeType = null; + org.bukkit.Location location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, level.getWorld()); -+ List blocks = new java.util.ArrayList<>(level.capturedBlockStates.values()); ++ List states = new java.util.ArrayList<>(level.capturedBlockStates.values()); + level.capturedBlockStates.clear(); + org.bukkit.event.world.StructureGrowEvent structureEvent = null; + if (treeType != null) { -+ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, blocks); ++ structureEvent = new org.bukkit.event.world.StructureGrowEvent(location, treeType, false, null, states); + org.bukkit.Bukkit.getPluginManager().callEvent(structureEvent); + } + -+ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(location.getBlock(), null, blocks); ++ org.bukkit.event.block.BlockFertilizeEvent fertilizeEvent = new org.bukkit.event.block.BlockFertilizeEvent(location.getBlock(), null, states); + fertilizeEvent.setCancelled(structureEvent != null && structureEvent.isCancelled()); + org.bukkit.Bukkit.getPluginManager().callEvent(fertilizeEvent); + + if (!fertilizeEvent.isCancelled()) { -+ for (org.bukkit.block.BlockState blockstate : blocks) { -+ blockstate.update(true); -+ blockSource.level().checkCapturedTreeStateForObserverNotify(blockPos, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed ++ for (org.bukkit.block.BlockState state : states) { ++ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) state; ++ craftBlockState.place(craftBlockState.getFlags()); ++ blockSource.level().checkCapturedTreeStateForObserverNotify(blockPos, craftBlockState); // Paper - notify observers even if grow failed + } + } + } @@ -373,79 +272,61 @@ return item; } -@@ -280,11 +_,39 @@ - protected ItemStack execute(BlockSource blockSource, ItemStack item) { - Level level = blockSource.level(); - BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); -- PrimedTnt primedTnt = new PrimedTnt(level, blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, null); -+ // CraftBukkit start -+ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink at end and single item in event -+ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockPos.getX() + 0.5D, (double) blockPos.getY(), (double) blockPos.getZ() + 0.5D)); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); -+ } -+ -+ if (event.isCancelled()) { -+ // item.grow(1); // Paper - shrink below -+ return item; -+ } -+ -+ boolean shrink = true; // Paper -+ if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ -+ PrimedTnt primedTnt = new PrimedTnt(level, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), null); -+ // CraftBukkit end - level.addFreshEntity(primedTnt); - level.playSound(null, primedTnt.getX(), primedTnt.getY(), primedTnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); - level.gameEvent(null, GameEvent.ENTITY_PLACE, blockPos); -- item.shrink(1); -+ if (shrink) item.shrink(1); // Paper - actually handle here - return item; - } - }); -@@ -296,6 +_,29 @@ - Level level = blockSource.level(); - Direction direction = blockSource.state().getValue(DispenserBlock.FACING); - BlockPos blockPos = blockSource.pos().relative(direction); +@@ -266,11 +_,36 @@ + return item; + } else { + BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); +- PrimedTnt primedTnt = new PrimedTnt(serverLevel, blockPos.getX() + 0.5, blockPos.getY(), blockPos.getZ() + 0.5, null); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event ++ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink at end and single item in event ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) blockPos.getX() + 0.5D, (double) blockPos.getY(), (double) blockPos.getZ() + 0.5D)); ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return item; + } + ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; + } + } ++ ++ PrimedTnt primedTnt = new PrimedTnt(serverLevel, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), null); + // CraftBukkit end + serverLevel.addFreshEntity(primedTnt); + serverLevel.playSound(null, primedTnt.getX(), primedTnt.getY(), primedTnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); +- serverLevel.gameEvent(null, GameEvent.ENTITY_PLACE, blockPos); +- item.shrink(1); ++ serverLevel.gameEvent(null, GameEvent.ENTITY_PLACE, org.bukkit.craftbukkit.util.CraftVector.toBlockPos(event.getVelocity())); // Paper - update game event position ++ if (shrink) item.shrink(1); // Paper + this.setSuccess(true); + return item; + } +@@ -284,6 +_,13 @@ + Level level = blockSource.level(); + Direction direction = blockSource.state().getValue(DispenserBlock.FACING); + BlockPos blockPos = blockSource.pos().relative(direction); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ this.setSuccess(false); ++ return result; ++ } ++ // Paper end - Call BlockDispenseEvent if (level.isEmptyBlock(blockPos) && WitherSkullBlock.canSpawnMob(level, blockPos, item)) { level.setBlock( blockPos, -@@ -313,7 +_,7 @@ +@@ -299,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -454,37 +335,21 @@ } return item; -@@ -326,6 +_,29 @@ +@@ -312,6 +_,13 @@ Level level = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); CarvedPumpkinBlock carvedPumpkinBlock = (CarvedPumpkinBlock)Blocks.CARVED_PUMPKIN; -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); -+ if (!DispenserBlock.eventFired) { -+ level.getCraftServer().getPluginManager().callEvent(event); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ this.setSuccess(false); ++ return result; + } -+ -+ if (event.isCancelled()) { -+ return item; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ // CraftBukkit end ++ // Paper end - Call BlockDispenseEvent if (level.isEmptyBlock(blockPos) && carvedPumpkinBlock.canSpawnGolem(level, blockPos)) { if (!level.isClientSide) { level.setBlock(blockPos, carvedPumpkinBlock.defaultBlockState(), 3); -@@ -335,7 +_,7 @@ +@@ -321,7 +_,7 @@ item.shrink(1); this.setSuccess(true); } else { @@ -493,51 +358,34 @@ } return item; -@@ -361,6 +_,29 @@ +@@ -347,6 +_,12 @@ ServerLevel serverLevel = blockSource.level(); BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); BlockState blockState = serverLevel.getBlockState(blockPos); -+ // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - only single item in event -+ -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); ++ // Paper start - Call BlockDispenseEvent ++ ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); ++ if (result != null) { ++ return result; + } -+ -+ if (event.isCancelled()) { -+ return item; -+ } -+ -+ if (!event.getItem().equals(craftItem)) { -+ // Chain to handler for new item -+ ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { -+ dispenseBehavior.dispense(blockSource, eventStack); -+ return item; -+ } -+ } -+ // CraftBukkit end ++ // Paper end - Call BlockDispenseEvent if (blockState.is( BlockTags.BEEHIVES, blockStateBase -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL) && blockStateBase.getBlock() instanceof BeehiveBlock -@@ -389,6 +_,13 @@ +@@ -375,6 +_,13 @@ this.setSuccess(true); if (blockState.is(Blocks.RESPAWN_ANCHOR)) { if (blockState.getValue(RespawnAnchorBlock.CHARGE) != 4) { -+ // Paper start - Call missing BlockDispenseEvent ++ // Paper start - Call BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); + if (result != null) { + this.setSuccess(false); + return result; + } -+ // Paper end - Call missing BlockDispenseEvent ++ // Paper end - Call BlockDispenseEvent RespawnAnchorBlock.charge(null, level, blockPos, blockState); item.shrink(1); } else { -@@ -412,6 +_,29 @@ +@@ -398,6 +_,28 @@ this.setSuccess(false); return item; } else { @@ -546,19 +394,18 @@ + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item); // Paper - ignore stack size on damageable items + + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), entitiesOfClass.get(0).getBukkitLivingEntity()); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { ++ this.setSuccess(false); + return item; + } + + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { // Paper - fix possible StackOverflowError ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; + } @@ -567,30 +414,30 @@ for (Armadillo armadillo : entitiesOfClass) { if (armadillo.brushOffScute()) { item.hurtAndBreak(16, serverLevel, null, item1 -> {}); -@@ -432,6 +_,13 @@ +@@ -418,6 +_,13 @@ BlockState blockState = level.getBlockState(blockPos); Optional waxed = HoneycombItem.getWaxed(blockState); if (waxed.isPresent()) { -+ // Paper start - Call missing BlockDispenseEvent ++ // Paper start - Call BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos, item, this); + if (result != null) { + this.setSuccess(false); + return result; + } -+ // Paper end - Call missing BlockDispenseEvent ++ // Paper end - Call BlockDispenseEvent level.setBlockAndUpdate(blockPos, waxed.get()); level.levelEvent(3003, blockPos, 0); item.shrink(1); -@@ -459,6 +_,12 @@ +@@ -445,6 +_,12 @@ if (!serverLevel.getBlockState(blockPos1).is(BlockTags.CONVERTABLE_TO_MUD)) { return this.defaultDispenseItemBehavior.dispense(blockSource, item); } else { -+ // Paper start - Call missing BlockDispenseEvent ++ // Paper start - Call BlockDispenseEvent + ItemStack result = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDispenseEvent(blockSource, blockPos1, item, this); + if (result != null) { + return result; + } -+ // Paper end - Call missing BlockDispenseEvent ++ // Paper end - Call BlockDispenseEvent if (!serverLevel.isClientSide) { for (int i = 0; i < 5; i++) { serverLevel.sendParticles( diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch index 08275c166..bf7562248 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/EquipmentDispenseItemBehavior.java -@@ -14,10 +_,16 @@ +@@ -14,10 +_,17 @@ @Override protected ItemStack execute(BlockSource blockSource, ItemStack item) { @@ -13,12 +13,13 @@ + // Paper start + return dispenseEquipment(blockSource, item, null); + } ++ + public static boolean dispenseEquipment(BlockSource blockSource, ItemStack item, @javax.annotation.Nullable DispenseItemBehavior currentBehavior) { + // Paper end BlockPos blockPos = blockSource.pos().relative(blockSource.state().getValue(DispenserBlock.FACING)); List entitiesOfClass = blockSource.level() .getEntitiesOfClass(LivingEntity.class, new AABB(blockPos), entity -> entity.canEquipWithDispenser(item)); -@@ -26,13 +_,42 @@ +@@ -26,13 +_,39 @@ } else { LivingEntity livingEntity = entitiesOfClass.getFirst(); EquipmentSlot equipmentSlotForItem = livingEntity.getEquipmentSlotForItem(item); @@ -31,22 +32,19 @@ + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack); + + org.bukkit.event.block.BlockDispenseArmorEvent event = new org.bukkit.event.block.BlockDispenseArmorEvent(block, craftItem.clone(), (org.bukkit.craftbukkit.entity.CraftLivingEntity) livingEntity.getBukkitEntity()); -+ if (!DispenserBlock.eventFired) { -+ world.getCraftServer().getPluginManager().callEvent(event); -+ } ++ world.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // stack.grow(1); // Paper - shrink below + return false; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (dispenseItemBehavior != DispenseItemBehavior.NOOP && (currentBehavior == null || dispenseItemBehavior != currentBehavior)) { // Paper - fix possible StackOverflowError ++ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); ++ if (dispenseItemBehavior != DispenseItemBehavior.NOOP && (currentBehavior == null || dispenseItemBehavior != currentBehavior)) { + dispenseItemBehavior.dispense(blockSource, eventStack); + return true; + } @@ -55,7 +53,7 @@ + livingEntity.setItemSlot(equipmentSlotForItem, org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem())); + // CraftBukkit end if (livingEntity instanceof Mob mob) { - mob.setDropChance(equipmentSlotForItem, 2.0F); + mob.setGuaranteedDrop(equipmentSlotForItem); mob.setPersistenceRequired(); } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch index 1f891175a..4622e161c 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/MinecartDispenseItemBehavior.java -@@ -57,12 +_,38 @@ +@@ -57,12 +_,35 @@ } Vec3 vec31 = new Vec3(d, d1 + d3, d2); @@ -11,22 +11,19 @@ + org.bukkit.block.Block block2 = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack1); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block2, craftItem.clone(), new org.bukkit.util.Vector(vec31.x, vec31.y, vec31.z)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block2, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(vec31)); ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // stack.grow(1); // Paper - shrink below + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseItemBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseItemBehavior != DispenseItemBehavior.NOOP && dispenseItemBehavior != this) { + dispenseItemBehavior.dispense(blockSource, eventStack); + return item; diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java.patch index 73ef78c79..3fa36c36d 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ProjectileDispenseBehavior.java -@@ -27,17 +_,39 @@ +@@ -27,17 +_,36 @@ ServerLevel serverLevel = blockSource.level(); Direction direction = blockSource.state().getValue(DispenserBlock.FACING); Position dispensePosition = this.dispenseConfig.positionFunction().getDispensePosition(blockSource, direction); @@ -15,38 +15,35 @@ - this.dispenseConfig.uncertainty() - ); - item.shrink(1); -+ ItemStack itemstack1 = item.copyWithCount(1); // Paper - shrink below and single item in event ++ ItemStack singleItemStack = item.copyWithCount(1); // Paper - shrink below and single item in event + org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack1); ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(singleItemStack); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) direction.getStepX(), (double) direction.getStepY(), (double) direction.getStepZ())); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(direction.getStepX(), direction.getStepY(), direction.getStepZ())); ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { -+ // item.grow(1); // Paper - shrink below + return item; + } + -+ boolean shrink = true; // Paper ++ boolean shrink = true; + if (!event.getItem().equals(craftItem)) { -+ shrink = false; // Paper - shrink below ++ shrink = false; + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior idispensebehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior -+ if (idispensebehavior != DispenseItemBehavior.NOOP && idispensebehavior != this) { -+ idispensebehavior.dispense(blockSource, eventStack); ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); ++ if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { ++ dispenseBehavior.dispense(blockSource, eventStack); + return item; + } + } + + // SPIGOT-7923: Avoid create projectiles with empty item -+ if (!itemstack1.isEmpty()) { -+ Projectile iprojectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(serverLevel, dispensePosition, org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()), direction), serverLevel, itemstack1, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // Paper - track changed items in the dispense event; unwrap is safe here because all uses of the stack make their own copies -+ iprojectile.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(blockSource.blockEntity()); ++ if (!singleItemStack.isEmpty()) { ++ Projectile projectile = Projectile.spawnProjectileUsingShoot(this.projectileItem.asProjectile(serverLevel, dispensePosition, org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getItem()), direction), serverLevel, singleItemStack, event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.dispenseConfig.power(), this.dispenseConfig.uncertainty()); // Paper - track changed items in the dispense event; unwrap is safe here because all uses of the stack make their own copies ++ projectile.projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource(blockSource.blockEntity()); + } -+ if (shrink) item.shrink(1); // Paper - actually handle here ++ if (shrink) item.shrink(1); + // CraftBukkit end return item; } diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch index fb3b9ff27..40242cb71 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java.patch @@ -1,26 +1,24 @@ --- a/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java +++ b/net/minecraft/core/dispenser/ShearsDispenseItemBehavior.java -@@ -20,9 +_,32 @@ +@@ -20,9 +_,30 @@ @Override protected ItemStack execute(BlockSource blockSource, ItemStack item) { ServerLevel serverLevel = blockSource.level(); -+ + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(serverLevel, blockSource.pos()); + org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item); // Paper - ignore stack size on damageable items + org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(0, 0, 0)); -+ if (!DispenserBlock.eventFired) { -+ serverLevel.getCraftServer().getPluginManager().callEvent(event); -+ } ++ serverLevel.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { ++ this.setSuccess(false); + return item; + } + + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; diff --git a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch index 56088e941..06c88a185 100644 --- a/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java.patch @@ -1,17 +1,15 @@ --- a/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java +++ b/net/minecraft/core/dispenser/ShulkerBoxDispenseBehavior.java -@@ -22,10 +_,38 @@ +@@ -22,10 +_,36 @@ BlockPos blockPos = blockSource.pos().relative(direction); Direction direction1 = blockSource.level().isEmptyBlock(blockPos.below()) ? direction : Direction.UP; + // CraftBukkit start + org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(blockSource.level(), blockSource.pos()); -+ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); // Paper - single item in event ++ org.bukkit.craftbukkit.inventory.CraftItemStack craftItem = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item.copyWithCount(1)); + -+ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), new org.bukkit.util.Vector(blockPos.getX(), blockPos.getY(), blockPos.getZ())); -+ if (!DispenserBlock.eventFired) { -+ blockSource.level().getCraftServer().getPluginManager().callEvent(event); -+ } ++ org.bukkit.event.block.BlockDispenseEvent event = new org.bukkit.event.block.BlockDispenseEvent(bukkitBlock, craftItem.clone(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(blockPos)); ++ blockSource.level().getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return item; @@ -20,7 +18,7 @@ + if (!event.getItem().equals(craftItem)) { + // Chain to handler for new item + ItemStack eventStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItem()); -+ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); // Paper - Fix NPE with equippable and items without behavior ++ DispenseItemBehavior dispenseBehavior = DispenserBlock.getDispenseBehavior(blockSource, eventStack); + if (dispenseBehavior != DispenseItemBehavior.NOOP && dispenseBehavior != this) { + dispenseBehavior.dispense(blockSource, eventStack); + return item; diff --git a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch index 36c52e0a7..82d661403 100644 --- a/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch +++ b/paper-server/patches/sources/net/minecraft/core/registries/BuiltInRegistries.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/core/registries/BuiltInRegistries.java +++ b/net/minecraft/core/registries/BuiltInRegistries.java -@@ -296,6 +_,17 @@ - public static final Registry> SLOT_DISPLAY = registerSimple(Registries.SLOT_DISPLAY, SlotDisplays::bootstrap); - public static final Registry RECIPE_BOOK_CATEGORY = registerSimple(Registries.RECIPE_BOOK_CATEGORY, RecipeBookCategories::bootstrap); +@@ -311,6 +_,17 @@ + ); + public static final Registry> TEST_FUNCTION = registerSimple(Registries.TEST_FUNCTION, BuiltinTestFunctions::bootstrap); public static final Registry> REGISTRY = WRITABLE_REGISTRY; + // Paper start - add built-in registry conversions + public static final io.papermc.paper.registry.data.util.Conversions BUILT_IN_CONVERSIONS = new io.papermc.paper.registry.data.util.Conversions(new net.minecraft.resources.RegistryOps.RegistryInfoLookup() { @@ -18,7 +18,7 @@ private static Registry registerSimple(ResourceKey> key, BuiltInRegistries.RegistryBootstrap bootstrap) { return internalRegister(key, new MappedRegistry<>(key, Lifecycle.stable(), false), bootstrap); -@@ -321,6 +_,7 @@ +@@ -336,6 +_,7 @@ ResourceKey> key, R registry, BuiltInRegistries.RegistryBootstrap bootstrap ) { Bootstrap.checkBootstrapCalled(() -> "registry " + key.location()); @@ -26,7 +26,7 @@ ResourceLocation resourceLocation = key.location(); LOADERS.put(resourceLocation, () -> bootstrap.run(registry)); WRITABLE_REGISTRY.register((ResourceKey)key, registry, RegistrationInfo.BUILT_IN); -@@ -328,16 +_,34 @@ +@@ -343,16 +_,34 @@ } public static void bootStrap() { @@ -61,7 +61,7 @@ }); } -@@ -346,6 +_,7 @@ +@@ -361,6 +_,7 @@ for (Registry registry : REGISTRY) { bindBootstrappedTagsToEmpty(registry); diff --git a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch index 5d8aa86e4..ea0bf2e1f 100644 --- a/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch +++ b/paper-server/patches/sources/net/minecraft/data/loot/packs/VanillaChestLoot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/data/loot/packs/VanillaChestLoot.java +++ b/net/minecraft/data/loot/packs/VanillaChestLoot.java -@@ -946,7 +_,6 @@ +@@ -1000,7 +_,6 @@ .add( LootItem.lootTableItem(Items.COMPASS) .apply(SetItemCountFunction.setCount(ConstantValue.exactly(1.0F))) diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch index 91fda07c6..405db6d11 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestInfo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/GameTestInfo.java +++ b/net/minecraft/gametest/framework/GameTestInfo.java -@@ -241,7 +_,7 @@ +@@ -247,7 +_,7 @@ AABB structureBounds = this.getStructureBounds(); List entitiesOfClass = this.getLevel() .getEntitiesOfClass(Entity.class, structureBounds.inflate(1.0), entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch new file mode 100644 index 000000000..9026c81bf --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestMainUtil.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/gametest/framework/GameTestMainUtil.java ++++ b/net/minecraft/gametest/framework/GameTestMainUtil.java +@@ -77,7 +_,7 @@ + copyPacks(string, string1); + } + +- LevelStorageSource.LevelStorageAccess levelStorageAccess = LevelStorageSource.createDefault(Paths.get(string)).createAccess("gametestworld"); ++ LevelStorageSource.LevelStorageAccess levelStorageAccess = LevelStorageSource.createDefault(Paths.get(string)).createAccess("gametestworld", net.minecraft.world.level.dimension.LevelStem.OVERWORLD); // Paper + PackRepository packRepository = ServerPacksSource.createPackRepository(levelStorageAccess); + MinecraftServer.spin( + thread -> GameTestServer.create(thread, levelStorageAccess, packRepository, optionalFromOption(optionSet, tests), optionSet.has(verify)) diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch index 5bfe64d45..201ba6f03 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/GameTestServer.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/gametest/framework/GameTestServer.java +++ b/net/minecraft/gametest/framework/GameTestServer.java -@@ -139,6 +_,8 @@ - BlockPos spawnPos +@@ -133,6 +_,8 @@ + boolean verify ) { super( + null, // Paper @@ -9,7 +9,7 @@ serverThread, storageSource, packRepository, -@@ -154,8 +_,15 @@ +@@ -148,8 +_,15 @@ @Override public boolean initServer() { @@ -25,9 +25,9 @@ + this.loadLevel("blah"); + // Paper end ServerLevel serverLevel = this.overworld(); - this.testBatches = Lists.newArrayList(GameTestBatchFactory.fromTestFunction(this.testFunctions, serverLevel)); - serverLevel.setDefaultSpawnPos(this.spawnPos, 0.0F); -@@ -303,6 +_,13 @@ + this.testBatches = this.evaluateTestsToRun(serverLevel); + LOGGER.info("Started game test server"); +@@ -338,6 +_,13 @@ public boolean shouldInformAdmins() { return false; } diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch index 23eeabf7b..4c113b07f 100644 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/StructureUtils.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/gametest/framework/StructureUtils.java +++ b/net/minecraft/gametest/framework/StructureUtils.java -@@ -187,7 +_,7 @@ +@@ -86,7 +_,7 @@ level.clearBlockEvents(boundingBox1); AABB aabb = AABB.of(boundingBox1); List entitiesOfClass = level.getEntitiesOfClass(Entity.class, aabb, entity -> !(entity instanceof Player)); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch deleted file mode 100644 index 6ca1c0d34..000000000 --- a/paper-server/patches/sources/net/minecraft/gametest/framework/TestCommand.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/gametest/framework/TestCommand.java -+++ b/net/minecraft/gametest/framework/TestCommand.java -@@ -278,7 +_,7 @@ - } - - private static int resetGameTestInfo(GameTestInfo gameTestInfo) { -- gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED)); -+ gameTestInfo.getLevel().getEntities(null, gameTestInfo.getStructureBounds()).stream().forEach(entity -> entity.remove(Entity.RemovalReason.DISCARDED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper - gameTestInfo.getStructureBlockEntity().placeStructure(gameTestInfo.getLevel()); - StructureUtils.removeBarriers(gameTestInfo.getStructureBounds(), gameTestInfo.getLevel()); - say(gameTestInfo.getLevel(), "Reset succeded for: " + gameTestInfo.getTestName(), ChatFormatting.GREEN); diff --git a/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch new file mode 100644 index 000000000..142439d7e --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/gametest/framework/TestEnvironmentDefinition.java.patch @@ -0,0 +1,30 @@ +--- a/net/minecraft/gametest/framework/TestEnvironmentDefinition.java ++++ b/net/minecraft/gametest/framework/TestEnvironmentDefinition.java +@@ -132,11 +_,11 @@ + MinecraftServer server = level.getServer(); + + for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { +- gameRules.getRule(entry.key()).set(entry.value(), server); ++ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world + } + + for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { +- gameRules.getRule(entry.key()).set(entry.value(), server); ++ gameRules.getRule(entry.key()).set(entry.value(), level); // Paper - per-world + } + } + +@@ -146,11 +_,11 @@ + MinecraftServer server = level.getServer(); + + for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.boolRules) { +- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); ++ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world + } + + for (TestEnvironmentDefinition.SetGameRules.Entry entry : this.intRules) { +- gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), server); ++ gameRules.getRule(entry.key()).setFrom(GameRules.getType(entry.key()).createRule(), level); // Paper - per-world + } + } + diff --git a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch index 837aed26f..26f53ef9e 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/CompoundTag.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/CompoundTag.java +++ b/net/minecraft/nbt/CompoundTag.java -@@ -49,7 +_,7 @@ +@@ -54,7 +_,7 @@ private static CompoundTag loadCompound(DataInput input, NbtAccounter nbtAccounter) throws IOException { nbtAccounter.accountBytes(48L); @@ -9,55 +9,21 @@ byte b; while ((b = input.readByte()) != 0) { -@@ -166,7 +_,7 @@ +@@ -171,7 +_,7 @@ } public CompoundTag() { -- this(Maps.newHashMap()); +- this(new HashMap<>()); + this(new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(8, 0.8f)); // Paper - Reduce memory footprint of CompoundTag } @Override -@@ -232,14 +_,34 @@ - } - - public void putUUID(String key, UUID value) { -+ // Paper start - Support old UUID format -+ if (this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ this.tags.remove(key + "Most"); -+ this.tags.remove(key + "Least"); -+ } -+ // Paper end - Support old UUID format - this.tags.put(key, NbtUtils.createUUID(value)); - } - -+ -+ /** -+ * You must use {@link #hasUUID(String)} before or else it will throw an NPE. -+ */ - public UUID getUUID(String key) { -+ // Paper start - Support old UUID format -+ if (!contains(key, 11) && this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ return new UUID(this.getLong(key + "Most"), this.getLong(key + "Least")); -+ } -+ // Paper end - Support old UUID format - return NbtUtils.loadUUID(this.get(key)); - } - - public boolean hasUUID(String key) { -+ // Paper start - Support old UUID format -+ if (this.contains(key + "Most", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC) && this.contains(key + "Least", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ return true; -+ } -+ // Paper end - Support old UUID format - Tag tag = this.get(key); - return tag != null && tag.getType() == IntArrayTag.TYPE && ((IntArrayTag)tag).getAsIntArray().length == 4; - } -@@ -477,8 +_,16 @@ +@@ -402,9 +_,16 @@ @Override public CompoundTag copy() { -- Map map = Maps.newHashMap(Maps.transformValues(this.tags, Tag::copy)); +- HashMap map = new HashMap<>(); +- this.tags.forEach((string, tag) -> map.put(string, tag.copy())); - return new CompoundTag(map); + // Paper start - Reduce memory footprint of CompoundTag + it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap ret = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(this.tags.size(), 0.8f); @@ -72,3 +38,55 @@ } @Override +@@ -525,22 +_,47 @@ + this.merge((CompoundTag)mapCodec.encoder().encodeStart(ops, data).getOrThrow()); + } + +- public Optional read(String key, Codec codec) { ++ public Optional read(String key, Codec codec) { // Paper - option to read via codec without logging errors - diff on change + return this.read(key, codec, NbtOps.INSTANCE); + } + +- public Optional read(String key, Codec codec, DynamicOps ops) { ++ public Optional read(String key, Codec codec, DynamicOps ops) { // Paper - option to read via codec without logging errors - diff on change + Tag tag = this.get(key); + return tag == null + ? Optional.empty() + : codec.parse(ops, tag).resultOrPartial(string -> LOGGER.error("Failed to read field ({}={}): {}", key, tag, string)); + } + +- public Optional read(MapCodec mapCodec) { ++ public Optional read(MapCodec mapCodec) { // Paper - option to read via codec without logging errors - diff on change + return this.read(mapCodec, NbtOps.INSTANCE); + } + +- public Optional read(MapCodec mapCodec, DynamicOps ops) { ++ public Optional read(MapCodec mapCodec, DynamicOps ops) { // Paper - option to read via codec without logging errors - diff on change + return mapCodec.decode(ops, ops.getMap(this).getOrThrow()).resultOrPartial(string -> LOGGER.error("Failed to read value ({}): {}", this, string)); + } ++ ++ // Paper start - option to read via codec without logging errors ++ // The below methods are 1 to 1 copies of the above-defined read methods without the logging part. ++ // Copying was chosen over overloading the read methods as a boolean parameter to mark a method as quiet ++ // is not intuitive and would require even more overloads. ++ // Not a lot of diff in these methods is expected ++ public Optional readQuiet(String key, Codec codec) { ++ return this.readQuiet(key, codec, NbtOps.INSTANCE); ++ } ++ ++ public Optional readQuiet(String key, Codec codec, DynamicOps ops) { ++ Tag tag = this.get(key); ++ return tag == null ++ ? Optional.empty() ++ : codec.parse(ops, tag).resultOrPartial(); ++ } ++ ++ public Optional readQuiet(MapCodec mapCodec) { ++ return this.readQuiet(mapCodec, NbtOps.INSTANCE); ++ } ++ ++ public Optional readQuiet(MapCodec mapCodec, DynamicOps ops) { ++ return mapCodec.decode(ops, ops.getMap(this).getOrThrow()).resultOrPartial(); ++ } ++ // Paper end - option to read via codec without logging errors + } diff --git a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch index 5cd314e96..926de4366 100644 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch +++ b/paper-server/patches/sources/net/minecraft/nbt/NbtIo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/nbt/NbtIo.java +++ b/net/minecraft/nbt/NbtIo.java -@@ -118,6 +_,11 @@ +@@ -119,6 +_,11 @@ } public static CompoundTag read(DataInput input, NbtAccounter accounter) throws IOException { diff --git a/paper-server/patches/sources/net/minecraft/nbt/NbtUtils.java.patch b/paper-server/patches/sources/net/minecraft/nbt/NbtUtils.java.patch deleted file mode 100644 index 00ff16e9e..000000000 --- a/paper-server/patches/sources/net/minecraft/nbt/NbtUtils.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/nbt/NbtUtils.java -+++ b/net/minecraft/nbt/NbtUtils.java -@@ -143,8 +_,10 @@ - if (!tag.contains("Name", 8)) { - return Blocks.AIR.defaultBlockState(); - } else { -- ResourceLocation resourceLocation = ResourceLocation.parse(tag.getString("Name")); -- Optional> optional = blockGetter.get(ResourceKey.create(Registries.BLOCK, resourceLocation)); -+ // Paper start - Validate resource location -+ ResourceLocation resourceLocation = ResourceLocation.tryParse(tag.getString("Name")); -+ Optional> optional = resourceLocation != null ? blockGetter.get(ResourceKey.create(Registries.BLOCK, resourceLocation)) : Optional.empty(); -+ // Paper end - Validate resource location - if (optional.isEmpty()) { - return Blocks.AIR.defaultBlockState(); - } else { diff --git a/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch new file mode 100644 index 000000000..6bf901555 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/nbt/SnbtGrammar.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/nbt/SnbtGrammar.java ++++ b/net/minecraft/nbt/SnbtGrammar.java +@@ -591,7 +_,7 @@ + Atom>> atom30 = Atom.of("map_entries"); + dictionary.put(atom30, Term.repeatedWithTrailingSeparator(namedRule3, atom30, StringReaderTerms.character(',')), scope -> scope.getOrThrow(atom30)); + Atom atom31 = Atom.of("map_literal"); +- dictionary.put(atom31, Term.sequence(StringReaderTerms.character('{'), dictionary.named(atom30), StringReaderTerms.character('}')), scope -> { ++ dictionary.put(atom31, Term.sequence(StringReaderTerms.character('{'), Scope.increaseDepth(), dictionary.named(atom30), Scope.decreaseDepth(), StringReaderTerms.character('}')), scope -> { // Paper - track depth + List> list = scope.getOrThrow(atom30); + if (list.isEmpty()) { + return object2; +@@ -626,7 +_,9 @@ + atom35, + Term.sequence( + StringReaderTerms.character('['), ++ Scope.increaseDepth(), // Paper - track depth + Term.alternative(Term.sequence(dictionary.named(atom33), StringReaderTerms.character(';'), dictionary.named(atom34)), dictionary.named(atom32)), ++ Scope.decreaseDepth(), // Paper - track depth + StringReaderTerms.character(']') + ), + parseState -> { diff --git a/paper-server/patches/sources/net/minecraft/nbt/TagParser.java.patch b/paper-server/patches/sources/net/minecraft/nbt/TagParser.java.patch deleted file mode 100644 index 8d8938c69..000000000 --- a/paper-server/patches/sources/net/minecraft/nbt/TagParser.java.patch +++ /dev/null @@ -1,54 +0,0 @@ ---- a/net/minecraft/nbt/TagParser.java -+++ b/net/minecraft/nbt/TagParser.java -@@ -49,6 +_,7 @@ - }, CompoundTag::toString); - public static final Codec LENIENT_CODEC = Codec.withAlternative(AS_CODEC, CompoundTag.CODEC); - private final StringReader reader; -+ private int depth; // Paper - - public static CompoundTag parseTag(String text) throws CommandSyntaxException { - return new TagParser(new StringReader(text)).readSingleStruct(); -@@ -159,6 +_,7 @@ - - public CompoundTag readStruct() throws CommandSyntaxException { - this.expect('{'); -+ this.increaseDepth(); // Paper - CompoundTag compoundTag = new CompoundTag(); - this.reader.skipWhitespace(); - -@@ -182,6 +_,7 @@ - } - - this.expect('}'); -+ this.depth--; // Paper - return compoundTag; - } - -@@ -191,6 +_,7 @@ - if (!this.reader.canRead()) { - throw ERROR_EXPECTED_VALUE.createWithContext(this.reader); - } else { -+ this.increaseDepth(); // Paper - ListTag listTag = new ListTag(); - TagType tagType = null; - -@@ -216,6 +_,7 @@ - } - - this.expect(']'); -+ this.depth--; // Paper - return listTag; - } - } -@@ -287,5 +_,11 @@ - private void expect(char expected) throws CommandSyntaxException { - this.reader.skipWhitespace(); - this.reader.expect(expected); -+ } -+ private void increaseDepth() throws CommandSyntaxException { -+ this.depth++; -+ if (this.depth > 512) { -+ throw new io.papermc.paper.brigadier.TagParseCommandSyntaxException("NBT tag is too complex, depth > 512"); -+ } - } - } diff --git a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch index e28fd7bb0..dfcc70664 100644 --- a/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/FriendlyByteBuf.java.patch @@ -36,7 +36,7 @@ } public static IntFunction limitValue(IntFunction function, int limit) { -@@ -527,7 +_,7 @@ +@@ -539,7 +_,7 @@ try { NbtIo.writeAnyTag(nbt, new ByteBufOutputStream(buffer)); diff --git a/paper-server/patches/sources/net/minecraft/network/HashedStack.java.patch b/paper-server/patches/sources/net/minecraft/network/HashedStack.java.patch new file mode 100644 index 000000000..8f72f1fe5 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/network/HashedStack.java.patch @@ -0,0 +1,33 @@ +--- a/net/minecraft/network/HashedStack.java ++++ b/net/minecraft/network/HashedStack.java +@@ -17,7 +_,7 @@ + } + + @Override +- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) { ++ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic + return stack.isEmpty(); + } + }; +@@ -27,7 +_,7 @@ + hashedStack -> hashedStack instanceof HashedStack.ActualItem actualItem ? Optional.of(actualItem) : Optional.empty() + ); + +- boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator); ++ boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching); // Paper - add flag to simplify remote matching logic + + static HashedStack create(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) { + return (HashedStack)(stack.isEmpty() +@@ -47,10 +_,10 @@ + ); + + @Override +- public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator) { ++ public boolean matches(ItemStack stack, HashedPatchMap.HashGenerator hashGenerator, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic + return this.count == stack.getCount() + && this.item.equals(stack.getItemHolder()) +- && this.components.matches(stack.getComponentsPatch(), hashGenerator); ++ && (simplifyMatching || this.components.matches(stack.getComponentsPatch(), hashGenerator)); // Paper - add flag to simplify remote matching logic + } + } + } diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch index dbc8aeb60..f0ee199b6 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ChatDecorator.java.patch @@ -9,7 +9,7 @@ - Component decorate(@Nullable ServerPlayer player, Component message); + ChatDecorator PLAIN = (player, message) -> java.util.concurrent.CompletableFuture.completedFuture(message); // Paper - adventure; support async chat decoration events + -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack) ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - adventure; support chat decoration events (callers should use the overload with CommandSourceStack) + java.util.concurrent.CompletableFuture decorate(@Nullable ServerPlayer player, Component message); // Paper - adventure; support async chat decoration events + + // Paper start - adventure; support async chat decoration events diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch index daf7751fe..62fe579b9 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentSerialization.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/ComponentSerialization.java +++ b/net/minecraft/network/chat/ComponentSerialization.java -@@ -37,9 +_,31 @@ +@@ -35,9 +_,31 @@ public class ComponentSerialization { public static final Codec CODEC = Codec.recursive("Component", ComponentSerialization::createCodec); @@ -34,7 +34,7 @@ public static final StreamCodec> TRUSTED_OPTIONAL_STREAM_CODEC = TRUSTED_STREAM_CODEC.apply( ByteBufCodecs::optional ); -@@ -102,7 +_,25 @@ +@@ -94,7 +_,25 @@ return ExtraCodecs.orCompressed(mapCodec2, mapCodec1); } @@ -60,7 +60,7 @@ ComponentContents.Type[] types = new ComponentContents.Type[]{ PlainTextContents.TYPE, TranslatableContents.TYPE, KeybindContents.TYPE, ScoreContents.TYPE, SelectorContents.TYPE, NbtContents.TYPE }; -@@ -115,6 +_,34 @@ +@@ -107,6 +_,34 @@ ) .apply(instance, MutableComponent::new) ); diff --git a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch index e3ea7a636..bec15be58 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/ComponentUtils.java.patch @@ -4,7 +4,7 @@ } } -+ @io.papermc.paper.annotation.DoNotUse // Paper - validate separators - right now this method is only used for separator evaluation. Error on build if this changes to re-evaluate. ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - validate separators - right now this method is only used for separator evaluation. Error on build if this changes to re-evaluate. public static Optional updateForEntity( @Nullable CommandSourceStack commandSourceStack, Optional optionalComponent, @Nullable Entity entity, int recursionDepth ) throws CommandSyntaxException { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch index cd887f535..260977823 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/PlayerChatMessage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/chat/PlayerChatMessage.java +++ b/net/minecraft/network/chat/PlayerChatMessage.java -@@ -17,6 +_,43 @@ +@@ -18,6 +_,43 @@ public record PlayerChatMessage( SignedMessageLink link, @Nullable MessageSignature signature, SignedMessageBody signedBody, @Nullable Component unsignedContent, FilterMask filterMask ) { @@ -44,7 +44,7 @@ public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( instance -> instance.group( SignedMessageLink.CODEC.fieldOf("link").forGetter(PlayerChatMessage::link), -@@ -47,7 +_,14 @@ +@@ -48,7 +_,14 @@ } public PlayerChatMessage withUnsignedContent(Component message) { diff --git a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch index ee118dfd0..9155bc56c 100644 --- a/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/chat/contents/NbtContents.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/network/chat/contents/NbtContents.java +++ b/net/minecraft/network/chat/contents/NbtContents.java -@@ -115,7 +_,7 @@ - }).map(Tag::getAsString); +@@ -119,7 +_,7 @@ if (this.interpreting) { + RegistryOps registryOps = nbtPathPattern.registryAccess().createSerializationContext(NbtOps.INSTANCE); Component component = DataFixUtils.orElse( - ComponentUtils.updateForEntity(nbtPathPattern, this.separator, entity, recursionDepth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR + ComponentUtils.updateSeparatorForEntity(nbtPathPattern, this.separator, entity, recursionDepth), ComponentUtils.DEFAULT_NO_STYLE_SEPARATOR // Paper - validate separator ); - return stream.flatMap(text -> { + return stream.flatMap(tag -> { try { -@@ -127,7 +_,7 @@ - } +@@ -132,7 +_,7 @@ }).reduce((mutableComponent, component1) -> mutableComponent.append(component).append(component1)).orElseGet(Component::empty); } else { + Stream stream1 = stream.map(NbtContents::asString); - return ComponentUtils.updateForEntity(nbtPathPattern, this.separator, entity, recursionDepth) + return ComponentUtils.updateSeparatorForEntity(nbtPathPattern, this.separator, entity, recursionDepth) // Paper - validate separator .map( - mutableComponent -> stream.map(Component::literal) + mutableComponent -> stream1.map(Component::literal) .reduce((mutableComponent1, otherMutableComponent) -> mutableComponent1.append(mutableComponent).append(otherMutableComponent)) diff --git a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch index 129aa1daf..40d331531 100644 --- a/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/codec/ByteBufCodecs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/codec/ByteBufCodecs.java +++ b/net/minecraft/network/codec/ByteBufCodecs.java -@@ -378,6 +_,48 @@ +@@ -389,6 +_,48 @@ }; } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch index 5eb9a5a4e..09c75d241 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java -@@ -35,6 +_,20 @@ - this.items = ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(buffer); - this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer); - } +@@ -22,6 +_,21 @@ + ClientboundContainerSetContentPacket::new + ); + + // Paper start - Handle large packets disconnecting client + @Override + public boolean hasLargePacketFallback() { @@ -18,6 +18,7 @@ + return true; + } + // Paper end - Handle large packets disconnecting client - - private void write(RegistryFriendlyByteBuf buffer) { - buffer.writeContainerId(this.containerId); ++ + @Override + public PacketType type() { + return GamePacketTypes.CLIENTBOUND_CONTAINER_SET_CONTENT; diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch index 0ffb3dd70..3ff4b6655 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java +++ b/net/minecraft/network/protocol/game/ClientboundLevelChunkPacketData.java -@@ -52,7 +_,7 @@ - throw new RuntimeException("Can't read heightmap in packet for [" + x + ", " + z + "]"); +@@ -50,7 +_,7 @@ + public ClientboundLevelChunkPacketData(RegistryFriendlyByteBuf buffer, int x, int z) { + this.heightmaps = HEIGHTMAPS_STREAM_CODEC.decode(buffer); + int varInt = buffer.readVarInt(); +- if (varInt > 2097152) { ++ if (varInt > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder + throw new RuntimeException("Chunk Packet trying to allocate too much memory on read."); } else { - int varInt = buffer.readVarInt(); -- if (varInt > 2097152) { -+ if (varInt > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder - throw new RuntimeException("Chunk Packet trying to allocate too much memory on read."); - } else { - this.buffer = new byte[varInt]; -@@ -154,6 +_,7 @@ + this.buffer = new byte[varInt]; +@@ -151,6 +_,7 @@ CompoundTag updateTag = blockEntity.getUpdateTag(blockEntity.getLevel().registryAccess()); BlockPos blockPos = blockEntity.getBlockPos(); int i = SectionPos.sectionRelative(blockPos.getX()) << 4 | SectionPos.sectionRelative(blockPos.getZ()); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch index de1815cf3..c3451472e 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java.patch @@ -97,7 +97,7 @@ - true, + listed, // Paper - Add Listing API for Player player.connection.latency(), - player.gameMode.getGameModeForPlayer(), + player.gameMode(), player.getTabListDisplayName(), @@ -172,6 +_,11 @@ Optionull.map(player.getChatSession(), RemoteChatSession::asData) diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch index d98c55251..f8353c254 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEntityDataPacket.java.patch @@ -4,7 +4,7 @@ } private static void pack(List> dataValues, RegistryFriendlyByteBuf buffer) { -+ try (io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization ++ try (io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level)) { // Paper - data sanitization for (SynchedEntityData.DataValue dataValue : dataValues) { dataValue.write(buffer); } diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch index 0021ba7c5..1a8efdc47 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetEquipmentPacket.java.patch @@ -18,7 +18,7 @@ buffer.writeVarInt(this.entity); int size = this.slots.size(); -+ try (final io.papermc.paper.util.ItemObfuscationSession ignored = io.papermc.paper.util.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization ++ try (final io.papermc.paper.util.sanitizer.ItemObfuscationSession ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.start(this.sanitize ? io.papermc.paper.configuration.GlobalConfiguration.get().anticheat.obfuscation.items.binding.level : io.papermc.paper.util.sanitizer.ItemObfuscationSession.ObfuscationLevel.NONE)) { // Paper - data sanitization for (int i = 0; i < size; i++) { Pair pair = this.slots.get(i); EquipmentSlot equipmentSlot = pair.getFirst(); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch index 3f4c2e05a..cfe10e029 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java +++ b/net/minecraft/network/protocol/game/ClientboundSetPlayerTeamPacket.java -@@ -30,6 +_,11 @@ +@@ -31,6 +_,11 @@ private final Collection players; private final Optional parameters; @@ -12,12 +12,12 @@ private ClientboundSetPlayerTeamPacket(String name, int method, Optional parameters, Collection players) { this.name = name; this.method = method; -@@ -198,7 +_,7 @@ +@@ -199,7 +_,7 @@ ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.displayName); buffer.writeByte(this.options); - buffer.writeUtf(this.nametagVisibility); -- buffer.writeUtf(this.collisionRule); -+ buffer.writeUtf(!io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.NEVER.name : this.collisionRule); // Paper - Configurable player collision + Team.Visibility.STREAM_CODEC.encode(buffer, this.nametagVisibility); +- Team.CollisionRule.STREAM_CODEC.encode(buffer, this.collisionRule); ++ Team.CollisionRule.STREAM_CODEC.encode(buffer, !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions ? PlayerTeam.CollisionRule.NEVER : this.collisionRule); // Paper - Configurable player collision buffer.writeEnum(this.color); ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerPrefix); ComponentSerialization.TRUSTED_STREAM_CODEC.encode(buffer, this.playerSuffix); diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch index c741092d3..3e28db0d8 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ClientboundSystemChatPacket.java.patch @@ -6,7 +6,7 @@ ); + // Spigot start + public ClientboundSystemChatPacket(net.md_5.bungee.api.chat.BaseComponent[] content, boolean overlay) { -+ this(org.bukkit.craftbukkit.util.CraftChatMessage.fromJSON(net.md_5.bungee.chat.ComponentSerializer.toString(content)), overlay); ++ this(org.bukkit.craftbukkit.util.CraftChatMessage.bungeeToVanilla(content), overlay); + } + // Spigot end + // Paper start diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch deleted file mode 100644 index 05b6fc07c..000000000 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java -+++ b/net/minecraft/network/protocol/game/ServerboundContainerClickPacket.java -@@ -17,7 +_,7 @@ - ); - private static final int MAX_SLOT_COUNT = 128; - private static final StreamCodec> SLOTS_STREAM_CODEC = ByteBufCodecs.map( -- Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC, 128 -+ Int2ObjectOpenHashMap::new, ByteBufCodecs.SHORT.map(Short::intValue, Integer::shortValue), ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth), 128 // Paper - Track codec depth - ); - private final int containerId; - private final int stateId; -@@ -46,7 +_,7 @@ - this.buttonNum = buffer.readByte(); - this.clickType = buffer.readEnum(ClickType.class); - this.changedSlots = Int2ObjectMaps.unmodifiable(SLOTS_STREAM_CODEC.decode(buffer)); -- this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.decode(buffer); -+ this.carriedItem = ItemStack.OPTIONAL_STREAM_CODEC.apply(ByteBufCodecs::trackDepth).decode(buffer); // Paper - Track codec depth - } - - private void write(RegistryFriendlyByteBuf buffer) { diff --git a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch index 1ebb632f6..a7a297b54 100644 --- a/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/protocol/game/ServerboundSetCreativeModeSlotPacket.java.patch @@ -4,8 +4,8 @@ public static final StreamCodec STREAM_CODEC = StreamCodec.composite( ByteBufCodecs.SHORT, ServerboundSetCreativeModeSlotPacket::slotNum, -- ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC), -+ ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_STREAM_CODEC).apply(ByteBufCodecs::trackDepth), // Paper - Track codec depth +- ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_UNTRUSTED_STREAM_CODEC), ++ ItemStack.validatedStreamCodec(ItemStack.OPTIONAL_UNTRUSTED_STREAM_CODEC).apply(ByteBufCodecs::trackDepth), // Paper - Track codec depth ServerboundSetCreativeModeSlotPacket::itemStack, ServerboundSetCreativeModeSlotPacket::new ); diff --git a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch index ea9d95ec4..9a5fc7c22 100644 --- a/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch +++ b/paper-server/patches/sources/net/minecraft/network/syncher/SynchedEntityData.java.patch @@ -1,14 +1,5 @@ --- a/net/minecraft/network/syncher/SynchedEntityData.java +++ b/net/minecraft/network/syncher/SynchedEntityData.java -@@ -45,7 +_,7 @@ - } - } - -- private SynchedEntityData.DataItem getItem(EntityDataAccessor key) { -+ public SynchedEntityData.DataItem getItem(EntityDataAccessor key) { // Paper - public - return (SynchedEntityData.DataItem)this.itemsById[key.id()]; - } - @@ -67,6 +_,13 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch index 97a14239e..5f037fe85 100644 --- a/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/RegistryDataLoader.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/RegistryDataLoader.java +++ b/net/minecraft/resources/RegistryDataLoader.java -@@ -247,13 +_,14 @@ +@@ -271,13 +_,14 @@ RegistryOps ops, ResourceKey resourceKey, Resource resource, @@ -17,7 +17,7 @@ } } -@@ -267,6 +_,7 @@ +@@ -291,6 +_,7 @@ FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); RegistryOps registryOps = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); @@ -25,7 +25,7 @@ for (Entry entry : fileToIdConverter.listMatchingResources(resourceManager).entrySet()) { ResourceLocation resourceLocation = entry.getKey(); ResourceKey resourceKey = ResourceKey.create(registry.key(), fileToIdConverter.fileToId(resourceLocation)); -@@ -274,7 +_,7 @@ +@@ -298,7 +_,7 @@ RegistrationInfo registrationInfo = REGISTRATION_INFO_CACHE.apply(resource.knownPackInfo()); try { @@ -34,7 +34,7 @@ } catch (Exception var14) { loadingErrors.put( resourceKey, -@@ -283,7 +_,9 @@ +@@ -307,7 +_,9 @@ } } @@ -45,7 +45,7 @@ } static void loadContentsFromNetwork( -@@ -300,6 +_,7 @@ +@@ -324,6 +_,7 @@ RegistryOps registryOps1 = RegistryOps.create(JsonOps.INSTANCE, registryInfoLookup); FileToIdConverter fileToIdConverter = FileToIdConverter.registry(registry.key()); @@ -53,7 +53,7 @@ for (RegistrySynchronization.PackedRegistryEntry packedRegistryEntry : networkedRegistryData.elements) { ResourceKey resourceKey = ResourceKey.create(registry.key(), packedRegistryEntry.id()); Optional optional = packedRegistryEntry.data(); -@@ -318,7 +_,7 @@ +@@ -342,7 +_,7 @@ try { Resource resourceOrThrow = resourceProvider.getResourceOrThrow(resourceLocation); @@ -62,7 +62,7 @@ } catch (Exception var17) { loadingErrors.put(resourceKey, new IllegalStateException("Failed to parse local data", var17)); } -@@ -360,6 +_,7 @@ +@@ -384,6 +_,7 @@ RegistryDataLoader.Loader create(Lifecycle registryLifecycle, Map, Exception> loadingErrors) { WritableRegistry writableRegistry = new MappedRegistry<>(this.key, registryLifecycle); diff --git a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch b/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch index db3f21405..8aeb19513 100644 --- a/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch +++ b/paper-server/patches/sources/net/minecraft/resources/ResourceLocation.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/resources/ResourceLocation.java +++ b/net/minecraft/resources/ResourceLocation.java -@@ -32,6 +_,7 @@ +@@ -23,6 +_,7 @@ public static final char NAMESPACE_SEPARATOR = ':'; public static final String DEFAULT_NAMESPACE = "minecraft"; public static final String REALMS_NAMESPACE = "realms"; @@ -8,7 +8,7 @@ private final String namespace; private final String path; -@@ -40,6 +_,13 @@ +@@ -31,6 +_,13 @@ assert isValidPath(path); @@ -22,7 +22,7 @@ this.namespace = namespace; this.path = path; } -@@ -252,7 +_,7 @@ +@@ -243,7 +_,7 @@ private static String assertValidNamespace(String namespace, String path) { if (!isValidNamespace(namespace)) { @@ -31,7 +31,7 @@ } else { return namespace; } -@@ -277,7 +_,7 @@ +@@ -268,7 +_,7 @@ private static String assertValidPath(String namespace, String path) { if (!isValidPath(path)) { diff --git a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch index c2cbc6a23..2700e1f08 100644 --- a/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Bootstrap.java.patch @@ -8,7 +8,7 @@ if (BuiltInRegistries.REGISTRY.keySet().isEmpty()) { throw new IllegalStateException("Unable to load registries"); } else { -@@ -54,11 +_,80 @@ +@@ -54,11 +_,85 @@ EntitySelectorOptions.bootStrap(); DispenseItemBehavior.bootStrap(); CauldronInteraction.bootStrap(); @@ -25,25 +25,30 @@ + // CraftBukkit start + // TODO Check what of this is needed, maybe report it to Mojira. if deemed relevant, move to the respective classes + // Used in CraftLegacy -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1008, "{Name:'minecraft:oak_sign',Properties:{rotation:'0'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'0'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1009, "{Name:'minecraft:oak_sign',Properties:{rotation:'1'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'1'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1010, "{Name:'minecraft:oak_sign',Properties:{rotation:'2'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'2'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1011, "{Name:'minecraft:oak_sign',Properties:{rotation:'3'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'3'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1012, "{Name:'minecraft:oak_sign',Properties:{rotation:'4'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'4'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1013, "{Name:'minecraft:oak_sign',Properties:{rotation:'5'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'5'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1014, "{Name:'minecraft:oak_sign',Properties:{rotation:'6'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'6'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1015, "{Name:'minecraft:oak_sign',Properties:{rotation:'7'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'7'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1016, "{Name:'minecraft:oak_sign',Properties:{rotation:'8'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'8'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1017, "{Name:'minecraft:oak_sign',Properties:{rotation:'9'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'9'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1018, "{Name:'minecraft:oak_sign',Properties:{rotation:'10'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'10'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1019, "{Name:'minecraft:oak_sign',Properties:{rotation:'11'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'11'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1020, "{Name:'minecraft:oak_sign',Properties:{rotation:'12'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'12'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1021, "{Name:'minecraft:oak_sign',Properties:{rotation:'13'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'13'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1022, "{Name:'minecraft:oak_sign',Properties:{rotation:'14'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'14'}}"); -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1023, "{Name:'minecraft:oak_sign',Properties:{rotation:'15'}}", "{Name:'minecraft:standing_sign',Properties:{rotation:'15'}}"); -+ net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(323, "minecraft:oak_sign"); ++ for (int i = 0; i <= 15; i++) { ++ net.minecraft.util.datafix.fixes.BlockStateData.register( ++ 1008 + i, ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:oak_sign", ++ "Properties", java.util.Map.of("rotation", String.valueOf(i)) ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:standing_sign", ++ "Properties", java.util.Map.of("rotation", String.valueOf(i)) ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) ++ ); ++ } + -+ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, "{Name:'minecraft:portal',Properties:{axis:'x'}}", "{Name:'minecraft:portal',Properties:{axis:'x'}}"); ++ net.minecraft.util.datafix.fixes.BlockStateData.register(1440, ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:portal", ++ "Properties", java.util.Map.of("axis", "x") ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE), ++ new com.mojang.serialization.Dynamic<>(com.mojang.serialization.JavaOps.INSTANCE, java.util.Map.of( ++ "Name", "minecraft:portal", ++ "Properties", java.util.Map.of("axis", "x") ++ )).convert(net.minecraft.nbt.NbtOps.INSTANCE) ++ ); + + net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(409, "minecraft:prismarine_shard"); + net.minecraft.util.datafix.fixes.ItemIdFix.ITEM_NAMES.put(410, "minecraft:prismarine_crystals"); diff --git a/paper-server/patches/sources/net/minecraft/server/Main.java.patch b/paper-server/patches/sources/net/minecraft/server/Main.java.patch index b9d9570fd..3ee6c7ea3 100644 --- a/paper-server/patches/sources/net/minecraft/server/Main.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Main.java.patch @@ -52,13 +52,13 @@ + File configFile = (File) optionSet.valueOf("bukkit-settings"); + org.bukkit.configuration.file.YamlConfiguration configuration = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(configFile); + configuration.options().copyDefaults(true); -+ configuration.setDefaults(org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(new java.io.InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/bukkit.yml"), com.google.common.base.Charsets.UTF_8))); ++ configuration.setDefaults(org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(new java.io.InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/bukkit.yml"), java.nio.charset.StandardCharsets.UTF_8))); + configuration.save(configFile); + + File commandFile = (File) optionSet.valueOf("commands-settings"); + org.bukkit.configuration.file.YamlConfiguration commandsConfiguration = org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(commandFile); + commandsConfiguration.options().copyDefaults(true); -+ commandsConfiguration.setDefaults(org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(new java.io.InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/commands.yml"), com.google.common.base.Charsets.UTF_8))); ++ commandsConfiguration.setDefaults(org.bukkit.configuration.file.YamlConfiguration.loadConfiguration(new java.io.InputStreamReader(Main.class.getClassLoader().getResourceAsStream("configurations/commands.yml"), java.nio.charset.StandardCharsets.UTF_8))); + commandsConfiguration.save(commandFile); + // CraftBukkit end LOGGER.info("Initialized '{}' and '{}'", path1.toAbsolutePath(), path2.toAbsolutePath()); @@ -116,7 +116,7 @@ Dynamic dataTag; if (levelStorageAccess.hasWorldData()) { LevelSummary summary; -@@ -169,12 +_,30 @@ +@@ -169,12 +_,33 @@ } Dynamic dynamic = dataTag; @@ -134,12 +134,15 @@ + } + File mcMeta = new File(bukkitDataPackFolder, "pack.mcmeta"); + try { -+ com.google.common.io.Files.write("{\n" -+ + " \"pack\": {\n" -+ + " \"description\": \"Data pack for resources provided by Bukkit plugins\",\n" -+ + " \"pack_format\": " + SharedConstants.getCurrentVersion().getPackVersion(net.minecraft.server.packs.PackType.SERVER_DATA) + "\n" -+ + " }\n" -+ + "}\n", mcMeta, com.google.common.base.Charsets.UTF_8); ++ com.google.common.io.Files.asCharSink(mcMeta, java.nio.charset.StandardCharsets.UTF_8).write(""" ++ { ++ "pack": { ++ "description": "Data pack for resources provided by Bukkit plugins", ++ "pack_format": %d ++ } ++ } ++ """.formatted(SharedConstants.getCurrentVersion().getPackVersion(net.minecraft.server.packs.PackType.SERVER_DATA)) ++ ); + } catch (java.io.IOException ex) { + throw new RuntimeException("Could not initialize Bukkit datapack", ex); + } @@ -180,11 +183,11 @@ + /* RegistryAccess.Frozen frozen = worldStem.registries().compositeAccess(); - boolean hasOptionSpec1 = optionSet.has(optionSpec6); - if (optionSet.has(optionSpec4) || hasOptionSpec1) { -@@ -245,9 +_,13 @@ - WorldData worldData = worldStem.worldData(); + boolean hasOptionSpec1 = optionSet.has(optionSpec6); +@@ -245,9 +_,13 @@ + } + levelStorageAccess.saveDataTag(frozen, worldData); + */ final DedicatedServer dedicatedServer = MinecraftServer.spin( @@ -241,12 +244,12 @@ } catch (Exception var42) { LOGGER.error(LogUtils.FATAL_MARKER, "Failed to start the minecraft server", (Throwable)var42); } -@@ -316,7 +_,7 @@ +@@ -317,7 +_,7 @@ RegistryAccess registryAccess, boolean recreateRegionFiles ) { - LOGGER.info("Forcing world upgrade!"); + LOGGER.info("Forcing world upgrade! {}", levelStorage.getLevelId()); // CraftBukkit - try (WorldUpgrader worldUpgrader = new WorldUpgrader(levelStorage, dataFixer, registryAccess, eraseCache, recreateRegionFiles)) { + try (WorldUpgrader worldUpgrader = new WorldUpgrader(levelStorage, dataFixer, worldData, registryAccess, eraseCache, recreateRegionFiles)) { Component component = null; diff --git a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch index 868865c03..f7c930147 100644 --- a/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/MinecraftServer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -174,11 +_,13 @@ +@@ -173,11 +_,13 @@ import org.slf4j.Logger; public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ServerInfo, ChunkIOErrorReporter, CommandSource { @@ -15,7 +15,7 @@ private static final int OVERLOADED_TICKS_THRESHOLD = 20; private static final long OVERLOADED_WARNING_INTERVAL_NANOS = 10L * TimeUtil.NANOSECONDS_PER_SECOND; private static final int OVERLOADED_TICKS_WARNING_INTERVAL = 100; -@@ -218,6 +_,7 @@ +@@ -217,6 +_,7 @@ private Map, ServerLevel> levels = Maps.newLinkedHashMap(); private PlayerList playerList; private volatile boolean running = true; @@ -23,7 +23,7 @@ private boolean stopped; private int tickCount; private int ticksUntilAutosave = 6000; -@@ -226,11 +_,15 @@ +@@ -225,11 +_,15 @@ private boolean preventProxyConnections; private boolean pvp; private boolean allowFlight; @@ -41,7 +41,7 @@ @Nullable private KeyPair keyPair; @Nullable -@@ -271,10 +_,37 @@ +@@ -270,10 +_,37 @@ private final SuppressedExceptionCollector suppressedExceptions = new SuppressedExceptionCollector(); private final DiscontinuousFrame tickFrame; @@ -80,7 +80,7 @@ if (Runtime.getRuntime().availableProcessors() > 4) { thread.setPriority(8); } -@@ -286,6 +_,10 @@ +@@ -285,6 +_,10 @@ } public MinecraftServer( @@ -91,7 +91,7 @@ Thread serverThread, LevelStorageSource.LevelStorageAccess storageSource, PackRepository packRepository, -@@ -296,9 +_,10 @@ +@@ -295,9 +_,10 @@ ChunkProgressListenerFactory progressListenerFactory ) { super("Server"); @@ -103,7 +103,7 @@ throw new IllegalStateException("Missing Overworld dimension data"); } else { this.proxy = proxy; -@@ -309,7 +_,7 @@ +@@ -308,7 +_,7 @@ services.profileCache().setExecutor(this); } @@ -112,7 +112,7 @@ this.tickRateManager = new ServerTickRateManager(this); this.progressListenerFactory = progressListenerFactory; this.storageSource = storageSource; -@@ -328,6 +_,38 @@ +@@ -327,6 +_,38 @@ this.fuelValues = FuelValues.vanillaBurnTimes(this.registries.compositeAccess(), this.worldData.enabledFeatures()); this.tickFrame = TracyClient.createDiscontinuousFrame("Server Tick"); } @@ -151,7 +151,7 @@ } private void readScoreboard(DimensionDataStorage dataStorage) { -@@ -336,18 +_,13 @@ +@@ -335,18 +_,13 @@ protected abstract boolean initServer() throws IOException; @@ -172,7 +172,7 @@ if (profiledDuration != null) { profiledDuration.finish(true); } -@@ -364,25 +_,265 @@ +@@ -363,25 +_,265 @@ protected void forceDifficulty() { } @@ -349,7 +349,7 @@ + + primaryLevelData.checkName(name); // CraftBukkit - Migration did not rewrite the level.dat; This forces 1.8 to take the last loaded world as respawn (in this case the end) + if (this.options.has("forceUpgrade")) { -+ net.minecraft.server.Main.forceUpgrade(levelStorageAccess, net.minecraft.util.datafix.DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> true, registryAccess, this.options.has("recreateRegionFiles")); ++ net.minecraft.server.Main.forceUpgrade(levelStorageAccess, primaryLevelData, net.minecraft.util.datafix.DataFixers.getDataFixer(), this.options.has("eraseCache"), () -> true, registryAccess, this.options.has("recreateRegionFiles")); + } + + // Now modelled off the createLevels method @@ -457,7 +457,7 @@ if (!serverLevelData.isInitialized()) { try { setInitialSpawn(serverLevel, serverLevelData, worldOptions.generateBonusChest(), isDebugWorld); -@@ -403,47 +_,30 @@ +@@ -402,47 +_,30 @@ serverLevelData.setInitialized(true); } @@ -522,7 +522,7 @@ int spawnHeight = chunkSource.getGenerator().getSpawnHeight(level); if (spawnHeight < level.getMinY()) { BlockPos worldPosition = chunkPos.getWorldPosition(); -@@ -495,26 +_,31 @@ +@@ -494,36 +_,48 @@ serverLevelData.setGameType(GameType.SPECTATOR); } @@ -557,12 +557,11 @@ - for (ServerLevel serverLevel1 : this.levels.values()) { + if (true) { -+ ServerLevel serverLevel1 = serverLevel; ++ final ServerLevel serverLevel1 = serverLevel; + // CraftBukkit end - ForcedChunksSavedData forcedChunksSavedData = serverLevel1.getDataStorage().get(ForcedChunksSavedData.factory(), "chunks"); - if (forcedChunksSavedData != null) { - LongIterator longIterator = forcedChunksSavedData.getChunks().iterator(); -@@ -527,10 +_,17 @@ + TicketStorage ticketStorage = serverLevel1.getDataStorage().get(TicketStorage.TYPE); + if (ticketStorage != null) { + ticketStorage.activateAllDeactivatedTickets(); } } @@ -583,11 +582,11 @@ } public GameType getDefaultGameType() { -@@ -559,11 +_,14 @@ +@@ -552,11 +_,14 @@ flag = true; } -+ /* // CraftBukkit start - moved to WorldServer.save ++ /* // CraftBukkit start - moved to ServerLevel#save ServerLevel serverLevel1 = this.overworld(); ServerLevelData serverLevelData = this.worldData.overworldData(); serverLevelData.setWorldBorder(serverLevel1.getWorldBorder().createSettings()); @@ -598,7 +597,7 @@ if (flush) { for (ServerLevel serverLevel2 : this.getAllLevels()) { LOGGER.info("ThreadedAnvilChunkStorage ({}): All chunks are saved", serverLevel2.getChunkSource().chunkMap.getStorageName()); -@@ -593,18 +_,48 @@ +@@ -586,18 +_,48 @@ this.stopServer(); } @@ -648,7 +647,7 @@ } LOGGER.info("Saving worlds"); -@@ -646,6 +_,25 @@ +@@ -639,6 +_,25 @@ } catch (IOException var4) { LOGGER.error("Failed to unlock level {}", this.storageSource.getLevelId(), var4); } @@ -674,7 +673,7 @@ } public String getLocalIp() { -@@ -661,6 +_,14 @@ +@@ -654,6 +_,14 @@ } public void halt(boolean waitForServer) { @@ -689,7 +688,7 @@ this.running = false; if (waitForServer) { try { -@@ -671,6 +_,57 @@ +@@ -664,6 +_,57 @@ } } @@ -747,7 +746,7 @@ protected void runServer() { try { if (!this.initServer()) { -@@ -681,6 +_,35 @@ +@@ -674,6 +_,35 @@ this.statusIcon = this.loadStatusIcon().orElse(null); this.status = this.buildServerStatus(); @@ -783,7 +782,7 @@ while (this.running) { long l; if (!this.isPaused() && this.tickRateManager.isSprinting() && this.tickRateManager.checkShouldSprintThisTick()) { -@@ -693,11 +_,30 @@ +@@ -686,11 +_,30 @@ if (l1 > OVERLOADED_THRESHOLD_NANOS + 20L * l && this.nextTickTimeNanos - this.lastOverloadWarningNanos >= OVERLOADED_WARNING_INTERVAL_NANOS + 100L * l) { long l2 = l1 / l; @@ -814,7 +813,7 @@ boolean flag = l == 0L; if (this.debugCommandProfilerDelayStart) { -@@ -705,6 +_,8 @@ +@@ -698,6 +_,8 @@ this.debugCommandProfiler = new MinecraftServer.TimeProfiler(Util.getNanos(), this.tickCount); } @@ -823,7 +822,7 @@ this.nextTickTimeNanos += l; try (Profiler.Scope scope = Profiler.use(this.createProfiler())) { -@@ -755,7 +_,7 @@ +@@ -748,7 +_,7 @@ this.services.profileCache().clearExecutor(); } @@ -832,7 +831,7 @@ } } } -@@ -807,7 +_,14 @@ +@@ -800,7 +_,14 @@ } private boolean haveTime() { @@ -848,7 +847,7 @@ } public static boolean throwIfFatalException() { -@@ -852,6 +_,12 @@ +@@ -845,6 +_,12 @@ @Override public TickTask wrapRunnable(Runnable runnable) { @@ -861,7 +860,7 @@ return new TickTask(this.tickCount, runnable); } -@@ -871,15 +_,16 @@ +@@ -864,15 +_,16 @@ if (super.pollTask()) { return true; } else { @@ -880,7 +879,7 @@ } } -@@ -927,26 +_,44 @@ +@@ -920,26 +_,44 @@ } public void tickServer(BooleanSupplier hasTimeLeft) { @@ -926,7 +925,7 @@ this.tickCount++; this.tickRateManager.tick(); this.tickChildren(hasTimeLeft); -@@ -956,11 +_,19 @@ +@@ -949,11 +_,19 @@ } this.ticksUntilAutosave--; @@ -947,7 +946,7 @@ profilerFiller.push("tallying"); long l = Util.getNanos() - nanos; int i1 = this.tickCount % 100; -@@ -968,12 +_,17 @@ +@@ -961,12 +_,17 @@ this.aggregatedTickTimesNanos += l; this.tickTimesNanos[i1] = l; this.smoothedTickTimeMillis = this.smoothedTickTimeMillis * 0.8F + (float)l / (float)TimeUtil.NANOSECONDS_PER_MILLISECOND * 0.19999999F; @@ -966,7 +965,7 @@ LOGGER.debug("Autosave started"); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("save"); -@@ -1015,7 +_,7 @@ +@@ -1008,7 +_,7 @@ private ServerStatus buildServerStatus() { ServerStatus.Players players = this.buildPlayerStatus(); return new ServerStatus( @@ -975,7 +974,7 @@ Optional.of(players), Optional.of(ServerStatus.Version.current()), Optional.ofNullable(this.statusIcon), -@@ -1029,7 +_,7 @@ +@@ -1022,7 +_,7 @@ if (this.hidesOnlinePlayers()) { return new ServerStatus.Players(maxPlayers, players.size(), List.of()); } else { @@ -984,7 +983,7 @@ ObjectArrayList list = new ObjectArrayList<>(min); int randomInt = Mth.nextInt(this.random, 0, players.size() - min); -@@ -1046,17 +_,66 @@ +@@ -1039,17 +_,66 @@ protected void tickChildren(BooleanSupplier hasTimeLeft) { ProfilerFiller profilerFiller = Profiler.get(); this.getPlayerList().getPlayers().forEach(serverPlayer1 -> serverPlayer1.connection.suspendFlushing()); @@ -1051,7 +1050,7 @@ profilerFiller.push("tick"); -@@ -1070,7 +_,9 @@ +@@ -1063,7 +_,9 @@ profilerFiller.pop(); profilerFiller.pop(); @@ -1061,7 +1060,7 @@ profilerFiller.popPush("connection"); this.tickConnection(); -@@ -1148,6 +_,22 @@ +@@ -1141,6 +_,22 @@ return this.levels.get(dimension); } @@ -1084,7 +1083,7 @@ public Set> levelKeys() { return this.levels.keySet(); } -@@ -1177,7 +_,7 @@ +@@ -1170,7 +_,7 @@ @DontObfuscate public String getServerModName() { @@ -1093,7 +1092,7 @@ } public SystemReport fillSystemReport(SystemReport systemReport) { -@@ -1212,7 +_,7 @@ +@@ -1205,7 +_,7 @@ @Override public void sendSystemMessage(Component component) { @@ -1102,7 +1101,7 @@ } public KeyPair getKeyPair() { -@@ -1250,11 +_,14 @@ +@@ -1243,11 +_,14 @@ } } @@ -1112,9 +1111,9 @@ - this.updateMobSpawningFlags(); - this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); + // Paper start - per level difficulty -+ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forceUpdate) { -+ net.minecraft.world.level.storage.PrimaryLevelData worldData = (net.minecraft.world.level.storage.PrimaryLevelData) level.serverLevelData; -+ if (forceUpdate || !worldData.isDifficultyLocked()) { ++ public void setDifficulty(ServerLevel level, Difficulty difficulty, boolean forced) { ++ net.minecraft.world.level.storage.PrimaryLevelData worldData = level.serverLevelData; ++ if (forced || !worldData.isDifficultyLocked()) { + worldData.setDifficulty(worldData.isHardcore() ? Difficulty.HARD : difficulty); + level.setSpawnSettings(worldData.getDifficulty() != Difficulty.PEACEFUL && ((net.minecraft.server.dedicated.DedicatedServer) this).settings.getProperties().spawnMonsters); + // this.getPlayerList().getPlayers().forEach(this::sendDifficultyUpdate); @@ -1122,7 +1121,7 @@ } } -@@ -1264,7 +_,7 @@ +@@ -1257,7 +_,7 @@ private void updateMobSpawningFlags() { for (ServerLevel serverLevel : this.getAllLevels()) { @@ -1131,7 +1130,7 @@ } } -@@ -1340,10 +_,20 @@ +@@ -1333,10 +_,20 @@ @Override public String getMotd() { @@ -1153,7 +1152,7 @@ this.motd = motd; } -@@ -1366,7 +_,7 @@ +@@ -1359,7 +_,7 @@ } public ServerConnectionListener getConnection() { @@ -1162,7 +1161,7 @@ } public boolean isReady() { -@@ -1452,7 +_,7 @@ +@@ -1445,7 +_,7 @@ @Override public void executeIfPossible(Runnable task) { if (this.isStopped()) { @@ -1171,7 +1170,7 @@ } else { super.executeIfPossible(task); } -@@ -1491,7 +_,13 @@ +@@ -1484,7 +_,14 @@ return this.functionManager; } @@ -1180,12 +1179,13 @@ public CompletableFuture reloadResources(Collection selectedIds) { + return this.reloadResources(selectedIds, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause.PLUGIN); + } ++ + public CompletableFuture reloadResources(Collection selectedIds, io.papermc.paper.event.server.ServerResourcesReloadedEvent.Cause cause) { + // Paper end - Add ServerResourcesReloadedEvent CompletableFuture completableFuture = CompletableFuture.supplyAsync( () -> selectedIds.stream().map(this.packRepository::getPack).filter(Objects::nonNull).map(Pack::open).collect(ImmutableList.toImmutableList()), this -@@ -1499,7 +_,7 @@ +@@ -1492,7 +_,7 @@ .thenCompose( list -> { CloseableResourceManager closeableResourceManager = new MultiPackResourceManager(PackType.SERVER_DATA, list); @@ -1194,7 +1194,7 @@ return ReloadableServerResources.loadResources( closeableResourceManager, this.registries, -@@ -1520,20 +_,39 @@ +@@ -1513,20 +_,39 @@ ) .thenAcceptAsync( reloadableResources -> { @@ -1236,7 +1236,7 @@ }, this ); -@@ -1550,7 +_,7 @@ +@@ -1543,7 +_,7 @@ DataPackConfig dataPackConfig = initialDataConfig.dataPacks(); FeatureFlagSet featureFlagSet = initMode ? FeatureFlagSet.of() : initialDataConfig.enabledFeatures(); FeatureFlagSet featureFlagSet1 = initMode ? FeatureFlags.REGISTRY.allFlags() : initialDataConfig.enabledFeatures(); @@ -1245,7 +1245,7 @@ if (safeMode) { return configureRepositoryWithSelection(packRepository, List.of("vanilla"), featureFlagSet, false); } else { -@@ -1605,7 +_,7 @@ +@@ -1598,7 +_,7 @@ private static WorldDataConfiguration configureRepositoryWithSelection( PackRepository packRepository, Collection selectedPacks, FeatureFlagSet enabledFeatures, boolean safeMode ) { @@ -1254,7 +1254,7 @@ enableForcedFeaturePacks(packRepository, enabledFeatures); DataPackConfig selectedPacks1 = getSelectedPacks(packRepository, safeMode); FeatureFlagSet featureFlagSet = packRepository.getRequestedFeatureFlags().join(enabledFeatures); -@@ -1637,7 +_,7 @@ +@@ -1630,7 +_,7 @@ } } @@ -1263,7 +1263,7 @@ } } -@@ -1651,11 +_,12 @@ +@@ -1644,11 +_,12 @@ public void kickUnlistedPlayers(CommandSourceStack commandSource) { if (this.isEnforceWhitelist()) { PlayerList playerList = commandSource.getServer().getPlayerList(); @@ -1278,7 +1278,7 @@ } } } -@@ -1859,6 +_,22 @@ +@@ -1852,6 +_,17 @@ } } @@ -1289,19 +1289,14 @@ + } + + public static MinecraftServer getServer() { -+ return SERVER; // Paper -+ } -+ -+ @Deprecated -+ public static RegistryAccess getDefaultRegistryAccess() { -+ return org.bukkit.craftbukkit.CraftRegistry.getMinecraftRegistry(); ++ return SERVER; + } + // CraftBukkit end + private ProfilerFiller createProfiler() { if (this.willStartRecordingMetrics) { this.metricsRecorder = ActiveMetricsRecorder.createStarted( -@@ -1980,16 +_,22 @@ +@@ -1973,16 +_,22 @@ } public void logChatMessage(Component content, ChatType.Bound boundChatType, @Nullable String header) { @@ -1328,7 +1323,7 @@ } public boolean logIPs() { -@@ -2122,4 +_,53 @@ +@@ -2115,4 +_,53 @@ }; } } diff --git a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch index 361c401ab..777791f77 100644 --- a/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/PlayerAdvancements.java.patch @@ -68,7 +68,7 @@ }); } @@ -247,7 +_,7 @@ - public void flushDirty(ServerPlayer serverPlayer) { + public void flushDirty(ServerPlayer player, boolean showAdvancements) { if (this.isFirstPacket || !this.rootsToUpdate.isEmpty() || !this.progressChanged.isEmpty()) { Map map = new HashMap<>(); - Set set = new HashSet<>(); diff --git a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch index 5b73435f3..24e1381dd 100644 --- a/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/ServerScoreboard.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/ServerScoreboard.java +++ b/net/minecraft/server/ServerScoreboard.java -@@ -39,9 +_,7 @@ +@@ -43,9 +_,7 @@ protected void onScoreChanged(ScoreHolder scoreHolder, Objective objective, Score score) { super.onScoreChanged(scoreHolder, objective, score); if (this.trackedObjectives.contains(objective)) { @@ -11,7 +11,7 @@ new ClientboundSetScorePacket( scoreHolder.getScoreboardName(), objective.getName(), -@@ -64,7 +_,7 @@ +@@ -68,7 +_,7 @@ @Override public void onPlayerRemoved(ScoreHolder scoreHolder) { super.onPlayerRemoved(scoreHolder); @@ -20,7 +20,7 @@ this.setDirty(); } -@@ -72,7 +_,7 @@ +@@ -76,7 +_,7 @@ public void onPlayerScoreRemoved(ScoreHolder scoreHolder, Objective objective) { super.onPlayerScoreRemoved(scoreHolder, objective); if (this.trackedObjectives.contains(objective)) { @@ -29,7 +29,7 @@ } this.setDirty(); -@@ -84,7 +_,7 @@ +@@ -88,7 +_,7 @@ super.setDisplayObjective(slot, objective); if (displayObjective != objective && displayObjective != null) { if (this.getObjectiveDisplaySlotCount(displayObjective) > 0) { @@ -38,7 +38,7 @@ } else { this.stopTrackingObjective(displayObjective); } -@@ -92,7 +_,7 @@ +@@ -96,7 +_,7 @@ if (objective != null) { if (this.trackedObjectives.contains(objective)) { @@ -47,7 +47,7 @@ } else { this.startTrackingObjective(objective); } -@@ -104,24 +_,50 @@ +@@ -108,24 +_,50 @@ @Override public boolean addPlayerToTeam(String playerName, PlayerTeam team) { if (super.addPlayerToTeam(playerName, team)) { @@ -112,7 +112,7 @@ @Override public void onObjectiveAdded(Objective objective) { -@@ -133,7 +_,7 @@ +@@ -137,7 +_,7 @@ public void onObjectiveChanged(Objective objective) { super.onObjectiveChanged(objective); if (this.trackedObjectives.contains(objective)) { @@ -121,7 +121,7 @@ } this.setDirty(); -@@ -152,21 +_,21 @@ +@@ -156,21 +_,21 @@ @Override public void onTeamAdded(PlayerTeam playerTeam) { super.onTeamAdded(playerTeam); @@ -146,7 +146,7 @@ this.setDirty(); } -@@ -209,6 +_,7 @@ +@@ -213,6 +_,7 @@ List> startTrackingPackets = this.getStartTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -154,7 +154,7 @@ for (Packet packet : startTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -234,6 +_,7 @@ +@@ -238,6 +_,7 @@ List> stopTrackingPackets = this.getStopTrackingPackets(objective); for (ServerPlayer serverPlayer : this.server.getPlayerList().getPlayers()) { @@ -162,9 +162,9 @@ for (Packet packet : stopTrackingPackets) { serverPlayer.connection.send(packet); } -@@ -267,6 +_,16 @@ - private ScoreboardSaveData createData(CompoundTag tag, HolderLookup.Provider registries) { - return this.createData().load(tag, registries); +@@ -269,6 +_,16 @@ + scoreboardSaveData.loadFrom(data); + return scoreboardSaveData; } + + // CraftBukkit start - Send to players diff --git a/paper-server/patches/sources/net/minecraft/server/Services.java.patch b/paper-server/patches/sources/net/minecraft/server/Services.java.patch index 86364d06c..53adad7a3 100644 --- a/paper-server/patches/sources/net/minecraft/server/Services.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/Services.java.patch @@ -7,11 +7,9 @@ - MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache + MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache, @javax.annotation.Nullable io.papermc.paper.configuration.PaperConfigurations paperConfigurations // Paper - add paper configuration files ) { -- private static final String USERID_CACHE_FILE = "usercache.json"; -- + public static final String USERID_CACHE_FILE = "usercache.json"; + - public static Services create(YggdrasilAuthenticationService authenticationService, File profileRepository) { -+ public static final String USERID_CACHE_FILE = "usercache.json"; // Paper - private -> public -+ + // Paper start - add paper configuration files + public Services(MinecraftSessionService sessionService, ServicesKeySet servicesKeySet, GameProfileRepository profileRepository, GameProfileCache profileCache) { + this(sessionService, servicesKeySet, profileRepository, profileCache, null); diff --git a/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch index be76cc357..7cc7cb15f 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/GiveCommand.java.patch @@ -8,15 +8,6 @@ int maxStackSize = itemStack.getMaxStackSize(); int i = maxStackSize * 100; if (count > i) { -@@ -66,7 +_,7 @@ - ItemStack itemStack1 = item.createItemStack(min, false); - boolean flag = serverPlayer.getInventory().add(itemStack1); - if (flag && itemStack1.isEmpty()) { -- ItemEntity itemEntity = serverPlayer.drop(itemStack, false); -+ ItemEntity itemEntity = serverPlayer.drop(itemStack, false, false, false); // CraftBukkit - SPIGOT-2942: Add boolean to call event - if (itemEntity != null) { - itemEntity.makeFakeItem(); - } @@ -95,11 +_,11 @@ if (targets.size() == 1) { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/OpCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/OpCommand.java.patch deleted file mode 100644 index bb5525dd8..000000000 --- a/paper-server/patches/sources/net/minecraft/server/commands/OpCommand.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/server/commands/OpCommand.java -+++ b/net/minecraft/server/commands/OpCommand.java -@@ -46,7 +_,7 @@ - if (!playerList.isOp(gameProfile)) { - playerList.op(gameProfile); - i++; -- source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfiles.iterator().next().getName()), true); -+ source.sendSuccess(() -> Component.translatable("commands.op.success", gameProfile.getName()), true); // Paper - fixes MC-253721 - } - } - diff --git a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch index ec190202c..b84004a49 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/PlaceCommand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/commands/PlaceCommand.java +++ b/net/minecraft/server/commands/PlaceCommand.java -@@ -280,6 +_,7 @@ +@@ -301,6 +_,7 @@ if (!structureStart.isValid()) { throw ERROR_STRUCTURE_FAILED.create(); } else { diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch index a2a722311..df6b7c54f 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SetSpawnCommand.java.patch @@ -6,10 +6,10 @@ + final Collection actualTargets = new java.util.ArrayList<>(); // Paper - Add PlayerSetSpawnEvent for (ServerPlayer serverPlayer : targets) { -- serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false); +- serverPlayer.setRespawnPosition(new ServerPlayer.RespawnConfig(resourceKey, pos, angle, true), false); - } + // Paper start - Add PlayerSetSpawnEvent -+ if (serverPlayer.setRespawnPosition(resourceKey, pos, angle, true, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) { ++ if (serverPlayer.setRespawnPosition(new ServerPlayer.RespawnConfig(resourceKey, pos, angle, true), false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.COMMAND)) { + actualTargets.add(serverPlayer); + } + // Paper end - Add PlayerSetSpawnEvent diff --git a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch index e35d0b032..c436b4d04 100644 --- a/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/commands/SummonCommand.java.patch @@ -3,7 +3,7 @@ @@ -82,6 +_,7 @@ ServerLevel level = source.getLevel(); Entity entity = EntityType.loadEntityRecursive(compoundTag, level, EntitySpawnReason.COMMAND, entity1 -> { - entity1.moveTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot()); + entity1.snapTo(pos.x, pos.y, pos.z, entity1.getYRot(), entity1.getXRot()); + entity1.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.COMMAND; // Paper - Entity#getEntitySpawnReason return entity1; }); diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch index 1b3175021..24a45b377 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/DedicatedServer.java.patch @@ -33,56 +33,24 @@ this.serverTextFilter = ServerTextFilter.createFromConfig(settings.getProperties()); this.serverLinks = createServerLinks(settings); } -@@ -102,26 +_,95 @@ +@@ -102,6 +_,10 @@ Thread thread = new Thread("Server console handler") { @Override public void run() { -- BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); -- -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.Main.useConsole) return; ++ if (!org.bukkit.craftbukkit.Main.useConsole) return; // CraftBukkit + // Paper start - Use TerminalConsoleAppender + new com.destroystokyo.paper.console.PaperConsole(DedicatedServer.this).start(); + /* -+ jline.console.ConsoleReader bufferedreader = DedicatedServer.this.reader; -+ // MC-33041, SPIGOT-5538: if System.in is not valid due to javaw, then return -+ try { -+ System.in.available(); -+ } catch (IOException ex) { -+ return; -+ } -+ // CraftBukkit end + BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8)); + String string1; - try { -- while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning() && (string1 = bufferedReader.readLine()) != null) { -- DedicatedServer.this.handleConsoleInput(string1, DedicatedServer.this.createCommandSourceStack()); -+ // CraftBukkit start - JLine disabling compatibility -+ while (!DedicatedServer.this.isStopped() && DedicatedServer.this.isRunning()) { -+ if (org.bukkit.craftbukkit.Main.useJline) { -+ string1 = bufferedreader.readLine(">", null); -+ } else { -+ string1 = bufferedreader.readLine(); -+ } -+ -+ // SPIGOT-5220: Throttle if EOF (ctrl^d) or stdin is /dev/null -+ if (string1 == null) { -+ try { -+ Thread.sleep(50L); -+ } catch (InterruptedException ex) { -+ Thread.currentThread().interrupt(); -+ } -+ continue; -+ } -+ if (string1.trim().length() > 0) { // Trim to filter lines which are just spaces -+ DedicatedServer.this.issueCommand(s, DedicatedServer.this.getServerCommandListener()); -+ } -+ // CraftBukkit end +@@ -111,17 +_,41 @@ } } catch (IOException var4) { DedicatedServer.LOGGER.error("Exception handling console input", (Throwable)var4); - } -+ */ -+ // Paper end +- } ++ }*/ ++ // Paper end - Use TerminalConsoleAppender } }; + // CraftBukkit start - TODO: handle command-line logging arguments @@ -93,21 +61,7 @@ + } + global.addHandler(new org.bukkit.craftbukkit.util.ForwardLogHandler()); + -+ // Paper start - Not needed with TerminalConsoleAppender + final org.apache.logging.log4j.Logger logger = org.apache.logging.log4j.LogManager.getRootLogger(); -+ /* -+ final org.apache.logging.log4j.core.Logger logger = ((org.apache.logging.log4j.core.Logger) LogManager.getRootLogger()); -+ for (org.apache.logging.log4j.core.Appender appender : logger.getAppenders().values()) { -+ if (appender instanceof org.apache.logging.log4j.core.appender.ConsoleAppender) { -+ logger.removeAppender(appender); -+ } -+ } -+ -+ TerminalConsoleWriterThread writerThread = new TerminalConsoleWriterThread(System.out, this.reader); -+ this.reader.setCompletionHandler(new TerminalCompletionHandler(writerThread, this.reader.getCompletionHandler())); -+ writerThread.start(); -+ */ -+ // Paper end - Not needed with TerminalConsoleAppender + + System.setOut(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(org.apache.logging.log4j.Level.INFO).buildPrintStream()); + System.setErr(org.apache.logging.log4j.io.IoBuilder.forLogger(logger).setLevel(org.apache.logging.log4j.Level.WARN).buildPrintStream()); @@ -187,7 +141,7 @@ InetAddress inetAddress = null; if (!this.getLocalIp().isEmpty()) { inetAddress = InetAddress.getByName(this.getLocalIp()); -@@ -147,36 +_,62 @@ +@@ -147,36 +_,61 @@ if (this.getPort() < 0) { this.setPort(properties.serverPort); } @@ -210,7 +164,6 @@ } + // CraftBukkit start -+ // this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); // Spigot - moved up + this.server.loadPlugins(); + this.server.enablePlugins(org.bukkit.plugin.PluginLoadOrder.STARTUP); + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch index 26a7bec38..399d3cb66 100644 --- a/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/dedicated/Settings.java.patch @@ -15,7 +15,7 @@ + } + + private String getOverride(String name, String value) { -+ if ((this.options != null) && (this.options.has(name))) { ++ if (this.options != null && this.options.has(name)) { + return String.valueOf(this.options.valueOf(name)); + } + diff --git a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch index 06c477be8..e09adc2fe 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ChunkMap.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -145,6 +_,33 @@ +@@ -149,6 +_,33 @@ public int serverViewDistance; private final WorldGenContext worldGenContext; @@ -34,7 +34,7 @@ public ChunkMap( ServerLevel level, LevelStorageSource.LevelStorageAccess levelStorageAccess, -@@ -171,13 +_,19 @@ +@@ -176,13 +_,19 @@ this.level = level; RegistryAccess registryAccess = level.registryAccess(); long seed = level.getSeed(); @@ -56,7 +56,7 @@ this.mainThreadExecutor = mainThreadExecutor; ConsecutiveExecutor consecutiveExecutor = new ConsecutiveExecutor(dispatcher, "worldgen"); this.progressListener = progressListener; -@@ -207,6 +_,12 @@ +@@ -213,6 +_,12 @@ this.chunksToEagerlySave.add(chunkPos.toLong()); } @@ -69,7 +69,7 @@ protected ChunkGenerator generator() { return this.worldGenContext.generator(); } -@@ -354,9 +_,9 @@ +@@ -352,9 +_,9 @@ } ); stringBuilder.append("Updating:").append(System.lineSeparator()); @@ -81,17 +81,15 @@ CrashReport crashReport = CrashReport.forThrowable(exception, "Chunk loading"); CrashReportCategory crashReportCategory = crashReport.addCategory("Chunk loading"); crashReportCategory.setDetail("Details", details); -@@ -392,6 +_,9 @@ +@@ -390,6 +_,7 @@ holder.setTicketLevel(newLevel); } else { holder = new ChunkHolder(new ChunkPos(chunkPos), newLevel, this.level, this.lightEngine, this::onLevelChange, this); -+ // Paper start -+ ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, holder); -+ // Paper end ++ ca.spottedleaf.moonrise.common.PlatformHooks.get().onChunkHolderCreate(this.level, holder); // Paper } this.updatingChunkMap.put(chunkPos, holder); -@@ -420,8 +_,8 @@ +@@ -418,8 +_,8 @@ protected void saveAllChunks(boolean flush) { if (flush) { @@ -102,7 +100,7 @@ .stream() .filter(ChunkHolder::wasAccessibleSinceLastSave) .peek(ChunkHolder::refreshAccessibility) -@@ -447,7 +_,7 @@ +@@ -445,7 +_,7 @@ this.nextChunkSaveTime.clear(); long millis = Util.getMillis(); @@ -111,7 +109,7 @@ this.saveChunkIfNeeded(chunkHolder, millis); } } -@@ -468,6 +_,7 @@ +@@ -466,6 +_,7 @@ public boolean hasWork() { return this.lightEngine.hasLightWork() || !this.pendingUnloads.isEmpty() @@ -119,7 +117,7 @@ || !this.updatingChunkMap.isEmpty() || this.poiManager.hasWork() || !this.toDrop.isEmpty() -@@ -526,7 +_,11 @@ +@@ -524,7 +_,11 @@ this.scheduleUnload(chunkPos, chunkHolder); } else { ChunkAccess latestChunk = chunkHolder.getLatestChunk(); @@ -132,7 +130,7 @@ if (latestChunk instanceof LevelChunk levelChunk) { levelChunk.setLoaded(false); } -@@ -540,7 +_,9 @@ +@@ -538,7 +_,9 @@ this.lightEngine.tryScheduleUpdate(); this.progressListener.onStatusChange(latestChunk.getPos(), null); this.nextChunkSaveTime.remove(latestChunk.getPos().toLong()); @@ -143,7 +141,7 @@ } }, this.unloadQueue::add).whenComplete((_void, error) -> { if (error != null) { -@@ -856,7 +_,7 @@ +@@ -854,7 +_,7 @@ } public int size() { @@ -152,7 +150,7 @@ } public net.minecraft.server.level.DistanceManager getDistanceManager() { -@@ -864,7 +_,7 @@ +@@ -862,7 +_,7 @@ } protected Iterable getChunks() { @@ -161,9 +159,9 @@ } void dumpChunks(Writer writer) throws IOException { -@@ -888,10 +_,10 @@ +@@ -885,10 +_,10 @@ + .addColumn("fluid_ticks") .build(writer); - TickingTracker tickingTracker = this.distanceManager.tickingTracker(); - for (Entry entry : this.visibleChunkMap.long2ObjectEntrySet()) { - long longKey = entry.getLongKey(); @@ -175,7 +173,7 @@ Optional optional = Optional.ofNullable(chunkHolder.getLatestChunk()); Optional optional1 = optional.flatMap(chunk -> chunk instanceof LevelChunk ? Optional.of((LevelChunk)chunk) : Optional.empty()); csvOutput.writeRow( -@@ -931,11 +_,13 @@ +@@ -928,11 +_,13 @@ } private CompletableFuture> readChunk(ChunkPos pos) { @@ -191,18 +189,28 @@ + // CraftBukkit end } - void forEachSpawnCandidateChunk(Consumer action) { -@@ -951,12 +_,34 @@ + void collectSpawningChunks(List output) { +@@ -942,7 +_,7 @@ + ChunkHolder chunkHolder = this.visibleChunkMap.get(spawnCandidateChunks.nextLong()); + if (chunkHolder != null) { + LevelChunk tickingChunk = chunkHolder.getTickingChunk(); +- if (tickingChunk != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkHolder.getPos())) { ++ if (tickingChunk != null && this.anyPlayerCloseEnoughForSpawningInternal(chunkHolder.getPos(), true)) { // Spigot + output.add(tickingChunk); + } + } +@@ -962,13 +_,35 @@ } public boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos) { -- return this.distanceManager.hasPlayersNearby(chunkPos.toLong()) && this.anyPlayerCloseEnoughForSpawningInternal(chunkPos); + // Spigot start + return this.anyPlayerCloseEnoughForSpawning(chunkPos, false); + } + + boolean anyPlayerCloseEnoughForSpawning(ChunkPos chunkPos, boolean reducedRange) { -+ return this.distanceManager.hasPlayersNearby(chunkPos.toLong()) && this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, reducedRange); + TriState triState = this.distanceManager.hasPlayersNearby(chunkPos.toLong()); +- return triState == TriState.DEFAULT ? this.anyPlayerCloseEnoughForSpawningInternal(chunkPos) : triState.toBoolean(true); ++ return triState == TriState.DEFAULT ? this.anyPlayerCloseEnoughForSpawningInternal(chunkPos, reducedRange) : triState.toBoolean(true); + // Spigot end } @@ -224,12 +232,12 @@ + if (event == null || event.isCancelled()) continue; + blockRange = (double) ((event.getSpawnRadius() << 4) * (event.getSpawnRadius() << 4)); + } -+ // Paper end - PlayerNaturallySpawnCreaturesEvent + if (this.playerIsCloseEnoughForSpawning(serverPlayer, chunkPos, blockRange)) { ++ // Paper end - PlayerNaturallySpawnCreaturesEvent return true; } } -@@ -972,7 +_,7 @@ +@@ -984,7 +_,7 @@ Builder builder = ImmutableList.builder(); for (ServerPlayer serverPlayer : this.playerMap.getAllPlayers()) { @@ -238,7 +246,7 @@ builder.add(serverPlayer); } } -@@ -981,12 +_,12 @@ +@@ -993,12 +_,12 @@ } } @@ -247,13 +255,13 @@ if (player.isSpectator()) { return false; } else { - double d = euclideanDistanceSquared(chunkPos, player); + double d = euclideanDistanceSquared(chunkPos, player.position()); - return d < 16384.0; + return d < range; // Spigot } } -@@ -1100,9 +_,19 @@ +@@ -1120,9 +_,19 @@ } public void addEntity(Entity entity) { @@ -273,7 +281,7 @@ if (i != 0) { int updateInterval = type.updateInterval(); if (this.entityMap.containsKey(entity.getId())) { -@@ -1126,6 +_,7 @@ +@@ -1146,6 +_,7 @@ } protected void removeEntity(Entity entity) { @@ -281,16 +289,7 @@ if (entity instanceof ServerPlayer serverPlayer) { this.updatePlayerStatus(serverPlayer, false); -@@ -1230,7 +_,7 @@ - }); - } - -- class DistanceManager extends net.minecraft.server.level.DistanceManager { -+ public class DistanceManager extends net.minecraft.server.level.DistanceManager { // Paper - public - protected DistanceManager(final Executor dispatcher, final Executor mainThreadExecutor) { - super(dispatcher, mainThreadExecutor); - } -@@ -1258,10 +_,10 @@ +@@ -1278,10 +_,10 @@ final Entity entity; private final int range; SectionPos lastSectionPos; @@ -298,12 +297,12 @@ + public final Set seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl public TrackedEntity(final Entity entity, final int range, final int updateInterval, final boolean trackDelta) { -- this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast); -+ this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this.seenBy); // CraftBukkit +- this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers); ++ this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, updateInterval, trackDelta, this::broadcast, this::broadcastIgnorePlayers, this.seenBy); // Paper this.entity = entity; this.range = range; this.lastSectionPos = SectionPos.of(entity); -@@ -1297,24 +_,47 @@ +@@ -1325,24 +_,47 @@ } public void removePlayer(ServerPlayer player) { @@ -356,7 +355,7 @@ } } else if (this.seenBy.remove(player.connection)) { this.serverEntity.removePairing(player); -@@ -1331,6 +_,7 @@ +@@ -1359,6 +_,7 @@ for (Entity entity : this.entity.getIndirectPassengers()) { int i1 = entity.getType().clientTrackingRange() * 16; diff --git a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch index 2ac4d5bef..0ef527512 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/DistanceManager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/DistanceManager.java +++ b/net/minecraft/server/level/DistanceManager.java -@@ -107,6 +_,12 @@ +@@ -72,6 +_,12 @@ } if (!this.chunksToUpdateFutures.isEmpty()) { @@ -13,51 +13,7 @@ for (ChunkHolder chunkHolder : this.chunksToUpdateFutures) { chunkHolder.updateHighestAllowedStatus(chunkMap); } -@@ -177,16 +_,42 @@ - public void addRegionTicket(TicketType type, ChunkPos pos, int distance, T value) { - Ticket ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); - long packedChunkPos = pos.toLong(); -- this.addTicket(packedChunkPos, ticket); -+ this.addTicket(packedChunkPos, ticket); // Paper - diff on change above - this.tickingTicketsTracker.addTicket(packedChunkPos, ticket); - } - - public void removeRegionTicket(TicketType type, ChunkPos pos, int distance, T value) { - Ticket ticket = new Ticket<>(type, ChunkLevel.byStatus(FullChunkStatus.FULL) - distance, value); - long packedChunkPos = pos.toLong(); -+ this.removeTicket(packedChunkPos, ticket); // Paper - diff on change above -+ this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket); -+ } -+ -+ // Paper start -+ public boolean addPluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { -+ Ticket ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31 -+ final long packedChunkPos = pos.toLong(); -+ final Set> tickets = this.getTickets(packedChunkPos); -+ if (tickets.contains(ticket)) { -+ return false; -+ } -+ this.addTicket(packedChunkPos, ticket); -+ this.tickingTicketsTracker.addTicket(packedChunkPos, ticket); -+ return true; -+ } -+ -+ public boolean removePluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { -+ Ticket ticket = new Ticket<>(TicketType.PLUGIN_TICKET, ChunkLevel.byStatus(FullChunkStatus.FULL) - 2, value); // Copied from below and keep in-line with force loading, add at level 31 -+ final long packedChunkPos = pos.toLong(); -+ final Set> tickets = this.tickets.get(packedChunkPos); // Don't use getTickets, we don't want to create a new set -+ if (tickets == null || !tickets.contains(ticket)) { -+ return false; -+ } - this.removeTicket(packedChunkPos, ticket); - this.tickingTicketsTracker.removeTicket(packedChunkPos, ticket); -+ return true; - } -+ // Paper end - - private SortedArraySet> getTickets(long chunkPos) { - return this.tickets.computeIfAbsent(chunkPos, l -> SortedArraySet.create(4)); -@@ -217,8 +_,10 @@ +@@ -121,8 +_,10 @@ ChunkPos chunkPos = sectionPos.chunk(); long packedChunkPos = chunkPos.toLong(); ObjectSet set = this.playersPerChunk.get(packedChunkPos); @@ -70,39 +26,3 @@ this.playersPerChunk.remove(packedChunkPos); this.naturalSpawnChunkCounter.update(packedChunkPos, Integer.MAX_VALUE, false); this.playerTicketManager.update(packedChunkPos, Integer.MAX_VALUE, false); -@@ -299,7 +_,7 @@ - } - - public void removeTicketsOnClosing() { -- ImmutableSet> set = ImmutableSet.of(TicketType.UNKNOWN); -+ ImmutableSet> set = ImmutableSet.of(TicketType.UNKNOWN, TicketType.POST_TELEPORT, TicketType.FUTURE_AWAIT); // Paper - add additional tickets to preserve - ObjectIterator>>> objectIterator = this.tickets.long2ObjectEntrySet().fastIterator(); - - while (objectIterator.hasNext()) { -@@ -329,6 +_,26 @@ - public boolean hasTickets() { - return !this.tickets.isEmpty(); - } -+ -+ // CraftBukkit start -+ public void removeAllTicketsFor(TicketType ticketType, int ticketLevel, T ticketIdentifier) { -+ Ticket target = new Ticket<>(ticketType, ticketLevel, ticketIdentifier); -+ -+ for (java.util.Iterator>>> iterator = this.tickets.long2ObjectEntrySet().fastIterator(); iterator.hasNext();) { -+ Entry>> entry = iterator.next(); -+ SortedArraySet> tickets = entry.getValue(); -+ if (tickets.remove(target)) { -+ // copied from removeTicket -+ this.ticketTracker.update(entry.getLongKey(), DistanceManager.getTicketLevelAt(tickets), false); -+ -+ // can't use entry after it's removed -+ if (tickets.isEmpty()) { -+ iterator.remove(); -+ } -+ } -+ } -+ } -+ // CraftBukkit end - - class ChunkTicketTracker extends ChunkTracker { - private static final int MAX_LEVEL = ChunkLevel.MAX_LEVEL + 1; diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch index ec01e0da0..299330b83 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerChunkCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -73,6 +_,13 @@ +@@ -77,6 +_,13 @@ @Nullable @VisibleForDebug private NaturalSpawner.SpawnState lastSpawnState; @@ -14,7 +14,7 @@ public ServerChunkCache( ServerLevel level, -@@ -121,6 +_,64 @@ +@@ -127,6 +_,64 @@ this.clearCache(); } @@ -46,12 +46,12 @@ + return holder.getLatestChunk(); + } + -+ public void addTicketAtLevel(TicketType ticketType, ChunkPos chunkPos, int ticketLevel, T identifier) { -+ this.distanceManager.addTicket(ticketType, chunkPos, ticketLevel, identifier); ++ public void addTicketAtLevel(TicketType ticketType, ChunkPos chunkPos, int ticketLevel) { ++ this.ticketStorage.addTicket(new Ticket(ticketType, ticketLevel), chunkPos); + } + -+ public void removeTicketAtLevel(TicketType ticketType, ChunkPos chunkPos, int ticketLevel, T identifier) { -+ this.distanceManager.removeTicket(ticketType, chunkPos, ticketLevel, identifier); ++ public void removeTicketAtLevel(TicketType ticketType, ChunkPos chunkPos, int ticketLevel) { ++ this.ticketStorage.removeTicket(new Ticket(ticketType, ticketLevel), chunkPos); + } + + // "real" get chunk if loaded @@ -79,7 +79,7 @@ @Override public ThreadedLevelLightEngine getLightEngine() { return this.lightEngine; -@@ -160,7 +_,7 @@ +@@ -166,7 +_,7 @@ for (int i = 0; i < 4; i++) { if (packedChunkPos == this.lastChunkPos[i] && chunkStatus == this.lastChunkStatus[i]) { ChunkAccess chunkAccess = this.lastChunk[i]; @@ -88,7 +88,7 @@ return chunkAccess; } } -@@ -169,6 +_,7 @@ +@@ -175,6 +_,7 @@ profilerFiller.incrementCounter("getChunkCacheMiss"); CompletableFuture> chunkFutureMainThread = this.getChunkFutureMainThread(x, z, chunkStatus, requireChunk); this.mainThreadProcessor.managedBlock(chunkFutureMainThread::isDone); @@ -96,7 +96,7 @@ ChunkResult chunkResult = chunkFutureMainThread.join(); ChunkAccess chunkAccess1 = chunkResult.orElse(null); if (chunkAccess1 == null && requireChunk) { -@@ -240,7 +_,15 @@ +@@ -246,7 +_,15 @@ long packedChunkPos = chunkPos.toLong(); int i = ChunkLevel.byStatus(chunkStatus); ChunkHolder visibleChunkIfPresent = this.getVisibleChunkIfPresent(packedChunkPos); @@ -109,11 +109,11 @@ + currentlyUnloading = (oldChunkState.isOrAfter(FullChunkStatus.FULL) && !currentChunkState.isOrAfter(FullChunkStatus.FULL)); + } + if (requireChunk && !currentlyUnloading) { -+ // CraftBukkit end - this.distanceManager.addTicket(TicketType.UNKNOWN, chunkPos, i, chunkPos); ++ // CraftBukkit end + this.addTicket(new Ticket(TicketType.UNKNOWN, i), chunkPos); if (this.chunkAbsent(visibleChunkIfPresent, i)) { ProfilerFiller profilerFiller = Profiler.get(); -@@ -260,7 +_,7 @@ +@@ -266,7 +_,7 @@ } private boolean chunkAbsent(@Nullable ChunkHolder chunkHolder, int status) { @@ -122,16 +122,7 @@ } @Override -@@ -287,7 +_,7 @@ - return this.mainThreadProcessor.pollTask(); - } - -- boolean runDistanceManagerUpdates() { -+ public boolean runDistanceManagerUpdates() { // Paper - public - boolean flag = this.distanceManager.runAllUpdates(this.chunkMap); - boolean flag1 = this.chunkMap.promoteChunkMap(); - this.chunkMap.runGenerationTasks(); -@@ -315,17 +_,39 @@ +@@ -321,17 +_,39 @@ @Override public void close() throws IOException { @@ -155,7 +146,7 @@ + ProfilerFiller gameprofilerfiller = Profiler.get(); + + gameprofilerfiller.push("purge"); -+ this.distanceManager.purgeStaleTickets(); ++ this.ticketStorage.purgeStaleTickets(); + this.runDistanceManagerUpdates(); + gameprofilerfiller.popPush("unload"); + this.chunkMap.tick(() -> true); @@ -170,10 +161,10 @@ profilerFiller.push("purge"); - if (this.level.tickRateManager().runsNormally() || !tickChunks) { + if (this.level.tickRateManager().runsNormally() || !tickChunks || this.level.spigotConfig.unloadFrozenChunks) { // Spigot - this.distanceManager.purgeStaleTickets(); + this.ticketStorage.purgeStaleTickets(); } -@@ -400,12 +_,20 @@ +@@ -388,12 +_,20 @@ ); this.lastSpawnState = spawnState; profiler.popPush("spawnAndTick"); @@ -197,16 +188,7 @@ } else { filteredSpawningCategories = List.of(); } -@@ -413,7 +_,7 @@ - for (LevelChunk levelChunk : chunks) { - ChunkPos pos = levelChunk.getPos(); - levelChunk.incrementInhabitedTime(timeInhabited); -- if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos)) { -+ if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot - NaturalSpawner.spawnForChunk(this.level, levelChunk, spawnState, filteredSpawningCategories); - } - -@@ -526,8 +_,13 @@ +@@ -544,8 +_,13 @@ @Override public void setSpawnSettings(boolean spawnSettings) { @@ -221,7 +203,7 @@ } public String getChunkDebugData(ChunkPos chunkPos) { -@@ -603,12 +_,18 @@ +@@ -618,12 +_,18 @@ @Override public boolean pollTask() { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch index 7932d7570..1de63e2c7 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -65,13 +_,17 @@ +@@ -69,11 +_,12 @@ private Vec3 lastSentMovement; private int tickCount; private int teleportDelay; @@ -10,26 +10,25 @@ private boolean wasOnGround; @Nullable private List> trackedDataValues; ++ private final Set trackedPlayers; // Paper -- public ServerEntity(ServerLevel level, Entity entity, int updateInterval, boolean trackDelta, Consumer> broadcast) { -+ // CraftBukkit start -+ private final Set trackedPlayers; -+ public ServerEntity(ServerLevel level, Entity entity, int updateInterval, boolean trackDelta, Consumer> broadcast, final Set trackedPlayers) { -+ this.trackedPlayers = trackedPlayers; -+ // CraftBukkit end + public ServerEntity( + ServerLevel level, +@@ -81,8 +_,12 @@ + int updateInterval, + boolean trackDelta, + Consumer> broadcast, +- BiConsumer, List> broadcastWithIgnore ++ // Paper start ++ BiConsumer, List> broadcastWithIgnore, ++ final Set trackedPlayers ++ // Paper end + ) { ++ this.trackedPlayers = trackedPlayers; // Paper this.level = level; this.broadcast = broadcast; this.entity = entity; -@@ -89,7 +_,7 @@ - public void sendChanges() { - List passengers = this.entity.getPassengers(); - if (!passengers.equals(this.lastPassengers)) { -- this.broadcast.accept(new ClientboundSetPassengersPacket(this.entity)); -+ this.broadcastAndSend(new ClientboundSetPassengersPacket(this.entity)); // CraftBukkit - removedPassengers(passengers, this.lastPassengers) - .forEach( - removedPassenger -> { -@@ -102,13 +_,14 @@ +@@ -106,13 +_,14 @@ this.lastPassengers = passengers; } @@ -48,7 +47,7 @@ savedData.tickCarriedBy(serverPlayer, item); Packet updatePacket = savedData.getUpdatePacket(mapId, serverPlayer); if (updatePacket != null) { -@@ -141,7 +_,13 @@ +@@ -145,7 +_,13 @@ } else { this.teleportDelay++; Vec3 vec3 = this.entity.trackingPosition(); @@ -63,7 +62,7 @@ Packet packet = null; boolean flag2 = flag1 || this.tickCount % 60 == 0; boolean flag3 = false; -@@ -219,6 +_,25 @@ +@@ -223,6 +_,25 @@ this.tickCount++; if (this.entity.hurtMarked) { @@ -89,7 +88,7 @@ this.entity.hurtMarked = false; this.broadcastAndSend(new ClientboundSetEntityMotionPacket(this.entity)); } -@@ -273,7 +_,10 @@ +@@ -280,7 +_,10 @@ public void sendPairingData(ServerPlayer player, Consumer> consumer) { if (this.entity.isRemoved()) { @@ -101,7 +100,7 @@ } Packet addEntityPacket = this.entity.getAddEntityPacket(this); -@@ -285,6 +_,12 @@ +@@ -292,6 +_,12 @@ boolean flag = this.trackDelta; if (this.entity instanceof LivingEntity) { Collection syncableAttributes = ((LivingEntity)this.entity).getAttributes().getSyncableAttributes(); @@ -114,18 +113,18 @@ if (!syncableAttributes.isEmpty()) { consumer.accept(new ClientboundUpdateAttributesPacket(this.entity.getId(), syncableAttributes)); } -@@ -309,8 +_,9 @@ +@@ -316,8 +_,9 @@ } if (!list.isEmpty()) { - consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list)); + consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list, true)); // Paper - data sanitization } -+ ((LivingEntity) this.entity).detectEquipmentUpdatesPublic(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending ++ ((LivingEntity) this.entity).detectEquipmentUpdates(); // CraftBukkit - SPIGOT-3789: sync again immediately after sending } if (!this.entity.getPassengers().isEmpty()) { -@@ -357,6 +_,11 @@ +@@ -364,6 +_,11 @@ if (this.entity instanceof LivingEntity) { Set attributesToSync = ((LivingEntity)this.entity).getAttributes().getAttributesToSync(); if (!attributesToSync.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch index 69e9d0f01..b278b58c6 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerLevel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -182,7 +_,7 @@ +@@ -178,7 +_,7 @@ final List players = Lists.newArrayList(); public final ServerChunkCache chunkSource; private final MinecraftServer server; @@ -9,17 +9,18 @@ private int lastSpawnChunkRadius; final EntityTickList entityTickList = new EntityTickList(); public final PersistentEntitySectionManager entityManager; -@@ -209,11 +_,132 @@ +@@ -205,11 +_,131 @@ private final boolean tickTime; private final RandomSequences randomSequences; + // CraftBukkit start + public final LevelStorageSource.LevelStorageAccess levelStorageAccess; -+ public final UUID uuid; ++ public final java.util.UUID uuid; + public boolean hasPhysicsEvent = true; // Paper - BlockPhysicsEvent + public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent + -+ public LevelChunk getChunkIfLoaded(int x, int z) { ++ @Override ++ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { + return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately + } + @@ -91,14 +92,12 @@ + int requiredChunks = (maxChunkX - minChunkX + 1) * (maxChunkZ - minChunkZ + 1); + int[] loadedChunks = new int[1]; + -+ Long holderIdentifier = Long.valueOf(chunkProvider.chunkFutureAwaitCounter++); -+ + java.util.function.Consumer consumer = (net.minecraft.world.level.chunk.ChunkAccess chunk) -> { + if (chunk != null) { + int ticketLevel = Math.max(33, chunkProvider.chunkMap.getUpdatingChunkIfPresent(chunk.getPos().toLong()).getTicketLevel()); + ret.add(chunk); + ticketLevels.add(ticketLevel); -+ chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel, holderIdentifier); ++ chunkProvider.addTicketAtLevel(TicketType.FUTURE_AWAIT, chunk.getPos(), ticketLevel); + } + if (++loadedChunks[0] == requiredChunks) { + try { @@ -108,8 +107,8 @@ + ChunkPos chunkPos = ret.get(i).getPos(); + int ticketLevel = ticketLevels.getInt(i); + -+ chunkProvider.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, ticketLevel, chunkPos); -+ chunkProvider.removeTicketAtLevel(TicketType.FUTURE_AWAIT, chunkPos, ticketLevel, holderIdentifier); ++ chunkProvider.addTicketAtLevel(TicketType.UNKNOWN, chunkPos, ticketLevel); ++ chunkProvider.removeTicketAtLevel(TicketType.FUTURE_AWAIT, chunkPos, ticketLevel); + } + } + } @@ -128,7 +127,7 @@ + // Paper start - optimise getPlayerByUUID + @Nullable + @Override -+ public Player getPlayerByUUID(UUID uuid) { ++ public Player getPlayerByUUID(java.util.UUID uuid) { + final Player player = this.getServer().getPlayerList().getPlayer(uuid); + return player != null && player.level() == this ? player : null; + } @@ -143,7 +142,7 @@ ResourceKey dimension, LevelStem levelStem, ChunkProgressListener progressListener, -@@ -221,14 +_,38 @@ +@@ -217,14 +_,38 @@ long biomeZoomSeed, List customSpawners, boolean tickTime, @@ -158,7 +157,7 @@ + super(serverLevelData, dimension, server.registryAccess(), levelStem.type(), false, isDebug, biomeZoomSeed, server.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> server.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(levelStorageAccess.levelDirectory.path(), serverLevelData.getLevelName(), dimension.location(), spigotConfig, server.registryAccess(), serverLevelData.getGameRules()))); // Paper - create paper world configs + this.pvpMode = server.isPvpAllowed(); + this.levelStorageAccess = levelStorageAccess; -+ this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getUUID(levelStorageAccess.levelDirectory.path().toFile()); ++ this.uuid = org.bukkit.craftbukkit.util.WorldUUID.getOrCreate(levelStorageAccess.levelDirectory.path().toFile()); + // CraftBukkit end this.tickTime = tickTime; this.server = server; @@ -184,7 +183,7 @@ boolean flag = server.forceSynchronousWrites(); DataFixer fixerUpper = server.getFixerUpper(); EntityPersistentStorage entityPersistentStorage = new EntityStorage( -@@ -250,8 +_,8 @@ +@@ -246,8 +_,8 @@ server.getStructureManager(), dispatcher, chunkGenerator, @@ -195,7 +194,7 @@ flag, progressListener, this.entityManager::updateChunkStatus, -@@ -272,7 +_,7 @@ +@@ -268,7 +_,7 @@ this.chunkSource.chunkScanner(), this.registryAccess(), server.getStructureManager(), @@ -204,7 +203,7 @@ chunkGenerator, this.chunkSource.randomState(), this, -@@ -280,9 +_,9 @@ +@@ -276,9 +_,9 @@ seed, fixerUpper ); @@ -217,10 +216,10 @@ } else { this.dragonFight = null; } -@@ -292,7 +_,15 @@ - this.randomSequences = Objects.requireNonNullElseGet( - randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.factory(seed), "random_sequences") - ); +@@ -286,7 +_,15 @@ + this.sleepStatus = new SleepStatus(); + this.gameEventDispatcher = new GameEventDispatcher(this); + this.randomSequences = Objects.requireNonNullElseGet(randomSequences, () -> this.getDataStorage().computeIfAbsent(RandomSequences.TYPE)); - } + this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit + } @@ -234,7 +233,7 @@ @Deprecated @VisibleForTesting -@@ -304,8 +_,8 @@ +@@ -298,8 +_,8 @@ this.serverLevelData.setClearWeatherTime(clearTime); this.serverLevelData.setRainTime(weatherTime); this.serverLevelData.setThunderTime(weatherTime); @@ -245,7 +244,7 @@ } @Override -@@ -332,12 +_,25 @@ +@@ -326,12 +_,25 @@ int _int = this.getGameRules().getInt(GameRules.RULE_PLAYERS_SLEEPING_PERCENTAGE); if (this.sleepStatus.areEnoughSleeping(_int) && this.sleepStatus.areEnoughDeepSleeping(_int, this.players)) { @@ -274,7 +273,7 @@ if (this.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE) && this.isRaining()) { this.resetWeatherCycle(); } -@@ -352,9 +_,9 @@ +@@ -346,9 +_,9 @@ if (!this.isDebug() && runsNormally) { long l = this.getGameTime(); profilerFiller.push("blockTicks"); @@ -286,16 +285,30 @@ profilerFiller.pop(); } -@@ -372,7 +_,7 @@ +@@ -366,7 +_,7 @@ this.handlingTick = false; profilerFiller.pop(); -- boolean flag = !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); -+ boolean flag = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForcedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this +- boolean flag = !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); ++ boolean flag = !paperConfig().unsupportedSettings.disableWorldTickingWhenEmpty || !this.players.isEmpty() || !this.getForceLoadedChunks().isEmpty(); // CraftBukkit - this prevents entity cleanup, other issues on servers with no players // Paper - restore this if (flag) { this.resetEmptyTime(); } -@@ -461,12 +_,12 @@ +@@ -455,11 +_,13 @@ + ProfilerFiller profilerFiller = Profiler.get(); + profilerFiller.push("iceandsnow"); + ++ if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow + for (int i = 0; i < randomTickSpeed; i++) { + if (this.random.nextInt(48) == 0) { + this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); + } + } ++ } // Paper - Option to disable ice and snow + + profilerFiller.popPush("tickBlocks"); + if (randomTickSpeed > 0) { +@@ -502,12 +_,12 @@ int minBlockZ = pos.getMinBlockZ(); ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("thunder"); @@ -310,7 +323,7 @@ && !this.getBlockState(blockPos.below()).is(Blocks.LIGHTNING_ROD); if (flag) { SkeletonHorse skeletonHorse = EntityType.SKELETON_HORSE.create(this, EntitySpawnReason.EVENT); -@@ -474,7 +_,7 @@ +@@ -515,7 +_,7 @@ skeletonHorse.setTrap(true); skeletonHorse.setAge(0); skeletonHorse.setPos(blockPos.getX(), blockPos.getY(), blockPos.getZ()); @@ -319,63 +332,51 @@ } } -@@ -482,18 +_,20 @@ +@@ -523,7 +_,7 @@ if (lightningBolt != null) { - lightningBolt.moveTo(Vec3.atBottomCenterOf(blockPos)); + lightningBolt.snapTo(Vec3.atBottomCenterOf(blockPos)); lightningBolt.setVisualOnly(flag); - this.addFreshEntity(lightningBolt); + this.strikeLightning(lightningBolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.WEATHER); // CraftBukkit } } } - - profilerFiller.popPush("iceandsnow"); - -+ if (!this.paperConfig().environment.disableIceAndSnow) { // Paper - Option to disable ice and snow - for (int i = 0; i < randomTickSpeed; i++) { - if (this.random.nextInt(48) == 0) { - this.tickPrecipitation(this.getBlockRandomPos(minBlockX, 0, minBlockZ, 15)); - } - } -+ } // Paper - Option to disable ice and snow - - profilerFiller.popPush("tickBlocks"); - if (randomTickSpeed > 0) { -@@ -535,7 +_,7 @@ +@@ -537,7 +_,7 @@ BlockPos blockPos1 = heightmapPos.below(); Biome biome = this.getBiome(heightmapPos).value(); if (biome.shouldFreeze(this, blockPos1)) { - this.setBlockAndUpdate(blockPos1, Blocks.ICE.defaultBlockState()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockPos1, Blocks.ICE.defaultBlockState(), null); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, blockPos1, Blocks.ICE.defaultBlockState(), 3, null); // CraftBukkit } if (this.isRaining()) { -@@ -547,10 +_,10 @@ +@@ -549,10 +_,10 @@ if (layersValue < Math.min(_int, 8)) { - BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, Integer.valueOf(layersValue + 1)); + BlockState blockState1 = blockState.setValue(SnowLayerBlock.LAYERS, layersValue + 1); Block.pushEntitiesUp(blockState, blockState1, this, heightmapPos); - this.setBlockAndUpdate(heightmapPos, blockState1); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, heightmapPos, blockState1, null); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, heightmapPos, blockState1, 3, null); // CraftBukkit } } else { - this.setBlockAndUpdate(heightmapPos, Blocks.SNOW.defaultBlockState()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, heightmapPos, Blocks.SNOW.defaultBlockState(), null); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this, heightmapPos, Blocks.SNOW.defaultBlockState(), 3, null); // CraftBukkit } } -@@ -575,6 +_,11 @@ +@@ -577,6 +_,12 @@ } protected BlockPos findLightningTargetAround(BlockPos pos) { + // Paper start - Add methods to find targets for lightning strikes + return this.findLightningTargetAround(pos, false); + } ++ + public BlockPos findLightningTargetAround(BlockPos pos, boolean returnNullWhenNoTarget) { + // Paper end - Add methods to find targets for lightning strikes BlockPos heightmapPos = this.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING, pos); Optional optional = this.findLightningRod(heightmapPos); if (optional.isPresent()) { -@@ -582,11 +_,12 @@ +@@ -584,11 +_,12 @@ } else { AABB aabb = AABB.encapsulatingFullBlocks(heightmapPos, heightmapPos.atY(this.getMaxY() + 1)).inflate(3.0); List entitiesOfClass = this.getEntitiesOfClass( @@ -389,7 +390,7 @@ if (heightmapPos.getY() == this.getMinY() - 1) { heightmapPos = heightmapPos.above(2); } -@@ -673,8 +_,8 @@ +@@ -675,8 +_,8 @@ this.serverLevelData.setThunderTime(thunderTime); this.serverLevelData.setRainTime(rainTime); this.serverLevelData.setClearWeatherTime(clearWeatherTime); @@ -400,7 +401,7 @@ } this.oThunderLevel = this.thunderLevel; -@@ -695,6 +_,7 @@ +@@ -697,6 +_,7 @@ this.rainLevel = Mth.clamp(this.rainLevel, 0.0F, 1.0F); } @@ -408,7 +409,7 @@ if (this.oRainLevel != this.rainLevel) { this.server .getPlayerList() -@@ -717,14 +_,47 @@ +@@ -719,14 +_,47 @@ this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, this.rainLevel)); this.server.getPlayerList().broadcastAll(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, this.thunderLevel)); } @@ -460,7 +461,7 @@ } public void resetEmptyTime() { -@@ -746,18 +_,46 @@ +@@ -748,18 +_,46 @@ } } @@ -507,7 +508,7 @@ } private void tickPassenger(Entity ridingEntity, Entity passengerEntity) { -@@ -766,10 +_,12 @@ +@@ -768,10 +_,12 @@ } else if (passengerEntity instanceof Player || this.entityTickList.contains(passengerEntity)) { passengerEntity.setOldPosAndRot(); passengerEntity.tickCount++; @@ -520,7 +521,7 @@ profilerFiller.pop(); for (Entity entity : passengerEntity.getPassengers()) { -@@ -786,6 +_,7 @@ +@@ -788,6 +_,7 @@ public void save(@Nullable ProgressListener progress, boolean flush, boolean skipSave) { ServerChunkCache chunkSource = this.getChunkSource(); if (!skipSave) { @@ -528,15 +529,15 @@ if (progress != null) { progress.progressStartNoAbort(Component.translatable("menu.savingLevel")); } -@@ -802,11 +_,19 @@ +@@ -804,11 +_,19 @@ this.entityManager.autoSave(); } } + -+ // CraftBukkit start - moved from MinecraftServer.saveChunks -+ ServerLevel worldserver1 = this; ++ // CraftBukkit start - moved from MinecraftServer#saveAllChunks ++ ServerLevel serverLevel1 = this; + -+ this.serverLevelData.setWorldBorder(worldserver1.getWorldBorder().createSettings()); ++ this.serverLevelData.setWorldBorder(serverLevel1.getWorldBorder().createSettings()); + this.serverLevelData.setCustomBossEvents(this.server.getCustomBossEvents().save(this.registryAccess())); + this.levelStorageAccess.saveDataTag(this.server.registryAccess(), this.serverLevelData, this.server.getPlayerList().getSingleplayerData()); + // CraftBukkit end @@ -549,7 +550,7 @@ } DimensionDataStorage dataStorage = this.getChunkSource().getDataStorage(); -@@ -871,18 +_,40 @@ +@@ -873,18 +_,40 @@ @Override public boolean addFreshEntity(Entity entity) { @@ -559,7 +560,7 @@ + } + + @Override -+ public boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -570,7 +571,7 @@ + return this.addWithUUID(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } + -+ public boolean addWithUUID(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public boolean addWithUUID(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + return this.addEntity(entity, reason); + // CraftBukkit end } @@ -583,7 +584,7 @@ + this.addDuringTeleport(entity, null); + } + -+ public void addDuringTeleport(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ public void addDuringTeleport(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + // CraftBukkit end if (entity instanceof ServerPlayer serverPlayer) { this.addPlayer(serverPlayer); @@ -593,13 +594,13 @@ } } -@@ -905,40 +_,119 @@ +@@ -907,40 +_,119 @@ this.entityManager.addNewEntity(player); } - private boolean addEntity(Entity entity) { + // CraftBukkit start -+ private boolean addEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { ++ private boolean addEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) { + org.spigotmc.AsyncCatcher.catchOp("entity add"); // Spigot + entity.generation = false; // Paper - Don't fire sync event during generation; Reset flag if it was added during a ServerLevel generation process + // Paper start - extra debug info @@ -718,16 +719,16 @@ if (d * d + d1 * d1 + d2 * d2 < 1024.0) { serverPlayer.connection.send(new ClientboundBlockDestructionPacket(breakerId, pos, progress)); } -@@ -1000,7 +_,7 @@ - public void levelEvent(@Nullable Player player, int type, BlockPos pos, int data) { - this.server - .getPlayerList() -- .broadcast(player, pos.getX(), pos.getY(), pos.getZ(), 64.0, this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false)); -+ .broadcast(player, pos.getX(), pos.getY(), pos.getZ(), 64.0, this.dimension(), new ClientboundLevelEventPacket(type, pos, data, false)); // Paper - diff on change (the 64.0 distance is used as defaults for sound ranges in spigot config for ender dragon, end portal and wither) - } - - public int getLogicalHeight() { -@@ -1009,6 +_,11 @@ +@@ -1015,7 +_,7 @@ + pos.getX(), + pos.getY(), + pos.getZ(), +- 64.0, ++ 64.0, // Paper - diff on change (the 64.0 distance is used as defaults for sound ranges in spigot config for ender dragon, end portal and wither) + this.dimension(), + new ClientboundLevelEventPacket(type, pos, data, false) + ); +@@ -1027,6 +_,11 @@ @Override public void gameEvent(Holder gameEvent, Vec3 pos, GameEvent.Context context) { @@ -739,7 +740,7 @@ this.gameEventDispatcher.post(gameEvent, pos, context); } -@@ -1021,17 +_,28 @@ +@@ -1039,17 +_,28 @@ this.getChunkSource().blockChanged(pos); this.pathTypesByPosCache.invalidate(pos); @@ -768,7 +769,7 @@ try { this.isUpdatingNavigations = true; -@@ -1043,15 +_,18 @@ +@@ -1061,15 +_,23 @@ this.isUpdatingNavigations = false; } } @@ -777,6 +778,11 @@ @Override public void updateNeighborsAt(BlockPos pos, Block block) { ++ // CraftBukkit start ++ if (this.populating) { ++ return; ++ } ++ // CraftBukkit end + if (captureBlockStates) { return; } // Paper - Cancel all physics during placement this.updateNeighborsAt(pos, block, ExperimentalRedstoneUtils.initialOrientation(this, null, null)); } @@ -787,7 +793,7 @@ this.neighborUpdater.updateNeighborsAtExceptFromFacing(pos, block, null, orientation); } -@@ -1100,6 +_,42 @@ +@@ -1118,6 +_,42 @@ ParticleOptions largeExplosionParticles, Holder explosionSound ) { @@ -830,7 +836,7 @@ Explosion.BlockInteraction blockInteraction = switch (explosionInteraction) { case NONE -> Explosion.BlockInteraction.KEEP; case BLOCK -> this.getDestroyType(GameRules.RULE_BLOCK_EXPLOSION_DROP_DECAY); -@@ -1108,10 +_,17 @@ +@@ -1126,10 +_,17 @@ : Explosion.BlockInteraction.KEEP; case TNT -> this.getDestroyType(GameRules.RULE_TNT_EXPLOSION_DROP_DECAY); case TRIGGER -> Explosion.BlockInteraction.TRIGGER_BLOCK; @@ -848,7 +854,7 @@ ParticleOptions particleOptions = serverExplosion.isSmall() ? smallExplosionParticles : largeExplosionParticles; for (ServerPlayer serverPlayer : this.players) { -@@ -1120,6 +_,8 @@ +@@ -1138,6 +_,8 @@ serverPlayer.connection.send(new ClientboundExplodePacket(vec3, optional, particleOptions, explosionSound)); } } @@ -857,7 +863,7 @@ } private Explosion.BlockInteraction getDestroyType(GameRules.Key decayGameRule) { -@@ -1190,7 +_,7 @@ +@@ -1208,7 +_,7 @@ public int sendParticles( T type, double posX, double posY, double posZ, int particleCount, double xOffset, double yOffset, double zOffset, double speed ) { @@ -866,7 +872,7 @@ } public int sendParticles( -@@ -1206,13 +_,49 @@ +@@ -1224,13 +_,49 @@ double zOffset, double speed ) { @@ -874,7 +880,7 @@ + return this.sendParticlesSource(null, type, overrideLimiter, alwaysShow, posX, posY, posZ, particleCount, xOffset, yOffset, zOffset, speed); + } + public int sendParticlesSource( -+ @javax.annotation.Nullable Entity sender, ++ @Nullable Entity sender, + T type, + boolean overrideLimiter, + boolean alwaysShow, @@ -891,7 +897,7 @@ + } + public int sendParticlesSource( + List receivers, -+ @javax.annotation.Nullable Entity sender, ++ @Nullable Entity sender, + T type, + boolean overrideLimiter, + boolean alwaysShow, @@ -918,7 +924,7 @@ if (this.sendParticles(serverPlayer, overrideLimiter, posX, posY, posZ, clientboundLevelParticlesPacket)) { i++; } -@@ -1280,7 +_,7 @@ +@@ -1293,7 +_,7 @@ @Nullable public BlockPos findNearestMapStructure(TagKey structureTag, BlockPos pos, int radius, boolean skipExistingChunks) { @@ -927,17 +933,17 @@ return null; } else { Optional> optional = this.registryAccess().lookupOrThrow(Registries.STRUCTURE).get(structureTag); -@@ -1327,11 +_,38 @@ +@@ -1340,10 +_,36 @@ @Nullable @Override public MapItemSavedData getMapData(MapId mapId) { -- return this.getServer().overworld().getDataStorage().get(MapItemSavedData.factory(), mapId.key()); +- return this.getServer().overworld().getDataStorage().get(MapItemSavedData.type(mapId)); + // Paper start - Call missing map initialize event and set id + final DimensionDataStorage storage = this.getServer().overworld().getDataStorage(); + + final Optional cacheEntry = storage.cache.get(mapId.key()); + if (cacheEntry == null) { // Cache did not contain, try to load and may init -+ final MapItemSavedData mapData = storage.get(MapItemSavedData.factory(), mapId.key()); // get populates the cache ++ final MapItemSavedData mapData = storage.get(MapItemSavedData.type(mapId)); // get populates the cache + if (mapData != null) { // map was read, init it and return + mapData.id = mapId; + new org.bukkit.event.server.MapInitializeEvent(mapData.mapView).callEvent(); @@ -946,7 +952,6 @@ + + return null; // Map does not exist, reading failed. + } -+ + // Cache entry exists, update it with the id ref and return. + if (cacheEntry.orElse(null) instanceof final MapItemSavedData mapItemSavedData) { + mapItemSavedData.id = mapId; @@ -957,17 +962,16 @@ + // Paper end - Call missing map initialize event and set id } - @Override - public void setMapData(MapId mapId, MapItemSavedData mapData) { + public void setMapData(MapId mapId, MapItemSavedData data) { + // CraftBukkit start -+ mapData.id = mapId; -+ org.bukkit.event.server.MapInitializeEvent event = new org.bukkit.event.server.MapInitializeEvent(mapData.mapView); ++ data.id = mapId; ++ org.bukkit.event.server.MapInitializeEvent event = new org.bukkit.event.server.MapInitializeEvent(data.mapView); + event.callEvent(); + // CraftBukkit end - this.getServer().overworld().getDataStorage().set(mapId.key(), mapData); + this.getServer().overworld().getDataStorage().set(MapItemSavedData.type(mapId), data); } -@@ -1344,17 +_,27 @@ +@@ -1355,17 +_,27 @@ BlockPos spawnPos = this.levelData.getSpawnPos(); float spawnAngle = this.levelData.getSpawnAngle(); if (!spawnPos.equals(pos) || spawnAngle != angle) { @@ -978,50 +982,38 @@ } if (this.lastSpawnChunkRadius > 1) { -- this.getChunkSource().removeRegionTicket(TicketType.START, new ChunkPos(spawnPos), this.lastSpawnChunkRadius, Unit.INSTANCE); +- this.getChunkSource().removeTicketWithRadius(TicketType.START, new ChunkPos(spawnPos), this.lastSpawnChunkRadius); + // Paper start - allow disabling gamerule limits + for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(spawnPos, this.lastSpawnChunkRadius - 2)) { -+ this.getChunkSource().removeTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE); ++ this.getChunkSource().removeTicketAtLevel(TicketType.START, chunkPos, ChunkLevel.ENTITY_TICKING_LEVEL); + } + // Paper end - allow disabling gamerule limits } int i = this.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS) + 1; if (i > 1) { -- this.getChunkSource().addRegionTicket(TicketType.START, new ChunkPos(pos), i, Unit.INSTANCE); +- this.getChunkSource().addTicketWithRadius(TicketType.START, new ChunkPos(pos), i); + // Paper start - allow disabling gamerule limits + for (ChunkPos chunkPos : io.papermc.paper.util.MCUtil.getSpiralOutChunks(pos, i - 2)) { -+ this.getChunkSource().addTicketAtLevel(TicketType.START, chunkPos, net.minecraft.server.level.ChunkLevel.ENTITY_TICKING_LEVEL, Unit.INSTANCE); ++ this.getChunkSource().addTicketAtLevel(TicketType.START, chunkPos, ChunkLevel.ENTITY_TICKING_LEVEL); + } + // Paper end - allow disabling gamerule limits } this.lastSpawnChunkRadius = i; -@@ -1403,6 +_,11 @@ +@@ -1400,6 +_,11 @@ DebugPackets.sendPoiRemovedPacket(this, blockPos); })); - optional1.ifPresent(poiType -> this.getServer().execute(() -> { + optional1.ifPresent(holder -> this.getServer().execute(() -> { + // Paper start - Remove stale POIs + if (optional.isEmpty() && this.getPoiManager().exists(blockPos, ignored -> true)) { + this.getPoiManager().remove(blockPos); + } + // Paper end - Remove stale POIs - this.getPoiManager().add(blockPos, (Holder)poiType); + this.getPoiManager().add(blockPos, (Holder)holder); DebugPackets.sendPoiAddedPacket(this, blockPos); })); -@@ -1543,6 +_,11 @@ - @Override - public void blockUpdated(BlockPos pos, Block block) { - if (!this.isDebug()) { -+ // CraftBukkit start -+ if (this.populating) { -+ return; -+ } -+ // CraftBukkit end - this.updateNeighborsAt(pos, block); - } - } -@@ -1562,12 +_,12 @@ +@@ -1552,12 +_,12 @@ } public boolean isFlat() { @@ -1036,7 +1028,7 @@ } @Nullable -@@ -1618,6 +_,7 @@ +@@ -1608,6 +_,7 @@ @Override public LevelEntityGetter getEntities() { @@ -1044,7 +1036,7 @@ return this.entityManager.getEntityGetter(); } -@@ -1699,6 +_,27 @@ +@@ -1697,6 +_,28 @@ return this.serverLevelData.getGameRules(); } @@ -1059,12 +1051,13 @@ + } + // Paper end - respect global sound events gamerule + // Paper start - notify observers even if grow failed ++ @Deprecated + public void checkCapturedTreeStateForObserverNotify(final BlockPos pos, final org.bukkit.craftbukkit.block.CraftBlockState craftBlockState) { + // notify observers if the block state is the same and the Y level equals the original y level (for mega trees) + // blocks at the same Y level with the same state can be assumed to be saplings which trigger observers regardless of if the + // tree grew or not + if (craftBlockState.getPosition().getY() == pos.getY() && this.getBlockState(craftBlockState.getPosition()) == craftBlockState.getHandle()) { -+ this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlag(), 512); ++ this.notifyAndUpdatePhysics(craftBlockState.getPosition(), null, craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getHandle(), craftBlockState.getFlags(), 512); + } + } + // Paper end - notify observers even if grow failed @@ -1072,7 +1065,7 @@ @Override public CrashReportCategory fillReportDetails(CrashReport report) { CrashReportCategory crashReportCategory = super.fillReportDetails(report); -@@ -1714,6 +_,7 @@ +@@ -1712,6 +_,7 @@ final class EntityCallbacks implements LevelCallback { @Override public void onCreated(Entity entity) { @@ -1080,7 +1073,7 @@ } @Override -@@ -1723,24 +_,32 @@ +@@ -1721,24 +_,32 @@ @Override public void onTickingStart(Entity entity) { @@ -1115,7 +1108,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1757,10 +_,52 @@ +@@ -1755,10 +_,52 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::add); @@ -1123,12 +1116,12 @@ + entity.valid = true; // CraftBukkit + ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server + // Paper start - Entity origin API -+ if (entity.getOriginVector() == null) { -+ entity.setOrigin(entity.getBukkitEntity().getLocation()); ++ if (entity.origin == null) { ++ entity.origin = entity.position(); + } + // Default to current world if unknown, gross assumption but entities rarely change world -+ if (entity.getOriginWorld() == null) { -+ entity.setOrigin(entity.getOriginVector().toLocation(getWorld())); ++ if (entity.originWorld == null) { ++ entity.originWorld = ServerLevel.this.getWorld().getUID(); + } + // Paper end - Entity origin API + new com.destroystokyo.paper.event.entity.EntityAddToWorldEvent(entity.getBukkitEntity(), ServerLevel.this.getWorld()).callEvent(); // Paper - fire while valid @@ -1168,7 +1161,7 @@ ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); -@@ -1768,7 +_,7 @@ +@@ -1766,7 +_,7 @@ } if (entity instanceof Mob mob) { @@ -1177,7 +1170,7 @@ String string = "onTrackingStart called during navigation iteration"; Util.logAndPauseIfInIde( "onTrackingStart called during navigation iteration", new IllegalStateException("onTrackingStart called during navigation iteration") -@@ -1785,6 +_,15 @@ +@@ -1783,6 +_,15 @@ } entity.updateDynamicGameEventListener(DynamicGameEventListener::remove); @@ -1193,7 +1186,7 @@ } @Override -@@ -1792,4 +_,24 @@ +@@ -1790,4 +_,24 @@ entity.updateDynamicGameEventListener(DynamicGameEventListener::move); } } @@ -1201,7 +1194,7 @@ + // Paper start - check global player list where appropriate + @Override + @Nullable -+ public Player getGlobalPlayerByUUID(UUID uuid) { ++ public Player getGlobalPlayerByUUID(java.util.UUID uuid) { + return this.server.getPlayerList().getPlayer(uuid); + } + // Paper end - check global player list where appropriate diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch index a1ac8281e..fbf19d2e5 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -223,7 +_,8 @@ +@@ -235,7 +_,8 @@ private int levitationStartTime; private boolean disconnected; private int requestedViewDistance = 2; @@ -10,7 +10,7 @@ @Nullable private Vec3 startingToFallPosition; @Nullable -@@ -258,6 +_,20 @@ +@@ -281,6 +_,20 @@ } } @@ -31,7 +31,16 @@ @Override public void sendSlotChange(AbstractContainerMenu container, int slot, ItemStack itemStack) { ServerPlayer.this.connection.send(new ClientboundContainerSetSlotPacket(container.containerId, container.incrementStateId(), slot, itemStack)); -@@ -288,6 +_,32 @@ +@@ -302,7 +_,7 @@ + + @Override + public RemoteSlot createSlot() { +- return new RemoteSlot.Synchronized(this.cache::getUnchecked); ++ return new RemoteSlot.Synchronized(this.cache::getUnchecked, ServerPlayer.this.getBukkitEntity().simplifyContainerDesyncCheck()); // Paper - add flag to simplify remote matching logic + } + }; + private final ContainerListener containerListener = new ContainerListener() { +@@ -316,6 +_,32 @@ } } @@ -64,7 +73,7 @@ @Override public void dataChanged(AbstractContainerMenu containerMenu, int dataSlotIndex, int value) { } -@@ -316,9 +_,43 @@ +@@ -344,9 +_,43 @@ public void sendSystemMessage(Component component) { ServerPlayer.this.sendSystemMessage(component); } @@ -83,13 +92,13 @@ + public int patrolSpawnDelay; // Paper - Pillager patrol spawn settings and per player options + // Paper start - cancellable death event + public boolean queueHealthUpdatePacket; -+ public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; ++ public @Nullable net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; + // Paper end - cancellable death event + // CraftBukkit start + public org.bukkit.craftbukkit.entity.CraftPlayer.TransferCookieConnection transferCookieConnection; + public String displayName; + public net.kyori.adventure.text.Component adventure$displayName; // Paper -+ public Component listName; ++ public @Nullable Component listName; + public int listOrder = 0; + public org.bukkit.Location compassTarget; + public int newExp = 0; @@ -102,19 +111,19 @@ + public boolean supressTrackerForLogin = false; // Paper - Fire PlayerJoinEvent when Player is actually ready + // CraftBukkit end + public boolean isRealPlayer; // Paper -+ public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent ++ public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public @Nullable String clientBrandName = null; // Paper - Brand support -+ public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event ++ public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event public ServerPlayer(MinecraftServer server, ServerLevel level, GameProfile gameProfile, ClientInformation clientInformation) { super(level, level.getSharedSpawnPos(), level.getSharedSpawnAngle(), gameProfile); -@@ -328,16 +_,22 @@ +@@ -356,16 +_,22 @@ this.server = server; this.stats = server.getPlayerList().getPlayerStats(this); this.advancements = server.getPlayerList().getPlayerAdvancements(this); -- this.moveTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); +- this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); - this.updateOptions(clientInformation); -+ // this.moveTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn ++ // this.snapTo(this.adjustSpawnLocation(level, level.getSharedSpawnPos()).getBottomCenter(), 0.0F, 0.0F); // Paper - Don't move existing players to world spawn + this.updateOptionsNoEvents(clientInformation); // Paper - don't call options events on login this.object = null; + @@ -134,36 +143,21 @@ int max = Math.max(0, this.server.getSpawnRadius(level)); int floor = Mth.floor(level.getWorldBorder().getDistanceToBorder(pos.getX(), pos.getZ())); if (floor < max) { -@@ -420,11 +_,20 @@ - if (compound.contains("recipeBook", 10)) { - this.recipeBook.fromNbt(compound.getCompound("recipeBook"), key -> this.server.getRecipeManager().byKey(key).isPresent()); - } +@@ -436,6 +_,7 @@ + this.enteredNetherPosition = compound.read("entered_nether_pos", Vec3.CODEC).orElse(null); + this.seenCredits = compound.getBooleanOr("seenCredits", false); + this.recipeBook.fromNbt(compound.getCompoundOrEmpty("recipeBook"), key -> this.server.getRecipeManager().byKey(key).isPresent()); + this.getBukkitEntity().readExtraData(compound); // CraftBukkit - if (this.isSleeping()) { this.stopSleeping(); } - -+ // CraftBukkit start -+ String spawnWorld = compound.getString("SpawnWorld"); -+ org.bukkit.craftbukkit.CraftWorld oldWorld = (org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(spawnWorld); -+ if (oldWorld != null) { -+ this.respawnDimension = oldWorld.getHandle().dimension(); -+ } -+ // CraftBukkit end -+ - if (compound.contains("SpawnX", 99) && compound.contains("SpawnY", 99) && compound.contains("SpawnZ", 99)) { - this.respawnPosition = new BlockPos(compound.getInt("SpawnX"), compound.getInt("SpawnY"), compound.getInt("SpawnZ")); - this.respawnForced = compound.getBoolean("SpawnForced"); -@@ -475,6 +_,7 @@ - .resultOrPartial(LOGGER::error) - .ifPresent(spawnDimension -> compound.put("SpawnDimension", spawnDimension)); - } -+ this.getBukkitEntity().setExtraData(compound); // CraftBukkit - +@@ -459,12 +_,24 @@ compound.putBoolean("spawn_extra_particles_on_fall", this.spawnExtraParticlesOnFall); - if (this.raidOmenPosition != null) { -@@ -490,7 +_,18 @@ + compound.storeNullable("raid_omen_position", BlockPos.CODEC, this.raidOmenPosition); + this.saveEnderPearls(compound); ++ this.getBukkitEntity().setExtraData(compound); // CraftBukkit + } + private void saveParentVehicle(CompoundTag tag) { Entity rootVehicle = this.getRootVehicle(); Entity vehicle = this.getVehicle(); @@ -183,29 +177,29 @@ CompoundTag compoundTag = new CompoundTag(); CompoundTag compoundTag1 = new CompoundTag(); rootVehicle.save(compoundTag1); -@@ -504,7 +_,7 @@ - if (tag.isPresent() && tag.get().contains("RootVehicle", 10) && this.level() instanceof ServerLevel serverLevel) { - CompoundTag compound = tag.get().getCompound("RootVehicle"); +@@ -479,7 +_,7 @@ + if (!compound.isEmpty()) { + ServerLevel serverLevel = this.serverLevel(); Entity entity = EntityType.loadEntityRecursive( -- compound.getCompound("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2 -+ compound.getCompound("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason +- compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2) ? null : entity2 ++ compound.get().getCompoundOrEmpty("Entity"), serverLevel, EntitySpawnReason.LOAD, entity2 -> !serverLevel.addWithUUID(entity2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.MOUNT) ? null : entity2 // Paper - Entity#getEntitySpawnReason ); - if (entity == null) { - return; -@@ -530,10 +_,10 @@ + if (entity != null) { + UUID uuid = compound.get().read("Attach", UUIDUtil.CODEC).orElse(null); +@@ -496,10 +_,10 @@ - if (!this.isPassenger()) { - LOGGER.warn("Couldn't reattach entity to player"); -- entity.discard(); -+ entity.discard(null); // CraftBukkit - add Bukkit remove cause + if (!this.isPassenger()) { + LOGGER.warn("Couldn't reattach entity to player"); +- entity.discard(); ++ entity.discard(null); // CraftBukkit - add Bukkit remove cause - for (Entity entity1x : entity.getIndirectPassengers()) { -- entity1x.discard(); -+ entity1x.discard(null); // CraftBukkit - add Bukkit remove cause + for (Entity entity1x : entity.getIndirectPassengers()) { +- entity1x.discard(); ++ entity1x.discard(null); // CraftBukkit - add Bukkit remove cause + } } } - } -@@ -544,6 +_,7 @@ +@@ -511,6 +_,7 @@ ListTag listTag = new ListTag(); for (ThrownEnderpearl thrownEnderpearl : this.enderPearls) { @@ -213,7 +207,7 @@ if (thrownEnderpearl.isRemoved()) { LOGGER.warn("Trying to save removed ender pearl, skipping"); } else { -@@ -593,6 +_,16 @@ +@@ -546,6 +_,16 @@ } } @@ -230,7 +224,7 @@ public void setExperiencePoints(int experiencePoints) { float f = this.getXpNeededForNextLevel(); float f1 = (f - 1.0F) / f; -@@ -650,6 +_,11 @@ +@@ -603,6 +_,11 @@ @Override public void tick() { @@ -242,7 +236,7 @@ this.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); -@@ -657,9 +_,14 @@ +@@ -610,9 +_,14 @@ this.invulnerableTime--; } @@ -260,7 +254,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -709,7 +_,7 @@ +@@ -662,7 +_,7 @@ public void doTick() { try { @@ -269,7 +263,7 @@ super.tick(); } -@@ -723,7 +_,7 @@ +@@ -676,7 +_,7 @@ if (this.getHealth() != this.lastSentHealth || this.lastSentFood != this.foodData.getFoodLevel() || this.foodData.getSaturationLevel() == 0.0F != this.lastFoodSaturationZero) { @@ -278,7 +272,7 @@ this.lastSentHealth = this.getHealth(); this.lastSentFood = this.foodData.getFoodLevel(); this.lastFoodSaturationZero = this.foodData.getSaturationLevel() == 0.0F; -@@ -754,6 +_,12 @@ +@@ -707,6 +_,12 @@ this.updateScoreForCriteria(ObjectiveCriteria.EXPERIENCE, Mth.ceil((float)this.lastRecordedExperience)); } @@ -291,7 +285,7 @@ if (this.experienceLevel != this.lastRecordedLevel) { this.lastRecordedLevel = this.experienceLevel; this.updateScoreForCriteria(ObjectiveCriteria.LEVEL, Mth.ceil((float)this.lastRecordedLevel)); -@@ -767,6 +_,21 @@ +@@ -720,6 +_,21 @@ if (this.tickCount % 20 == 0) { CriteriaTriggers.LOCATION.trigger(this); } @@ -313,7 +307,7 @@ } catch (Throwable var4) { CrashReport crashReport = CrashReport.forThrowable(var4, "Ticking player"); CrashReportCategory crashReportCategory = crashReport.addCategory("Player being ticked"); -@@ -791,7 +_,7 @@ +@@ -744,7 +_,7 @@ if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) { if (this.tickCount % 20 == 0) { if (this.getHealth() < this.getMaxHealth()) { @@ -322,52 +316,36 @@ } float saturationLevel = this.foodData.getSaturationLevel(); -@@ -840,15 +_,100 @@ +@@ -793,15 +_,84 @@ } private void updateScoreForCriteria(ObjectiveCriteria criteria, int points) { -- this.getScoreboard().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); +- this.getScoreboard().forAllObjectives(criteria, this, score -> score.set(points)); - } -+ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, scoreAccess -> scoreAccess.set(points)); // CraftBukkit - Use our scores instead ++ this.level().getCraftServer().getScoreboardManager().forAllObjectives(criteria, this, score -> score.set(points)); // CraftBukkit - Use our scores instead + } + + // Paper start - PlayerDeathEvent#getItemsToKeep -+ private static void processKeep(org.bukkit.event.entity.PlayerDeathEvent event, NonNullList inv) { -+ List itemsToKeep = event.getItemsToKeep(); -+ if (inv == null) { -+ // remainder of items left in toKeep - plugin added stuff on death that wasn't in the initial loot? -+ if (!itemsToKeep.isEmpty()) { -+ for (org.bukkit.inventory.ItemStack itemStack : itemsToKeep) { -+ event.getEntity().getInventory().addItem(itemStack); -+ } -+ } -+ -+ return; ++ private static boolean shouldKeepDeathEventItem( ++ final org.bukkit.event.entity.PlayerDeathEvent event, ++ final ItemStack item ++ ) { ++ final List itemsToKeep = event.getItemsToKeep(); ++ if (EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP) || itemsToKeep.isEmpty() || item.isEmpty()) { ++ return false; + } + -+ for (int i = 0; i < inv.size(); ++i) { -+ ItemStack item = inv.get(i); -+ if (EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP) || itemsToKeep.isEmpty() || item.isEmpty()) { -+ inv.set(i, ItemStack.EMPTY); -+ continue; -+ } -+ -+ final org.bukkit.inventory.ItemStack bukkitStack = item.getBukkitStack(); -+ boolean keep = false; -+ final java.util.Iterator iterator = itemsToKeep.iterator(); -+ while (iterator.hasNext()) { -+ final org.bukkit.inventory.ItemStack itemStack = iterator.next(); -+ if (bukkitStack.equals(itemStack)) { -+ iterator.remove(); -+ keep = true; -+ break; -+ } -+ } -+ -+ if (!keep) { -+ inv.set(i, ItemStack.EMPTY); ++ final org.bukkit.inventory.ItemStack bukkitStack = item.getBukkitStack(); ++ final java.util.Iterator iterator = itemsToKeep.iterator(); ++ while (iterator.hasNext()) { ++ final org.bukkit.inventory.ItemStack itemStack = iterator.next(); ++ if (bukkitStack.equals(itemStack)) { ++ iterator.remove(); ++ return true; + } + } ++ ++ return false; + } + // Paper end - PlayerDeathEvent#getItemsToKeep @@ -388,13 +366,13 @@ + if (!keepInventory) { + for (ItemStack item : this.getInventory().getContents()) { + if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { -+ loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event) ++ loot.add(new DefaultDrop(item, stack -> this.drop(stack, true, false, false, null))); // Paper - Restore vanilla drops behavior; drop function taken from Inventory#dropAll (don't fire drop event) + } + } + } + if (this.shouldDropLoot() && this.serverLevel().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - fix player loottables running when mob loot gamerule is false + // SPIGOT-5071: manually add player loot tables (SPIGOT-5195 - ignores keepInventory rule) -+ this.dropFromLootTable(this.serverLevel(), cause, this.lastHurtByPlayerTime > 0); ++ this.dropFromLootTable(this.serverLevel(), cause, this.lastHurtByPlayerMemoryTime > 0); + // Paper - Restore vanilla drops behaviour; custom death loot is a noop on server player, remove. + loot.addAll(this.drops); + this.drops.clear(); // SPIGOT-5188: make sure to clear @@ -429,7 +407,7 @@ this.connection .send( new ClientboundPlayerCombatKillPacket(this.getId(), deathMessage), -@@ -882,11 +_,22 @@ +@@ -835,11 +_,35 @@ this.tellNeutralMobsThatIDied(); } @@ -440,10 +418,23 @@ + // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. + if (!event.getKeepInventory()) { + // Paper start - PlayerDeathEvent#getItemsToKeep -+ for (NonNullList inv : this.getInventory().compartments) { -+ processKeep(event, inv); ++ for (int i = 0; i < this.getInventory().getNonEquipmentItems().size(); i++) { ++ if (!shouldKeepDeathEventItem(event, this.getInventory().getNonEquipmentItems().get(i))) { ++ this.getInventory().getNonEquipmentItems().set(i, net.minecraft.world.item.ItemStack.EMPTY); ++ } ++ } ++ for (final EquipmentSlot value : EquipmentSlot.VALUES) { ++ if (this.getInventory().equipment.has(value) && !shouldKeepDeathEventItem(event, this.getInventory().equipment.get(value))) { ++ this.getInventory().equipment.set(value, net.minecraft.world.item.ItemStack.EMPTY); ++ } ++ } ++ ++ // remainder of items left in toKeep - plugin added stuff on death that wasn't in the initial loot? ++ if (!event.getItemsToKeep().isEmpty()) { ++ for (org.bukkit.inventory.ItemStack itemStack : event.getItemsToKeep()) { ++ event.getEntity().getInventory().addItem(itemStack); ++ } + } -+ processKeep(event, null); + // Paper end - PlayerDeathEvent#getItemsToKeep } @@ -455,7 +446,7 @@ LivingEntity killCredit = this.getKillCredit(); if (killCredit != null) { this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); -@@ -919,10 +_,10 @@ +@@ -872,10 +_,10 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity != this) { super.awardKillScore(entity, damageSource); @@ -468,7 +459,7 @@ } else { this.awardStat(Stats.MOB_KILLS); } -@@ -938,7 +_,7 @@ +@@ -891,7 +_,7 @@ if (playersTeam != null) { int id = playersTeam.getColor().getId(); if (id >= 0 && id < crtieria.length) { @@ -477,7 +468,7 @@ } } } -@@ -949,9 +_,20 @@ +@@ -902,9 +_,20 @@ return false; } else { Entity entity = damageSource.getEntity(); @@ -500,7 +491,7 @@ } } -@@ -961,10 +_,15 @@ +@@ -914,23 +_,81 @@ } private boolean isPvpAllowed() { @@ -510,16 +501,15 @@ - public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition) { + // CraftBukkit start -+ public TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason respawnReason) { ++ public @Nullable TeleportTransition findRespawnPositionAndUseSpawnBlock(boolean useCharge, TeleportTransition.PostTeleportTransition postTeleportTransition, @Nullable org.bukkit.event.player.PlayerRespawnEvent.RespawnReason respawnReason) { + TeleportTransition teleportTransition; + boolean isBedSpawn = false; + boolean isAnchorSpawn = false; + // CraftBukkit end - BlockPos respawnPosition = this.getRespawnPosition(); - float respawnAngle = this.getRespawnAngle(); - boolean isRespawnForced = this.isRespawnForced(); -@@ -973,13 +_,66 @@ - Optional optional = findRespawnAndUseSpawnBlock(level, respawnPosition, respawnAngle, isRespawnForced, useCharge); + ServerPlayer.RespawnConfig respawnConfig = this.getRespawnConfig(); + ServerLevel level = this.server.getLevel(ServerPlayer.RespawnConfig.getDimensionOrDefault(respawnConfig)); + if (level != null && respawnConfig != null) { + Optional optional = findRespawnAndUseSpawnBlock(level, respawnConfig, useCharge); if (optional.isPresent()) { ServerPlayer.RespawnPosAngle respawnPosAngle = optional.get(); - return new TeleportTransition(level, respawnPosAngle.position(), Vec3.ZERO, respawnPosAngle.yaw(), 0.0F, postTeleportTransition); @@ -575,7 +565,7 @@ + + return new TeleportTransition( + ((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), -+ org.bukkit.craftbukkit.util.CraftLocation.toVec3D(location), ++ org.bukkit.craftbukkit.util.CraftLocation.toVec3(location), + teleportTransition.deltaMovement(), + location.getYaw(), + location.getPitch(), @@ -589,29 +579,29 @@ } public static Optional findRespawnAndUseSpawnBlock( -@@ -993,10 +_,10 @@ - level.setBlock(pos, blockState.setValue(RespawnAnchorBlock.CHARGE, Integer.valueOf(blockState.getValue(RespawnAnchorBlock.CHARGE) - 1)), 3); +@@ -947,10 +_,10 @@ + level.setBlock(blockPos, blockState.setValue(RespawnAnchorBlock.CHARGE, blockState.getValue(RespawnAnchorBlock.CHARGE) - 1), 3); } -- return optional.map(vec3 -> ServerPlayer.RespawnPosAngle.of(vec3, pos)); -+ return optional.map(vec3 -> ServerPlayer.RespawnPosAngle.of(vec3, pos, false, true)); // CraftBukkit +- return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos)); ++ return optional.map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, false, true)); // CraftBukkit } else if (block instanceof BedBlock && BedBlock.canSetSpawn(level)) { - return BedBlock.findStandUpPosition(EntityType.PLAYER, level, pos, blockState.getValue(BedBlock.FACING), angle) -- .map(vec3 -> ServerPlayer.RespawnPosAngle.of(vec3, pos)); -+ .map(vec3 -> ServerPlayer.RespawnPosAngle.of(vec3, pos, true, false)); // CraftBukkit - } else if (!forced) { + return BedBlock.findStandUpPosition(EntityType.PLAYER, level, blockPos, blockState.getValue(BedBlock.FACING), f) +- .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos)); ++ .map(pos -> ServerPlayer.RespawnPosAngle.of(pos, blockPos, true, false)); // CraftBukkit + } else if (!flag) { return Optional.empty(); } else { -@@ -1004,7 +_,7 @@ - BlockState blockState1 = level.getBlockState(pos.above()); +@@ -958,7 +_,7 @@ + BlockState blockState1 = level.getBlockState(blockPos.above()); boolean isPossibleToRespawnInThis1 = blockState1.getBlock().isPossibleToRespawnInThis(blockState1); return isPossibleToRespawnInThis && isPossibleToRespawnInThis1 -- ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle)) -+ ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(pos.getX() + 0.5, pos.getY() + 0.1, pos.getZ() + 0.5), angle, false, false)) // CraftBukkit +- ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(blockPos.getX() + 0.5, blockPos.getY() + 0.1, blockPos.getZ() + 0.5), f)) ++ ? Optional.of(new ServerPlayer.RespawnPosAngle(new Vec3(blockPos.getX() + 0.5, blockPos.getY() + 0.1, blockPos.getZ() + 0.5), f, false, false)) // CraftBukkit : Optional.empty(); } } -@@ -1022,6 +_,7 @@ +@@ -976,6 +_,7 @@ @Nullable @Override public ServerPlayer teleport(TeleportTransition teleportTransition) { @@ -619,7 +609,7 @@ if (this.isRemoved()) { return null; } else { -@@ -1031,17 +_,52 @@ +@@ -985,17 +_,52 @@ ServerLevel level = teleportTransition.newLevel(); ServerLevel serverLevel = this.serverLevel(); @@ -629,7 +619,7 @@ + + org.bukkit.Location enter = this.getBukkitEntity().getLocation(); + PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); -+ org.bukkit.Location exit = /* (worldserver == null) ? null : // Paper - always non-null */org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), level.getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); ++ org.bukkit.Location exit = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(absolutePosition.position(), level.getWorld(), absolutePosition.yRot(), absolutePosition.xRot()); + org.bukkit.event.player.PlayerTeleportEvent tpEvent = new org.bukkit.event.player.PlayerTeleportEvent(this.getBukkitEntity(), enter, exit, teleportTransition.cause()); + // Paper start - gateway-specific teleport event + if (this.portalProcess != null && this.portalProcess.isSamePortal(((net.minecraft.world.level.block.EndGatewayBlock) net.minecraft.world.level.block.Blocks.END_GATEWAY)) && this.serverLevel().getBlockEntity(this.portalProcess.getEntryPosition()) instanceof net.minecraft.world.level.block.entity.TheEndGatewayBlockEntity theEndGatewayBlockEntity) { @@ -645,7 +635,7 @@ + level = ((org.bukkit.craftbukkit.CraftWorld) newExit.getWorld()).getHandle(); + teleportTransition = new TeleportTransition( + level, -+ org.bukkit.craftbukkit.util.CraftLocation.toVec3D(newExit), ++ org.bukkit.craftbukkit.util.CraftLocation.toVec3(newExit), + Vec3.ZERO, + newExit.getYaw(), + newExit.getPitch(), @@ -657,7 +647,7 @@ + } + // CraftBukkit end if (!teleportTransition.asPassenger()) { - this.stopRiding(); + this.removeVehicle(); } - if (level.dimension() == resourceKey) { @@ -675,7 +665,7 @@ this.isChangingDimension = true; LevelData levelData = level.getLevelData(); this.connection.send(new ClientboundRespawnPacket(this.createCommonSpawnInfo(level), (byte)3)); -@@ -1050,16 +_,30 @@ +@@ -1004,16 +_,30 @@ playerList.sendPlayerPermissionLevel(this); serverLevel.removePlayerImmediately(this, Entity.RemovalReason.CHANGED_DIMENSION); this.unsetRemoved(); @@ -708,7 +698,7 @@ this.connection.resetPosition(); level.addDuringTeleport(this); profilerFiller.pop(); -@@ -1073,10 +_,40 @@ +@@ -1027,10 +_,39 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -730,16 +720,15 @@ + + // CraftBukkit start + @Override -+ public org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent( ++ public @Nullable org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent( + Entity entity, + org.bukkit.Location exit, + org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, -+ int searchRadius, -+ int creationRadius ++ int searchRadius, int creationRadius + ) { + org.bukkit.Location enter = this.getBukkitEntity().getLocation(); + org.bukkit.event.player.PlayerPortalEvent event = new org.bukkit.event.player.PlayerPortalEvent(this.getBukkitEntity(), enter, exit, cause, searchRadius, true, creationRadius); -+ org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); ++ event.callEvent(); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null) { + return null; + } @@ -749,7 +738,7 @@ @Override public void forceSetRotation(float yRot, float xRot) { -@@ -1086,12 +_,26 @@ +@@ -1040,12 +_,26 @@ public void triggerDimensionChangeTriggers(ServerLevel level) { ResourceKey resourceKey = level.dimension(); ResourceKey resourceKey1 = this.level().dimension(); @@ -779,7 +768,7 @@ this.enteredNetherPosition = null; } } -@@ -1107,19 +_,18 @@ +@@ -1061,19 +_,18 @@ this.containerMenu.broadcastChanges(); } @@ -798,12 +787,12 @@ } else if (this.bedBlocked(at, direction)) { return Either.left(Player.BedSleepingProblem.OBSTRUCTED); } else { -- this.setRespawnPosition(this.level().dimension(), at, this.getYRot(), false, true); -+ this.setRespawnPosition(this.level().dimension(), at, this.getYRot(), false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - Add PlayerSetSpawnEvent - if (this.level().isDay()) { +- this.setRespawnPosition(new ServerPlayer.RespawnConfig(this.level().dimension(), at, this.getYRot(), false), true); ++ this.setRespawnPosition(new ServerPlayer.RespawnConfig(this.level().dimension(), at, this.getYRot(), false), true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.BED); // Paper - Add PlayerSetSpawnEvent + if (this.level().isBrightOutside()) { return Either.left(Player.BedSleepingProblem.NOT_POSSIBLE_NOW); } else { -@@ -1138,7 +_,34 @@ +@@ -1092,7 +_,34 @@ } } @@ -816,8 +805,8 @@ + + @Override + public Either startSleepInBed(BlockPos at, boolean force) { -+ Direction enumdirection = (Direction) this.level().getBlockState(at).getValue(HorizontalDirectionalBlock.FACING); -+ Either bedResult = this.getBedResult(at, enumdirection); ++ Direction direction = this.level().getBlockState(at).getValue(HorizontalDirectionalBlock.FACING); ++ Either bedResult = this.getBedResult(at, direction); + + if (bedResult.left().orElse(null) == net.minecraft.world.entity.player.Player.BedSleepingProblem.OTHER_PROBLEM) { + return bedResult; // return immediately if the result is not bypassable by plugins @@ -839,25 +828,15 @@ this.awardStat(Stats.SLEEP_IN_BED); CriteriaTriggers.SLEPT_IN_BED.trigger(this); }); -@@ -1174,13 +_,31 @@ +@@ -1128,21 +_,29 @@ @Override public void stopSleepInBed(boolean wakeImmediately, boolean updateLevelForSleepingPlayers) { + if (!this.isSleeping()) return; // CraftBukkit - Can't leave bed if not in one! + // CraftBukkit start - fire PlayerBedLeaveEvent -+ org.bukkit.craftbukkit.entity.CraftPlayer player = this.getBukkitEntity(); -+ BlockPos bedPosition = this.getSleepingPos().orElse(null); -+ -+ org.bukkit.block.Block bed; -+ if (bedPosition != null) { -+ bed = this.level().getWorld().getBlockAt(bedPosition.getX(), bedPosition.getY(), bedPosition.getZ()); -+ } else { -+ bed = this.level().getWorld().getBlockAt(player.getLocation()); -+ } -+ -+ org.bukkit.event.player.PlayerBedLeaveEvent event = new org.bukkit.event.player.PlayerBedLeaveEvent(player, bed, true); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { ++ org.bukkit.block.Block bed = org.bukkit.craftbukkit.block.CraftBlock.at(this.level(), this.getSleepingPos().orElse(this.blockPosition())); ++ org.bukkit.event.player.PlayerBedLeaveEvent event = new org.bukkit.event.player.PlayerBedLeaveEvent(this.getBukkitEntity(), bed, true); ++ if (!event.callEvent()) { + return; + } + // CraftBukkit end @@ -872,8 +851,6 @@ } } -@@ -1192,9 +_,9 @@ - @Override public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) { - return super.isInvulnerableTo(level, damageSource) @@ -884,7 +861,7 @@ } @Override -@@ -1237,8 +_,9 @@ +@@ -1185,8 +_,9 @@ this.connection.send(new ClientboundOpenSignEditorPacket(signEntity.getBlockPos(), isFrontText)); } @@ -895,17 +872,14 @@ } @Override -@@ -1246,12 +_,43 @@ +@@ -1194,12 +_,39 @@ if (menu == null) { return OptionalInt.empty(); } else { -+ // CraftBukkit start - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEvent(...) -+ /* - if (this.containerMenu != this.inventoryMenu) { +- if (this.containerMenu != this.inventoryMenu) { ++ if (false && this.containerMenu != this.inventoryMenu) { // CraftBukkit - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEventWithTitle(...) this.closeContainer(); } -+ */ -+ // CraftBukkit end this.nextContainerCounter(); AbstractContainerMenu abstractContainerMenu = menu.createMenu(this.containerCounter, this.getInventory(), this); @@ -922,8 +896,8 @@ + // Paper end - Add titleOverride to InventoryOpenEvent + if (abstractContainerMenu == null && !cancelled) { // Let pre-cancelled events fall through + // SPIGOT-5263 - close chest if cancelled -+ if (menu instanceof Container) { -+ ((Container) menu).stopOpen(this); ++ if (menu instanceof Container container) { ++ container.stopOpen(this); + } else if (menu instanceof net.minecraft.world.level.block.ChestBlock.DoubleInventory doubleInventory) { + // SPIGOT-5355 - double chests too :( + doubleInventory.container.stopOpen(this); @@ -939,7 +913,7 @@ if (abstractContainerMenu == null) { if (this.isSpectator()) { this.displayClientMessage(Component.translatable("container.spectatorCantOpen").withStyle(ChatFormatting.RED), true); -@@ -1259,10 +_,14 @@ +@@ -1207,10 +_,14 @@ return OptionalInt.empty(); } else { @@ -956,7 +930,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1275,14 +_,25 @@ +@@ -1223,14 +_,25 @@ @Override public void openHorseInventory(AbstractHorse horse, Container inventory) { @@ -985,7 +959,7 @@ this.initMenu(this.containerMenu); } -@@ -1304,9 +_,28 @@ +@@ -1252,10 +_,30 @@ @Override public void closeContainer() { @@ -999,6 +973,7 @@ this.connection.send(new ClientboundContainerClosePacket(this.containerMenu.containerId)); this.doCloseContainer(); } + + // Paper start - special close for unloaded inventory + @Override + public void closeUnloadedInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason reason) { @@ -1011,10 +986,11 @@ + // do not run close logic + } + // Paper end - special close for unloaded inventory - ++ @Override public void doCloseContainer() { -@@ -1330,19 +_,19 @@ + this.containerMenu.removed(this); +@@ -1278,19 +_,19 @@ int rounded = Math.round((float)Math.sqrt(dx * dx + dy * dy + dz * dz) * 100.0F); if (rounded > 0) { this.awardStat(Stats.SWIM_ONE_CM, rounded); @@ -1037,7 +1013,7 @@ } } else if (this.onClimbable()) { if (dy > 0.0) { -@@ -1353,13 +_,13 @@ +@@ -1301,13 +_,13 @@ if (rounded > 0) { if (this.isSprinting()) { this.awardStat(Stats.SPRINT_ONE_CM, rounded); @@ -1054,7 +1030,7 @@ } } } else if (this.isFallFlying()) { -@@ -1399,13 +_,13 @@ +@@ -1347,13 +_,13 @@ @Override public void awardStat(Stat stat, int amount) { this.stats.increment(this, stat, amount); @@ -1070,7 +1046,7 @@ } @Override -@@ -1436,9 +_,9 @@ +@@ -1384,9 +_,9 @@ super.jumpFromGround(); this.awardStat(Stats.JUMP); if (this.isSprinting()) { @@ -1082,7 +1058,7 @@ } } -@@ -1451,6 +_,13 @@ +@@ -1399,6 +_,13 @@ public void disconnect() { this.disconnected = true; this.ejectPassengers(); @@ -1096,7 +1072,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, false); } -@@ -1462,6 +_,7 @@ +@@ -1410,6 +_,7 @@ public void resetSentInfo() { this.lastSentHealth = -1.0E8F; @@ -1104,7 +1080,7 @@ } @Override -@@ -1496,12 +_,12 @@ +@@ -1444,12 +_,12 @@ this.onUpdateAbilities(); if (keepEverything) { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1119,7 +1095,7 @@ } this.getInventory().replaceWith(that.getInventory()); -@@ -1512,7 +_,7 @@ +@@ -1460,7 +_,7 @@ this.portalProcess = that.portalProcess; } else { this.getAttributes().assignBaseValues(that.getAttributes()); @@ -1128,7 +1104,7 @@ if (this.serverLevel().getGameRules().getBoolean(GameRules.RULE_KEEPINVENTORY) || that.isSpectator()) { this.getInventory().replaceWith(that.getInventory()); this.experienceLevel = that.experienceLevel; -@@ -1528,7 +_,7 @@ +@@ -1476,7 +_,7 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -1137,7 +1113,7 @@ this.seenCredits = that.seenCredits; this.enteredNetherPosition = that.enteredNetherPosition; this.chunkTrackingView = that.chunkTrackingView; -@@ -1581,7 +_,7 @@ +@@ -1529,7 +_,7 @@ } @Override @@ -1146,7 +1122,7 @@ if (this.isSleeping()) { this.stopSleepInBed(true, true); } -@@ -1590,7 +_,7 @@ +@@ -1538,7 +_,7 @@ this.setCamera(this); } @@ -1155,7 +1131,7 @@ if (flag) { this.setYHeadRot(relativeMovements.contains(Relative.Y_ROT) ? this.getYHeadRot() + yaw : yaw); } -@@ -1627,9 +_,17 @@ +@@ -1575,9 +_,17 @@ } public boolean setGameMode(GameType gameMode) { @@ -1175,7 +1151,7 @@ } else { this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { -@@ -1645,7 +_,7 @@ +@@ -1593,7 +_,7 @@ this.onUpdateAbilities(); this.updateEffectVisibility(); @@ -1184,7 +1160,7 @@ } } -@@ -1705,8 +_,13 @@ +@@ -1649,8 +_,13 @@ } public void sendChatMessage(OutgoingChatMessage message, boolean filtered, ChatType.Bound boundType) { @@ -1199,7 +1175,7 @@ } } -@@ -1717,7 +_,42 @@ +@@ -1661,7 +_,42 @@ } public void updateOptions(ClientInformation clientInformation) { @@ -1242,7 +1218,7 @@ this.requestedViewDistance = clientInformation.viewDistance(); this.chatVisibility = clientInformation.chatVisibility(); this.canChatColor = clientInformation.chatColors(); -@@ -1803,8 +_,23 @@ +@@ -1747,8 +_,23 @@ Entity camera = this.getCamera(); this.camera = (Entity)(entityToSpectate == null ? this : entityToSpectate); if (camera != this.camera) { @@ -1267,7 +1243,7 @@ } if (entityToSpectate != null) { -@@ -1838,11 +_,11 @@ +@@ -1782,11 +_,11 @@ @Nullable public Component getTabListDisplayName() { @@ -1281,35 +1257,28 @@ } @Override -@@ -1884,11 +_,56 @@ - this.setRespawnPosition(player.getRespawnDimension(), player.getRespawnPosition(), player.getRespawnAngle(), player.isRespawnForced(), false); +@@ -1817,11 +_,56 @@ } -+ @Deprecated // Paper - Add PlayerSetSpawnEvent - public void setRespawnPosition(ResourceKey dimension, @Nullable BlockPos position, float angle, boolean forced, boolean sendMessage) { + public void setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat) { +- if (displayInChat && respawnConfig != null && !respawnConfig.isSamePosition(this.respawnConfig)) { +- this.sendSystemMessage(SPAWN_SET_MESSAGE); + // Paper start - Add PlayerSetSpawnEvent -+ this.setRespawnPosition(dimension, position, angle, forced, sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN); ++ this.setRespawnPosition(respawnConfig, displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.UNKNOWN); + } -+ @Deprecated -+ public boolean setRespawnPosition(ResourceKey dimension, @Nullable BlockPos position, float angle, boolean forced, boolean sendMessage, org.bukkit.event.player.PlayerSpawnChangeEvent.Cause cause) { -+ return this.setRespawnPosition(dimension, position, angle, forced, sendMessage, cause == org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESET ? -+ com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN : com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.valueOf(cause.name())); -+ } -+ public boolean setRespawnPosition(ResourceKey dimension, @Nullable BlockPos position, float angle, boolean forced, boolean sendMessage, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { ++ ++ public boolean setRespawnPosition(@Nullable ServerPlayer.RespawnConfig respawnConfig, boolean displayInChat, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause cause) { + org.bukkit.Location spawnLoc = null; -+ boolean willNotify = false; - if (position != null) { - boolean flag = position.equals(this.respawnPosition) && dimension.equals(this.respawnDimension); -- if (sendMessage && !flag) { -- this.sendSystemMessage(Component.translatable("block.minecraft.set_spawn")); -+ spawnLoc = io.papermc.paper.util.MCUtil.toLocation(this.getServer().getLevel(dimension), position); -+ spawnLoc.setYaw(angle); -+ willNotify = sendMessage && !flag; ++ boolean actuallyDisplayInChat = false; ++ if (respawnConfig != null) { ++ actuallyDisplayInChat = displayInChat && !respawnConfig.isSamePosition(this.respawnConfig); ++ spawnLoc = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(respawnConfig.pos(), this.getServer().getLevel(respawnConfig.dimension())); ++ spawnLoc.setYaw(respawnConfig.angle()); + } + org.bukkit.event.player.PlayerSpawnChangeEvent dumbEvent = new org.bukkit.event.player.PlayerSpawnChangeEvent( + this.getBukkitEntity(), + spawnLoc, -+ forced, ++ respawnConfig != null && respawnConfig.forced(), + cause == com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN + ? org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.RESET + : org.bukkit.event.player.PlayerSpawnChangeEvent.Cause.valueOf(cause.name()) @@ -1321,114 +1290,70 @@ + cause, + dumbEvent.getNewSpawn(), + dumbEvent.isForced(), -+ willNotify, -+ willNotify ? net.kyori.adventure.text.Component.translatable("block.minecraft.set_spawn") : null ++ actuallyDisplayInChat, ++ actuallyDisplayInChat ? io.papermc.paper.adventure.PaperAdventure.asAdventure(SPAWN_SET_MESSAGE) : null + ); + event.setCancelled(dumbEvent.isCancelled()); + if (!event.callEvent()) { + return false; + } ++ + if (event.getLocation() != null) { -+ dimension = event.getLocation().getWorld() != null ? ((org.bukkit.craftbukkit.CraftWorld) event.getLocation().getWorld()).getHandle().dimension() : dimension; -+ position = io.papermc.paper.util.MCUtil.toBlockPosition(event.getLocation()); -+ angle = event.getLocation().getYaw(); -+ forced = event.isForced(); -+ // Paper end - Add PlayerSetSpawnEvent -+ -+ if (event.willNotifyPlayer() && event.getNotification() != null) { // Paper - Add PlayerSetSpawnEvent -+ this.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.getNotification())); // Paper - Add PlayerSetSpawnEvent - } - - this.respawnPosition = position; -@@ -1901,6 +_,8 @@ - this.respawnAngle = 0.0F; - this.respawnForced = false; ++ respawnConfig = new ServerPlayer.RespawnConfig( ++ ((org.bukkit.craftbukkit.CraftWorld) event.getLocation().getWorld()).getHandle().dimension(), ++ org.bukkit.craftbukkit.util.CraftLocation.toBlockPosition(event.getLocation()), ++ event.getLocation().getYaw(), ++ event.isForced() ++ ); ++ if (event.willNotifyPlayer() && event.getNotification() != null) { ++ this.sendSystemMessage(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.getNotification())); ++ } } -+ -+ return true; // Paper - Add PlayerSetSpawnEvent + + this.respawnConfig = respawnConfig; ++ return true; ++ // Paper end - Add PlayerSetSpawnEvent } public SectionPos getLastSectionPos() { -@@ -1930,21 +_,55 @@ +@@ -1851,16 +_,23 @@ } @Override - public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem) { -+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { // Paper start - Extend HumanEntity#dropItem API - ItemEntity itemEntity = this.createItemStackToDrop(droppedItem, dropAround, traceItem); - if (itemEntity == null) { - return null; - } else { -+ // CraftBukkit start - fire PlayerDropItemEvent -+ if (entityOperation != null) entityOperation.accept((org.bukkit.entity.Item) itemEntity.getBukkitEntity()); -+ if (callEvent) { -+ org.bukkit.entity.Player player = this.getBukkitEntity(); -+ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) itemEntity.getBukkitEntity(); -+ -+ org.bukkit.event.player.PlayerDropItemEvent event = new org.bukkit.event.player.PlayerDropItemEvent(player, drop); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { -+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand(); -+ if (traceItem && (cur == null || cur.getAmount() == 0)) { -+ // The complete stack was dropped -+ player.getInventory().setItemInHand(drop.getItemStack()); -+ } else if (traceItem && cur.isSimilar(drop.getItemStack()) && cur.getAmount() < cur.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { -+ // Only one item is dropped -+ cur.setAmount(cur.getAmount() + 1); -+ player.getInventory().setItemInHand(cur); -+ } else { -+ // Fallback -+ player.getInventory().addItem(drop.getItemStack()); -+ } -+ return null; -+ } -+ } -+ // CraftBukkit end - this.level().addFreshEntity(itemEntity); - ItemStack item = itemEntity.getItem(); - if (traceItem) { - if (!item.isEmpty()) { -- this.awardStat(Stats.ITEM_DROPPED.get(item.getItem()), droppedItem.getCount()); -+ this.awardStat(Stats.ITEM_DROPPED.get(item.getItem()), item.getCount()); // Paper - Fix PlayerDropItemEvent using wrong item - } - +- ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem); ++ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean traceItem, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { // Paper - Extend dropItem API ++ ItemEntity itemEntity = super.drop(droppedItem, dropAround, traceItem, callEvent, entityOperation); // Paper - Extend dropItem API ++ ItemStack itemStack = itemEntity != null ? itemEntity.getItem() : ItemStack.EMPTY; // Paper - move up + if (traceItem) { +- ItemStack itemStack = itemEntity != null ? itemEntity.getItem() : ItemStack.EMPTY; + if (!itemStack.isEmpty()) { + this.awardStat(Stats.ITEM_DROPPED.get(itemStack.getItem()), droppedItem.getCount()); this.awardStat(Stats.DROP); } - -+ // Paper start - remove player from map on drop -+ if (item.getItem() == net.minecraft.world.item.Items.FILLED_MAP) { -+ final MapItemSavedData mapData = MapItem.getSavedData(item, this.level()); -+ if (mapData != null) { -+ mapData.tickCarriedBy(this, item); -+ } -+ } -+ // Paper end - remove player from map on drop - return itemEntity; } +- ++ // Paper start - remove player from map on drop ++ if (itemStack.is(net.minecraft.world.item.Items.FILLED_MAP)) { ++ final MapItemSavedData mapData = MapItem.getSavedData(itemStack, this.level()); ++ if (mapData != null) { ++ mapData.tickCarriedBy(this, itemStack); ++ } ++ } ++ // Paper end - remove player from map on drop + return itemEntity; } -@@ -1955,6 +_,11 @@ - return null; - } else { - double d = this.getEyeY() - 0.3F; -+ // Paper start -+ ItemStack tmp = droppedItem.copy(); -+ droppedItem.setCount(0); -+ droppedItem = tmp; -+ // Paper end - ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), droppedItem); - itemEntity.setPickUpDelay(40); - if (includeThrowerName) { -@@ -2008,6 +_,16 @@ + +@@ -1888,6 +_,16 @@ } public void loadGameTypes(@Nullable CompoundTag tag) { + // Paper start - Expand PlayerGameModeChangeEvent -+ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != ServerPlayer.readPlayerMode(tag, "playerGameType")) { ++ if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(tag, "playerGameType")) { + if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { + this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE); + } else { -+ this.gameMode.setGameModeForPlayer(ServerPlayer.readPlayerMode(tag,"playerGameType"), ServerPlayer.readPlayerMode(tag, "previousPlayerGameType")); ++ this.gameMode.setGameModeForPlayer(readPlayerMode(tag,"playerGameType"), readPlayerMode(tag, "previousPlayerGameType")); + } + return; + } @@ -1436,31 +1361,35 @@ this.gameMode .setGameModeForPlayer(this.calculateGameModeForNewPlayer(readPlayerMode(tag, "playerGameType")), readPlayerMode(tag, "previousPlayerGameType")); } -@@ -2108,8 +_,14 @@ +@@ -1989,8 +_,14 @@ @Override - public void stopRiding() { + public void removeVehicle() { + // Paper start - Force entity dismount during teleportation -+ this.stopRiding(false); ++ this.removeVehicle(false); + } + @Override -+ public void stopRiding(boolean suppressCancellation) { ++ public void removeVehicle(final boolean suppressCancellation) { + // Paper end - Force entity dismount during teleportation Entity vehicle = this.getVehicle(); -- super.stopRiding(); -+ super.stopRiding(suppressCancellation); // Paper - Force entity dismount during teleportation +- super.removeVehicle(); ++ super.removeVehicle(suppressCancellation); // Paper - Force entity dismount during teleportation if (vehicle instanceof LivingEntity livingEntity) { for (MobEffectInstance mobEffectInstance : livingEntity.getActiveEffects()) { this.connection.send(new ClientboundRemoveMobEffectPacket(vehicle.getId(), mobEffectInstance.getEffect())); -@@ -2204,13 +_,15 @@ +@@ -2089,7 +_,7 @@ } public static long placeEnderPearlTicket(ServerLevel level, ChunkPos pos) { -- level.getChunkSource().addRegionTicket(TicketType.ENDER_PEARL, pos, 2, pos); -+ if (!level.paperConfig().misc.legacyEnderPearlBehavior) level.getChunkSource().addRegionTicket(TicketType.ENDER_PEARL, pos, 2, pos); // Paper - Allow using old ender pearl behavior +- level.getChunkSource().addTicketWithRadius(TicketType.ENDER_PEARL, pos, 2); ++ if (!level.paperConfig().misc.legacyEnderPearlBehavior) level.getChunkSource().addTicketWithRadius(TicketType.ENDER_PEARL, pos, 2); // Paper - Allow using old ender pearl behavior return TicketType.ENDER_PEARL.timeout(); } +@@ -2113,9 +_,11 @@ + } + } + - public record RespawnPosAngle(Vec3 position, float yaw) { - public static ServerPlayer.RespawnPosAngle of(Vec3 position, BlockPos towardsPos) { - return new ServerPlayer.RespawnPosAngle(position, calculateLookAtYaw(position, towardsPos)); @@ -1468,11 +1397,11 @@ + public record RespawnPosAngle(Vec3 position, float yaw, boolean isBedSpawn, boolean isAnchorSpawn) { + public static ServerPlayer.RespawnPosAngle of(Vec3 position, BlockPos towardsPos, boolean isBedSpawn, boolean isAnchorSpawn) { + return new ServerPlayer.RespawnPosAngle(position, calculateLookAtYaw(position, towardsPos), isBedSpawn, isAnchorSpawn); -+ // CraftBukkit end ++ // CraftBukkit end } private static float calculateLookAtYaw(Vec3 position, BlockPos towardsPos) { -@@ -2218,4 +_,147 @@ +@@ -2123,4 +_,143 @@ return (float)Mth.wrapDegrees(Mth.atan2(vec3.z, vec3.x) * 180.0F / (float)Math.PI - 90.0); } } @@ -1491,19 +1420,15 @@ + } + } + -+ public org.bukkit.WeatherType weather = null; -+ -+ public org.bukkit.WeatherType getPlayerWeather() { -+ return this.weather; -+ } ++ public @Nullable org.bukkit.WeatherType weatherType = null; + + public void setPlayerWeather(org.bukkit.WeatherType type, boolean plugin) { -+ if (!plugin && this.weather != null) { ++ if (!plugin && this.weatherType != null) { + return; + } + + if (plugin) { -+ this.weather = type; ++ this.weatherType = type; + } + + if (type == org.bukkit.WeatherType.DOWNFALL) { @@ -1517,7 +1442,7 @@ + private float pluginRainPositionPrevious; + + public void updateWeather(float oldRain, float newRain, float oldThunder, float newThunder) { -+ if (this.weather == null) { ++ if (this.weatherType == null) { + // Vanilla + if (oldRain != newRain) { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.RAIN_LEVEL_CHANGE, newRain)); @@ -1530,7 +1455,7 @@ + } + + if (oldThunder != newThunder) { -+ if (this.weather == org.bukkit.WeatherType.DOWNFALL || this.weather == null) { ++ if (this.weatherType == org.bukkit.WeatherType.DOWNFALL || this.weatherType == null) { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, newThunder)); + } else { + this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.THUNDER_LEVEL_CHANGE, 0)); @@ -1539,20 +1464,20 @@ + } + + public void tickWeather() { -+ if (this.weather == null) return; ++ if (this.weatherType == null) return; + + this.pluginRainPositionPrevious = this.pluginRainPosition; -+ if (this.weather == org.bukkit.WeatherType.DOWNFALL) { -+ this.pluginRainPosition += 0.01; ++ if (this.weatherType == org.bukkit.WeatherType.DOWNFALL) { ++ this.pluginRainPosition += 0.01F; + } else { -+ this.pluginRainPosition -= 0.01; ++ this.pluginRainPosition -= 0.01F; + } + + this.pluginRainPosition = Mth.clamp(this.pluginRainPosition, 0.0F, 1.0F); + } + + public void resetPlayerWeather() { -+ this.weather = null; ++ this.weatherType = null; + this.setPlayerWeather(this.level().getLevelData().isRaining() ? org.bukkit.WeatherType.DOWNFALL : org.bukkit.WeatherType.CLEAR, false); + } + @@ -1563,7 +1488,7 @@ + + // SPIGOT-1903, MC-98153 + public void forceSetPositionRotation(double x, double y, double z, float yaw, float pitch) { -+ this.moveTo(x, y, z, yaw, pitch); ++ this.snapTo(x, y, z, yaw, pitch); + this.connection.resetPosition(); + } + diff --git a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch index df1886611..0236b0722 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/ServerPlayerGameMode.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -41,28 +_,49 @@ +@@ -41,28 +_,50 @@ private BlockPos delayedDestroyPos = BlockPos.ZERO; private int delayedTickStart; private int lastSentState = -1; @@ -18,6 +18,7 @@ + org.bukkit.event.player.PlayerGameModeChangeEvent event = this.changeGameModeForPlayer(gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.UNKNOWN, null); + return event != null && event.isCancelled(); + } ++ + @Nullable + public org.bukkit.event.player.PlayerGameModeChangeEvent changeGameModeForPlayer(GameType gameModeForPlayer, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause playerGameModeChangeCause, @Nullable net.kyori.adventure.text.Component cancelMessage) { + // Paper end - Expand PlayerGameModeChangeEvent @@ -92,34 +93,30 @@ this.debugLogging(pos, false, sequence, "too far"); } else if (pos.getY() > maxBuildHeight) { this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); -@@ -138,16 +_,39 @@ +@@ -138,16 +_,35 @@ } else { if (action == ServerboundPlayerActionPacket.Action.START_DESTROY_BLOCK) { if (!this.level.mayInteract(this.player, pos)) { + // CraftBukkit start - fire PlayerInteractEvent -+ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, face, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, face, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); this.player.connection.send(new ClientboundBlockUpdatePacket(pos, this.level.getBlockState(pos))); this.debugLogging(pos, false, sequence, "may not interact"); - return; - } -+ // Update any tile entity data for this block + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + // CraftBukkit end + return; + } + + // CraftBukkit start -+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, face, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); ++ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(this.player, org.bukkit.event.block.Action.LEFT_CLICK_BLOCK, pos, face, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + if (event.isCancelled()) { -+ // Let the client know the block still exists -+ // this.player.connection.send(new ClientboundBlockUpdatePacket(this.level, pos)); // Paper - Don't resync blocks -+ // Update any tile entity data for this block + this.capturedBlockEntity = true; // Paper - Send block entities after destroy prediction + return; + } + // CraftBukkit end - if (this.isCreative()) { + if (this.player.getAbilities().instabuild) { this.destroyAndAck(pos, sequence, "creative destroy"); return; } @@ -153,7 +150,7 @@ + return; + } + -+ org.bukkit.event.block.BlockDamageEvent blockEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageEvent(this.player, pos, face, this.player.getInventory().getSelected(), f >= 1.0f); // Paper - Add BlockFace to BlockDamageEvent ++ org.bukkit.event.block.BlockDamageEvent blockEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageEvent(this.player, pos, face, this.player.getInventory().getSelectedItem(), f >= 1.0f); // Paper - Add BlockFace to BlockDamageEvent + + if (blockEvent.isCancelled()) { + return; @@ -188,7 +185,7 @@ this.level.destroyBlockProgress(this.player.getId(), pos, -1); this.debugLogging(pos, true, sequence, "aborted destroying"); + -+ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelected()); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callBlockDamageAbortEvent(this.player, pos, this.player.getInventory().getSelectedItem()); // CraftBukkit } } } @@ -196,13 +193,13 @@ public boolean destroyBlock(BlockPos pos) { BlockState blockState = this.level.getBlockState(pos); -- if (!this.player.getMainHandItem().getItem().canAttackBlock(blockState, this.level, pos, this.player)) { +- if (!this.player.getMainHandItem().canDestroyBlock(blockState, this.level, pos, this.player)) { + // CraftBukkit start - fire BlockBreakEvent + org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, pos); + org.bukkit.event.block.BlockBreakEvent event = null; + if (this.player instanceof ServerPlayer) { + // Sword + Creative mode pre-cancel -+ boolean canAttackBlock = !this.player.getMainHandItem().getItem().canAttackBlock(blockState, this.level, pos, this.player); ++ boolean canAttackBlock = !this.player.getMainHandItem().canDestroyBlock(blockState, this.level, pos, this.player); + event = new org.bukkit.event.block.BlockBreakEvent(bblock, this.player.getBukkitEntity()); + + // Sword + Creative mode pre-cancel @@ -238,7 +235,7 @@ + } + // CraftBukkit end + -+ if (false && !this.player.getMainHandItem().getItem().canAttackBlock(blockState, this.level, pos, this.player)) { // CraftBukkit - false ++ if (false && !this.player.getMainHandItem().canDestroyBlock(blockState, this.level, pos, this.player)) { // CraftBukkit - false return false; } else { + blockState = this.level.getBlockState(pos); // CraftBukkit - update state from plugins @@ -264,7 +261,7 @@ + ItemStack mainHandStack = null; // Paper - Trigger bee_nest_destroyed trigger in the correct place + boolean isCorrectTool = false; // Paper - Trigger bee_nest_destroyed trigger in the correct place - if (this.isCreative()) { + if (this.player.preventsBlockDrops()) { - return true; + // return true; // CraftBukkit } else { @@ -368,7 +365,7 @@ + if (!stack.isEmpty() && !this.interactResult) { // add !interactResult SPIGOT-764 UseOnContext useOnContext = new UseOnContext(player, hand, hitResult); InteractionResult interactionResult1; - if (this.isCreative()) { + if (player.hasInfiniteMaterials()) { @@ -357,6 +_,11 @@ return interactionResult1; diff --git a/paper-server/patches/sources/net/minecraft/server/level/Ticket.java.patch b/paper-server/patches/sources/net/minecraft/server/level/Ticket.java.patch new file mode 100644 index 000000000..8e7b25aff --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/server/level/Ticket.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/server/level/Ticket.java ++++ b/net/minecraft/server/level/Ticket.java +@@ -14,17 +_,36 @@ + ExtraCodecs.NON_NEGATIVE_INT.fieldOf("level").forGetter(Ticket::getTicketLevel), + Codec.LONG.optionalFieldOf("ticks_left", 0L).forGetter(ticket -> ticket.ticksLeft) + ) +- .apply(instance, Ticket::new) ++ .apply(instance, (type, level, ticks) -> new Ticket(type, level.intValue(), ticks.longValue())) // Paper - add identifier + ); + private final TicketType type; + private final int ticketLevel; + private long ticksLeft; ++ // Paper start - add identifier ++ private Object identifier; ++ ++ public Object getIdentifier() { ++ return this.identifier; ++ } ++ // Paper end - add identifier ++ + + public Ticket(TicketType type, int ticketLevel) { +- this(type, ticketLevel, type.timeout()); ++ // Paper start - add identifier ++ this(type, ticketLevel, null); ++ } ++ public Ticket(TicketType type, int ticketLevel, Object identifier) { ++ this(type, ticketLevel, type.timeout(), identifier); ++ // Paper end - add identifier + } + + private Ticket(TicketType type, int ticketLevel, long ticksLeft) { ++ // Paper start - add identifier ++ this(type, ticketLevel, ticksLeft, null); ++ } ++ private Ticket(TicketType type, int ticketLevel, long ticksLeft, Object identifier) { ++ this.identifier = identifier; ++ // Paper end - add identifier + this.type = type; + this.ticketLevel = ticketLevel; + this.ticksLeft = ticksLeft; diff --git a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch index 12796a0ff..9e6471522 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/TicketType.java.patch @@ -1,20 +1,36 @@ --- a/net/minecraft/server/level/TicketType.java +++ b/net/minecraft/server/level/TicketType.java -@@ -7,6 +_,7 @@ - import net.minecraft.world.level.ChunkPos; +@@ -13,11 +_,24 @@ + public static final TicketType PORTAL = register("portal", 300L, true, TicketType.TicketUse.LOADING_AND_SIMULATION); + public static final TicketType ENDER_PEARL = register("ender_pearl", 40L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); + public static final TicketType UNKNOWN = register("unknown", 1L, false, TicketType.TicketUse.LOADING); ++ public static final TicketType PLUGIN = register("plugin", 0L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // CraftBukkit ++ public static final TicketType POST_TELEPORT = register("post_teleport", 5L, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper ++ public static final TicketType PLUGIN_TICKET = register("plugin_ticket", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper ++ public static final TicketType FUTURE_AWAIT = register("future_await", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING_AND_SIMULATION); // Paper ++ public static final TicketType CHUNK_LOAD = register("chunk_load", TicketType.NO_TIMEOUT, false, TicketType.TicketUse.LOADING); // Paper - moonrise - public class TicketType { -+ public static final TicketType FUTURE_AWAIT = create("future_await", Long::compareTo); // Paper - private final String name; - private final Comparator comparator; - public long timeout; -@@ -17,6 +_,9 @@ - public static final TicketType PORTAL = create("portal", Vec3i::compareTo, 300); - public static final TicketType ENDER_PEARL = create("ender_pearl", Comparator.comparingLong(ChunkPos::toLong), 40); - public static final TicketType UNKNOWN = create("unknown", Comparator.comparingLong(ChunkPos::toLong), 1); -+ public static final TicketType PLUGIN = TicketType.create("plugin", (a, b) -> 0); // CraftBukkit -+ public static final TicketType PLUGIN_TICKET = TicketType.create("plugin_ticket", (plugin1, plugin2) -> plugin1.getClass().getName().compareTo(plugin2.getClass().getName())); // CraftBukkit -+ public static final TicketType POST_TELEPORT = TicketType.create("post_teleport", Integer::compare, 5); // Paper - post teleport ticket type + public static TicketType register(String name, long timeout, boolean persist, TicketType.TicketUse use) { + return Registry.register(BuiltInRegistries.TICKET_TYPE, name, new TicketType(timeout, persist, use)); + } - public static TicketType create(String name, Comparator comparator) { - return new TicketType<>(name, comparator, 0L); ++ // Paper start - chunk-gc config ++ public static int PLUGIN_TYPE_TIMEOUT = 600; ++ @Override ++ public long timeout() { ++ return this == PLUGIN ? PLUGIN_TYPE_TIMEOUT : this.timeout; ++ } ++ // Paper end - chunk-gc config ++ + public boolean doesLoad() { + return this.use == TicketType.TicketUse.LOADING || this.use == TicketType.TicketUse.LOADING_AND_SIMULATION; + } +@@ -27,7 +_,7 @@ + } + + public boolean hasTimeout() { +- return this.timeout != 0L; ++ return this.timeout() != 0L; // Paper - chunk-gc config + } + + public static enum TicketUse { diff --git a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch index 6daf126e1..7f48377c4 100644 --- a/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/level/WorldGenRegion.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/level/WorldGenRegion.java +++ b/net/minecraft/server/level/WorldGenRegion.java -@@ -151,6 +_,26 @@ +@@ -151,6 +_,28 @@ return chessboardDistance < this.generatingStep.directDependencies().size(); } @@ -11,16 +11,18 @@ + return this.getChunk(x, z, ChunkStatus.FULL, false); + } + ++ @Nullable + @Override -+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { -+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); -+ return chunk == null ? null : chunk.getBlockState(blockposition); ++ public final BlockState getBlockStateIfLoaded(BlockPos pos) { ++ ChunkAccess chunk = this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); ++ return chunk == null ? null : chunk.getBlockState(pos); + } + ++ @Nullable + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { -+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); -+ return chunk == null ? null : chunk.getFluidState(blockposition); ++ public final FluidState getFluidIfLoaded(BlockPos pos) { ++ ChunkAccess chunk = this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); ++ return chunk == null ? null : chunk.getFluidState(pos); + } + // Paper end + @@ -71,10 +73,10 @@ return false; } else { ChunkAccess chunk = this.getChunk(pos); -- BlockState blockState = chunk.setBlockState(pos, state, false); -+ BlockState blockState = chunk.setBlockState(pos, state, false); final BlockState previousBlockState = blockState; // Paper - Clear block entity before setting up a DUMMY block entity - obfhelper +- BlockState blockState = chunk.setBlockState(pos, state, flags); ++ BlockState blockState = chunk.setBlockState(pos, state, flags); final BlockState previousBlockState = blockState; // Paper - Clear block entity before setting up a DUMMY block entity - obfhelper if (blockState != null) { - this.level.onBlockStateChange(pos, blockState, state); + this.level.updatePOIOnBlockStateChange(pos, blockState, state); } @@ -294,6 +_,17 @@ chunk.removeBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch index 9bda2a754..53e52d055 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/LegacyQueryHandler.java.patch @@ -100,7 +100,7 @@ } + + // Paper start -+ private static String readLegacyString(ByteBuf buf) { ++ private static @javax.annotation.Nullable String readLegacyString(ByteBuf buf) { + int size = buf.readShort() * Character.BYTES; + if (!buf.isReadable(size)) { + return null; @@ -111,7 +111,7 @@ + return result; + } + -+ private String readLegacy1_6(ChannelHandlerContext ctx, ByteBuf part) { ++ private @javax.annotation.Nullable String readLegacy1_6(ChannelHandlerContext ctx, ByteBuf part) { + ByteBuf buf = this.buf; + + if (buf == null) { @@ -168,7 +168,7 @@ + return null; + } + -+ String response = String.format("\u00a71\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", event.getProtocolVersion(), event.getVersion(), ++ String response = String.format("§1\u0000%d\u0000%s\u0000%s\u0000%d\u0000%d", event.getProtocolVersion(), event.getVersion(), + com.destroystokyo.paper.network.PaperLegacyStatusClient.getMotd(event), event.getNumPlayers(), event.getMaxPlayers()); + return response; + } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch index 74d485b66..1a65ac30d 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerCommonPacketListenerImpl.java.patch @@ -47,7 +47,7 @@ + } + + public org.bukkit.craftbukkit.entity.CraftPlayer getCraftPlayer() { -+ return this.player == null ? null : this.player.getBukkitEntity(); ++ return this.player.getBukkitEntity(); + } + + @Override @@ -81,7 +81,7 @@ + this.onDisconnect(details, null); + } + -+ public void onDisconnect(DisconnectionDetails info, @Nullable net.kyori.adventure.text.Component quitMessage) { ++ public void onDisconnect(DisconnectionDetails details, @Nullable net.kyori.adventure.text.Component quitMessage) { + // Paper end - Fix kick event leave message not being sent if (this.isSingleplayerOwner()) { LOGGER.info("Stopping singleplayer server as player logged out"); @@ -99,7 +99,7 @@ public void handlePong(ServerboundPongPacket packet) { } -+ private static final net.minecraft.resources.ResourceLocation CUSTOM_REGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("register"); // CraftBukkit ++ public static final net.minecraft.resources.ResourceLocation CUSTOM_REGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("register"); // CraftBukkit + private static final net.minecraft.resources.ResourceLocation CUSTOM_UNREGISTER = net.minecraft.resources.ResourceLocation.withDefaultNamespace("unregister"); // CraftBukkit + @Override @@ -272,7 +272,7 @@ + this.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); + } + -+ public void disconnect(final Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) { ++ public void disconnect(Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) { + this.disconnect(new DisconnectionDetails(reason), cause); + // Paper end - kick event causes + } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch index 6ce6f262a..8d173d9bb 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerGamePacketListenerImpl.java.patch @@ -1,34 +1,19 @@ --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -193,6 +_,59 @@ +@@ -204,6 +_,39 @@ import net.minecraft.world.phys.shapes.VoxelShape; import org.slf4j.Logger; +// CraftBukkit start -+import io.papermc.paper.adventure.ChatProcessor; // Paper +import io.papermc.paper.adventure.PaperAdventure; // Paper -+import com.mojang.datafixers.util.Pair; -+import java.util.Arrays; -+import java.util.concurrent.ExecutionException; -+import java.util.function.Function; -+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; -+import net.minecraft.network.chat.OutgoingChatMessage; -+import net.minecraft.world.entity.animal.Bucketable; -+import net.minecraft.world.entity.animal.allay.Allay; -+import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; -+import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.HitResult; +import org.bukkit.Location; +import org.bukkit.NamespacedKey; -+import org.bukkit.craftbukkit.CraftInput; +import org.bukkit.craftbukkit.entity.CraftEntity; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.craftbukkit.inventory.CraftItemType; +import org.bukkit.craftbukkit.util.CraftLocation; -+import org.bukkit.craftbukkit.util.LazyPlayerSet; -+import org.bukkit.craftbukkit.util.Waitable; +import org.bukkit.event.Event; +import org.bukkit.event.block.Action; +import org.bukkit.event.inventory.ClickType; @@ -38,8 +23,6 @@ +import org.bukkit.event.inventory.InventoryCreativeEvent; +import org.bukkit.event.inventory.InventoryType.SlotType; +import org.bukkit.event.inventory.SmithItemEvent; -+import org.bukkit.event.player.AsyncPlayerChatEvent; -+import org.bukkit.event.player.PlayerChatEvent; +import org.bukkit.event.player.PlayerCommandPreprocessEvent; +import org.bukkit.event.player.PlayerInputEvent; +import org.bukkit.event.player.PlayerInteractAtEntityEvent; @@ -52,15 +35,12 @@ +import org.bukkit.event.player.PlayerToggleFlightEvent; +import org.bukkit.event.player.PlayerToggleSneakEvent; +import org.bukkit.event.player.PlayerToggleSprintEvent; -+import org.bukkit.inventory.CraftingInventory; -+import org.bukkit.inventory.InventoryView; -+import org.bukkit.inventory.SmithingInventory; +// CraftBukkit end + public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl - implements ServerGamePacketListener, -@@ -210,7 +_,9 @@ + implements GameProtocols.Context, +@@ -222,7 +_,9 @@ private int tickCount; private int ackBlockChangesUpTo = -1; private final TickThrottler chatSpamThrottler = new TickThrottler(20, 200); @@ -70,7 +50,7 @@ private double firstGoodX; private double firstGoodY; private double firstGoodZ; -@@ -236,22 +_,41 @@ +@@ -248,23 +_,42 @@ private int receivedMovePacketCount; private int knownMovePacketCount; private boolean receivedMovementThisTick; @@ -94,6 +74,7 @@ + private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins private SignedMessageChain.Decoder signedMessageDecoder; private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20); + private int nextChatIndex; private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault(); private final FutureChain chatMessageChain; private boolean waitingForSwitchToConfig; @@ -114,7 +95,7 @@ } @Override -@@ -272,7 +_,7 @@ +@@ -285,7 +_,7 @@ if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString()); @@ -123,7 +104,7 @@ return; } } else { -@@ -291,7 +_,7 @@ +@@ -304,7 +_,7 @@ if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString()); @@ -132,7 +113,7 @@ return; } } else { -@@ -307,11 +_,20 @@ +@@ -320,11 +_,20 @@ this.keepConnectionAlive(); this.chatSpamThrottler.tick(); this.dropSpamThrottler.tick(); @@ -156,20 +137,20 @@ } private int getMaximumFlyingTicks(Entity entity) { -@@ -371,6 +_,12 @@ +@@ -384,6 +_,12 @@ @Override public void handlePlayerInput(ServerboundPlayerInputPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); + // CraftBukkit start + if (!packet.input().equals(this.player.getLastClientInput())) { -+ PlayerInputEvent event = new PlayerInputEvent(this.player.getBukkitEntity(), new CraftInput(packet.input())); ++ PlayerInputEvent event = new PlayerInputEvent(this.player.getBukkitEntity(), new org.bukkit.craftbukkit.CraftInput(packet.input())); + this.cserver.getPluginManager().callEvent(event); + } + // CraftBukkit end this.player.setLastClientInput(packet.input()); } -@@ -390,17 +_,29 @@ +@@ -403,17 +_,29 @@ public void handleMoveVehicle(ServerboundMoveVehiclePacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (containsInvalidValues(packet.position().x(), packet.position().y(), packet.position().z(), packet.yRot(), packet.xRot())) { @@ -203,7 +184,7 @@ float f = Mth.wrapDegrees(packet.yRot()); float f1 = Mth.wrapDegrees(packet.xRot()); double d3 = d - this.vehicleFirstGoodX; -@@ -408,7 +_,53 @@ +@@ -421,7 +_,52 @@ double d5 = d2 - this.vehicleFirstGoodZ; double d6 = rootVehicle.getDeltaMovement().lengthSqr(); double d7 = d3 * d3 + d4 * d4 + d5 * d5; @@ -219,7 +200,6 @@ + d7 = Math.max(d7, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1); + // Paper end - fix large move vectors killing the server + -+ // CraftBukkit start - handle custom speeds and skipped ticks + this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; + this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); + this.lastTick = (int) (System.currentTimeMillis() / 50); @@ -253,12 +233,12 @@ + return; + } + // Paper end - Prevent moving into unloaded chunks -+ if (d7 - d6 > Math.max(100.0, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) { ++ if (d7 - d6 > Math.max(100.0, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed)) && !this.isSingleplayerOwner()) { + // CraftBukkit end LOGGER.warn( "{} (vehicle of {}) moved too quickly! {},{},{}", rootVehicle.getName().getString(), this.player.getName().getString(), d3, d4, d5 ); -@@ -417,15 +_,16 @@ +@@ -430,15 +_,16 @@ } boolean flag = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625)); @@ -274,11 +254,11 @@ } rootVehicle.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); -+ double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source ++ double verticalDelta = d4; // Paper - Decompile fix: lvt reassignment lost d3 = d - rootVehicle.getX(); d4 = d1 - rootVehicle.getY(); if (d4 > -0.5 || d4 < 0.5) { -@@ -435,18 +_,71 @@ +@@ -448,27 +_,80 @@ d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag2 = false; @@ -288,16 +268,17 @@ LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7)); } - rootVehicle.absMoveTo(d, d1, d2, f, f1); -+ this.player.absMoveTo(d, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + rootVehicle.absSnapTo(d, d1, d2, f, f1); ++ this.player.absSnapTo(d, d1, d2, this.player.getYRot(), this.player.getXRot()); // CraftBukkit boolean flag3 = serverLevel.noCollision(rootVehicle, rootVehicle.getBoundingBox().deflate(0.0625)); if (flag && (flag2 || !flag3)) { - rootVehicle.absMoveTo(x, y, z, f, f1); -+ this.player.absMoveTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit + rootVehicle.absSnapTo(x, y, z, f, f1); ++ this.player.absSnapTo(x, y, z, this.player.getYRot(), this.player.getXRot()); // CraftBukkit this.send(ClientboundMoveVehiclePacket.fromEntity(rootVehicle)); + rootVehicle.removeLatestMovementRecordingBatch(); return; } -+ + + // CraftBukkit start - fire PlayerMoveEvent + org.bukkit.entity.Player player = this.getCraftPlayer(); + if (!this.hasMoved) { @@ -312,7 +293,7 @@ + Location to = CraftLocation.toBukkit(packet.position(), player.getWorld(), packet.yRot(), packet.xRot()); + + // Prevent 40 event-calls for less than a single pixel of movement >.> -+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); ++ double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); + float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); + + if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { @@ -348,10 +329,10 @@ + } + } + // CraftBukkit end - ++ this.player.serverLevel().getChunkSource().move(this.player); - rootVehicle.recordMovementThroughBlocks(new Vec3(x, y, z), rootVehicle.position()); -@@ -455,7 +_,7 @@ + Vec3 vec3 = new Vec3(rootVehicle.getX() - x, rootVehicle.getY() - y, rootVehicle.getZ() - z); + this.handlePlayerKnownMovement(vec3); rootVehicle.setOnGroundWithMovement(packet.onGround(), vec3); rootVehicle.doCheckFallDamage(vec3.x, vec3.y, vec3.z, packet.onGround()); this.player.checkMovementStatistics(vec3.x, vec3.y, vec3.z); @@ -360,7 +341,7 @@ && !flag1 && !this.server.isFlightAllowed() && !rootVehicle.isNoGravity() -@@ -478,12 +_,12 @@ +@@ -491,12 +_,12 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (packet.getId() == this.awaitingTeleport) { if (this.awaitingPositionFromClient == null) { @@ -370,12 +351,12 @@ } this.player -- .absMoveTo( -+ .moveTo( // Paper - Fix Entity Teleportation and cancel velocity if teleported +- .absSnapTo( ++ .snapTo( // Paper - Fix Entity Teleportation and cancel velocity if teleported this.awaitingPositionFromClient.x, this.awaitingPositionFromClient.y, this.awaitingPositionFromClient.z, -@@ -495,12 +_,20 @@ +@@ -508,12 +_,20 @@ this.lastGoodZ = this.awaitingPositionFromClient.z; this.player.hasChangedDimension(); this.awaitingPositionFromClient = null; @@ -396,7 +377,7 @@ this.player.setClientLoaded(true); } -@@ -521,6 +_,7 @@ +@@ -535,6 +_,7 @@ @Override public void handleRecipeBookChangeSettingsPacket(ServerboundRecipeBookChangeSettingsPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -404,7 +385,7 @@ this.player.getRecipeBook().setBookSetting(packet.getBookType(), packet.isOpen(), packet.isFiltering()); } -@@ -536,25 +_,110 @@ +@@ -550,25 +_,110 @@ } } @@ -520,7 +501,7 @@ } ); } -@@ -564,7 +_,7 @@ +@@ -578,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (!this.server.isCommandBlockEnabled()) { this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); @@ -529,7 +510,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock baseCommandBlock = null; -@@ -620,7 +_,7 @@ +@@ -633,7 +_,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (!this.server.isCommandBlockEnabled()) { this.player.sendSystemMessage(Component.translatable("advMode.notEnabled")); @@ -538,7 +519,7 @@ this.player.sendSystemMessage(Component.translatable("advMode.notAllowed")); } else { BaseCommandBlock commandBlock = packet.getCommandBlock(this.player.level()); -@@ -648,7 +_,7 @@ +@@ -661,7 +_,7 @@ boolean flag = this.player.hasInfiniteMaterials() && packet.includeData(); ItemStack cloneItemStack = blockState.getCloneItemStack(serverLevel, blockPos, flag); if (!cloneItemStack.isEmpty()) { @@ -547,7 +528,7 @@ addBlockDataToItem(blockState, serverLevel, blockPos, cloneItemStack); } -@@ -685,18 +_,29 @@ +@@ -698,18 +_,29 @@ if (stack.isItemEnabled(this.player.level().enabledFeatures())) { Inventory inventory = this.player.getInventory(); int i = inventory.findSlotMatchingItem(stack); @@ -563,9 +544,9 @@ + // Paper end - Add PlayerPickItemEvent if (i != -1) { - if (Inventory.isHotbarSlot(i)) { -- inventory.selected = i; +- inventory.setSelectedSlot(i); + if (Inventory.isHotbarSlot(i) && Inventory.isHotbarSlot(event.getTargetSlot())) { // Paper - Add PlayerPickItemEvent -+ inventory.selected = event.getTargetSlot(); // Paper - Add PlayerPickItemEvent ++ inventory.setSelectedSlot(event.getTargetSlot()); // Paper - Add PlayerPickItemEvent } else { - inventory.pickSlot(i); + inventory.pickSlot(i, event.getTargetSlot()); // Paper - Add PlayerPickItemEvent @@ -575,18 +556,18 @@ + inventory.addAndPickItem(stack, event.getTargetSlot()); // Paper - Add PlayerPickItemEvent } - this.player.connection.send(new ClientboundSetHeldSlotPacket(inventory.selected)); + this.player.connection.send(new ClientboundSetHeldSlotPacket(inventory.getSelectedSlot())); this.player.inventoryMenu.broadcastChanges(); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } } -@@ -814,6 +_,13 @@ +@@ -887,6 +_,13 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); int item = packet.getItem(); if (this.player.containerMenu instanceof MerchantMenu merchantMenu) { + // CraftBukkit start -+ final org.bukkit.event.inventory.TradeSelectEvent tradeSelectEvent = CraftEventFactory.callTradeSelectEvent(this.player, item, merchantMenu); ++ final org.bukkit.event.inventory.TradeSelectEvent tradeSelectEvent = CraftEventFactory.callTradeSelectEvent(item, merchantMenu); + if (tradeSelectEvent.isCancelled()) { + this.player.containerMenu.sendAllDataToRemote(); + return; @@ -595,7 +576,7 @@ if (!merchantMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, merchantMenu); return; -@@ -826,6 +_,51 @@ +@@ -899,6 +_,51 @@ @Override public void handleEditBook(ServerboundEditBookPacket packet) { @@ -647,7 +628,7 @@ int slot = packet.slot(); if (Inventory.isHotbarSlot(slot) || slot == 40) { List list = Lists.newArrayList(); -@@ -840,10 +_,14 @@ +@@ -913,10 +_,14 @@ } private void updateBookContents(List pages, int index) { @@ -663,7 +644,7 @@ } } -@@ -857,7 +_,8 @@ +@@ -930,7 +_,8 @@ DataComponents.WRITTEN_BOOK_CONTENT, new WrittenBookContent(this.filterableFromOutgoing(title), this.player.getName().getString(), 0, list, true) ); @@ -673,7 +654,7 @@ } } -@@ -901,24 +_,32 @@ +@@ -974,27 +_,35 @@ public void handleMovePlayer(ServerboundMovePlayerPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (containsInvalidValues(packet.getX(0.0), packet.getY(0.0), packet.getZ(0.0), packet.getYRot(0.0F), packet.getXRot(0.0F))) { @@ -687,289 +668,298 @@ this.resetPosition(); } - if (!this.updateAwaitingTeleport() && this.player.hasClientLoaded()) { -- double d = clampHorizontal(packet.getX(this.player.getX())); -- double d1 = clampVertical(packet.getY(this.player.getY())); -- double d2 = clampHorizontal(packet.getZ(this.player.getZ())); + if (this.player.hasClientLoaded()) { - float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); - float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); -+ double d = clampHorizontal(packet.getX(this.player.getX())); final double toX = d; // Paper - OBFHELPER -+ double d1 = clampVertical(packet.getY(this.player.getY())); final double toY = d1; // Paper - OBFHELPER -+ double d2 = clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER + float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER + float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); final float toPitch = f1; // Paper - OBFHELPER - if (this.player.isPassenger()) { - this.player.absMoveTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); - this.player.serverLevel().getChunkSource().move(this.player); -+ this.allowedPlayerTicks = 20; // CraftBukkit + if (this.updateAwaitingTeleport()) { + this.player.absSnapRotationTo(f, f1); } else { -+ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify -+ double prevX = this.player.getX(); -+ double prevY = this.player.getY(); -+ double prevZ = this.player.getZ(); -+ float prevYaw = this.player.getYRot(); -+ float prevPitch = this.player.getXRot(); -+ // CraftBukkit end - double x = this.player.getX(); - double y = this.player.getY(); - double z = this.player.getZ(); -@@ -927,6 +_,16 @@ - double d5 = d2 - this.firstGoodZ; - double d6 = this.player.getDeltaMovement().lengthSqr(); - double d7 = d3 * d3 + d4 * d4 + d5 * d5; -+ // Paper start - fix large move vectors killing the server -+ double currDeltaX = toX - prevX; -+ double currDeltaY = toY - prevY; -+ double currDeltaZ = toZ - prevZ; -+ d7 = Math.max(d7, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); -+ double otherFieldX = d - this.lastGoodX; -+ double otherFieldY = d1 - this.lastGoodY; -+ double otherFieldZ = d2 - this.lastGoodZ; -+ d7 = Math.max(d7, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1); -+ // Paper end - fix large move vectors killing the server - if (this.player.isSleeping()) { - if (d7 > 1.0) { - this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); -@@ -936,32 +_,105 @@ - if (serverLevel.tickRateManager().runsNormally()) { - this.receivedMovePacketCount++; - int i = this.receivedMovePacketCount - this.knownMovePacketCount; -- if (i > 5) { +- double d = clampHorizontal(packet.getX(this.player.getX())); +- double d1 = clampVertical(packet.getY(this.player.getY())); +- double d2 = clampHorizontal(packet.getZ(this.player.getZ())); ++ double d = clampHorizontal(packet.getX(this.player.getX())); final double toX = d; // Paper - OBFHELPER ++ double d1 = clampVertical(packet.getY(this.player.getY())); final double toY = d1; // Paper - OBFHELPER ++ double d2 = clampHorizontal(packet.getZ(this.player.getZ())); final double toZ = d2; // Paper - OBFHELPER + if (this.player.isPassenger()) { + this.player.absSnapTo(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); + this.player.serverLevel().getChunkSource().move(this.player); ++ this.allowedPlayerTicks = 20; // CraftBukkit + } else { ++ // CraftBukkit - Make sure the move is valid but then reset it for plugins to modify ++ double prevX = this.player.getX(); ++ double prevY = this.player.getY(); ++ double prevZ = this.player.getZ(); ++ float prevYaw = this.player.getYRot(); ++ float prevPitch = this.player.getXRot(); ++ // CraftBukkit end + double x = this.player.getX(); + double y = this.player.getY(); + double z = this.player.getZ(); +@@ -1003,6 +_,16 @@ + double d5 = d2 - this.firstGoodZ; + double d6 = this.player.getDeltaMovement().lengthSqr(); + double d7 = d3 * d3 + d4 * d4 + d5 * d5; ++ // Paper start - fix large move vectors killing the server ++ double currDeltaX = toX - prevX; ++ double currDeltaY = toY - prevY; ++ double currDeltaZ = toZ - prevZ; ++ d7 = Math.max(d7, (currDeltaX * currDeltaX + currDeltaY * currDeltaY + currDeltaZ * currDeltaZ) - 1); ++ double otherFieldX = d - this.lastGoodX; ++ double otherFieldY = d1 - this.lastGoodY; ++ double otherFieldZ = d2 - this.lastGoodZ; ++ d7 = Math.max(d7, (otherFieldX * otherFieldX + otherFieldY * otherFieldY + otherFieldZ * otherFieldZ) - 1); ++ // Paper end - fix large move vectors killing the server + if (this.player.isSleeping()) { + if (d7 > 1.0) { + this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), f, f1); +@@ -1012,36 +_,109 @@ + if (serverLevel.tickRateManager().runsNormally()) { + this.receivedMovePacketCount++; + int i = this.receivedMovePacketCount - this.knownMovePacketCount; +- if (i > 5) { ++ // CraftBukkit start - handle custom speeds and skipped ticks ++ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; ++ this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); ++ this.lastTick = (int) (System.currentTimeMillis() / 50); + -+ // CraftBukkit start - handle custom speeds and skipped ticks -+ this.allowedPlayerTicks += (System.currentTimeMillis() / 50) - this.lastTick; -+ this.allowedPlayerTicks = Math.max(this.allowedPlayerTicks, 1); -+ this.lastTick = (int) (System.currentTimeMillis() / 50); -+ -+ if (i > Math.max(this.allowedPlayerTicks, 5)) { - LOGGER.debug("{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i); - i = 1; - } - -+ if (packet.hasRot || d7 > 0) { -+ this.allowedPlayerTicks -= 1; -+ } else { -+ this.allowedPlayerTicks = 20; -+ } -+ double speed; -+ if (this.player.getAbilities().flying) { -+ speed = this.player.getAbilities().flyingSpeed * 20f; -+ } else { -+ speed = this.player.getAbilities().walkingSpeed * 10f; -+ } -+ // Paper start - Prevent moving into unloaded chunks -+ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !serverLevel.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) { -+ // Paper start - Add fail move event -+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_INTO_UNLOADED_CHUNK, -+ toX, toY, toZ, toYaw, toPitch, false); -+ if (!event.isAllowed()) { -+ this.internalTeleport(PositionMoveRotation.of(this.player), Collections.emptySet()); -+ return; ++ if (i > Math.max(this.allowedPlayerTicks, 5)) { ++ // CraftBukkit end + LOGGER.debug( + "{} is sending move packets too frequently ({} packets since last tick)", this.player.getName().getString(), i + ); + i = 1; + } ++ // CraftBukkit start - handle custom speeds and skipped ticks ++ if (packet.hasRot || d7 > 0) { ++ this.allowedPlayerTicks -= 1; ++ } else { ++ this.allowedPlayerTicks = 20; + } -+ // Paper end - Add fail move event -+ } -+ // Paper end - Prevent moving into unloaded chunks -+ - if (this.shouldCheckPlayerMovement(isFallFlying)) { - float f2 = isFallFlying ? 300.0F : 100.0F; -- if (d7 - d6 > f2 * i) { -- LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5); -- this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); -- return; -+ if (d7 - d6 > Math.max(f2, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed))) { -+ // CraftBukkit end ++ double speed; ++ if (this.player.getAbilities().flying) { ++ speed = this.player.getAbilities().flyingSpeed * 20f; ++ } else { ++ speed = this.player.getAbilities().walkingSpeed * 10f; ++ } ++ // Paper start - Prevent moving into unloaded chunks ++ if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (this.player.getX() != toX || this.player.getZ() != toZ) && !serverLevel.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position())))) { + // Paper start - Add fail move event -+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, -+ toX, toY, toZ, toYaw, toPitch, true); ++ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_INTO_UNLOADED_CHUNK, ++ toX, toY, toZ, toYaw, toPitch, false); + if (!event.isAllowed()) { -+ if (event.getLogWarning()) { -+ LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5); -+ } -+ this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot()); ++ this.internalTeleport(PositionMoveRotation.of(this.player), Collections.emptySet()); + return; + } + // Paper end - Add fail move event ++ } ++ // Paper end - Prevent moving into unloaded chunks + + if (this.shouldCheckPlayerMovement(isFallFlying)) { + float f2 = isFallFlying ? 300.0F : 100.0F; +- if (d7 - d6 > f2 * i) { +- LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5); +- this.teleport( +- this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot() +- ); +- return; ++ if (d7 - d6 > Math.max(f2, Mth.square(org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed))) { ++ // CraftBukkit end ++ // Paper start - Add fail move event ++ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, ++ toX, toY, toZ, toYaw, toPitch, true); ++ if (!event.isAllowed()) { ++ if (event.getLogWarning()) { ++ LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5); ++ } ++ this.teleport( ++ this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot() ++ ); ++ return; ++ } ++ // Paper end - Add fail move event + } } } - } - AABB boundingBox = this.player.getBoundingBox(); -- d3 = d - this.lastGoodX; -- d4 = d1 - this.lastGoodY; -- d5 = d2 - this.lastGoodZ; -+ d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above -+ d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above -+ d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above - boolean flag = d4 > 0.0; - if (this.player.onGround() && !packet.isOnGround() && flag) { -- this.player.jumpFromGround(); -+ // Paper start - Add PlayerJumpEvent -+ org.bukkit.entity.Player player = this.getCraftPlayer(); -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + AABB boundingBox = this.player.getBoundingBox(); +- d3 = d - this.lastGoodX; +- d4 = d1 - this.lastGoodY; +- d5 = d2 - this.lastGoodZ; ++ d3 = d - this.lastGoodX; // Paper - diff on change, used for checking large move vectors above ++ d4 = d1 - this.lastGoodY; // Paper - diff on change, used for checking large move vectors above ++ d5 = d2 - this.lastGoodZ; // Paper - diff on change, used for checking large move vectors above + boolean flag = d4 > 0.0; + if (this.player.onGround() && !packet.isOnGround() && flag) { +- this.player.jumpFromGround(); ++ // Paper start - Add PlayerJumpEvent ++ org.bukkit.entity.Player player = this.getCraftPlayer(); ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. ++ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. + -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPos) { -+ to.setX(packet.x); -+ to.setY(packet.y); -+ to.setZ(packet.z); -+ } ++ // If the packet contains movement information then we update the To location with the correct XYZ. ++ if (packet.hasPos) { ++ to.setX(packet.x); ++ to.setY(packet.y); ++ to.setZ(packet.z); ++ } + -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRot) { -+ to.setYaw(packet.yRot); -+ to.setPitch(packet.xRot); -+ } ++ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. ++ if (packet.hasRot) { ++ to.setYaw(packet.yRot); ++ to.setPitch(packet.xRot); ++ } + -+ com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to); ++ com.destroystokyo.paper.event.player.PlayerJumpEvent event = new com.destroystokyo.paper.event.player.PlayerJumpEvent(player, from, to); + -+ if (event.callEvent()) { -+ this.player.jumpFromGround(); -+ } else { -+ from = event.getFrom(); -+ this.internalTeleport(new PositionMoveRotation(org.bukkit.craftbukkit.util.CraftLocation.toVec3D(from), Vec3.ZERO, from.getYaw(), from.getPitch()), Collections.emptySet()); -+ return; -+ } -+ // Paper end - Add PlayerJumpEvent - } ++ if (event.callEvent()) { ++ this.player.jumpFromGround(); ++ } else { ++ from = event.getFrom(); ++ this.internalTeleport(new PositionMoveRotation(org.bukkit.craftbukkit.util.CraftLocation.toVec3(from), Vec3.ZERO, from.getYaw(), from.getPitch()), Collections.emptySet()); ++ return; ++ } ++ // Paper end - Add PlayerJumpEvent + } - boolean flag1 = this.player.verticalCollisionBelow; - this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); -+ this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move -+ // Paper start - prevent position desync -+ if (this.awaitingPositionFromClient != null) { -+ return; // ... thanks Mojang for letting move calls teleport across dimensions. -+ } -+ // Paper end - prevent position desync -+ double verticalDelta = d4; // Paper - Decompile fix, was named d11 previously, is now gone in the source - d3 = d - this.player.getX(); - d4 = d1 - this.player.getY(); - if (d4 > -0.5 || d4 < 0.5) { -@@ -970,23 +_,104 @@ + boolean flag1 = this.player.verticalCollisionBelow; + this.player.move(MoverType.PLAYER, new Vec3(d3, d4, d5)); ++ this.player.onGround = packet.isOnGround(); // CraftBukkit - SPIGOT-5810, SPIGOT-5835, SPIGOT-6828: reset by this.player.move ++ // Paper start - prevent position desync ++ if (this.awaitingPositionFromClient != null) { ++ return; // ... thanks Mojang for letting move calls teleport across dimensions. ++ } ++ // Paper end - prevent position desync ++ double verticalDelta = d4; // Paper - Decompile fix: lvt reassignment lost + d3 = d - this.player.getX(); + d4 = d1 - this.player.getY(); + if (d4 > -0.5 || d4 < 0.5) { +@@ -1050,23 +_,104 @@ - d5 = d2 - this.player.getZ(); - d7 = d3 * d3 + d4 * d4 + d5 * d5; -- boolean flag2 = false; -+ boolean movedWrongly = false; // Paper - Add fail move event; rename - if (!this.player.isChangingDimension() -- && d7 > 0.0625 -+ && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot - && !this.player.isSleeping() - && !this.player.gameMode.isCreative() - && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR) { -- flag2 = true; -+ // Paper start - Add fail move event -+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, -+ toX, toY, toZ, toYaw, toPitch, true); -+ if (!event.isAllowed()) { -+ movedWrongly = true; -+ if (event.getLogWarning()) -+ // Paper end - LOGGER.warn("{} moved wrongly!", this.player.getName().getString()); -- } + d5 = d2 - this.player.getZ(); + d7 = d3 * d3 + d4 * d4 + d5 * d5; +- boolean flag2 = false; ++ boolean movedWrongly = false; // Paper - Add fail move event; rename + if (!this.player.isChangingDimension() +- && d7 > 0.0625 ++ && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold // Spigot + && !this.player.isSleeping() + && !this.player.isCreative() + && !this.player.isSpectator()) { +- flag2 = true; ++ // Paper start - Add fail move event ++ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, ++ toX, toY, toZ, toYaw, toPitch, true); ++ if (!event.isAllowed()) { ++ movedWrongly = true; ++ if (event.getLogWarning()) ++ // Paper end + LOGGER.warn("{} moved wrongly!", this.player.getName().getString()); +- } - -- if (this.player.noPhysics -- || this.player.isSleeping() -- || (!flag2 || !serverLevel.noCollision(this.player, boundingBox)) -- && !this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)) { -+ } // Paper -+ } -+ -+ // Paper start - Add fail move event -+ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && serverLevel.noCollision(this.player, boundingBox) || this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)); -+ if (teleportBack) { -+ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, -+ toX, toY, toZ, toYaw, toPitch, false); -+ if (event.isAllowed()) { -+ teleportBack = false; -+ } -+ } -+ if (!teleportBack) { -+ // Paper end - Add fail move event -+ // CraftBukkit start - fire PlayerMoveEvent -+ // Reset to old location first -+ this.player.absMoveTo(prevX, prevY, prevZ, prevYaw, prevPitch); -+ -+ org.bukkit.entity.Player player = this.getCraftPlayer(); -+ if (!this.hasMoved) { -+ this.lastPosX = prevX; -+ this.lastPosY = prevY; -+ this.lastPosZ = prevZ; -+ this.lastYaw = prevYaw; -+ this.lastPitch = prevPitch; -+ this.hasMoved = true; +- if (this.player.noPhysics +- || this.player.isSleeping() +- || (!flag2 || !serverLevel.noCollision(this.player, boundingBox)) +- && !this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)) { ++ } // Paper + } + -+ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. -+ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. -+ -+ // If the packet contains movement information then we update the To location with the correct XYZ. -+ if (packet.hasPos) { -+ to.setX(packet.x); -+ to.setY(packet.y); -+ to.setZ(packet.z); -+ } -+ -+ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. -+ if (packet.hasRot) { -+ to.setYaw(packet.yRot); -+ to.setPitch(packet.xRot); -+ } -+ -+ // Prevent 40 event-calls for less than a single pixel of movement >.> -+ double delta = Math.pow(this.lastPosX - to.getX(), 2) + Math.pow(this.lastPosY - to.getY(), 2) + Math.pow(this.lastPosZ - to.getZ(), 2); -+ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); -+ -+ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { -+ this.lastPosX = to.getX(); -+ this.lastPosY = to.getY(); -+ this.lastPosZ = to.getZ(); -+ this.lastYaw = to.getYaw(); -+ this.lastPitch = to.getPitch(); -+ -+ Location oldTo = to.clone(); -+ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); -+ this.cserver.getPluginManager().callEvent(event); -+ -+ // If the event is cancelled we move the player back to their old location. -+ if (event.isCancelled()) { -+ this.teleport(from); -+ return; -+ } -+ -+ // If a Plugin has changed the To destination then we teleport the Player -+ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. -+ // We only do this if the Event was not cancelled. -+ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { -+ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); -+ return; -+ } -+ -+ // Check to see if the Players Location has some how changed during the call of the event. -+ // This can happen due to a plugin teleporting the player instead of using .setTo() -+ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { -+ this.justTeleported = false; -+ return; ++ // Paper start - Add fail move event ++ boolean teleportBack = !this.player.noPhysics && !this.player.isSleeping() && (movedWrongly && serverLevel.noCollision(this.player, boundingBox) || this.isPlayerCollidingWithAnythingNew(serverLevel, boundingBox, d, d1, d2)); ++ if (teleportBack) { ++ io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, ++ toX, toY, toZ, toYaw, toPitch, false); ++ if (event.isAllowed()) { ++ teleportBack = false; + } + } -+ // CraftBukkit end - this.player.absMoveTo(d, d1, d2, f, f1); - boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); -- this.clientIsFloating = d4 >= -0.03125 -+ this.clientIsFloating = verticalDelta >= -0.03125 // Paper - Decompile fix - && !flag1 - && this.player.gameMode.getGameModeForPlayer() != GameType.SPECTATOR - && !this.server.isFlightAllowed() -@@ -1019,7 +_,7 @@ - this.lastGoodY = this.player.getY(); - this.lastGoodZ = this.player.getZ(); - } else { -- this.teleport(x, y, z, f, f1); -+ this.internalTeleport(x, y, z, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. - this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); - } - } -@@ -1053,6 +_,7 @@ ++ if (!teleportBack) { ++ // Paper end - Add fail move event ++ // CraftBukkit start - fire PlayerMoveEvent ++ // Reset to old location first ++ this.player.absSnapTo(prevX, prevY, prevZ, prevYaw, prevPitch); ++ ++ org.bukkit.entity.Player player = this.getCraftPlayer(); ++ if (!this.hasMoved) { ++ this.lastPosX = prevX; ++ this.lastPosY = prevY; ++ this.lastPosZ = prevZ; ++ this.lastYaw = prevYaw; ++ this.lastPitch = prevPitch; ++ this.hasMoved = true; ++ } ++ ++ Location from = new Location(player.getWorld(), this.lastPosX, this.lastPosY, this.lastPosZ, this.lastYaw, this.lastPitch); // Get the Players previous Event location. ++ Location to = player.getLocation().clone(); // Start off the To location as the Players current location. ++ ++ // If the packet contains movement information then we update the To location with the correct XYZ. ++ if (packet.hasPos) { ++ to.setX(packet.x); ++ to.setY(packet.y); ++ to.setZ(packet.z); ++ } ++ ++ // If the packet contains look information then we update the To location with the correct Yaw & Pitch. ++ if (packet.hasRot) { ++ to.setYaw(packet.yRot); ++ to.setPitch(packet.xRot); ++ } ++ ++ // Prevent 40 event-calls for less than a single pixel of movement >.> ++ double delta = Mth.square(this.lastPosX - to.getX()) + Mth.square(this.lastPosY - to.getY()) + Mth.square(this.lastPosZ - to.getZ()); ++ float deltaAngle = Math.abs(this.lastYaw - to.getYaw()) + Math.abs(this.lastPitch - to.getPitch()); ++ ++ if ((delta > 1f / 256 || deltaAngle > 10f) && !this.player.isImmobile()) { ++ this.lastPosX = to.getX(); ++ this.lastPosY = to.getY(); ++ this.lastPosZ = to.getZ(); ++ this.lastYaw = to.getYaw(); ++ this.lastPitch = to.getPitch(); ++ ++ Location oldTo = to.clone(); ++ PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); ++ this.cserver.getPluginManager().callEvent(event); ++ ++ // If the event is cancelled we move the player back to their old location. ++ if (event.isCancelled()) { ++ this.teleport(from); ++ return; ++ } ++ ++ // If a Plugin has changed the To destination then we teleport the Player ++ // there to avoid any 'Moved wrongly' or 'Moved too quickly' errors. ++ // We only do this if the Event was not cancelled. ++ if (!oldTo.equals(event.getTo()) && !event.isCancelled()) { ++ this.player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.PLUGIN); ++ return; ++ } ++ ++ // Check to see if the Players Location has some how changed during the call of the event. ++ // This can happen due to a plugin teleporting the player instead of using .setTo() ++ if (!from.equals(this.getCraftPlayer().getLocation()) && this.justTeleported) { ++ this.justTeleported = false; ++ return; ++ } ++ } ++ // CraftBukkit end + this.player.absSnapTo(d, d1, d2, f, f1); + boolean isAutoSpinAttack = this.player.isAutoSpinAttack(); +- this.clientIsFloating = d4 >= -0.03125 ++ this.clientIsFloating = verticalDelta >= -0.03125 // Paper - Decompile fix + && !flag1 + && !this.player.isSpectator() + && !this.server.isFlightAllowed() +@@ -1098,7 +_,7 @@ + this.lastGoodY = this.player.getY(); + this.lastGoodZ = this.player.getZ(); + } else { +- this.teleport(x, y, z, f, f1); ++ this.internalTeleport(x, y, z, f, f1); // CraftBukkit - SPIGOT-1807: Don't call teleport event, when the client thinks the player is falling, because the chunks are not loaded on the client yet. + this.player.doCheckFallDamage(this.player.getX() - x, this.player.getY() - y, this.player.getZ() - z, packet.isOnGround()); + this.player.removeLatestMovementRecordingBatch(); + } +@@ -1134,6 +_,7 @@ this.player.getXRot() ); } @@ -977,7 +967,7 @@ return true; } else { -@@ -1076,10 +_,77 @@ +@@ -1157,10 +_,77 @@ } public void teleport(double x, double y, double z, float yaw, float pitch) { @@ -1020,7 +1010,7 @@ + if (event.isCancelled() || !to.equals(event.getTo())) { + // set = Collections.emptySet(); // Can't relative teleport // Paper - Teleport API; Now you can! + to = event.isCancelled() ? event.getFrom() : event.getTo(); -+ posMoveRotation = new PositionMoveRotation(CraftLocation.toVec3D(to), Vec3.ZERO, to.getYaw(), to.getPitch()); ++ posMoveRotation = new PositionMoveRotation(CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch()); + } + + this.internalTeleport(posMoveRotation, relatives); @@ -1056,7 +1046,7 @@ this.awaitingTeleportTime = this.tickCount; if (++this.awaitingTeleport == Integer.MAX_VALUE) { this.awaitingTeleport = 0; -@@ -1087,12 +_,20 @@ +@@ -1168,12 +_,20 @@ this.player.teleportSetPosition(posMoveRotation, relatives); this.awaitingPositionFromClient = this.player.position(); @@ -1077,7 +1067,7 @@ if (this.player.hasClientLoaded()) { BlockPos pos = packet.getPos(); this.player.resetLastActionTime(); -@@ -1101,32 +_,95 @@ +@@ -1182,32 +_,95 @@ case SWAP_ITEM_WITH_OFFHAND: if (!this.player.isSpectator()) { ItemStack itemInHand = this.player.getItemInHand(InteractionHand.OFF_HAND); @@ -1103,7 +1093,7 @@ + } + // CraftBukkit end this.player.stopUsingItem(); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } return; @@ -1125,21 +1115,21 @@ + } + // CraftBukkit end this.player.drop(false); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } return; case DROP_ALL_ITEMS: if (!this.player.isSpectator()) { this.player.drop(true); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } return; case RELEASE_USE_ITEM: - this.player.releaseUsingItem(); + if (this.player.getUseItem() == this.player.getItemInHand(this.player.getUsedItemHand())) this.player.releaseUsingItem(); // Paper - validate use item before processing release -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. return; case START_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK: @@ -1172,11 +1162,11 @@ + } + } + // Paper end - Send block entities after destroy prediction -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. return; default: throw new IllegalArgumentException("Invalid player action"); -@@ -1143,9 +_,31 @@ +@@ -1224,9 +_,31 @@ } } @@ -1208,7 +1198,7 @@ if (this.player.hasClientLoaded()) { this.player.connection.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.serverLevel(); -@@ -1154,6 +_,11 @@ +@@ -1235,6 +_,11 @@ if (itemInHand.isItemEnabled(serverLevel.enabledFeatures())) { BlockHitResult hitResult = packet.getHitResult(); Vec3 location = hitResult.getLocation(); @@ -1220,7 +1210,7 @@ BlockPos blockPos = hitResult.getBlockPos(); if (this.player.canInteractWithBlock(blockPos, 1.0)) { Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); -@@ -1163,7 +_,8 @@ +@@ -1244,7 +_,8 @@ this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); if (blockPos.getY() <= maxY) { @@ -1230,7 +1220,7 @@ InteractionResult interactionResult = this.player.gameMode.useItemOn(this.player, serverLevel, itemInHand, hand, hitResult); if (interactionResult.consumesAction()) { CriteriaTriggers.ANY_BLOCK_USE.trigger(this.player, hitResult.getBlockPos(), itemInHand.copy()); -@@ -1176,10 +_,10 @@ +@@ -1257,10 +_,10 @@ Component component = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component, true); } else if (interactionResult instanceof InteractionResult.Success success @@ -1243,15 +1233,15 @@ } else { Component component1 = Component.translatable("build.tooHigh", maxY).withStyle(ChatFormatting.RED); this.player.sendSystemMessage(component1, true); -@@ -1187,6 +_,7 @@ +@@ -1268,6 +_,7 @@ this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos)); this.player.connection.send(new ClientboundBlockUpdatePacket(serverLevel, blockPos.relative(direction))); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } else { LOGGER.warn( "Rejecting UseItemOnPacket from {}: Location {} too far away from hit block {}.", -@@ -1203,6 +_,8 @@ +@@ -1284,6 +_,8 @@ @Override public void handleUseItem(ServerboundUseItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -1260,8 +1250,8 @@ if (this.player.hasClientLoaded()) { this.ackBlockChangesUpTo(packet.getSequence()); ServerLevel serverLevel = this.player.serverLevel(); -@@ -1216,6 +_,48 @@ - this.player.absRotateTo(f, f1); +@@ -1297,6 +_,48 @@ + this.player.absSnapRotationTo(f, f1); } + // CraftBukkit start @@ -1279,7 +1269,7 @@ + float f8 = f3 * f5; + double d3 = this.player.blockInteractionRange(); + Vec3 to = from.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3); -+ BlockHitResult hitResult = this.player.level().clip(new ClipContext(from, to, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.player)); ++ BlockHitResult hitResult = this.player.level().clip(new net.minecraft.world.level.ClipContext(from, to, net.minecraft.world.level.ClipContext.Block.OUTLINE, net.minecraft.world.level.ClipContext.Fluid.NONE, this.player)); + + boolean cancelled; + if (hitResult == null || hitResult.getType() != HitResult.Type.BLOCK) { @@ -1309,7 +1299,7 @@ if (this.player.gameMode.useItem(this.player, serverLevel, itemInHand, hand) instanceof InteractionResult.Success success && success.swingSource() == InteractionResult.SwingSource.SERVER) { this.player.swing(hand, true); -@@ -1231,7 +_,7 @@ +@@ -1312,7 +_,7 @@ for (ServerLevel serverLevel : this.server.getAllLevels()) { Entity entity = packet.getEntity(serverLevel); if (entity != null) { @@ -1318,7 +1308,7 @@ return; } } -@@ -1248,24 +_,54 @@ +@@ -1329,24 +_,54 @@ @Override public void onDisconnect(DisconnectionDetails details) { @@ -1376,28 +1366,28 @@ throw new IllegalArgumentException("Expected packet sequence nr >= 0"); } else { this.ackBlockChangesUpTo = Math.max(sequence, this.ackBlockChangesUpTo); -@@ -1275,20 +_,38 @@ +@@ -1356,20 +_,38 @@ @Override public void handleSetCarriedItem(ServerboundSetCarriedItemPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit if (packet.getSlot() >= 0 && packet.getSlot() < Inventory.getSelectionSize()) { -+ if (packet.getSlot() == this.player.getInventory().selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change -+ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().selected, packet.getSlot()); ++ if (packet.getSlot() == this.player.getInventory().getSelectedSlot()) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change ++ PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getCraftPlayer(), this.player.getInventory().getSelectedSlot(), packet.getSlot()); + this.cserver.getPluginManager().callEvent(event); + if (event.isCancelled()) { -+ this.send(new ClientboundSetHeldSlotPacket(this.player.getInventory().selected)); ++ this.send(new ClientboundSetHeldSlotPacket(this.player.getInventory().getSelectedSlot())); + this.player.resetLastActionTime(); + return; + } + // CraftBukkit end - if (this.player.getInventory().selected != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) { + if (this.player.getInventory().getSelectedSlot() != packet.getSlot() && this.player.getUsedItemHand() == InteractionHand.MAIN_HAND) { this.player.stopUsingItem(); } - this.player.getInventory().selected = packet.getSlot(); + this.player.getInventory().setSelectedSlot(packet.getSlot()); this.player.resetLastActionTime(); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } else { LOGGER.warn("{} tried to set an invalid carried item", this.player.getName().getString()); + this.disconnect(Component.literal("Invalid hotbar selection (Hacking?)"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // CraftBukkit // Paper - kick event cause @@ -1415,7 +1405,7 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.message(), () -> { -@@ -1300,25 +_,45 @@ +@@ -1381,25 +_,45 @@ return; } @@ -1423,10 +1413,10 @@ - Component component = this.server.getChatDecorator().decorate(this.player, signedMessage.decoratedContent()); - this.chatMessageChain.append(completableFuture, filteredText -> { - PlayerChatMessage playerChatMessage = signedMessage.withUnsignedContent(component).filter(filteredText.mask()); -+ CompletableFuture completableFuture = this.filterTextPacket(signedMessage.signedContent()).thenApplyAsync(Function.identity(), this.server.chatExecutor); // CraftBukkit - async chat ++ CompletableFuture completableFuture = this.filterTextPacket(signedMessage.signedContent()).thenApplyAsync(java.util.function.Function.identity(), this.server.chatExecutor); // CraftBukkit - async chat + CompletableFuture componentFuture = this.server.getChatDecorator().decorate(this.player, null, signedMessage.decoratedContent()); // Paper - Adventure + -+ this.chatMessageChain.append(CompletableFuture.allOf(completableFuture, componentFuture), (filteredtext) -> { // Paper - Adventure ++ this.chatMessageChain.append(CompletableFuture.allOf(completableFuture, componentFuture), ($) -> { // Paper - Adventure + PlayerChatMessage playerChatMessage = signedMessage.withUnsignedContent(componentFuture.join()).filter(completableFuture.join().mask()); // Paper - Adventure this.broadcastChatMessage(playerChatMessage); }); @@ -1457,7 +1447,7 @@ + LOGGER.info("{} issued server command: {}", this.player.getScoreboardName(), prefixedCommand); + } + -+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), prefixedCommand, new LazyPlayerSet(this.server)); ++ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), prefixedCommand, new org.bukkit.craftbukkit.util.LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); + + if (event.isCancelled()) { @@ -1468,7 +1458,7 @@ ParseResults parseResults = this.parseCommand(command); if (this.server.enforceSecureProfile() && SignableCommand.hasSignableArguments(parseResults)) { LOGGER.error( -@@ -1335,26 +_,55 @@ +@@ -1416,28 +_,57 @@ Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { this.tryHandleChat(packet.command(), () -> { @@ -1492,7 +1482,7 @@ + LOGGER.info("{} issued server command: {}", this.player.getScoreboardName(), command); + } // Paper - Add missing SpigotConfig logCommands check + -+ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server)); ++ PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new org.bukkit.craftbukkit.util.LazyPlayerSet(this.server)); + this.cserver.getPluginManager().callEvent(event); + command = event.getMessage().substring(1); + @@ -1521,13 +1511,15 @@ + // Paper end - Fix cancellation and message changing + CommandSigningContext commandSigningContext = new CommandSigningContext.SignedArguments(map); - parseResults = Commands.mapSource(parseResults, source -> source.withSigningContext(commandSigningContext, this.chatMessageChain)); + parseResults = Commands.mapSource( + parseResults, commandSourceStack -> commandSourceStack.withSigningContext(commandSigningContext, this.chatMessageChain) + ); - this.server.getCommands().performCommand(parseResults, packet.command()); + this.server.getCommands().performCommand(parseResults, command); // CraftBukkit } private void handleMessageDecodeFailure(SignedMessageChain.DecodeException exception) { -@@ -1418,14 +_,20 @@ +@@ -1501,14 +_,20 @@ return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -1552,118 +1544,42 @@ } } -@@ -1434,7 +_,7 @@ - Optional optional = this.lastSeenMessages.applyUpdate(update); - if (optional.isEmpty()) { - LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); +@@ -1520,7 +_,7 @@ + var10000 = Optional.of(lastSeenMessages); + } catch (LastSeenMessagesValidator.ValidationException var5) { + LOGGER.error("Failed to validate message acknowledgements from {}: {}", this.player.getName().getString(), var5.getMessage()); - this.disconnect(CHAT_VALIDATION_FAILED); + this.disconnectAsync(CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes & add proper async disconnect + return Optional.empty(); } - return optional; -@@ -1451,22 +_,157 @@ +@@ -1538,22 +_,81 @@ return false; } -+ // CraftBukkit start - add method ++ // CraftBukkit start + public void chat(String msg, PlayerChatMessage original, boolean async) { + if (msg.isEmpty() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { + return; + } -+ OutgoingChatMessage outgoing = OutgoingChatMessage.create(original); + -+ if (false && !async && msg.startsWith("/")) { // Paper - Don't handle commands in chat logic -+ this.handleCommand(msg); -+ } else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { ++ if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) { + // Do nothing, this is coming from a plugin + // Paper start -+ } else if (true) { ++ } else { + if (!async && !org.bukkit.Bukkit.isPrimaryThread()) { + org.spigotmc.AsyncCatcher.catchOp("Asynchronous player chat is not allowed here"); + } -+ final ChatProcessor cp = new ChatProcessor(this.server, this.player, original, async); -+ cp.process(); ++ new io.papermc.paper.adventure.ChatProcessor(this.server, this.player, original, async).process(); + // Paper end -+ } else if (false) { // Paper -+ org.bukkit.entity.Player player = this.getCraftPlayer(); -+ AsyncPlayerChatEvent event = new AsyncPlayerChatEvent(async, player, msg, new LazyPlayerSet(this.server)); -+ String originalFormat = event.getFormat(), originalMessage = event.getMessage(); -+ this.cserver.getPluginManager().callEvent(event); -+ -+ if (PlayerChatEvent.getHandlerList().getRegisteredListeners().length != 0) { -+ // Evil plugins still listening to deprecated event -+ final PlayerChatEvent queueEvent = new PlayerChatEvent(player, event.getMessage(), event.getFormat(), event.getRecipients()); -+ queueEvent.setCancelled(event.isCancelled()); -+ Waitable waitable = new Waitable<>() { -+ @Override -+ protected Object evaluate() { -+ org.bukkit.Bukkit.getPluginManager().callEvent(queueEvent); -+ -+ if (queueEvent.isCancelled()) { -+ return null; -+ } -+ -+ String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); -+ if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { -+ if (!org.spigotmc.SpigotConfig.bungee && originalFormat.equals(queueEvent.getFormat()) && originalMessage.equals(queueEvent.getMessage()) && queueEvent.getPlayer().getName().equalsIgnoreCase(queueEvent.getPlayer().getDisplayName())) { // Spigot -+ ServerGamePacketListenerImpl.this.server.getPlayerList().broadcastChatMessage(original, ServerGamePacketListenerImpl.this.player, ChatType.bind(ChatType.CHAT, (Entity) ServerGamePacketListenerImpl.this.player)); -+ return null; -+ } -+ -+ for (ServerPlayer recipient : ServerGamePacketListenerImpl.this.server.getPlayerList().players) { -+ recipient.getBukkitEntity().sendMessage(ServerGamePacketListenerImpl.this.player.getUUID(), message); -+ } -+ } else { -+ for (org.bukkit.entity.Player recipient : queueEvent.getRecipients()) { -+ recipient.sendMessage(ServerGamePacketListenerImpl.this.player.getUUID(), message); -+ } -+ } -+ ServerGamePacketListenerImpl.this.server.console.sendMessage(message); -+ -+ return null; -+ }}; -+ if (async) { -+ this.server.processQueue.add(waitable); -+ } else { -+ waitable.run(); -+ } -+ try { -+ waitable.get(); -+ } catch (InterruptedException e) { -+ Thread.currentThread().interrupt(); // This is proper habit for java. If we aren't handling it, pass it on! -+ } catch (ExecutionException e) { -+ throw new RuntimeException("Exception processing chat event", e.getCause()); -+ } -+ } else { -+ if (event.isCancelled()) { -+ return; -+ } -+ -+ msg = String.format(event.getFormat(), event.getPlayer().getDisplayName(), event.getMessage()); -+ if (((LazyPlayerSet) event.getRecipients()).isLazy()) { -+ if (!org.spigotmc.SpigotConfig.bungee && originalFormat.equals(event.getFormat()) && originalMessage.equals(event.getMessage()) && event.getPlayer().getName().equalsIgnoreCase(event.getPlayer().getDisplayName())) { // Spigot -+ ServerGamePacketListenerImpl.this.server.getPlayerList().broadcastChatMessage(original, ServerGamePacketListenerImpl.this.player, ChatType.bind(ChatType.CHAT, ServerGamePacketListenerImpl.this.player)); -+ return; -+ } -+ -+ for (ServerPlayer recipient : this.server.getPlayerList().players) { -+ recipient.getBukkitEntity().sendMessage(ServerGamePacketListenerImpl.this.player.getUUID(), msg); -+ } -+ } else { -+ for (org.bukkit.entity.Player recipient : event.getRecipients()) { -+ recipient.sendMessage(ServerGamePacketListenerImpl.this.player.getUUID(), msg); -+ } -+ } -+ this.server.console.sendMessage(msg); -+ } + } + } + + @Deprecated // Paper -+ public void handleCommand(String s) { // Paper - private -> public ++ public void handleCommand(String command) { + // Paper start - Remove all this old duplicated logic -+ if (s.startsWith("/")) { -+ s = s.substring(1); ++ if (command.startsWith("/")) { ++ command = command.substring(1); + } + /* + It should be noted that this represents the "legacy" command execution path. @@ -1671,7 +1587,7 @@ + This method should ONLY be used if you need to execute a command WITHOUT + an actual player's input. + */ -+ this.performUnsignedChatCommand(s); ++ this.performUnsignedChatCommand(command); + // Paper end + } + // CraftBukkit end @@ -1725,16 +1641,16 @@ } } -@@ -1475,7 +_,7 @@ - synchronized (this.lastSeenMessages) { - if (!this.lastSeenMessages.applyOffset(packet.offset())) { - LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString()); +@@ -1564,7 +_,7 @@ + this.lastSeenMessages.applyOffset(packet.offset()); + } catch (LastSeenMessagesValidator.ValidationException var5) { + LOGGER.error("Failed to validate message acknowledgement offset from {}: {}", this.player.getName().getString(), var5.getMessage()); - this.disconnect(CHAT_VALIDATION_FAILED); + this.disconnectAsync(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes & add proper async disconnect } } } -@@ -1483,7 +_,40 @@ +@@ -1572,7 +_,40 @@ @Override public void handleAnimate(ServerboundSwingPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -1756,13 +1672,13 @@ + return entity != this.player.getBukkitEntity() && this.player.getBukkitEntity().canSee(entity) && !handle.isSpectator() && handle.isPickable() && !handle.isPassengerOfSameVehicle(this.player); + }); + if (result == null) { -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + } else { // Paper start - Call interact event + GameType gameType = this.player.gameMode.getGameModeForPlayer(); + if (gameType == GameType.ADVENTURE && result.getHitBlock() != null) { -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_BLOCK, ((org.bukkit.craftbukkit.block.CraftBlock) result.getHitBlock()).getPosition(), org.bukkit.craftbukkit.block.CraftBlock.blockFaceToNotch(result.getHitBlockFace()), this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + } else if (gameType != GameType.CREATIVE && result.getHitEntity() != null && origin.toVector().distanceSquared(result.getHitPosition()) > this.player.entityInteractionRange() * this.player.entityInteractionRange()) { -+ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelected(), InteractionHand.MAIN_HAND); ++ CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.getInventory().getSelectedItem(), InteractionHand.MAIN_HAND); + } + } // Paper end - Call interact event + @@ -1775,7 +1691,7 @@ this.player.swing(packet.getHand()); } -@@ -1491,10 +_,41 @@ +@@ -1580,10 +_,41 @@ public void handlePlayerCommand(ServerboundPlayerCommandPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (this.player.hasClientLoaded()) { @@ -1817,14 +1733,7 @@ break; case RELEASE_SHIFT_KEY: this.player.setShiftKeyDown(false); -@@ -1551,12 +_,20 @@ - } - - if (i > 4096) { -- this.disconnect(Component.translatable("multiplayer.disconnect.too_many_pending_chats")); -+ this.disconnectAsync(Component.translatable("multiplayer.disconnect.too_many_pending_chats"), org.bukkit.event.player.PlayerKickEvent.Cause.TOO_MANY_PENDING_CHATS); // Paper - kick event cause & add proper async disconnect - } - } +@@ -1630,6 +_,14 @@ } public void sendPlayerChatMessage(PlayerChatMessage chatMessage, ChatType.Bound boundType) { @@ -1838,17 +1747,21 @@ + synchronized (this.messageSignatureCache) { this.send( new ClientboundPlayerChatPacket( - chatMessage.link().sender(), -@@ -1569,6 +_,8 @@ - ) - ); - this.addPendingMessage(chatMessage); + this.nextChatIndex++, +@@ -1652,9 +_,11 @@ + } + + if (i > 4096) { +- this.disconnect(Component.translatable("multiplayer.disconnect.too_many_pending_chats")); ++ this.disconnectAsync(Component.translatable("multiplayer.disconnect.too_many_pending_chats"), org.bukkit.event.player.PlayerKickEvent.Cause.TOO_MANY_PENDING_CHATS); // Paper - kick event cause & add proper async disconnect + } + } + } + // Paper end - Ensure that client receives chat packets in the same order that we add into the message signature cache } public void sendDisguisedChatMessage(Component message, ChatType.Bound boundType) { -@@ -1579,6 +_,17 @@ +@@ -1665,6 +_,17 @@ return this.connection.getRemoteAddress(); } @@ -1866,7 +1779,7 @@ public void switchToConfig() { this.waitingForSwitchToConfig = true; this.removePlayerFromWorld(); -@@ -1594,9 +_,16 @@ +@@ -1680,9 +_,16 @@ @Override public void handleInteract(ServerboundInteractPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -1883,7 +1796,7 @@ this.player.resetLastActionTime(); this.player.setShiftKeyDown(packet.isUsingSecondaryAction()); if (target != null) { -@@ -1605,16 +_,55 @@ +@@ -1691,16 +_,58 @@ } AABB boundingBox = target.getBoundingBox(); @@ -1900,28 +1813,31 @@ - ) - { + // CraftBukkit start -+ boolean triggerLeashUpdate = itemInHand != null && itemInHand.getItem() == Items.LEAD && target instanceof net.minecraft.world.entity.Mob; -+ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem(); ++ boolean triggerLeashUpdate = itemInHand.is(net.minecraft.world.item.Items.LEAD) && target instanceof net.minecraft.world.entity.Leashable; ++ Item origItem = ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() ? null : ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem(); + + ServerGamePacketListenerImpl.this.cserver.getPluginManager().callEvent(event); + + // Entity in bucket - SPIGOT-4048 and SPIGOT-6859a -+ if ((target instanceof Bucketable && target instanceof LivingEntity && origItem != null && origItem.asItem() == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { ++ if ((target instanceof net.minecraft.world.entity.animal.Bucketable && target instanceof LivingEntity && origItem != null && origItem == Items.WATER_BUCKET) && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || !ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().is(origItem))) { + target.resendPossiblyDesyncedEntityData(ServerGamePacketListenerImpl.this.player); // Paper - The entire mob gets deleted, so resend it + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); + } + -+ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem)) { ++ if (triggerLeashUpdate && (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem)) { + // Refresh the current leash state -+ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(target, ((net.minecraft.world.entity.Mob) target).getLeashHolder())); ++ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEntityLinkPacket(target, ((net.minecraft.world.entity.Leashable) target).getLeashHolder())); + } + -+ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelected() == null || ServerGamePacketListenerImpl.this.player.getInventory().getSelected().getItem() != origItem) { ++ if (event.isCancelled() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().isEmpty() || ServerGamePacketListenerImpl.this.player.getInventory().getSelectedItem().getItem() != origItem) { + // Refresh the current entity metadata + target.refreshEntityData(ServerGamePacketListenerImpl.this.player); + // SPIGOT-7136 - Allays -+ if (target instanceof Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync -+ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket(target.getId(), Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()).map((slot) -> Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())).collect(Collectors.toList()), true)); // Paper - sanitize ++ if (target instanceof net.minecraft.world.entity.animal.allay.Allay || target instanceof net.minecraft.world.entity.animal.horse.AbstractHorse) { // Paper - Fix horse armor desync ++ ServerGamePacketListenerImpl.this.send(new net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket( ++ target.getId(), java.util.Arrays.stream(net.minecraft.world.entity.EquipmentSlot.values()) ++ .map((slot) -> com.mojang.datafixers.util.Pair.of(slot, ((LivingEntity) target).getItemBySlot(slot).copy())) ++ .collect(Collectors.toList()), true)); // Paper - sanitize + } + + ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - fix slot desync - always refresh player inventory @@ -1944,7 +1860,7 @@ ItemStack itemStack1 = success.wasItemInteraction() ? itemStack : ItemStack.EMPTY; CriteriaTriggers.PLAYER_INTERACTED_WITH_ENTITY.trigger(ServerGamePacketListenerImpl.this.player, itemStack1, target); if (success.swingSource() == InteractionResult.SwingSource.SERVER) { -@@ -1626,13 +_,13 @@ +@@ -1712,13 +_,13 @@ @Override public void onInteraction(InteractionHand hand) { @@ -1960,7 +1876,7 @@ ); } -@@ -1640,14 +_,19 @@ +@@ -1726,14 +_,19 @@ public void onAttack() { if (!(target instanceof ItemEntity) && !(target instanceof ExperienceOrb) @@ -1982,7 +1898,7 @@ ServerGamePacketListenerImpl.LOGGER .warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getName().getString()); } -@@ -1656,6 +_,27 @@ +@@ -1742,6 +_,27 @@ ); } } @@ -2006,11 +1922,11 @@ + }); + } + // Paper end - PlayerUseUnknownEntityEvent -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } } -@@ -1668,7 +_,7 @@ +@@ -1754,7 +_,7 @@ case PERFORM_RESPAWN: if (this.player.wonGame) { this.player.wonGame = false; @@ -2019,7 +1935,7 @@ this.resetPosition(); CriteriaTriggers.CHANGED_DIMENSION.trigger(this.player, Level.END, Level.OVERWORLD); } else { -@@ -1676,11 +_,11 @@ +@@ -1762,11 +_,11 @@ return; } @@ -2034,7 +1950,7 @@ } } break; -@@ -1691,16 +_,28 @@ +@@ -1777,16 +_,28 @@ @Override public void handleContainerClose(ServerboundContainerClosePacket packet) { @@ -2057,43 +1973,43 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); + if (this.player.isImmobile()) return; // CraftBukkit this.player.resetLastActionTime(); -- if (this.player.containerMenu.containerId == packet.getContainerId()) { +- if (this.player.containerMenu.containerId == packet.containerId()) { - if (this.player.isSpectator()) { -+ if (this.player.containerMenu.containerId == packet.getContainerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit ++ if (this.player.containerMenu.containerId == packet.containerId() && this.player.containerMenu.stillValid(this.player)) { // CraftBukkit + boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if + if (false/*this.player.isSpectator()*/) { // CraftBukkit this.player.containerMenu.sendAllDataToRemote(); } else if (!this.player.containerMenu.stillValid(this.player)) { LOGGER.debug("Player {} interacted with invalid menu {}", this.player, this.player.containerMenu); -@@ -1713,7 +_,341 @@ +@@ -1799,7 +_,340 @@ } else { - boolean flag = packet.getStateId() != this.player.containerMenu.getStateId(); + boolean flag = packet.stateId() != this.player.containerMenu.getStateId(); this.player.containerMenu.suppressRemoteUpdates(); -- this.player.containerMenu.clicked(slotNum, packet.getButtonNum(), packet.getClickType(), this.player); +- this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player); + // CraftBukkit start - Call InventoryClickEvent -+ if (slotNum < -1 && slotNum != AbstractContainerMenu.SLOT_CLICKED_OUTSIDE) { ++ if (slotNum < -1 && slotNum != net.minecraft.world.inventory.AbstractContainerMenu.SLOT_CLICKED_OUTSIDE) { + return; + } + -+ InventoryView inventory = this.player.containerMenu.getBukkitView(); ++ org.bukkit.inventory.InventoryView inventory = this.player.containerMenu.getBukkitView(); + SlotType type = inventory.getSlotType(slotNum); + + InventoryClickEvent event; + ClickType click = ClickType.UNKNOWN; + InventoryAction action = InventoryAction.UNKNOWN; + -+ switch (packet.getClickType()) { ++ switch (packet.clickType()) { + case PICKUP: -+ if (packet.getButtonNum() == 0) { ++ if (packet.buttonNum() == 0) { + click = ClickType.LEFT; -+ } else if (packet.getButtonNum() == 1) { ++ } else if (packet.buttonNum() == 1) { + click = ClickType.RIGHT; + } -+ if (packet.getButtonNum() == 0 || packet.getButtonNum() == 1) { ++ if (packet.buttonNum() == 0 || packet.buttonNum() == 1) { + action = InventoryAction.NOTHING; // Don't want to repeat ourselves -+ if (slotNum == AbstractContainerMenu.SLOT_CLICKED_OUTSIDE) { ++ if (slotNum == net.minecraft.world.inventory.AbstractContainerMenu.SLOT_CLICKED_OUTSIDE) { + if (!this.player.containerMenu.getCarried().isEmpty()) { -+ action = packet.getButtonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; ++ action = packet.buttonNum() == 0 ? InventoryAction.DROP_ALL_CURSOR : InventoryAction.DROP_ONE_CURSOR; + } + } else if (slotNum < 0) { + action = InventoryAction.NOTHING; @@ -2104,22 +2020,22 @@ + ItemStack cursor = this.player.containerMenu.getCarried(); + if (clickedItem.isEmpty()) { + if (!cursor.isEmpty()) { -+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) { ++ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.buttonNum() != 0) { + action = cursor.get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PLACE_FROM_BUNDLE; + } else { -+ action = packet.getButtonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; ++ action = packet.buttonNum() == 0 ? InventoryAction.PLACE_ALL : InventoryAction.PLACE_ONE; + } + } + } else if (slot.mayPickup(this.player)) { + if (cursor.isEmpty()) { -+ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() != 0) { ++ if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.buttonNum() != 0) { + action = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).isEmpty() ? InventoryAction.NOTHING : InventoryAction.PICKUP_FROM_BUNDLE; + } else { -+ action = packet.getButtonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; ++ action = packet.buttonNum() == 0 ? InventoryAction.PICKUP_ALL : InventoryAction.PICKUP_HALF; + } + } else if (slot.mayPlace(cursor)) { + if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { -+ int toPlace = packet.getButtonNum() == 0 ? cursor.getCount() : 1; ++ int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1; + toPlace = Math.min(toPlace, clickedItem.getMaxStackSize() - clickedItem.getCount()); + toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); + if (toPlace == 1) { @@ -2132,7 +2048,7 @@ + action = InventoryAction.PLACE_SOME; + } + } else if (cursor.getCount() <= slot.getMaxStackSize()) { -+ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) { ++ if (cursor.getItem() instanceof net.minecraft.world.item.BundleItem && cursor.has(DataComponents.BUNDLE_CONTENTS) && packet.buttonNum() == 0) { + int toPickup = cursor.get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(slot.getItem()); + if (toPickup >= slot.getItem().getCount()) { + action = InventoryAction.PICKUP_ALL_INTO_BUNDLE; @@ -2141,7 +2057,7 @@ + } else { + action = InventoryAction.PICKUP_SOME_INTO_BUNDLE; + } -+ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.getButtonNum() == 0) { ++ } else if (slot.getItem().getItem() instanceof net.minecraft.world.item.BundleItem && slot.getItem().has(DataComponents.BUNDLE_CONTENTS) && packet.buttonNum() == 0) { + int toPickup = slot.getItem().get(DataComponents.BUNDLE_CONTENTS).getMaxAmountToAdd(cursor); + if (toPickup >= cursor.getCount()) { + action = InventoryAction.PLACE_ALL_INTO_BUNDLE; @@ -2169,12 +2085,12 @@ + break; + // TODO check on updates + case QUICK_MOVE: -+ if (packet.getButtonNum() == 0) { ++ if (packet.buttonNum() == 0) { + click = ClickType.SHIFT_LEFT; -+ } else if (packet.getButtonNum() == 1) { ++ } else if (packet.buttonNum() == 1) { + click = ClickType.SHIFT_RIGHT; + } -+ if (packet.getButtonNum() == 0 || packet.getButtonNum() == 1) { ++ if (packet.buttonNum() == 0 || packet.buttonNum() == 1) { + if (slotNum < 0) { + action = InventoryAction.NOTHING; + } else { @@ -2187,136 +2103,136 @@ + } + } + break; -+ case SWAP: -+ if ((packet.getButtonNum() >= 0 && packet.getButtonNum() < 9) || packet.getButtonNum() == Inventory.SLOT_OFFHAND) { -+ // Paper start - Add slot sanity checks to container clicks -+ if (slotNum < 0) { -+ action = InventoryAction.NOTHING; -+ break; -+ } -+ // Paper end - Add slot sanity checks to container clicks -+ click = (packet.getButtonNum() == Inventory.SLOT_OFFHAND) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; -+ Slot clickedSlot = this.player.containerMenu.getSlot(slotNum); -+ if (clickedSlot.mayPickup(this.player)) { -+ ItemStack hotbar = this.player.getInventory().getItem(packet.getButtonNum()); -+ if ((!hotbar.isEmpty() && clickedSlot.mayPlace(hotbar)) || (hotbar.isEmpty() && clickedSlot.hasItem())) { // Paper - modernify this logic (no such thing as a "hotbar move and readd" -+ action = InventoryAction.HOTBAR_SWAP; -+ } else { -+ action = InventoryAction.NOTHING; -+ } ++ case SWAP: ++ if ((packet.buttonNum() >= 0 && packet.buttonNum() < 9) || packet.buttonNum() == Inventory.SLOT_OFFHAND) { ++ // Paper start - Add slot sanity checks to container clicks ++ if (slotNum < 0) { ++ action = InventoryAction.NOTHING; ++ break; ++ } ++ // Paper end - Add slot sanity checks to container clicks ++ click = (packet.buttonNum() == Inventory.SLOT_OFFHAND) ? ClickType.SWAP_OFFHAND : ClickType.NUMBER_KEY; ++ Slot clickedSlot = this.player.containerMenu.getSlot(slotNum); ++ if (clickedSlot.mayPickup(this.player)) { ++ ItemStack hotbar = this.player.getInventory().getItem(packet.buttonNum()); ++ if ((!hotbar.isEmpty() && clickedSlot.mayPlace(hotbar)) || (hotbar.isEmpty() && clickedSlot.hasItem())) { // Paper - modernify this logic (no such thing as a "hotbar move and readd" ++ action = InventoryAction.HOTBAR_SWAP; + } else { + action = InventoryAction.NOTHING; + } -+ } -+ break; -+ case CLONE: -+ if (packet.getButtonNum() == 2) { -+ click = ClickType.MIDDLE; -+ if (slotNum < 0) { -+ action = InventoryAction.NOTHING; -+ } else { -+ Slot slot = this.player.containerMenu.getSlot(slotNum); -+ if (slot != null && slot.hasItem() && this.player.getAbilities().instabuild && this.player.containerMenu.getCarried().isEmpty()) { -+ action = InventoryAction.CLONE_STACK; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } + } else { -+ click = ClickType.UNKNOWN; -+ action = InventoryAction.UNKNOWN; -+ } -+ break; -+ case THROW: -+ if (slotNum >= 0) { -+ if (packet.getButtonNum() == 0) { -+ click = ClickType.DROP; -+ Slot slot = this.player.containerMenu.getSlot(slotNum); -+ if (slot != null && slot.hasItem() && slot.mayPickup(this.player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Items.AIR) { -+ action = InventoryAction.DROP_ONE_SLOT; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } else if (packet.getButtonNum() == 1) { -+ click = ClickType.CONTROL_DROP; -+ Slot slot = this.player.containerMenu.getSlot(slotNum); -+ if (slot != null && slot.hasItem() && slot.mayPickup(this.player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Items.AIR) { -+ action = InventoryAction.DROP_ALL_SLOT; -+ } else { -+ action = InventoryAction.NOTHING; -+ } -+ } -+ } else { -+ // Sane default (because this happens when they are holding nothing. Don't ask why.) -+ click = ClickType.LEFT; -+ if (packet.getButtonNum() == 1) { -+ click = ClickType.RIGHT; -+ } + action = InventoryAction.NOTHING; + } -+ break; -+ case QUICK_CRAFT: -+ // Paper start - Fix CraftBukkit drag system -+ AbstractContainerMenu containerMenu = this.player.containerMenu; -+ int currentStatus = this.player.containerMenu.quickcraftStatus; -+ int newStatus = AbstractContainerMenu.getQuickcraftHeader(packet.getButtonNum()); -+ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) { -+ } else if (containerMenu.getCarried().isEmpty()) { -+ } else if (newStatus == 0) { -+ } else if (newStatus == 1) { -+ } else if (newStatus == 2) { -+ if (!this.player.containerMenu.quickcraftSlots.isEmpty()) { -+ if (this.player.containerMenu.quickcraftSlots.size() == 1) { -+ int index = containerMenu.quickcraftSlots.iterator().next().index; -+ containerMenu.resetQuickCraft(); -+ this.handleContainerClick(new ServerboundContainerClickPacket(packet.getContainerId(), packet.getStateId(), index, containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.getCarriedItem(), packet.getChangedSlots())); -+ return; -+ } ++ } ++ break; ++ case CLONE: ++ if (packet.buttonNum() == 2) { ++ click = ClickType.MIDDLE; ++ if (slotNum < 0) { ++ action = InventoryAction.NOTHING; ++ } else { ++ Slot slot = this.player.containerMenu.getSlot(slotNum); ++ if (slot != null && slot.hasItem() && this.player.getAbilities().instabuild && this.player.containerMenu.getCarried().isEmpty()) { ++ action = InventoryAction.CLONE_STACK; ++ } else { ++ action = InventoryAction.NOTHING; + } + } -+ // Paper end - Fix CraftBukkit drag system -+ this.player.containerMenu.clicked(slotNum, packet.getButtonNum(), packet.getClickType(), this.player); -+ break; -+ case PICKUP_ALL: -+ click = ClickType.DOUBLE_CLICK; ++ } else { ++ click = ClickType.UNKNOWN; ++ action = InventoryAction.UNKNOWN; ++ } ++ break; ++ case THROW: ++ if (slotNum >= 0) { ++ if (packet.buttonNum() == 0) { ++ click = ClickType.DROP; ++ Slot slot = this.player.containerMenu.getSlot(slotNum); ++ if (slot != null && slot.hasItem() && slot.mayPickup(this.player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Items.AIR) { ++ action = InventoryAction.DROP_ONE_SLOT; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } else if (packet.buttonNum() == 1) { ++ click = ClickType.CONTROL_DROP; ++ Slot slot = this.player.containerMenu.getSlot(slotNum); ++ if (slot != null && slot.hasItem() && slot.mayPickup(this.player) && !slot.getItem().isEmpty() && slot.getItem().getItem() != Items.AIR) { ++ action = InventoryAction.DROP_ALL_SLOT; ++ } else { ++ action = InventoryAction.NOTHING; ++ } ++ } ++ } else { ++ // Sane default (because this happens when they are holding nothing. Don't ask why.) ++ click = ClickType.LEFT; ++ if (packet.buttonNum() == 1) { ++ click = ClickType.RIGHT; ++ } + action = InventoryAction.NOTHING; -+ if (slotNum >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { -+ ItemStack cursor = this.player.containerMenu.getCarried(); -+ action = InventoryAction.NOTHING; -+ // Quick check for if we have any of the item -+ if (inventory.getTopInventory().contains(CraftItemType.minecraftToBukkit(cursor.getItem())) || inventory.getBottomInventory().contains(CraftItemType.minecraftToBukkit(cursor.getItem()))) { -+ action = InventoryAction.COLLECT_TO_CURSOR; ++ } ++ break; ++ case QUICK_CRAFT: ++ // Paper start - Fix CraftBukkit drag system ++ net.minecraft.world.inventory.AbstractContainerMenu containerMenu = this.player.containerMenu; ++ int currentStatus = this.player.containerMenu.quickcraftStatus; ++ int newStatus = net.minecraft.world.inventory.AbstractContainerMenu.getQuickcraftHeader(packet.buttonNum()); ++ if ((currentStatus != 1 || newStatus != 2 && currentStatus != newStatus)) { ++ } else if (containerMenu.getCarried().isEmpty()) { ++ } else if (newStatus == 0) { ++ } else if (newStatus == 1) { ++ } else if (newStatus == 2) { ++ if (!this.player.containerMenu.quickcraftSlots.isEmpty()) { ++ if (this.player.containerMenu.quickcraftSlots.size() == 1) { ++ int index = containerMenu.quickcraftSlots.iterator().next().index; ++ containerMenu.resetQuickCraft(); ++ this.handleContainerClick(new ServerboundContainerClickPacket(packet.containerId(), packet.stateId(), (short) index, (byte) containerMenu.quickcraftType, net.minecraft.world.inventory.ClickType.PICKUP, packet.changedSlots(), packet.carriedItem())); ++ return; + } + } -+ break; -+ default: -+ break; ++ } ++ // Paper end - Fix CraftBukkit drag system ++ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player); ++ break; ++ case PICKUP_ALL: ++ click = ClickType.DOUBLE_CLICK; ++ action = InventoryAction.NOTHING; ++ if (slotNum >= 0 && !this.player.containerMenu.getCarried().isEmpty()) { ++ ItemStack cursor = this.player.containerMenu.getCarried(); ++ action = InventoryAction.NOTHING; ++ // Quick check for if we have any of the item ++ if (inventory.getTopInventory().contains(org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(cursor.getItem())) || inventory.getBottomInventory().contains(org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(cursor.getItem()))) { ++ action = InventoryAction.COLLECT_TO_CURSOR; ++ } ++ } ++ break; ++ default: ++ break; + } + -+ if (packet.getClickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) { ++ if (packet.clickType() != net.minecraft.world.inventory.ClickType.QUICK_CRAFT) { + if (click == ClickType.NUMBER_KEY) { -+ event = new InventoryClickEvent(inventory, type, slotNum, click, action, packet.getButtonNum()); ++ event = new InventoryClickEvent(inventory, type, slotNum, click, action, packet.buttonNum()); + } else { + event = new InventoryClickEvent(inventory, type, slotNum, click, action); + } + + org.bukkit.inventory.Inventory top = inventory.getTopInventory(); -+ if (slotNum == 0 && top instanceof CraftingInventory) { -+ org.bukkit.inventory.Recipe recipe = ((CraftingInventory) top).getRecipe(); ++ if (slotNum == 0 && top instanceof final org.bukkit.inventory.CraftingInventory craftingInv) { ++ org.bukkit.inventory.Recipe recipe = craftingInv.getRecipe(); + if (recipe != null) { + if (click == ClickType.NUMBER_KEY) { -+ event = new CraftItemEvent(recipe, inventory, type, slotNum, click, action, packet.getButtonNum()); ++ event = new CraftItemEvent(recipe, inventory, type, slotNum, click, action, packet.buttonNum()); + } else { + event = new CraftItemEvent(recipe, inventory, type, slotNum, click, action); + } + } + } + -+ if (slotNum == 3 && top instanceof SmithingInventory) { -+ org.bukkit.inventory.ItemStack result = ((SmithingInventory) top).getResult(); ++ if (slotNum == 3 && top instanceof final org.bukkit.inventory.SmithingInventory smithingInv) { ++ org.bukkit.inventory.ItemStack result = smithingInv.getResult(); + if (result != null) { + if (click == ClickType.NUMBER_KEY) { -+ event = new SmithItemEvent(inventory, type, slotNum, click, action, packet.getButtonNum()); ++ event = new SmithItemEvent(inventory, type, slotNum, click, action, packet.buttonNum()); + } else { + event = new SmithItemEvent(inventory, type, slotNum, click, action); + } @@ -2328,7 +2244,7 @@ + org.bukkit.inventory.ItemStack result = cartographyInventory.getResult(); + if (result != null && !result.isEmpty()) { + if (click == ClickType.NUMBER_KEY) { -+ event = new io.papermc.paper.event.player.CartographyItemEvent(inventory, type, slotNum, click, action, packet.getButtonNum()); ++ event = new io.papermc.paper.event.player.CartographyItemEvent(inventory, type, slotNum, click, action, packet.buttonNum()); + } else { + event = new io.papermc.paper.event.player.CartographyItemEvent(inventory, type, slotNum, click, action); + } @@ -2337,7 +2253,7 @@ + // Paper end - cartography item event + + event.setCancelled(cancelled); -+ AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 ++ net.minecraft.world.inventory.AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 + this.cserver.getPluginManager().callEvent(event); + if (this.player.containerMenu != oldContainer) { + return; @@ -2346,7 +2262,7 @@ + switch (event.getResult()) { + case ALLOW: + case DEFAULT: -+ this.player.containerMenu.clicked(slotNum, packet.getButtonNum(), packet.getClickType(), this.player); ++ this.player.containerMenu.clicked(slotNum, packet.buttonNum(), packet.clickType(), this.player); + break; + case DENY: + /* Needs enum constructor in InventoryAction @@ -2364,7 +2280,6 @@ + // Modified other slots + case PICKUP_ALL: + case MOVE_TO_OTHER_INVENTORY: -+ case HOTBAR_MOVE_AND_READD: + case HOTBAR_SWAP: + case COLLECT_TO_CURSOR: + case UNKNOWN: @@ -2379,12 +2294,12 @@ + case PLACE_ONE: + case SWAP_WITH_CURSOR: + this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(this.player.containerMenu.getCarried().copy())); // Paper - correctly set cursor -+ this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), slotNum, this.player.containerMenu.getSlot(slotNum).getItem())); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), slotNum, this.player.containerMenu.getSlot(slotNum).getItem())); + break; + // Modified clicked only + case DROP_ALL_SLOT: + case DROP_ONE_SLOT: -+ this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), slotNum, this.player.containerMenu.getSlot(slotNum).getItem())); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.player.containerMenu.containerId, this.player.inventoryMenu.incrementStateId(), slotNum, this.player.containerMenu.getSlot(slotNum).getItem())); + break; + // Modified cursor only + case DROP_ALL_CURSOR: @@ -2404,19 +2319,19 @@ + this.player.containerMenu.sendAllDataToRemote(); + } + } -+ // CraftBukkit end ++ // CraftBukkit end - for (Entry entry : Int2ObjectMaps.fastIterable(packet.getChangedSlots())) { - this.player.containerMenu.setRemoteSlotNoCopy(entry.getIntKey(), entry.getValue()); -@@ -1726,6 +_,7 @@ + for (Entry entry : Int2ObjectMaps.fastIterable(packet.changedSlots())) { + this.player.containerMenu.setRemoteSlotUnsafe(entry.getIntKey(), entry.getValue()); +@@ -1812,6 +_,7 @@ } else { this.player.containerMenu.broadcastChanges(); } -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } } } -@@ -1733,6 +_,14 @@ +@@ -1819,6 +_,14 @@ @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { @@ -2431,7 +2346,7 @@ PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); this.player.resetLastActionTime(); if (!this.player.isSpectator() && this.player.containerMenu.containerId == packet.containerId()) { -@@ -1749,9 +_,44 @@ +@@ -1835,9 +_,44 @@ return; } @@ -2477,7 +2392,7 @@ if (postPlaceAction == RecipeBookMenu.PostPlaceAction.PLACE_GHOST_RECIPE) { this.player .connection -@@ -1767,6 +_,7 @@ +@@ -1853,6 +_,7 @@ @Override public void handleContainerButtonClick(ServerboundContainerButtonClickPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -2485,21 +2400,21 @@ this.player.resetLastActionTime(); if (this.player.containerMenu.containerId == packet.containerId() && !this.player.isSpectator()) { if (!this.player.containerMenu.stillValid(this.player)) { -@@ -1776,6 +_,7 @@ +@@ -1862,6 +_,7 @@ if (flag) { this.player.containerMenu.broadcastChanges(); } -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } } } -@@ -1792,10 +_,48 @@ +@@ -1878,10 +_,48 @@ boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; boolean flag2 = itemStack.isEmpty() || itemStack.getCount() <= itemStack.getMaxStackSize(); + if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packet.slotNum()).getItem(), packet.itemStack()))) { // Insist on valid slot + // CraftBukkit start - Call click event -+ InventoryView inventory = this.player.inventoryMenu.getBukkitView(); ++ org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView(); + org.bukkit.inventory.ItemStack item = CraftItemStack.asBukkitCopy(packet.itemStack()); + + SlotType type = SlotType.QUICKBAR; @@ -2512,7 +2427,7 @@ + type = SlotType.CONTAINER; + } + } -+ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? AbstractContainerMenu.SLOT_CLICKED_OUTSIDE : packet.slotNum(), item); ++ InventoryCreativeEvent event = new InventoryCreativeEvent(inventory, type, flag ? net.minecraft.world.inventory.AbstractContainerMenu.SLOT_CLICKED_OUTSIDE : packet.slotNum(), item); + this.cserver.getPluginManager().callEvent(event); + + itemStack = CraftItemStack.asNMSCopy(event.getCursor()); @@ -2527,7 +2442,7 @@ + case DENY: + // Reset the slot + if (packet.slotNum() >= 0) { -+ this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.slotNum(), this.player.inventoryMenu.getSlot(packet.slotNum()).getItem())); ++ this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.slotNum(), this.player.inventoryMenu.getSlot(packet.slotNum()).getItem())); + this.player.connection.send(new net.minecraft.network.protocol.game.ClientboundSetCursorItemPacket(ItemStack.EMPTY.copy())); // Paper - correctly set cursor + } + return; @@ -2538,11 +2453,11 @@ this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack); this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack); this.player.inventoryMenu.broadcastChanges(); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdatesPublic(); // Paper - Force update attributes. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { this.dropSpamThrottler.increment(); -@@ -1809,11 +_,24 @@ +@@ -1895,11 +_,24 @@ @Override public void handleSignUpdate(ServerboundSignUpdatePacket packet) { @@ -2560,7 +2475,7 @@ + } + List list = Stream.of(lines).map(ChatFormatting::stripFormatting).collect(Collectors.toList()); + // Paper end - Limit client sign length - this.filterTextPacket(list).thenAcceptAsync(list1 -> this.updateSignText(packet, (List)list1), this.server); + this.filterTextPacket(list).thenAcceptAsync(texts -> this.updateSignText(packet, (List)texts), this.server); } private void updateSignText(ServerboundSignUpdatePacket packet, List filteredText) { @@ -2568,7 +2483,7 @@ this.player.resetLastActionTime(); ServerLevel serverLevel = this.player.serverLevel(); BlockPos pos = packet.getPos(); -@@ -1829,14 +_,32 @@ +@@ -1915,14 +_,32 @@ @Override public void handlePlayerAbilities(ServerboundPlayerAbilitiesPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -2602,7 +2517,7 @@ if (this.player.isModelPartShown(PlayerModelPart.HAT) != isModelPartShown) { this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_HAT, this.player)); } -@@ -1846,7 +_,7 @@ +@@ -1932,7 +_,7 @@ public void handleChangeDifficulty(ServerboundChangeDifficultyPacket packet) { PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); if (this.player.hasPermissions(2) || this.isSingleplayerOwner()) { @@ -2611,7 +2526,7 @@ } } -@@ -1866,7 +_,7 @@ +@@ -1952,7 +_,7 @@ ProfilePublicKey.Data data2 = data.profilePublicKey(); if (!Objects.equals(data1, data2)) { if (data1 != null && data2.expiresAt().isBefore(data1.expiresAt())) { @@ -2620,7 +2535,7 @@ } else { try { SignatureValidator profileKeySignatureValidator = this.server.getProfileKeySignatureValidator(); -@@ -1877,8 +_,8 @@ +@@ -1963,8 +_,8 @@ this.resetPlayerChatState(data.validate(this.player.getGameProfile(), profileKeySignatureValidator)); } catch (ProfilePublicKey.ValidationException var6) { @@ -2631,7 +2546,7 @@ } } } -@@ -1892,7 +_,7 @@ +@@ -1978,7 +_,7 @@ this.connection .setupInboundProtocol( ConfigurationProtocols.SERVERBOUND, @@ -2640,7 +2555,7 @@ ); } } -@@ -1911,6 +_,7 @@ +@@ -1997,6 +_,7 @@ private void resetPlayerChatState(RemoteChatSession chatSession) { this.chatSession = chatSession; @@ -2648,7 +2563,7 @@ this.signedMessageDecoder = chatSession.createMessageDecoder(this.player.getUUID()); this.chatMessageChain .append( -@@ -1919,19 +_,22 @@ +@@ -2005,7 +_,7 @@ this.server .getPlayerList() .broadcastAll( @@ -2657,16 +2572,12 @@ ); } ); - } +@@ -2013,11 +_,13 @@ -- @Override -- public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { -- } -+ // CraftBukkit start - handled in super -+ // @Override -+ // public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { -+ // } -+ // CraftBukkit end + @Override + public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { ++ super.handleCustomPayload(packet); // CraftBukkit - handled in super + } @Override public void handleClientTickEnd(ServerboundClientTickEndPacket packet) { @@ -2675,7 +2586,7 @@ if (!this.receivedMovementThisTick) { this.player.setKnownMovement(Vec3.ZERO); } -@@ -1957,4 +_,17 @@ +@@ -2048,4 +_,17 @@ interface EntityInteraction { InteractionResult run(ServerPlayer player, Entity entity, InteractionHand hand); } diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch index 218905a0a..e373ebb46 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java.patch @@ -1,14 +1,7 @@ --- a/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -@@ -12,11 +_,27 @@ - import net.minecraft.network.protocol.status.StatusProtocols; - import net.minecraft.server.MinecraftServer; +@@ -14,9 +_,20 @@ -+// CraftBukkit start -+import java.net.InetAddress; -+import java.util.HashMap; -+// CraftBukkit end -+ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener { private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); + // Spigot start @@ -17,7 +10,7 @@ + static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}"); + // Spigot end + // CraftBukkit start - add fields -+ private static final HashMap throttleTracker = new HashMap<>(); ++ private static final java.util.HashMap throttleTracker = new java.util.HashMap<>(); + private static int throttleCounter = 0; + // CraftBukkit end + private static final boolean BYPASS_HOSTCHECK = Boolean.getBoolean("Paper.bypassHostCheck"); // Paper @@ -54,7 +47,7 @@ + if (!(this.connection.channel.localAddress() instanceof io.netty.channel.unix.DomainSocketAddress)) { // Paper - Unix domain socket support; the connection throttle is useless when you have a Unix domain socket + long currentTime = System.currentTimeMillis(); + long connectionThrottle = this.server.server.getConnectionThrottle(); -+ InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); ++ java.net.InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); + + synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { + if (ServerHandshakePacketListenerImpl.throttleTracker.containsKey(address) && !"127.0.0.1".equals(address.getHostAddress()) && currentTime - ServerHandshakePacketListenerImpl.throttleTracker.get(address) < connectionThrottle) { @@ -102,7 +95,7 @@ + // Try and handle the handshake through the event + if (com.destroystokyo.paper.event.player.PlayerHandshakeEvent.getHandlerList().getRegisteredListeners().length != 0) { // Hello? Can you hear me? + java.net.SocketAddress socketAddress = this.connection.address; -+ String hostnameOfRemote = socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getHostString() : InetAddress.getLoopbackAddress().getHostAddress(); ++ String hostnameOfRemote = socketAddress instanceof java.net.InetSocketAddress ? ((java.net.InetSocketAddress) socketAddress).getHostString() : java.net.InetAddress.getLoopbackAddress().getHostAddress(); + com.destroystokyo.paper.event.player.PlayerHandshakeEvent event = new com.destroystokyo.paper.event.player.PlayerHandshakeEvent(packet.hostName(), hostnameOfRemote, !proxyLogicEnabled); + if (event.callEvent()) { + // If we've failed somehow, let the client know so and go no further. diff --git a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch index 4360d8653..d85b10aa3 100644 --- a/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/network/ServerLoginPacketListenerImpl.java.patch @@ -1,18 +1,16 @@ --- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -43,10 +_,19 @@ - import net.minecraft.util.StringUtil; +@@ -44,9 +_,17 @@ import org.apache.commons.lang3.Validate; import org.slf4j.Logger; + +-public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener { +// CraftBukkit start -+import net.minecraft.network.protocol.Packet; -+import net.minecraft.network.protocol.PacketUtils; +import org.bukkit.craftbukkit.entity.CraftPlayer; +import org.bukkit.craftbukkit.util.Waitable; +import org.bukkit.event.player.AsyncPlayerPreLoginEvent; +import org.bukkit.event.player.PlayerPreLoginEvent; - --public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener { ++ +public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, TickablePacketListener, CraftPlayer.TransferCookieConnection { + // CraftBukkit end private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0); @@ -47,7 +45,7 @@ + } + + @Override -+ public void sendPacket(Packet packet) { ++ public void sendPacket(net.minecraft.network.protocol.Packet packet) { + this.connection.send(packet); + } + @@ -342,7 +340,7 @@ @Override public void handleLoginAcknowledgement(ServerboundLoginAcknowledgedPacket packet) { -+ PacketUtils.ensureRunningOnSameThread(packet, this, this.server); // CraftBukkit ++ net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server); // CraftBukkit Validate.validState(this.state == ServerLoginPacketListenerImpl.State.PROTOCOL_SWITCHING, "Unexpected login acknowledgement packet"); this.connection.setupOutboundProtocol(ConfigurationProtocols.CLIENTBOUND); CommonListenerCookie commonListenerCookie = CommonListenerCookie.createInitial(Objects.requireNonNull(this.authenticatedProfile), this.transferred); @@ -359,7 +357,7 @@ @Override public void handleCookieResponse(ServerboundCookieResponsePacket packet) { + // CraftBukkit start -+ PacketUtils.ensureRunningOnSameThread(packet, this, this.server); ++ net.minecraft.network.protocol.PacketUtils.ensureRunningOnSameThread(packet, this, this.server); + if (this.player != null && this.player.getBukkitEntity().handleCookieResponse(packet)) { + return; + } diff --git a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch index 2336810f5..d6728405b 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/GameProfileCache.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/server/players/GameProfileCache.java +++ b/net/minecraft/server/players/GameProfileCache.java -@@ -56,6 +_,10 @@ +@@ -54,6 +_,10 @@ private final AtomicLong operationCount = new AtomicLong(); @Nullable private Executor executor; @@ -11,7 +11,7 @@ public GameProfileCache(GameProfileRepository profileRepository, File file) { this.profileRepository = profileRepository; -@@ -64,10 +_,12 @@ +@@ -62,17 +_,21 @@ } private void safeAdd(GameProfileCache.GameProfileInfo profile) { @@ -24,16 +24,17 @@ } private static Optional lookupGameProfile(GameProfileRepository profileRepo, String name) { -@@ -86,6 +_,8 @@ - atomicReference.set(null); - } - }; -+ if (!org.apache.commons.lang3.StringUtils.isBlank(name) // Paper - Don't lookup a profile with a blank name -+ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode()) // Paper - Add setting for proxy online mode status - profileRepo.findProfilesByNames(new String[]{name}, profileLookupCallback); - GameProfile gameProfile = atomicReference.get(); - return gameProfile != null ? Optional.of(gameProfile) : createUnknownProfile(name); -@@ -101,7 +_,7 @@ + if (!StringUtil.isValidPlayerName(name)) { + return createUnknownProfile(name); + } else { +- Optional optional = profileRepo.findProfileByName(name); ++ final boolean shouldLookup = !org.apache.commons.lang3.StringUtils.isBlank(name) // Paper - Don't lookup a profile with a blank name ++ && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode(); // Paper - Add setting for proxy online mode status ++ Optional optional = shouldLookup ? profileRepo.findProfileByName(name) : Optional.empty(); // Paper - Don't lookup a profile with a blank name + return optional.isEmpty() ? createUnknownProfile(name) : optional; + } + } +@@ -86,7 +_,7 @@ } private static boolean usesAuthentication() { @@ -42,7 +43,7 @@ } public void add(GameProfile gameProfile) { -@@ -111,15 +_,29 @@ +@@ -96,15 +_,29 @@ Date time = instance.getTime(); GameProfileCache.GameProfileInfo gameProfileInfo = new GameProfileCache.GameProfileInfo(gameProfile, time); this.safeAdd(gameProfileInfo); @@ -73,7 +74,7 @@ GameProfileCache.GameProfileInfo gameProfileInfo = this.profilesByName.get(string); boolean flag = false; if (gameProfileInfo != null && new Date().getTime() >= gameProfileInfo.expirationDate.getTime()) { -@@ -133,19 +_,24 @@ +@@ -118,19 +_,24 @@ if (gameProfileInfo != null) { gameProfileInfo.setLastAccess(this.getNextOperation()); optional = Optional.of(gameProfileInfo.getProfile()); @@ -101,7 +102,7 @@ } public CompletableFuture> getAsync(String name) { -@@ -157,7 +_,7 @@ +@@ -142,7 +_,7 @@ return completableFuture; } else { CompletableFuture> completableFuture1 = CompletableFuture.>supplyAsync( @@ -110,7 +111,7 @@ ) .whenCompleteAsync((gameProfile, exception) -> this.requests.remove(name), this.executor); this.requests.put(name, completableFuture1); -@@ -167,6 +_,7 @@ +@@ -152,6 +_,7 @@ } public Optional get(UUID uuid) { @@ -118,7 +119,7 @@ GameProfileCache.GameProfileInfo gameProfileInfo = this.profilesByUUID.get(uuid); if (gameProfileInfo == null) { return Optional.empty(); -@@ -174,6 +_,7 @@ +@@ -159,6 +_,7 @@ gameProfileInfo.setLastAccess(this.getNextOperation()); return Optional.of(gameProfileInfo.getProfile()); } @@ -126,7 +127,7 @@ } public void setExecutor(Executor exectutor) { -@@ -206,6 +_,11 @@ +@@ -191,6 +_,11 @@ return (List)var9; } catch (FileNotFoundException var7) { @@ -138,7 +139,7 @@ } catch (JsonParseException | IOException var8) { LOGGER.warn("Failed to load profile cache {}", this.file, var8); } -@@ -213,24 +_,45 @@ +@@ -198,24 +_,45 @@ return list; } diff --git a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch index cf078d768..62fd03c79 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/OldUsersConverter.java.patch @@ -1,15 +1,5 @@ --- a/net/minecraft/server/players/OldUsersConverter.java +++ b/net/minecraft/server/players/OldUsersConverter.java -@@ -20,6 +_,9 @@ - import java.util.UUID; - import javax.annotation.Nullable; - import net.minecraft.core.UUIDUtil; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.nbt.NbtAccounter; -+import net.minecraft.nbt.NbtIo; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.dedicated.DedicatedServer; - import net.minecraft.util.StringUtil; @@ -49,7 +_,8 @@ private static void lookupPlayers(MinecraftServer server, Collection names, ProfileLookupCallback callback) { @@ -61,10 +51,10 @@ File file4 = new File(worldPlayersDirectory, oldFileName + ".dat"); File file5 = new File(file3, newFileName + ".dat"); + // CraftBukkit start - Use old file name to seed lastKnownName -+ CompoundTag root = null; ++ net.minecraft.nbt.CompoundTag root = null; + + try { -+ root = NbtIo.readCompressed(new java.io.FileInputStream(file4), NbtAccounter.unlimitedHeap()); ++ root = net.minecraft.nbt.NbtIo.readCompressed(new java.io.FileInputStream(file4), net.minecraft.nbt.NbtAccounter.unlimitedHeap()); + } catch (Exception exception) { + // Paper start + io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(exception); @@ -75,13 +65,13 @@ + + if (root != null) { + if (!root.contains("bukkit")) { -+ root.put("bukkit", new CompoundTag()); ++ root.put("bukkit", new net.minecraft.nbt.CompoundTag()); + } -+ CompoundTag data = root.getCompound("bukkit"); ++ net.minecraft.nbt.CompoundTag data = root.getCompoundOrEmpty("bukkit"); + data.putString("lastKnownName", oldFileName); + + try { -+ NbtIo.writeCompressed(root, new java.io.FileOutputStream(file1)); ++ net.minecraft.nbt.NbtIo.writeCompressed(root, new java.io.FileOutputStream(file1)); + } catch (Exception exception) { + // Paper start + io.papermc.paper.util.StacktraceDeobfuscator.INSTANCE.deobfuscateThrowable(exception); diff --git a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch index 43fe40f3c..114e7eac7 100644 --- a/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch +++ b/paper-server/patches/sources/net/minecraft/server/players/PlayerList.java.patch @@ -47,7 +47,7 @@ GameProfile gameProfile = player.getGameProfile(); GameProfileCache profileCache = this.server.getProfileCache(); String string; -@@ -150,30 +_,93 @@ +@@ -150,30 +_,94 @@ } Optional optional = this.load(player); @@ -55,11 +55,7 @@ - compoundTag -> DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, compoundTag.get("Dimension"))).resultOrPartial(LOGGER::error) + // CraftBukkit start - Better rename detection + if (optional.isPresent()) { -+ CompoundTag nbttagcompound = optional.get(); -+ if (nbttagcompound.contains("bukkit")) { -+ CompoundTag bukkit = nbttagcompound.getCompound("bukkit"); -+ string = bukkit.contains("lastKnownName", 8) ? bukkit.getString("lastKnownName") : string; -+ } ++ string = optional.flatMap(t -> t.getCompound("bukkit")).flatMap(t -> t.getString("lastKnownName")).orElse(string); + } + // CraftBukkit end + // Paper start - move logic in Entity to here, to use bukkit supplied world UUID & reset to main world spawn if no valid world is found @@ -68,10 +64,15 @@ + bukkitData: if (optional.isPresent()) { + // The main way for bukkit worlds to store the world is the world UUID despite mojang adding custom worlds + final org.bukkit.World bWorld; -+ if (optional.get().contains("WorldUUIDMost") && optional.get().contains("WorldUUIDLeast")) { -+ bWorld = org.bukkit.Bukkit.getServer().getWorld(new UUID(optional.get().getLong("WorldUUIDMost"), optional.get().getLong("WorldUUIDLeast"))); -+ } else if (optional.get().contains("world", net.minecraft.nbt.Tag.TAG_STRING)) { // Paper - legacy bukkit world name -+ bWorld = org.bukkit.Bukkit.getServer().getWorld(optional.get().getString("world")); ++ final CompoundTag playerData = optional.get(); ++ // TODO maybe convert this to a codec and use compoundTag#read, we need silent variants of that method first. ++ final Optional worldUUIDMost = playerData.getLong("WorldUUIDMost"); ++ final Optional worldUUIDLeast = playerData.getLong("WorldUUIDLeast"); ++ final java.util.Optional worldName = playerData.getString("world"); ++ if (worldUUIDMost.isPresent() && worldUUIDLeast.isPresent()) { ++ bWorld = org.bukkit.Bukkit.getServer().getWorld(new UUID(worldUUIDMost.get(), worldUUIDLeast.get())); ++ } else if (worldName.isPresent()) { // Paper - legacy bukkit world name ++ bWorld = org.bukkit.Bukkit.getServer().getWorld(worldName.get()); + } else { + break bukkitData; // if neither of the bukkit data points exist, proceed to the vanilla migration section + } @@ -113,7 +114,7 @@ + } + if (optional.isEmpty() || invalidPlayerWorld[0]) { + // Paper end - reset to main world spawn if first spawn or invalid world -+ player.moveTo(player.adjustSpawnLocation(serverLevel, serverLevel.getSharedSpawnPos()).getBottomCenter(), serverLevel.getSharedSpawnAngle(), 0.0F); // Paper - MC-200092 - fix first spawn pos yaw being ignored ++ player.snapTo(player.adjustSpawnLocation(serverLevel, serverLevel.getSharedSpawnPos()).getBottomCenter(), serverLevel.getSharedSpawnAngle(), 0.0F); // Paper - MC-200092 - fix first spawn pos yaw being ignored + } + // Paper end - Entity#getEntitySpawnReason player.setServerLevel(serverLevel); @@ -153,7 +154,7 @@ LevelData levelData = serverLevel.getLevelData(); player.loadGameTypes(optional.orElse(null)); ServerGamePacketListenerImpl serverGamePacketListenerImpl = new ServerGamePacketListenerImpl(this.server, connection, player, cookie); -@@ -190,8 +_,8 @@ +@@ -191,8 +_,8 @@ levelData.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), @@ -164,15 +165,15 @@ _boolean1, !_boolean, _boolean2, -@@ -199,6 +_,7 @@ +@@ -200,6 +_,7 @@ this.server.enforceSecureProfile() ) ); + player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit serverGamePacketListenerImpl.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverGamePacketListenerImpl.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); - serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected)); -@@ -218,24 +_,117 @@ + serverGamePacketListenerImpl.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); +@@ -219,26 +_,119 @@ mutableComponent = Component.translatable("multiplayer.player.joined.renamed", player.getDisplayName(), string); } @@ -201,8 +202,10 @@ - this.sendActivePlayerEffects(player); + this.server.getCustomBossEvents().onPlayerConnect(player); // see commented out section below serverLevel.addPlayerJoin(player); + // Paper end - Fire PlayerJoinEvent when Player is actually ready - player.loadAndSpawnEnderpearls(optional); - player.loadAndSpawnParentVehicle(optional); + optional.ifPresent(compoundTag -> { + player.loadAndSpawnEnderPearls(compoundTag); + player.loadAndSpawnParentVehicle(compoundTag); + }); + // CraftBukkit start + org.bukkit.craftbukkit.entity.CraftPlayer bukkitPlayer = player.getBukkitEntity(); + @@ -296,7 +299,7 @@ } public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) { -@@ -258,30 +_,31 @@ +@@ -261,30 +_,31 @@ } public void addWorldborderListener(ServerLevel level) { @@ -333,7 +336,7 @@ } @Override -@@ -309,56 +_,162 @@ +@@ -312,56 +_,156 @@ } protected void save(ServerPlayer player) { @@ -353,11 +356,11 @@ } - public void remove(ServerPlayer player) { -+ public net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component ++ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component + // Paper start - Fix kick event leave message not being sent + return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); + } -+ public net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { ++ public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + // Paper end - Fix kick event leave message not being sent ServerLevel serverLevel = player.serverLevel(); player.awardStat(Stats.LEAVE_GAME); @@ -469,28 +472,22 @@ - if (this.bans.isBanned(gameProfile)) { - UserBanListEntry userBanListEntry = this.bans.get(gameProfile); + // CraftBukkit start - Whole method, SocketAddress to LoginListener, added hostname to signature, return EntityPlayer -+ public ServerPlayer canPlayerLogin(net.minecraft.server.network.ServerLoginPacketListenerImpl loginlistener, GameProfile gameProfile) { ++ public @Nullable ServerPlayer canPlayerLogin(net.minecraft.server.network.ServerLoginPacketListenerImpl loginlistener, GameProfile gameProfile) { + // if (this.bans.isBanned(gameProfile)) { + // UserBanListEntry userBanListEntry = this.bans.get(gameProfile); -+ // Moved from processLogin ++ // Moved from disconnectAllPlayersWithProfile + UUID uuid = gameProfile.getId(); + List list = Lists.newArrayList(); + -+ ServerPlayer entityplayer; -+ -+ for (int i = 0; i < this.players.size(); ++i) { -+ entityplayer = (ServerPlayer) this.players.get(i); -+ if (entityplayer.getUUID().equals(uuid) || (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && entityplayer.getGameProfile().getName().equalsIgnoreCase(gameProfile.getName()))) { // Paper - validate usernames -+ list.add(entityplayer); ++ for (net.minecraft.server.level.ServerPlayer serverPlayer : this.players) { ++ if (serverPlayer.getUUID().equals(uuid) || (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() && serverPlayer.getGameProfile().getName().equalsIgnoreCase(gameProfile.getName()))) { // Paper - validate usernames ++ list.add(serverPlayer); + } + } + -+ java.util.Iterator iterator = list.iterator(); -+ -+ while (iterator.hasNext()) { -+ entityplayer = (ServerPlayer) iterator.next(); -+ this.save(entityplayer); // CraftBukkit - Force the player's inventory to be saved -+ entityplayer.connection.disconnect(Component.translatable("multiplayer.disconnect.duplicate_login"), org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause ++ for (final net.minecraft.server.level.ServerPlayer serverPlayer : list) { ++ this.save(serverPlayer); // CraftBukkit - Force the player's inventory to be saved ++ serverPlayer.connection.disconnect(DUPLICATE_LOGIN_DISCONNECT_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.DUPLICATE_LOGIN); // Paper - kick event cause + } + + // Instead of kicking then returning, we need to store the kick reason @@ -510,7 +507,7 @@ MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned.reason", userBanListEntry.getReason()); if (userBanListEntry.getExpires() != null) { mutableComponent.append( -@@ -366,10 +_,12 @@ +@@ -369,10 +_,12 @@ ); } @@ -527,7 +524,7 @@ IpBanListEntry ipBanListEntry = this.ipBans.get(socketAddress); MutableComponent mutableComponent = Component.translatable("multiplayer.disconnect.banned_ip.reason", ipBanListEntry.getReason()); if (ipBanListEntry.getExpires() != null) { -@@ -378,69 +_,129 @@ +@@ -381,69 +_,130 @@ ); } @@ -614,10 +611,11 @@ + } + + // CraftBukkit start -+ public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason) { ++ public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, @Nullable org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason) { + return this.respawn(player, keepInventory, reason, eventReason, null); + } -+ public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, org.bukkit.Location location) { ++ ++ public ServerPlayer respawn(ServerPlayer player, boolean keepInventory, Entity.RemovalReason reason, @Nullable org.bukkit.event.player.PlayerRespawnEvent.RespawnReason eventReason, @Nullable org.bukkit.Location location) { + player.stopRiding(); // CraftBukkit this.players.remove(player); + this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot @@ -665,7 +663,7 @@ + location = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(teleportTransition.position(), teleportTransition.newLevel().getWorld(), teleportTransition.yRot(), teleportTransition.xRot()); + // Paper end - Add PlayerPostRespawnEvent + } else { -+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); ++ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) location.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(location), Vec3.ZERO, location.getYaw(), location.getPitch(), TeleportTransition.DO_NOTHING); + } + // Spigot start + if (teleportTransition == null) { // Paper - Add PlayerPostRespawnEvent - diff on change - spigot early returns if respawn pos is null, that is how they handle disconnected player in respawn event @@ -677,13 +675,13 @@ + serverPlayer.unsetRemoved(); + serverPlayer.setShiftKeyDown(false); Vec3 vec3 = teleportTransition.position(); -- serverPlayer.moveTo(vec3.x, vec3.y, vec3.z, teleportTransition.yRot(), teleportTransition.xRot()); +- serverPlayer.snapTo(vec3.x, vec3.y, vec3.z, teleportTransition.yRot(), teleportTransition.xRot()); + serverPlayer.forceSetPositionRotation(vec3.x, vec3.y, vec3.z, teleportTransition.yRot(), teleportTransition.xRot()); -+ level.getChunkSource().addRegionTicket(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3.x()) >> 4, net.minecraft.util.Mth.floor(vec3.z()) >> 4), 1, player.getId()); // Paper - post teleport ticket type ++ level.getChunkSource().addTicketWithRadius(net.minecraft.server.level.TicketType.POST_TELEPORT, new net.minecraft.world.level.ChunkPos(net.minecraft.util.Mth.floor(vec3.x()) >> 4, net.minecraft.util.Mth.floor(vec3.z()) >> 4), 1); // Paper - post teleport ticket type + // CraftBukkit end if (teleportTransition.missingRespawnBlock()) { serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.NO_RESPAWN_BLOCK_AVAILABLE, 0.0F)); -+ serverPlayer.setRespawnPosition(null, null, 0f, false, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent ++ serverPlayer.setRespawnPosition(null, false, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.PLAYER_RESPAWN); // CraftBukkit - SPIGOT-5988: Clear respawn location when obstructed // Paper - PlayerSetSpawnEvent } byte b = (byte)(keepInventory ? 1 : 0); @@ -698,7 +696,7 @@ serverPlayer.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getSharedSpawnPos(), level.getSharedSpawnAngle())); serverPlayer.connection.send(new ClientboundChangeDifficultyPacket(levelData.getDifficulty(), levelData.isDifficultyLocked())); serverPlayer.connection -@@ -448,10 +_,13 @@ +@@ -451,10 +_,13 @@ this.sendActivePlayerEffects(serverPlayer); this.sendLevelInfo(serverPlayer, level); this.sendPlayerPermissionLevel(serverPlayer); @@ -714,19 +712,19 @@ + } + // serverPlayer.initInventoryMenu(); serverPlayer.setHealth(serverPlayer.getHealth()); - BlockPos respawnPosition = serverPlayer.getRespawnPosition(); - ServerLevel level1 = this.server.getLevel(serverPlayer.getRespawnDimension()); -@@ -472,7 +_,40 @@ - ) - ); + ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); + if (!keepInventory && respawnConfig != null) { +@@ -477,8 +_,41 @@ + ) + ); + } ++ // Paper start - Add PlayerPostRespawnEvent ++ if (blockState.is(net.minecraft.tags.BlockTags.BEDS) && !teleportTransition.missingRespawnBlock()) { ++ isBedSpawn = true; ++ } ++ // Paper end - Add PlayerPostRespawnEvent } -- } -+ // Paper start - Add PlayerPostRespawnEvent -+ if (blockState.is(net.minecraft.tags.BlockTags.BEDS) && !teleportTransition.missingRespawnBlock()) { -+ isBedSpawn = true; -+ } -+ // Paper end - Add PlayerPostRespawnEvent -+ } + } + // Added from changeDimension + this.sendAllPlayerInfo(player); // Update health, etc... + player.onUpdateAbilities(); @@ -758,7 +756,7 @@ return serverPlayer; } -@@ -482,24 +_,60 @@ +@@ -488,24 +_,60 @@ } public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) { @@ -822,19 +820,20 @@ public void broadcastAll(Packet packet) { for (ServerPlayer serverPlayer : this.players) { serverPlayer.connection.send(packet); -@@ -575,6 +_,11 @@ +@@ -581,6 +_,12 @@ } private void sendPlayerPermissionLevel(ServerPlayer player, int permLevel) { + // Paper start - Add sendOpLevel API + this.sendPlayerPermissionLevel(player, permLevel, true); + } ++ + public void sendPlayerPermissionLevel(ServerPlayer player, int permLevel, boolean recalculatePermissions) { + // Paper end - Add sendOpLevel API if (player.connection != null) { byte b; if (permLevel <= 0) { -@@ -588,11 +_,32 @@ +@@ -594,11 +_,33 @@ player.connection.send(new ClientboundEntityEventPacket(player, b)); } @@ -849,6 +848,7 @@ + // Paper start - ProfileWhitelistVerifyEvent + return this.isWhiteListed(profile, null); + } ++ + public boolean isWhiteListed(GameProfile gameprofile, @Nullable org.bukkit.event.player.PlayerLoginEvent loginEvent) { + boolean isOp = this.ops.contains(gameprofile); + boolean isWhitelisted = !this.doWhiteList || isOp || this.whitelist.contains(gameprofile); @@ -868,7 +868,7 @@ } public boolean isOp(GameProfile profile) { -@@ -603,21 +_,17 @@ +@@ -609,21 +_,17 @@ @Nullable public ServerPlayer getPlayerByName(String username) { @@ -896,7 +896,7 @@ if (serverPlayer != except && serverPlayer.level().dimension() == dimension) { double d = x - serverPlayer.getX(); double d1 = y - serverPlayer.getY(); -@@ -630,9 +_,11 @@ +@@ -636,9 +_,11 @@ } public void saveAll() { @@ -908,7 +908,7 @@ } public UserWhiteList getWhiteList() { -@@ -655,14 +_,18 @@ +@@ -661,14 +_,18 @@ } public void sendLevelInfo(ServerPlayer player, ServerLevel level) { @@ -931,7 +931,7 @@ } player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LEVEL_CHUNKS_LOAD_START, 0.0F)); -@@ -671,8 +_,21 @@ +@@ -677,8 +_,21 @@ public void sendAllPlayerInfo(ServerPlayer player) { player.inventoryMenu.sendAllDataToRemote(); @@ -944,7 +944,7 @@ + player.connection.send(new net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket(player.getId(), syncableAttributes)); + // Paper end - send all attributes + player.refreshEntityData(player); // CraftBukkit - SPIGOT-7218: sync metadata - player.connection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected)); + player.connection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); + // CraftBukkit start - from GameRules + int i = player.serverLevel().getGameRules().getBoolean(GameRules.RULE_REDUCEDDEBUGINFO) ? 22 : 23; + player.connection.send(new ClientboundEntityEventPacket(player, (byte) i)); @@ -954,7 +954,7 @@ } public int getPlayerCount() { -@@ -688,6 +_,7 @@ +@@ -694,6 +_,7 @@ } public void setUsingWhiteList(boolean whitelistEnabled) { @@ -962,7 +962,7 @@ this.doWhiteList = whitelistEnabled; } -@@ -725,10 +_,35 @@ +@@ -731,10 +_,35 @@ } public void removeAll() { @@ -1002,7 +1002,7 @@ public void broadcastSystemMessage(Component message, boolean bypassHiddenChat) { this.broadcastSystemMessage(message, serverPlayer -> message, bypassHiddenChat); -@@ -750,20 +_,39 @@ +@@ -756,20 +_,39 @@ } public void broadcastChatMessage(PlayerChatMessage message, ServerPlayer sender, ChatType.Bound boundChatType) { @@ -1045,12 +1045,7 @@ flag1 |= flag2 && message.isFullyFiltered(); } -@@ -772,18 +_,25 @@ - } - } - -- private boolean verifyChatTrusted(PlayerChatMessage message) { -+ public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public +@@ -782,14 +_,21 @@ return message.hasSignature() && !message.hasExpiredServer(Instant.now()); } @@ -1076,7 +1071,7 @@ Path path = file2.toPath(); if (FileUtil.isPathNormalized(path) && FileUtil.isPathPortable(path) && path.startsWith(file.getPath()) && file2.isFile()) { file2.renameTo(file1); -@@ -791,7 +_,7 @@ +@@ -797,7 +_,7 @@ } serverStatsCounter = new ServerStatsCounter(this.server, file1); @@ -1085,7 +1080,7 @@ } return serverStatsCounter; -@@ -799,11 +_,11 @@ +@@ -805,11 +_,11 @@ public PlayerAdvancements getPlayerAdvancements(ServerPlayer player) { UUID uuid = player.getUUID(); @@ -1099,7 +1094,7 @@ } playerAdvancements.setPlayer(player); -@@ -846,11 +_,34 @@ +@@ -852,11 +_,34 @@ } public void reloadResources() { @@ -1118,7 +1113,7 @@ + // } + for (ServerPlayer player : this.players) { + player.getAdvancements().reload(this.server.getAdvancements()); -+ player.getAdvancements().flushDirty(player); // CraftBukkit - trigger immediate flush of advancements ++ player.getAdvancements().flushDirty(player, false); // CraftBukkit - trigger immediate flush of advancements } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerRecipeBook.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerRecipeBook.java.patch index d289aee48..852ce031d 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerRecipeBook.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerRecipeBook.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/stats/ServerRecipeBook.java +++ b/net/minecraft/stats/ServerRecipeBook.java -@@ -67,7 +_,7 @@ +@@ -66,7 +_,7 @@ for (RecipeHolder recipeHolder : recipes) { ResourceKey> resourceKey = recipeHolder.id(); @@ -9,7 +9,7 @@ this.add(resourceKey); this.addHighlight(resourceKey); this.displayResolver -@@ -78,7 +_,7 @@ +@@ -77,7 +_,7 @@ } } @@ -18,7 +18,7 @@ player.connection.send(new ClientboundRecipeBookAddPacket(list, false)); } -@@ -96,7 +_,7 @@ +@@ -95,7 +_,7 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch index 4d4c9288f..d52fd871f 100644 --- a/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch +++ b/paper-server/patches/sources/net/minecraft/stats/ServerStatsCounter.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/stats/ServerStatsCounter.java +++ b/net/minecraft/stats/ServerStatsCounter.java -@@ -51,9 +_,21 @@ +@@ -70,9 +_,21 @@ LOGGER.error("Couldn't parse statistics file {}", file, var5); } } @@ -9,8 +9,8 @@ + // Disables saving any forced stats, so it stays at the same value (without enabling disableStatSaving) + // Fixes stat initialization to not cause a NullPointerException + // Spigot start -+ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { -+ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats ++ for (Map.Entry entry : org.spigotmc.SpigotConfig.forcedStats.entrySet()) { ++ Stat wrapper = Stats.CUSTOM.get(java.util.Objects.requireNonNull(BuiltInRegistries.CUSTOM_STAT.getValue(entry.getKey()))); // Paper - ensured by SpigotConfig#stats + this.stats.put(wrapper, entry.getValue().intValue()); + } + // Spigot end @@ -22,12 +22,12 @@ try { FileUtils.writeStringToFile(this.file, this.toJson()); } catch (IOException var2) { -@@ -63,6 +_,8 @@ +@@ -82,6 +_,8 @@ @Override public void setValue(Player player, Stat stat, int i) { + if (org.spigotmc.SpigotConfig.disableStatSaving) return; // Spigot -+ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final ResourceLocation resourceLocation && org.spigotmc.SpigotConfig.forcedStats.get(resourceLocation) != null) return; // Paper - disable saving forced stats ++ if (stat.getType() == Stats.CUSTOM && stat.getValue() instanceof final net.minecraft.resources.ResourceLocation resourceLocation && org.spigotmc.SpigotConfig.forcedStats.get(resourceLocation) != null) return; // Paper - disable saving forced stats super.setValue(player, stat, i); this.dirty.add(stat); } diff --git a/paper-server/patches/sources/net/minecraft/util/SpawnUtil.java.patch b/paper-server/patches/sources/net/minecraft/util/SpawnUtil.java.patch index 89419f5c2..f28bb2f44 100644 --- a/paper-server/patches/sources/net/minecraft/util/SpawnUtil.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/SpawnUtil.java.patch @@ -39,7 +39,7 @@ )) { + // Paper start - PreCreatureSpawnEvent + final com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(level, pos), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), + org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entityType), + reason + ); diff --git a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch index 5c13ab781..7f97d57b1 100644 --- a/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/datafix/DataFixers.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/util/datafix/DataFixers.java +++ b/net/minecraft/util/datafix/DataFixers.java -@@ -505,6 +_,18 @@ +@@ -541,6 +_,18 @@ Schema schema44 = builder.addSchema(1456, SAME_NAMESPACED); builder.addFixer(new EntityItemFrameDirectionFix(schema44, false)); - Schema schema45 = builder.addSchema(1458, SAME_NAMESPACED); + Schema schema45 = builder.addSchema(1458, V1458::new); + // CraftBukkit start + builder.addFixer(new com.mojang.datafixers.DataFix(schema45, false) { + @Override + protected com.mojang.datafixers.TypeRewriteRule makeRule() { + return this.fixTypeEverywhereTyped("Player CustomName", this.getInputSchema().getType(References.PLAYER), (typed) -> { + return typed.update(DSL.remainderFinder(), (dynamic) -> { -+ return EntityCustomNameToComponentFix.fixTagCustomName(dynamic); ++ return EntityCustomNameToComponentFix.fixCustomName(dynamic.getOps(), dynamic.get("CustomName").asString(""), "minecraft:player"); + }); + }); + } + }); + // CraftBukkit end - builder.addFixer(new EntityCustomNameToComponentFix(schema45, false)); - builder.addFixer(new ItemCustomNameToComponentFix(schema45, false)); - builder.addFixer(new BlockEntityCustomNameToComponentFix(schema45, false)); + builder.addFixer(new EntityCustomNameToComponentFix(schema45)); + builder.addFixer(new ItemCustomNameToComponentFix(schema45)); + builder.addFixer(new BlockEntityCustomNameToComponentFix(schema45)); diff --git a/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch new file mode 100644 index 000000000..f2f1d5f3a --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/util/parsing/packrat/Scope.java.patch @@ -0,0 +1,39 @@ +--- a/net/minecraft/util/parsing/packrat/Scope.java ++++ b/net/minecraft/util/parsing/packrat/Scope.java +@@ -281,4 +_,36 @@ + + return true; + } ++ ++ // Paper start - track depth ++ private int depth; ++ @SuppressWarnings({"unchecked","rawtypes"}) ++ public static Term increaseDepth() { ++ class IncreasingDepthTerm implements Term { ++ public static final IncreasingDepthTerm INSTANCE = new IncreasingDepthTerm(); ++ @Override ++ public boolean parse(final ParseState parseState, final Scope scope, final Control control) { ++ if (++scope.depth > 512) { ++ parseState.errorCollector().store(parseState.mark(), new IllegalStateException("Too deep")); ++ return false; ++ } ++ return true; ++ } ++ } ++ return (Term) IncreasingDepthTerm.INSTANCE; ++ } ++ ++ @SuppressWarnings({"unchecked","rawtypes"}) ++ public static Term decreaseDepth() { ++ class DecreasingDepthTerm implements Term { ++ public static final DecreasingDepthTerm INSTANCE = new DecreasingDepthTerm(); ++ @Override ++ public boolean parse(final ParseState parseState, final Scope scope, final Control control) { ++ scope.depth--; ++ return true; ++ } ++ } ++ return (Term) DecreasingDepthTerm.INSTANCE; ++ } ++ // Paper end - track depth + } diff --git a/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch new file mode 100644 index 000000000..7997b5948 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/util/random/WeightedList.java.patch @@ -0,0 +1,28 @@ +--- a/net/minecraft/util/random/WeightedList.java ++++ b/net/minecraft/util/random/WeightedList.java +@@ -13,14 +_,14 @@ + import net.minecraft.util.ExtraCodecs; + import net.minecraft.util.RandomSource; + +-public final class WeightedList { ++public class WeightedList { // Paper - non-final + private static final int FLAT_THRESHOLD = 64; + private final int totalWeight; + private final List> items; + @Nullable + private final WeightedList.Selector selector; + +- WeightedList(List> items) { ++ protected WeightedList(List> items) { // Paper - protected + this.items = List.copyOf(items); + this.totalWeight = WeightedRandom.getTotalWeight(items, Weighted::weight); + if (this.totalWeight == 0) { +@@ -122,7 +_,7 @@ + } + + public static class Builder { +- private final ImmutableList.Builder> result = ImmutableList.builder(); ++ protected final ImmutableList.Builder> result = ImmutableList.builder(); + + public WeightedList.Builder add(E element) { + return this.add(element, 1); diff --git a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch index ac9d8ccac..31132f35d 100644 --- a/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/util/worldupdate/WorldUpgrader.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/util/worldupdate/WorldUpgrader.java +++ b/net/minecraft/util/worldupdate/WorldUpgrader.java -@@ -79,7 +_,7 @@ - LevelStorageSource.LevelStorageAccess levelStorage, DataFixer dataFixer, RegistryAccess registryAccess, boolean eraseCache, boolean recreateRegionFiles +@@ -87,7 +_,7 @@ + boolean recreateRegionFiles ) { this.dimensions = registryAccess.lookupOrThrow(Registries.LEVEL_STEM); - this.levels = this.dimensions.registryKeySet().stream().map(Registries::levelStemToLevel).collect(Collectors.toUnmodifiableSet()); @@ -9,12 +9,12 @@ this.eraseCache = eraseCache; this.dataFixer = dataFixer; this.levelStorage = levelStorage; -@@ -358,7 +_,7 @@ +@@ -369,7 +_,7 @@ int version = ChunkStorage.getVersion(compoundTag); ChunkGenerator chunkGenerator = WorldUpgrader.this.dimensions.getValueOrThrow(Registries.levelToLevelStem(dimension)).generator(); CompoundTag compoundTag1 = chunkStorage.upgradeChunkTag( - dimension, () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer() + Registries.levelToLevelStem(dimension), () -> WorldUpgrader.this.overworldDataStorage, compoundTag, chunkGenerator.getTypeNameForDataFixer(), chunkPos, null // CraftBukkit ); - ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getInt("xPos"), compoundTag1.getInt("zPos")); + ChunkPos chunkPos1 = new ChunkPos(compoundTag1.getIntOr("xPos", 0), compoundTag1.getIntOr("zPos", 0)); if (!chunkPos1.equals(chunkPos)) { diff --git a/paper-server/patches/sources/net/minecraft/world/BossEvent.java.patch b/paper-server/patches/sources/net/minecraft/world/BossEvent.java.patch index ae696def4..6d4cf0bfa 100644 --- a/paper-server/patches/sources/net/minecraft/world/BossEvent.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/BossEvent.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/BossEvent.java +++ b/net/minecraft/world/BossEvent.java -@@ -13,6 +_,7 @@ +@@ -15,6 +_,7 @@ protected boolean darkenScreen; protected boolean playBossMusic; protected boolean createWorldFog; @@ -8,7 +8,7 @@ public BossEvent(UUID id, Component name, BossEvent.BossBarColor color, BossEvent.BossBarOverlay overlay) { this.id = id; -@@ -27,61 +_,75 @@ +@@ -29,61 +_,75 @@ } public Component getName() { diff --git a/paper-server/patches/sources/net/minecraft/world/CompoundContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/CompoundContainer.java.patch index cf4dc6087..f64d64c82 100644 --- a/paper-server/patches/sources/net/minecraft/world/CompoundContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/CompoundContainer.java.patch @@ -1,12 +1,13 @@ --- a/net/minecraft/world/CompoundContainer.java +++ b/net/minecraft/world/CompoundContainer.java -@@ -7,6 +_,48 @@ +@@ -7,6 +_,53 @@ public final Container container1; public final Container container2; + // CraftBukkit start - add fields and methods + public java.util.List transaction = new java.util.ArrayList<>(); + ++ @Override + public java.util.List getContents() { + java.util.List result = new java.util.ArrayList<>(this.getContainerSize()); + for (int i = 0; i < this.getContainerSize(); i++) { @@ -15,23 +16,27 @@ + return result; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.container1.onOpen(player); + this.container2.onOpen(player); + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.container1.onClose(player); + this.container2.onClose(player); + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ @Override ++ public @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner() { + return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here + } + diff --git a/paper-server/patches/sources/net/minecraft/world/Container.java.patch b/paper-server/patches/sources/net/minecraft/world/Container.java.patch index e86d0c9b2..fc961086e 100644 --- a/paper-server/patches/sources/net/minecraft/world/Container.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/Container.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -24,9 +_,7 @@ +@@ -26,9 +_,7 @@ void setItem(int slot, ItemStack stack); @@ -11,9 +11,9 @@ default int getMaxStackSize(ItemStack stack) { return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); -@@ -87,4 +_,22 @@ - BlockPos blockPos = blockEntity.getBlockPos(); - return level != null && level.getBlockEntity(blockPos) == blockEntity && player.canInteractWithBlock(blockPos, distance); +@@ -117,4 +_,22 @@ + } + } } + + // CraftBukkit start @@ -25,11 +25,11 @@ + + java.util.List getViewers(); + -+ org.bukkit.inventory.@org.jetbrains.annotations.Nullable InventoryHolder getOwner(); ++ @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner(); + + void setMaxStackSize(int size); + -+ org.bukkit.Location getLocation(); ++ @javax.annotation.Nullable org.bukkit.Location getLocation(); + + int MAX_STACK = Item.ABSOLUTE_MAX_STACK_SIZE; + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch index 1f4c7b850..4e15d4eed 100644 --- a/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/RandomizableContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/RandomizableContainer.java +++ b/net/minecraft/world/RandomizableContainer.java -@@ -28,7 +_,7 @@ +@@ -26,7 +_,7 @@ void setLootTable(@Nullable ResourceKey lootTable); @@ -9,30 +9,21 @@ this.setLootTable(lootTable); this.setLootTableSeed(seed); } -@@ -50,15 +_,17 @@ - +@@ -49,8 +_,9 @@ default boolean tryLoadLootTable(CompoundTag tag) { - if (tag.contains("LootTable", 8)) { -- this.setLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString("LootTable")))); -+ this.setLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(tag.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation -+ if (this.lootableData() != null && this.getLootTable() != null) this.lootableData().loadNbt(tag); // Paper - LootTable API - if (tag.contains("LootTableSeed", 4)) { - this.setLootTableSeed(tag.getLong("LootTableSeed")); - } else { - this.setLootTableSeed(0L); - } - -- return true; -+ return this.lootableData() == null; // Paper - only track the loot table if there is chance for replenish - } else { -+ setLootTable(null); // Paper - Fix removing loottable from nbt not updating block entity, MC-279196 - return false; - } + ResourceKey resourceKey = tag.read("LootTable", LootTable.KEY_CODEC).orElse(null); + this.setLootTable(resourceKey); ++ if (this.lootableData() != null && resourceKey != null) this.lootableData().loadNbt(tag); // Paper - LootTable API + this.setLootTableSeed(tag.getLongOr("LootTableSeed", 0L)); +- return resourceKey != null; ++ return resourceKey != null && this.lootableData() == null; // Paper - only track the loot table if there is chance for replenish } -@@ -69,26 +_,42 @@ + + default boolean trySaveLootTable(CompoundTag tag) { +@@ -59,26 +_,42 @@ return false; } else { - tag.putString("LootTable", lootTable.location().toString()); + tag.store("LootTable", LootTable.KEY_CODEC, lootTable); + if (this.lootableData() != null) this.lootableData().saveNbt(tag); // Paper - LootTable API long lootTableSeed = this.getLootTableSeed(); if (lootTableSeed != 0L) { @@ -74,7 +65,7 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)level).withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(blockPos)); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -97,4 +_,17 @@ +@@ -87,4 +_,17 @@ lootTable1.fill(this, builder.create(LootContextParamSets.CHEST), this.getLootTableSeed()); } } diff --git a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch index 7fe606258..893e6c974 100644 --- a/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/SimpleContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/SimpleContainer.java +++ b/net/minecraft/world/SimpleContainer.java -@@ -19,7 +_,84 @@ +@@ -19,7 +_,90 @@ @Nullable private List listeners; @@ -9,18 +9,22 @@ + private int maxStack = MAX_STACK; + protected @Nullable org.bukkit.inventory.InventoryHolder bukkitOwner; // Paper - annotation + ++ @Override + public List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public List getViewers() { + return this.transaction; + } @@ -30,11 +34,13 @@ + return this.maxStack; + } + -+ public void setMaxStackSize(int i) { -+ this.maxStack = i; ++ @Override ++ public void setMaxStackSize(int size) { ++ this.maxStack = size; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ @Override ++ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.bukkitOwner == null && this.bukkitOwnerCreator != null) { + this.bukkitOwner = this.bukkitOwnerCreator.get(); @@ -44,7 +50,7 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + // Paper start - Fix inventories returning null Locations + // When the block inventory does not have a tile state that implements getLocation, e. g. composters + if (this.bukkitOwner instanceof org.bukkit.inventory.BlockInventoryHolder blockInventoryHolder) { @@ -79,7 +85,7 @@ + } + // Paper end - Add missing InventoryHolders + -+ public SimpleContainer(int size, org.bukkit.inventory.InventoryHolder owner) { ++ public SimpleContainer(int size, @Nullable org.bukkit.inventory.InventoryHolder owner) { + this.bukkitOwner = owner; + // Paper end this.size = size; diff --git a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch index d530c5c2c..dc1afa471 100644 --- a/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/damagesource/DamageSource.java.patch @@ -45,7 +45,7 @@ + return this.eventBlockDamager; + } + -+ public DamageSource eventBlockDamager(final @Nullable net.minecraft.world.level.LevelAccessor level, final @Nullable net.minecraft.core.BlockPos pos) { ++ public DamageSource eventBlockDamager(final net.minecraft.world.level.LevelAccessor level, final @Nullable net.minecraft.core.BlockPos pos) { + if (pos == null) { + return this; + } @@ -60,7 +60,7 @@ + return this.fromBlockSnapshot; + } + -+ public DamageSource causingBlockSnapshot(final @Nullable org.bukkit.block.BlockState blockState) { ++ public DamageSource causingBlockSnapshot(final org.bukkit.block.BlockState blockState) { + if (this.eventBlockDamager != null) { + throw new IllegalStateException("Cannot set a block snapshot when an event block damager is already set (report a bug to Paper)"); + } diff --git a/paper-server/patches/sources/net/minecraft/world/effect/InfestedMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/InfestedMobEffect.java.patch index 05442e740..b7ef4b139 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/InfestedMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/InfestedMobEffect.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/effect/InfestedMobEffect.java @@ -44,7 +_,11 @@ Vector3f vector3f = entity.getLookAngle().toVector3f().mul(0.3F).mul(1.0F, 1.5F, 1.0F).rotateY(f1); - silverfish.moveTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F); + silverfish.snapTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F); silverfish.setDeltaMovement(new Vec3(vector3f)); - level.addFreshEntity(silverfish); + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch index 20dfc7fa7..b131cd898 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffect.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/effect/MobEffect.java +++ b/net/minecraft/world/effect/MobEffect.java -@@ -76,6 +_,7 @@ +@@ -86,6 +_,7 @@ public void applyInstantenousEffect( ServerLevel level, @Nullable Entity source, @Nullable Entity indirectSource, LivingEntity entity, int amplifier, double health ) { diff --git a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch index 25df61219..7743e56b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/MobEffectInstance.java.patch @@ -1,14 +1,15 @@ --- a/net/minecraft/world/effect/MobEffectInstance.java +++ b/net/minecraft/world/effect/MobEffectInstance.java -@@ -216,6 +_,7 @@ +@@ -219,7 +_,7 @@ + return false; + } else { int i = this.isInfiniteDuration() ? entity.tickCount : this.duration; - if (entity.level() instanceof ServerLevel serverLevel - && this.effect.value().shouldApplyEffectTickThisTick(i, this.amplifier) -+ && new io.papermc.paper.event.entity.EntityEffectTickEvent(entity.getBukkitLivingEntity(), org.bukkit.craftbukkit.potion.CraftPotionEffectType.minecraftHolderToBukkit(this.effect), this.amplifier).callEvent() // Paper - Add EntityEffectTickEvent - && !this.effect.value().applyEffectTick(serverLevel, entity, this.amplifier)) { - entity.removeEffect(this.effect); - } -@@ -408,7 +_,7 @@ +- if (this.effect.value().shouldApplyEffectTickThisTick(i, this.amplifier) && !this.effect.value().applyEffectTick(level, entity, this.amplifier)) { ++ if (this.effect.value().shouldApplyEffectTickThisTick(i, this.amplifier) && new io.papermc.paper.event.entity.EntityEffectTickEvent(entity.getBukkitLivingEntity(), org.bukkit.craftbukkit.potion.CraftPotionEffectType.minecraftHolderToBukkit(this.effect), this.amplifier).callEvent() && !this.effect.value().applyEffectTick(level, entity, this.amplifier)) { // Paper - Add EntityEffectTickEvent + return false; + } else { + this.tickDownDuration(); +@@ -415,7 +_,7 @@ .apply(instance, MobEffectInstance.Details::create) ) ); @@ -17,7 +18,7 @@ codec -> StreamCodec.composite( ByteBufCodecs.VAR_INT, MobEffectInstance.Details::amplifier, -@@ -420,7 +_,7 @@ +@@ -427,7 +_,7 @@ MobEffectInstance.Details::showParticles, ByteBufCodecs.BOOL, MobEffectInstance.Details::showIcon, diff --git a/paper-server/patches/sources/net/minecraft/world/effect/OozingMobEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/effect/OozingMobEffect.java.patch index 33ed7473e..68b136c0d 100644 --- a/paper-server/patches/sources/net/minecraft/world/effect/OozingMobEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/effect/OozingMobEffect.java.patch @@ -3,7 +3,7 @@ @@ -49,7 +_,7 @@ if (slime != null) { slime.setSize(2, true); - slime.moveTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F); + slime.snapTo(x, y, z, level.getRandom().nextFloat() * 360.0F, 0.0F); - level.addFreshEntity(slime); + level.addFreshEntity(slime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.POTION_EFFECT); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch index a0e42a63d..9fc83b1d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AgeableMob.java.patch @@ -1,22 +1,31 @@ --- a/net/minecraft/world/entity/AgeableMob.java +++ b/net/minecraft/world/entity/AgeableMob.java -@@ -20,6 +_,7 @@ - protected int age; - protected int forcedAge; +@@ -22,6 +_,7 @@ + protected int age = 0; + protected int forcedAge = 0; protected int forcedAgeTimer; + public boolean ageLocked; // CraftBukkit protected AgeableMob(EntityType entityType, Level level) { super(entityType, level); -@@ -66,6 +_,7 @@ +@@ -68,13 +_,15 @@ } public void ageUp(int amount, boolean forced) { + if (this.ageLocked) return; // Paper - Honor ageLock int age = this.getAge(); ++ int previousAge = age; // Paper - Decompile fix: lvt reassignment lost age += amount * 20; if (age > 0) { -@@ -104,6 +_,7 @@ + age = 0; + } + +- int i1 = age - age; ++ int i1 = age - previousAge; // Paper - Decompile fix + this.setAge(age); + if (forced) { + this.forcedAge += i1; +@@ -106,6 +_,7 @@ super.addAdditionalSaveData(compound); compound.putInt("Age", this.getAge()); compound.putInt("ForcedAge", this.forcedAge); @@ -24,15 +33,15 @@ } @Override -@@ -111,6 +_,7 @@ +@@ -113,6 +_,7 @@ super.readAdditionalSaveData(compound); - this.setAge(compound.getInt("Age")); - this.forcedAge = compound.getInt("ForcedAge"); -+ this.ageLocked = compound.getBoolean("AgeLocked"); // CraftBukkit + this.setAge(compound.getIntOr("Age", 0)); + this.forcedAge = compound.getIntOr("ForcedAge", 0); ++ this.ageLocked = compound.getBooleanOr("AgeLocked", false); // CraftBukkit } @Override -@@ -125,7 +_,7 @@ +@@ -127,7 +_,7 @@ @Override public void aiStep() { super.aiStep(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch index ae128ef1a..439fa947c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/AreaEffectCloud.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/entity/AreaEffectCloud.java +++ b/net/minecraft/world/entity/AreaEffectCloud.java -@@ -47,7 +_,7 @@ - public float radiusOnUse; - public float radiusPerTick; +@@ -59,7 +_,7 @@ + public float radiusOnUse = 0.0F; + public float radiusPerTick = 0.0F; @Nullable - private LivingEntity owner; + private net.minecraft.world.entity.LivingEntity owner; @Nullable public UUID ownerUUID; -@@ -177,7 +_,7 @@ +@@ -193,7 +_,7 @@ private void serverTick(ServerLevel level) { - if (this.tickCount >= this.waitTime + this.duration) { + if (this.duration != -1 && this.tickCount >= this.waitTime + this.duration) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { boolean isWaiting = this.isWaiting(); boolean flag = this.tickCount < this.waitTime; -@@ -190,7 +_,7 @@ +@@ -206,7 +_,7 @@ if (this.radiusPerTick != 0.0F) { radius += this.radiusPerTick; if (radius < 0.5F) { @@ -27,15 +27,15 @@ return; } -@@ -220,6 +_,7 @@ - list.addAll(this.potionContents.customEffects()); +@@ -222,6 +_,7 @@ + this.potionContents.forEachEffect(list::add, this.potionDurationScale); List entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, this.getBoundingBox()); if (!entitiesOfClass.isEmpty()) { + List entities = new java.util.ArrayList<>(); // CraftBukkit for (LivingEntity livingEntity : entitiesOfClass) { if (!this.victims.containsKey(livingEntity) && livingEntity.isAffectedByPotions() -@@ -228,6 +_,17 @@ +@@ -230,6 +_,17 @@ double d1 = livingEntity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; if (d2 <= radius * radius) { @@ -52,13 +52,13 @@ + // CraftBukkit end this.victims.put(livingEntity, this.tickCount + this.reapplicationDelay); - for (MobEffectInstance mobEffectInstance1 : list) { -@@ -236,14 +_,14 @@ + for (MobEffectInstance mobEffectInstance : list) { +@@ -238,14 +_,14 @@ .value() - .applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance1.getAmplifier(), 0.5); + .applyInstantenousEffect(level, this, this.getOwner(), livingEntity, mobEffectInstance.getAmplifier(), 0.5); } else { -- livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this); -+ livingEntity.addEffect(new MobEffectInstance(mobEffectInstance1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit +- livingEntity.addEffect(new MobEffectInstance(mobEffectInstance), this); ++ livingEntity.addEffect(new MobEffectInstance(mobEffectInstance), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit } } @@ -70,8 +70,8 @@ return; } -@@ -253,7 +_,7 @@ - if (this.durationOnUse != 0) { +@@ -255,7 +_,7 @@ + if (this.durationOnUse != 0 && this.duration != -1) { this.duration = this.duration + this.durationOnUse; if (this.duration <= 0) { - this.discard(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch index 1bd938bdb..92bdec397 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ConversionType.java.patch @@ -9,3 +9,11 @@ } firstPassenger.startRiding(newMob); +@@ -70,6 +_,7 @@ + if (leashHolder != null) { + oldMob.dropLeash(); + } ++ newMob.aware = oldMob.aware; // Paper - Fix nerfed slime when splitting + + this.convertCommon(oldMob, newMob, conversionParams); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch deleted file mode 100644 index 467ae36f2..000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/Display.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/Display.java -+++ b/net/minecraft/world/entity/Display.java -@@ -213,7 +_,7 @@ - if (tag.contains("transformation")) { - Transformation.EXTENDED_CODEC - .decode(NbtOps.INSTANCE, tag.get("transformation")) -- .resultOrPartial(Util.prefix("Display entity", LOGGER::error)) -+ .result() // Paper - Hide text display error on spawn - .ifPresent(pair -> this.setTransformation(pair.getFirst())); - } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch index 72b325c8e..37f0ba306 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Entity.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -136,6 +_,108 @@ - import org.slf4j.Logger; +@@ -141,6 +_,107 @@ + import org.jetbrains.annotations.Contract; - public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder { -+ + public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter { + // CraftBukkit start ++ private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); + private static final int CURRENT_LEVEL = 2; -+ public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first setPositionRotation ++ public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first snapTo + static boolean isLevelAtLeast(CompoundTag tag, int level) { -+ return tag.contains("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level; ++ return tag.getIntOr("Bukkit.updateLevel", CURRENT_LEVEL) >= level; + } + + // Paper start - Share random for entities to make them more random @@ -84,7 +84,7 @@ + } + } + // Paper end - Share random for entities to make them more random -+ public org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason ++ public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + + private @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; + @@ -105,20 +105,19 @@ + return this.bukkitEntity; + } + // Paper end -+ - private static final Logger LOGGER = LogUtils.getLogger(); public static final String ID_TAG = "id"; public static final String PASSENGERS_TAG = "Passengers"; -@@ -196,7 +_,7 @@ + private static final String DATA_TAG = "data"; +@@ -203,7 +_,7 @@ + public double yOld; public double zOld; public boolean noPhysics; - private boolean wasOnFire; - public final RandomSource random = RandomSource.create(); + public final RandomSource random = SHARED_RANDOM; // Paper - Share random for entities to make them more random public int tickCount; private int remainingFireTicks = -this.getFireImmuneTicks(); public boolean wasTouchingWater; -@@ -233,7 +_,7 @@ +@@ -240,7 +_,7 @@ protected UUID uuid = Mth.createInsecureUUID(this.random); protected String stringUUID = this.uuid.toString(); private boolean hasGlowingTag; @@ -127,10 +126,10 @@ private final double[] pistonDeltas = new double[]{0.0, 0.0, 0.0}; private long pistonDeltasGameTime; private EntityDimensions dimensions; -@@ -250,6 +_,60 @@ - private final List movementThisTick = new ArrayList<>(); - private final Set blocksInside = new ReferenceArraySet<>(); +@@ -259,6 +_,41 @@ private final LongSet visitedBlocks = new LongOpenHashSet(); + private final InsideBlockEffectApplier.StepBasedCollector insideEffectCollector = new InsideBlockEffectApplier.StepBasedCollector(); + private CustomData customData = CustomData.EMPTY; + // CraftBukkit start + public boolean forceDrops; + public boolean persist = true; @@ -143,43 +142,24 @@ + public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only + public boolean lastDamageCancelled; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled + public boolean persistentInvisibility = false; -+ public BlockPos lastLavaContact; ++ public @Nullable BlockPos lastLavaContact; + // Marks an entity, that it was removed by a plugin via Entity#remove + // Main use case currently is for SPIGOT-7487, preventing dropping of leash when leash is removed + public boolean pluginRemoved = false; + protected int numCollisions = 0; // Paper - Cap entity collisions + public boolean fromNetherPortal; // Paper - Add option to nerf pigmen from nether portals + public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one -+ // Paper start - Entity origin API -+ @javax.annotation.Nullable -+ private org.bukkit.util.Vector origin; -+ @javax.annotation.Nullable -+ private UUID originWorld; ++ // Paper start ++ public @Nullable Vec3 origin; ++ public @Nullable UUID originWorld; ++ // Paper end + public boolean freezeLocked = false; // Paper - Freeze Tick Lock API + public boolean fixedPose = false; // Paper - Expand Pose API + private final int despawnTime; // Paper - entity despawn time limit + public int totalEntityAge; // Paper - age-like counter for all entities + public final io.papermc.paper.entity.activation.ActivationType activationType = io.papermc.paper.entity.activation.ActivationType.activationTypeFor(this); // Paper - EAR 2/tracking ranges -+ -+ public void setOrigin(@javax.annotation.Nonnull org.bukkit.Location location) { -+ this.origin = location.toVector(); -+ this.originWorld = location.getWorld().getUID(); -+ } -+ -+ @javax.annotation.Nullable -+ public org.bukkit.util.Vector getOriginVector() { -+ return this.origin != null ? this.origin.clone() : null; -+ } -+ -+ @javax.annotation.Nullable -+ public UUID getOriginWorld() { -+ return this.originWorld; -+ } -+ // Paper end - Entity origin API -+ public float getBukkitYaw() { -+ return this.yRot; -+ } + // CraftBukkit end ++ + // Paper start + public final AABB getBoundingBoxAt(double x, double y, double z) { + return this.dimensions.makeBoundingBox(x, y, z); @@ -188,7 +168,7 @@ public Entity(EntityType entityType, Level level) { this.type = entityType; -@@ -271,6 +_,7 @@ +@@ -280,6 +_,7 @@ this.entityData = builder.build(); this.setPos(0.0, 0.0, 0.0); this.eyeHeight = this.dimensions.eyeHeight(); @@ -196,7 +176,7 @@ } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -284,6 +_,12 @@ +@@ -292,6 +_,12 @@ return team != null && team.getColor().getColor() != null ? team.getColor().getColor() : 16777215; } @@ -209,7 +189,7 @@ public boolean isSpectator() { return false; } -@@ -324,7 +_,7 @@ +@@ -332,7 +_,7 @@ } public boolean addTag(String tag) { @@ -218,7 +198,7 @@ } public boolean removeTag(String tag) { -@@ -332,12 +_,18 @@ +@@ -340,12 +_,18 @@ } public void kill(ServerLevel level) { @@ -233,13 +213,13 @@ + this.discard(null); + } + -+ public final void discard(org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ public final void discard(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { + this.remove(Entity.RemovalReason.DISCARDED, cause); + // CraftBukkit end } protected abstract void defineSynchedData(SynchedEntityData.Builder builder); -@@ -346,6 +_,48 @@ +@@ -354,6 +_,48 @@ return this.entityData; } @@ -247,7 +227,7 @@ + public void refreshEntityData(ServerPlayer to) { + List> list = this.entityData.packAll(); // Paper - Update EVERYTHING not just not default + -+ if (list != null && to.getBukkitEntity().canSee(this.getBukkitEntity())) { // Paper ++ if (to.getBukkitEntity().canSee(this.getBukkitEntity())) { // Paper + to.connection.send(new net.minecraft.network.protocol.game.ClientboundSetEntityDataPacket(this.getId(), list)); + } + } @@ -288,22 +268,22 @@ @Override public boolean equals(Object object) { return object instanceof Entity && ((Entity)object).id == this.id; -@@ -357,7 +_,13 @@ +@@ -365,7 +_,13 @@ } public void remove(Entity.RemovalReason reason) { - this.setRemoved(reason); + // CraftBukkit start - add Bukkit remove cause -+ this.setRemoved(reason, null); ++ this.remove(reason, null); + } + -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { + this.setRemoved(reason, eventCause); + // CraftBukkit end } public void onClientRemoval() { -@@ -367,6 +_,17 @@ +@@ -375,6 +_,15 @@ } public void setPose(Pose pose) { @@ -312,16 +292,14 @@ + if (pose == this.getPose()) { + return; + } -+ // Paper start - Don't fire sync event during generation + if (!this.generation) { + this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.entity.EntityPoseChangeEvent(this.getBukkitEntity(), org.bukkit.entity.Pose.values()[pose.ordinal()])); + } -+ // Paper end - Don't fire sync event during generation + // CraftBukkit end this.entityData.set(DATA_POSE, pose); } -@@ -390,6 +_,32 @@ +@@ -398,6 +_,32 @@ } public void setRot(float yRot, float xRot) { @@ -354,7 +332,7 @@ this.setYRot(yRot % 360.0F); this.setXRot(xRot % 360.0F); } -@@ -399,8 +_,8 @@ +@@ -407,8 +_,8 @@ } public void setPos(double x, double y, double z) { @@ -365,7 +343,7 @@ } protected final AABB makeBoundingBox() { -@@ -430,12 +_,28 @@ +@@ -438,12 +_,28 @@ } public void tick() { @@ -394,28 +372,19 @@ this.inBlockState = null; if (this.isPassenger() && this.getVehicle().isRemoved()) { this.stopRiding(); -@@ -445,7 +_,7 @@ +@@ -453,7 +_,7 @@ this.boardingCooldown--; } - this.handlePortal(); -+ if (this instanceof ServerPlayer) this.handlePortal(); // CraftBukkit - // Moved up to postTick ++ if (this instanceof ServerPlayer) this.handlePortal(); // CraftBukkit - Moved up to postTick if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -@@ -470,7 +_,7 @@ - this.setRemainingFireTicks(this.remainingFireTicks - 1); - } +@@ -484,6 +_,10 @@ -- if (this.getTicksFrozen() > 0) { -+ if (this.getTicksFrozen() > 0 && !this.freezeLocked) { // Paper - Freeze Tick Lock API - this.setTicksFrozen(0); - this.level().levelEvent(null, 1009, this.blockPosition, 1); - } -@@ -482,6 +_,10 @@ if (this.isInLava()) { - this.lavaHurt(); - this.fallDistance *= 0.5F; + this.fallDistance *= 0.5; + // CraftBukkit start + } else { + this.lastLavaContact = null; @@ -423,7 +392,7 @@ } this.checkBelowWorld(); -@@ -502,7 +_,12 @@ +@@ -504,7 +_,12 @@ } public void checkBelowWorld() { @@ -437,20 +406,26 @@ this.onBelowWorld(); } } -@@ -531,9 +_,24 @@ +@@ -532,15 +_,41 @@ + } - public void lavaHurt() { + public void lavaIgnite() { ++ // Paper start - track lava contact ++ this.lavaIgnite(this.lastLavaContact); // fallback for minecarts if defined ++ } ++ ++ public void lavaIgnite(@Nullable BlockPos pos) { ++ // Paper end - track lava contact if (!this.fireImmune()) { - this.igniteForSeconds(15.0F); + // CraftBukkit start - Fallen in lava TODO: this event spams! + if (this instanceof net.minecraft.world.entity.LivingEntity && this.remainingFireTicks <= 0) { + // not on fire yet -+ org.bukkit.block.Block damager = (this.lastLavaContact == null) ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.lastLavaContact); ++ org.bukkit.block.Block damager = pos == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(this.level, pos); + org.bukkit.entity.Entity damagee = this.getBukkitEntity(); -+ org.bukkit.event.entity.EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15); -+ this.level.getCraftServer().getPluginManager().callEvent(combustEvent); ++ org.bukkit.event.entity.EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15.0F); + -+ if (!combustEvent.isCancelled()) { ++ if (combustEvent.callEvent()) { + this.igniteForSeconds(combustEvent.getDuration(), false); + } + } else { @@ -458,38 +433,45 @@ + this.igniteForSeconds(15.0F, false); + } + // CraftBukkit end + } + } + + public void lavaHurt() { ++ // Paper start - track lava contact ++ this.lavaHurt(this.lastLavaContact); // fallback for minecarts if defined ++ } ++ ++ public void lavaHurt(@Nullable BlockPos pos) { ++ // Paper end - track lava contact + if (!this.fireImmune()) { if (this.level() instanceof ServerLevel serverLevel - && this.hurtServer(serverLevel, this.damageSources().lava(), 4.0F) -+ && this.hurtServer(serverLevel, this.damageSources().lava().eventBlockDamager(this.level, this.lastLavaContact), 4.0F) // CraftBukkit - we also don't throw an event unless the object in lava is living, to save on some event calls ++ && this.hurtServer(serverLevel, this.damageSources().lava().eventBlockDamager(this.level, pos), 4.0F) // CraftBukkit - we also don't throw an event unless the object in lava is living, to save on some event calls && this.shouldPlayLavaHurtSound() && !this.isSilent()) { serverLevel.playSound( -@@ -548,7 +_,23 @@ +@@ -555,6 +_,20 @@ } public final void igniteForSeconds(float seconds) { -- this.igniteForTicks(Mth.floor(seconds * 20.0F)); + // CraftBukkit start + this.igniteForSeconds(seconds, true); + } + -+ public final void igniteForSeconds(float f, boolean callEvent) { ++ public final void igniteForSeconds(float seconds, boolean callEvent) { + if (callEvent) { -+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustEvent(this.getBukkitEntity(), f); -+ this.level.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustEvent(this.getBukkitEntity(), seconds); ++ if (!event.callEvent()) { + return; + } + -+ f = event.getDuration(); ++ seconds = event.getDuration(); + } + // CraftBukkit end -+ this.igniteForTicks(Mth.floor(f * 20.0F)); + this.igniteForTicks(Mth.floor(seconds * 20.0F)); } - public void igniteForTicks(int ticks) { -@@ -570,7 +_,7 @@ +@@ -579,7 +_,7 @@ } protected void onBelowWorld() { @@ -498,33 +480,18 @@ } public boolean isFree(double x, double y, double z) { -@@ -626,7 +_,43 @@ +@@ -635,7 +_,28 @@ return this.onGround; } + // Paper start - detailed watchdog information + public final Object posLock = new Object(); // Paper - log detailed entity tick information + ++ @Nullable + private Vec3 moveVector; + private double moveStartX; + private double moveStartY; + private double moveStartZ; -+ -+ public final Vec3 getMoveVector() { -+ return this.moveVector; -+ } -+ -+ public final double getMoveStartX() { -+ return this.moveStartX; -+ } -+ -+ public final double getMoveStartY() { -+ return this.moveStartY; -+ } -+ -+ public final double getMoveStartZ() { -+ return this.moveStartZ; -+ } + // Paper end - detailed watchdog information + public void move(MoverType type, Vec3 movement) { @@ -542,36 +509,35 @@ if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { -@@ -701,6 +_,28 @@ +@@ -721,6 +_,27 @@ + block.updateEntityMovementAfterFallOn(this.level(), this); } } - + // CraftBukkit start + if (this.horizontalCollision && this.getBukkitEntity() instanceof org.bukkit.entity.Vehicle) { + org.bukkit.entity.Vehicle vehicle = (org.bukkit.entity.Vehicle) this.getBukkitEntity(); -+ org.bukkit.block.Block bl = this.level.getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); ++ org.bukkit.block.Block block = this.level.getWorld().getBlockAt(Mth.floor(this.getX()), Mth.floor(this.getY()), Mth.floor(this.getZ())); + + if (movement.x > vec3.x) { -+ bl = bl.getRelative(org.bukkit.block.BlockFace.EAST); ++ block = block.getRelative(org.bukkit.block.BlockFace.EAST); + } else if (movement.x < vec3.x) { -+ bl = bl.getRelative(org.bukkit.block.BlockFace.WEST); ++ block = block.getRelative(org.bukkit.block.BlockFace.WEST); + } else if (movement.z > vec3.z) { -+ bl = bl.getRelative(org.bukkit.block.BlockFace.SOUTH); ++ block = block.getRelative(org.bukkit.block.BlockFace.SOUTH); + } else if (movement.z < vec3.z) { -+ bl = bl.getRelative(org.bukkit.block.BlockFace.NORTH); ++ block = block.getRelative(org.bukkit.block.BlockFace.NORTH); + } + -+ if (!bl.getType().isAir()) { -+ org.bukkit.event.vehicle.VehicleBlockCollisionEvent event = new org.bukkit.event.vehicle.VehicleBlockCollisionEvent(vehicle, bl, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity -+ this.level.getCraftServer().getPluginManager().callEvent(event); ++ if (!block.getType().isAir()) { ++ org.bukkit.event.vehicle.VehicleBlockCollisionEvent event = new org.bukkit.event.vehicle.VehicleBlockCollisionEvent(vehicle, block, org.bukkit.craftbukkit.util.CraftVector.toBukkit(originalMovement)); // Paper - Expose pre-collision velocity ++ event.callEvent(); + } + } + // CraftBukkit end -+ - if (!this.level().isClientSide() || this.isControlledByLocalInstance()) { + + if (!this.level().isClientSide() || this.isLocalInstanceAuthoritative()) { Entity.MovementEmission movementEmission = this.getMovementEmission(); - if (movementEmission.emitsAnything() && !this.isPassenger()) { -@@ -713,6 +_,13 @@ +@@ -734,6 +_,13 @@ profilerFiller.pop(); } } @@ -585,7 +551,7 @@ } private void applyMovementEmissionAndPlaySound(Entity.MovementEmission movementEmission, Vec3 movement, BlockPos pos, BlockState state) { -@@ -850,7 +_,7 @@ +@@ -898,7 +_,7 @@ } protected BlockPos getOnPos(float yOffset) { @@ -594,49 +560,46 @@ BlockPos blockPos = this.mainSupportingBlockPos.get(); if (!(yOffset > 1.0E-5F)) { return blockPos; -@@ -1049,6 +_,20 @@ - return SoundEvents.GENERIC_SPLASH; - } +@@ -1104,7 +_,7 @@ + || this.collidedWithShapeMovingFrom(vec3, vec31, entityInsideCollisionShape.move(new Vec3(pos)).toAabbs()); + if (flag) { + try { +- stepBasedCollector.advanceStep(step); ++ stepBasedCollector.advanceStep(step, pos); // Paper - track position inside effect was triggered on + blockState.entityInside(this.level(), pos, this, stepBasedCollector); + this.onInsideBlock(blockState); + } catch (Throwable var14) { +@@ -1119,7 +_,7 @@ -+ // CraftBukkit start - Add delegate methods -+ public SoundEvent getSwimSound0() { -+ return this.getSwimSound(); -+ } -+ -+ public SoundEvent getSwimSplashSound0() { -+ return this.getSwimSplashSound(); -+ } -+ -+ public SoundEvent getSwimHighSpeedSplashSound0() { -+ return this.getSwimHighSpeedSplashSound(); -+ } -+ // CraftBukkit end -+ - public void recordMovementThroughBlocks(Vec3 oldPosition, Vec3 position) { - this.movementThisTick.add(new Entity.Movement(oldPosition, position)); - } -@@ -1485,6 +_,7 @@ + boolean flag1 = this.collidedWithFluid(blockState.getFluidState(), pos, vec3, vec31); + if (flag1) { +- stepBasedCollector.advanceStep(step); ++ stepBasedCollector.advanceStep(step, pos); // Paper - track position inside effect was triggered on + blockState.getFluidState().entityInside(this.level(), pos, this, stepBasedCollector); + } + } +@@ -1519,6 +_,7 @@ this.setXRot(Mth.clamp(xRot, -90.0F, 90.0F) % 360.0F); this.yRotO = this.getYRot(); this.xRotO = this.getXRot(); + this.setYHeadRot(yRot); // Paper - Update head rotation } - public void absMoveTo(double x, double y, double z) { -@@ -1494,6 +_,7 @@ + public void absSnapTo(double x, double y, double z) { +@@ -1528,6 +_,7 @@ this.yo = y; this.zo = d1; this.setPos(d, y, d1); + if (this.valid) this.level.getChunk((int) Math.floor(this.getX()) >> 4, (int) Math.floor(this.getZ()) >> 4); // CraftBukkit } - public void moveTo(Vec3 vec) { -@@ -1513,11 +_,19 @@ + public void snapTo(Vec3 pos) { +@@ -1547,11 +_,19 @@ } - public void moveTo(double x, double y, double z, float yRot, float xRot) { + public void snapTo(double x, double y, double z, float yRot, float xRot) { + // Paper start - Fix Entity Teleportation and cancel velocity if teleported -+ if (!preserveMotion) { ++ if (!this.preserveMotion) { + this.deltaMovement = Vec3.ZERO; + } else { + this.preserveMotion = false; @@ -651,7 +614,7 @@ } public final void setOldPosAndRot() { -@@ -1584,6 +_,7 @@ +@@ -1618,6 +_,7 @@ public void push(Entity entity) { if (!this.isPassengerOfSameVehicle(entity)) { if (!entity.noPhysics && !this.noPhysics) { @@ -659,7 +622,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Mth.absMax(d, d1); -@@ -1617,7 +_,21 @@ +@@ -1651,7 +_,21 @@ } public void push(double x, double y, double z) { @@ -682,7 +645,7 @@ this.hasImpulse = true; } -@@ -1724,8 +_,20 @@ +@@ -1758,8 +_,20 @@ } public boolean isPushable() { @@ -703,7 +666,7 @@ public void awardKillScore(Entity entity, DamageSource damageSource) { if (entity instanceof ServerPlayer) { -@@ -1752,15 +_,22 @@ +@@ -1786,15 +_,23 @@ } public boolean saveAsPassenger(CompoundTag compound) { @@ -712,6 +675,7 @@ + // Paper start - Raw entity serialization API + return this.saveAsPassenger(compound, true, false, false); + } ++ + public boolean saveAsPassenger(CompoundTag compound, boolean includeAll, boolean includeNonSaveable, boolean forceSerialization) { + // Paper end - Raw entity serialization API + // CraftBukkit end @@ -730,7 +694,7 @@ return true; } } -@@ -1771,15 +_,37 @@ +@@ -1805,14 +_,34 @@ } public CompoundTag saveWithoutId(CompoundTag compound) { @@ -743,23 +707,15 @@ + // Paper end - Raw entity serialization API + // CraftBukkit end try { -- if (this.vehicle != null) { -- compound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); -- } else { -- compound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); -- } -+ // CraftBukkit start - selectively save position -+ if (includeAll) { -+ if (this.vehicle != null) { -+ compound.put("Pos", this.newDoubleList(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); -+ } else { -+ compound.put("Pos", this.newDoubleList(this.getX(), this.getY(), this.getZ())); -+ } -+ } -+ // CraftBukkit end ++ if (includeAll) { // CraftBukkit - selectively save position + if (this.vehicle != null) { + compound.store("Pos", Vec3.CODEC, new Vec3(this.vehicle.getX(), this.getY(), this.vehicle.getZ())); + } else { + compound.store("Pos", Vec3.CODEC, this.position()); + } ++ } // CraftBukkit - Vec3 deltaMovement = this.getDeltaMovement(); - compound.put("Motion", this.newDoubleList(deltaMovement.x, deltaMovement.y, deltaMovement.z)); + compound.store("Motion", Vec3.CODEC, this.getDeltaMovement()); + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // TODO: make sure this is the best way to address this. + if (Float.isNaN(this.yRot)) { @@ -770,17 +726,17 @@ + this.xRot = 0; + } + // CraftBukkit end - compound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); - compound.putFloat("FallDistance", this.fallDistance); + compound.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); + compound.putDouble("fall_distance", this.fallDistance); compound.putShort("Fire", (short)this.remainingFireTicks); -@@ -1787,7 +_,29 @@ +@@ -1820,7 +_,29 @@ compound.putBoolean("OnGround", this.onGround()); compound.putBoolean("Invulnerable", this.invulnerable); compound.putInt("PortalCooldown", this.portalCooldown); -- compound.putUUID("UUID", this.getUUID()); +- compound.store("UUID", UUIDUtil.CODEC, this.getUUID()); + // CraftBukkit start - selectively save uuid and world + if (includeAll) { -+ compound.putUUID("UUID", this.getUUID()); ++ compound.store("UUID", UUIDUtil.CODEC, this.getUUID()); + // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast + compound.putLong("WorldUUIDLeast", this.level.getWorld().getUID().getLeastSignificantBits()); + compound.putLong("WorldUUIDMost", this.level.getWorld().getUID().getMostSignificantBits()); @@ -803,9 +759,9 @@ + // CraftBukkit end Component customName = this.getCustomName(); if (customName != null) { - compound.putString("CustomName", Component.Serializer.toJson(customName, this.registryAccess())); -@@ -1828,13 +_,13 @@ - compound.put("Tags", listTag); + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); +@@ -1860,13 +_,13 @@ + compound.store("data", CustomData.CODEC, this.customData); } - this.addAdditionalSaveData(compound); @@ -820,7 +776,7 @@ listTag.add(compoundTag); } } -@@ -1844,6 +_,33 @@ +@@ -1876,6 +_,33 @@ } } @@ -831,11 +787,11 @@ + // CraftBukkit end + // Paper start + if (this.origin != null) { -+ UUID originWorld = this.originWorld != null ? this.originWorld : this.level != null ? this.level.getWorld().getUID() : null; ++ UUID originWorld = this.originWorld != null ? this.originWorld : (this.level != null ? this.level.getWorld().getUID() : null); + if (originWorld != null) { -+ compound.putUUID("Paper.OriginWorld", originWorld); ++ compound.store("Paper.OriginWorld", UUIDUtil.CODEC, originWorld); + } -+ compound.put("Paper.Origin", this.newDoubleList(this.origin.getX(), this.origin.getY(), this.origin.getZ())); ++ compound.store("Paper.Origin", Vec3.CODEC, this.origin); + } + if (this.spawnReason != null) { + compound.putString("Paper.SpawnReason", this.spawnReason.name()); @@ -852,53 +808,51 @@ + } + // Paper end return compound; - } catch (Throwable var9) { - CrashReport crashReport = CrashReport.forThrowable(var9, "Saving entity NBT"); -@@ -1930,6 +_,69 @@ + } catch (Throwable var8) { + CrashReport crashReport = CrashReport.forThrowable(var8, "Saving entity NBT"); +@@ -1932,6 +_,67 @@ } else { throw new IllegalStateException("Entity has invalid rotation"); } + // CraftBukkit start + // Spigot start + if (this instanceof net.minecraft.world.entity.LivingEntity) { -+ this.totalEntityAge = compound.getInt("Spigot.ticksLived"); // Paper ++ this.totalEntityAge = compound.getIntOr("Spigot.ticksLived", 0); // Paper + } + // Spigot end -+ this.persist = !compound.contains("Bukkit.persist") || compound.getBoolean("Bukkit.persist"); -+ this.visibleByDefault = !compound.contains("Bukkit.visibleByDefault") || compound.getBoolean("Bukkit.visibleByDefault"); ++ this.persist = compound.getBooleanOr("Bukkit.persist", true); ++ this.visibleByDefault = compound.getBooleanOr("Bukkit.visibleByDefault", true); + // SPIGOT-6907: re-implement LivingEntity#setMaximumAir() -+ if (compound.contains("Bukkit.MaxAirSupply")) { -+ this.maxAirTicks = compound.getInt("Bukkit.MaxAirSupply"); -+ } ++ this.maxAirTicks = compound.getIntOr("Bukkit.MaxAirSupply",this.maxAirTicks); + // CraftBukkit end + + // CraftBukkit start + // Paper - move world parsing/loading to PlayerList#placeNewPlayer + this.getBukkitEntity().readBukkitValues(compound); + if (compound.contains("Bukkit.invisible")) { -+ boolean bukkitInvisible = compound.getBoolean("Bukkit.invisible"); ++ boolean bukkitInvisible = compound.getBooleanOr("Bukkit.invisible", false); + this.setInvisible(bukkitInvisible); + this.persistentInvisibility = bukkitInvisible; + } + // CraftBukkit end + + // Paper start -+ ListTag originTag = compound.getList("Paper.Origin", net.minecraft.nbt.Tag.TAG_DOUBLE); -+ if (!originTag.isEmpty()) { ++ Optional originVec = compound.read("Paper.Origin", Vec3.CODEC); ++ if (originVec.isPresent()) { + UUID originWorld = null; + if (compound.contains("Paper.OriginWorld")) { -+ originWorld = compound.getUUID("Paper.OriginWorld"); ++ originWorld = compound.read("Paper.OriginWorld", UUIDUtil.CODEC).orElse(null); + } else if (this.level != null) { + originWorld = this.level.getWorld().getUID(); + } + this.originWorld = originWorld; -+ origin = new org.bukkit.util.Vector(originTag.getDouble(0), originTag.getDouble(1), originTag.getDouble(2)); ++ this.origin = originVec.get(); + } + -+ spawnedViaMobSpawner = compound.getBoolean("Paper.FromMobSpawner"); // Restore entity's from mob spawner status -+ fromNetherPortal = compound.getBoolean("Paper.FromNetherPortal"); ++ spawnedViaMobSpawner = compound.getBooleanOr("Paper.FromMobSpawner", false); // Restore entity's from mob spawner status ++ fromNetherPortal = compound.getBooleanOr("Paper.FromNetherPortal", false); + if (compound.contains("Paper.SpawnReason")) { -+ String spawnReasonName = compound.getString("Paper.SpawnReason"); ++ String spawnReasonName = compound.getString("Paper.SpawnReason").orElse(null); + try { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.valueOf(spawnReasonName); + } catch (Exception ignored) { @@ -909,7 +863,7 @@ + if (spawnedViaMobSpawner) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER; + } else if (this instanceof Mob && (this instanceof net.minecraft.world.entity.animal.Animal || this instanceof net.minecraft.world.entity.animal.AbstractFish) && !((Mob) this).removeWhenFarAway(0.0)) { -+ if (!compound.getBoolean("PersistenceRequired")) { ++ if (!compound.getBooleanOr("PersistenceRequired", false)) { + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL; + } + } @@ -918,13 +872,13 @@ + spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT; + } + if (compound.contains("Paper.FreezeLock")) { -+ freezeLocked = compound.getBoolean("Paper.FreezeLock"); ++ freezeLocked = compound.getBooleanOr("Paper.FreezeLock", false); + } + // Paper end - } catch (Throwable var17) { - CrashReport crashReport = CrashReport.forThrowable(var17, "Loading entity NBT"); + } catch (Throwable var8) { + CrashReport crashReport = CrashReport.forThrowable(var8, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -1944,10 +_,21 @@ +@@ -1946,10 +_,21 @@ @Nullable public final String getEncodeId() { @@ -948,13 +902,14 @@ protected abstract void readAdditionalSaveData(CompoundTag tag); -@@ -1990,11 +_,61 @@ +@@ -1972,11 +_,63 @@ @Nullable public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, float yOffset) { + // Paper start - Restore vanilla drops behavior + return this.spawnAtLocation(level, stack, yOffset, null); + } ++ + public record DefaultDrop(Item item, org.bukkit.inventory.ItemStack stack, @Nullable java.util.function.Consumer dropConsumer) { + public DefaultDrop(final ItemStack stack, final java.util.function.Consumer dropConsumer) { + this(stack.getItem(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), dropConsumer); @@ -968,6 +923,7 @@ + } + } + } ++ + @Nullable + public ItemEntity spawnAtLocation(ServerLevel level, ItemStack stack, float yOffset, @Nullable java.util.function.Consumer delayedAddConsumer) { + // Paper end - Restore vanilla drops behavior @@ -1011,7 +967,7 @@ level.addFreshEntity(itemEntity); return itemEntity; } -@@ -2028,7 +_,16 @@ +@@ -2008,7 +_,16 @@ if (this.isAlive() && this instanceof Leashable leashable) { if (leashable.getLeashHolder() == player) { if (!this.level().isClientSide()) { @@ -1029,7 +985,7 @@ leashable.removeLeash(); } else { leashable.dropLeash(); -@@ -2043,6 +_,13 @@ +@@ -2023,6 +_,13 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) { if (!this.level().isClientSide()) { @@ -1043,7 +999,7 @@ leashable.setLeashedTo(player, true); } -@@ -2116,11 +_,11 @@ +@@ -2096,11 +_,11 @@ } public boolean startRiding(Entity vehicle, boolean force) { @@ -1057,7 +1013,7 @@ return false; } else { for (Entity entity = vehicle; entity.vehicle != null; entity = entity.vehicle) { -@@ -2130,6 +_,27 @@ +@@ -2110,6 +_,27 @@ } if (force || this.canRide(vehicle) && vehicle.canAddPassenger(this)) { @@ -1085,7 +1041,7 @@ if (this.isPassenger()) { this.stopRiding(); } -@@ -2158,15 +_,26 @@ +@@ -2138,15 +_,26 @@ } public void removeVehicle() { @@ -1114,7 +1070,7 @@ } protected void addPassenger(Entity passenger) { -@@ -2190,10 +_,43 @@ +@@ -2170,10 +_,43 @@ } } @@ -1159,7 +1115,7 @@ if (this.passengers.size() == 1 && this.passengers.get(0) == passenger) { this.passengers = ImmutableList.of(); } else { -@@ -2203,6 +_,7 @@ +@@ -2183,6 +_,7 @@ passenger.boardingCooldown = 60; this.gameEvent(GameEvent.ENTITY_DISMOUNT, passenger); } @@ -1167,7 +1123,7 @@ } protected boolean canAddPassenger(Entity passenger) { -@@ -2295,8 +_,8 @@ +@@ -2266,8 +_,8 @@ TeleportTransition portalDestination = this.portalProcess.getPortalDestination(serverLevel, this); if (portalDestination != null) { ServerLevel level = portalDestination.newLevel(); @@ -1178,7 +1134,7 @@ this.teleport(portalDestination); } } -@@ -2377,7 +_,7 @@ +@@ -2348,7 +_,7 @@ } public boolean isCrouching() { @@ -1187,7 +1143,7 @@ } public boolean isSprinting() { -@@ -2393,7 +_,7 @@ +@@ -2364,7 +_,7 @@ } public boolean isVisuallySwimming() { @@ -1196,7 +1152,7 @@ } public boolean isVisuallyCrawling() { -@@ -2401,6 +_,13 @@ +@@ -2372,6 +_,13 @@ } public void setSwimming(boolean swimming) { @@ -1210,7 +1166,7 @@ this.setSharedFlag(4, swimming); } -@@ -2439,6 +_,7 @@ +@@ -2410,6 +_,7 @@ @Nullable public PlayerTeam getTeam() { @@ -1218,7 +1174,7 @@ return this.level().getScoreboard().getPlayersTeam(this.getScoreboardName()); } -@@ -2455,7 +_,11 @@ +@@ -2426,7 +_,11 @@ } public void setInvisible(boolean invisible) { @@ -1231,7 +1187,7 @@ } public boolean getSharedFlag(int flag) { -@@ -2472,7 +_,7 @@ +@@ -2443,7 +_,7 @@ } public int getMaxAirSupply() { @@ -1240,7 +1196,7 @@ } public int getAirSupply() { -@@ -2480,7 +_,18 @@ +@@ -2451,10 +_,22 @@ } public void setAirSupply(int air) { @@ -1259,8 +1215,12 @@ + // CraftBukkit end } - public int getTicksFrozen() { -@@ -2506,11 +_,43 @@ + public void clearFreeze() { ++ if (this.freezeLocked) return; // Paper - Freeze Tick Lock API + this.setTicksFrozen(0); + } + +@@ -2481,11 +_,43 @@ public void thunderHit(ServerLevel level, LightningBolt lightning) { this.setRemainingFireTicks(this.remainingFireTicks + 1); @@ -1307,8 +1267,8 @@ + // CraftBukkit end } - public void onAboveBubbleCol(boolean downwards) { -@@ -2636,26 +_,30 @@ + public void onAboveBubbleColumn(boolean downwards, BlockPos pos) { +@@ -2641,26 +_,30 @@ return this.removalReason != null ? String.format( Locale.ROOT, @@ -1342,7 +1302,7 @@ ); } -@@ -2679,6 +_,13 @@ +@@ -2684,6 +_,13 @@ } public void restoreFrom(Entity entity) { @@ -1356,13 +1316,13 @@ CompoundTag compoundTag = entity.saveWithoutId(new CompoundTag()); compoundTag.remove("Dimension"); this.load(compoundTag); -@@ -2688,7 +_,56 @@ +@@ -2693,7 +_,56 @@ @Nullable public Entity teleport(TeleportTransition teleportTransition) { + // Paper start - Fix item duplication and teleport issues + if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { -+ LOGGER.warn("Illegal Entity Teleport " + this + " to " + teleportTransition.newLevel() + ":" + teleportTransition.position(), new Throwable()); ++ LOGGER.warn("Illegal Entity Teleport {} to {}:{}", this, teleportTransition.newLevel(), teleportTransition.position(), new Throwable()); + return null; + } + // Paper end - Fix item duplication and teleport issues @@ -1385,7 +1345,7 @@ + } + if (!to.equals(teleEvent.getTo())) { + to = teleEvent.getTo(); -+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(to), Vec3.ZERO, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); ++ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); + // Paper start - Call EntityPortalExitEvent + velocity = Vec3.ZERO; + } @@ -1399,10 +1359,10 @@ + event.callEvent(); + + // Only change the target if actually needed, since we reset relative flags -+ if (!event.isCancelled() && event.getTo() != null && (!event.getTo().equals(event.getFrom()) || !event.getAfter().equals(event.getBefore()))) { ++ if (!event.isCancelled() && event.getTo() != null && (!event.getTo().equals(event.getFrom()) || !event.getAfter().equals(event.getBefore()))) { // todo this looks broken + to = event.getTo().clone(); -+ velocity = org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getAfter()); -+ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(to), velocity, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); ++ velocity = org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getAfter()); ++ teleportTransition = new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), velocity, to.getYaw(), to.getPitch(), teleportTransition.missingRespawnBlock(), teleportTransition.asPassenger(), Set.of(), teleportTransition.postTeleportTransition(), teleportTransition.cause()); + } + } + if (this.isRemoved()) { @@ -1413,7 +1373,7 @@ ServerLevel level = teleportTransition.newLevel(); boolean flag = level.dimension() != serverLevel.dimension(); if (!teleportTransition.asPassenger()) { -@@ -2737,10 +_,19 @@ +@@ -2742,10 +_,15 @@ profilerFiller.pop(); return null; } else { @@ -1424,17 +1384,13 @@ + // Paper end - Fix item duplication and teleport issues entityx.restoreFrom(this); this.removeAfterChangingDimensions(); -+ // CraftBukkit start - Forward the CraftEntity to the new entity -+ //this.getBukkitEntity().setHandle(entity); -+ //entity.bukkitEntity = this.getBukkitEntity(); // Paper - forward CraftEntity in teleport command; moved to Entity#restoreFrom -+ // CraftBukkit end entityx.teleportSetPosition(PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); - level.addDuringTeleport(entityx); + if (this.inWorld) level.addDuringTeleport(entityx); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned for (Entity entity2 : list) { entity2.startRiding(entityx, true); -@@ -2814,9 +_,17 @@ +@@ -2818,9 +_,17 @@ } protected void removeAfterChangingDimensions() { @@ -1455,16 +1411,20 @@ } } -@@ -2824,11 +_,34 @@ +@@ -2828,11 +_,37 @@ return PortalShape.getRelativePosition(portal, axis, this.position(), this.getDimensions(this.getPose())); } + // CraftBukkit start -+ public org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent(Entity entity, org.bukkit.Location exit, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) { ++ public @Nullable org.bukkit.craftbukkit.event.CraftPortalEvent callPortalEvent( ++ Entity entity, ++ org.bukkit.Location exit, ++ org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause, ++ int searchRadius, int creationRadius ++ ) { + org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity(); + org.bukkit.Location enter = bukkitEntity.getLocation(); + -+ // Paper start + final org.bukkit.PortalType portalType = switch (cause) { + case END_PORTAL -> org.bukkit.PortalType.ENDER; + case NETHER_PORTAL -> org.bukkit.PortalType.NETHER; @@ -1472,8 +1432,7 @@ + default -> org.bukkit.PortalType.CUSTOM; + }; + org.bukkit.event.entity.EntityPortalEvent event = new org.bukkit.event.entity.EntityPortalEvent(bukkitEntity, enter, exit, searchRadius, true, creationRadius, portalType); -+ // Paper end -+ event.getEntity().getServer().getPluginManager().callEvent(event); ++ event.callEvent(); + if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) { + return null; + } @@ -1490,24 +1449,24 @@ if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { for (Entity entity : this.getPassengers()) { if (entity instanceof ServerPlayer serverPlayer && !serverPlayer.seenCredits) { -@@ -2936,9 +_,14 @@ +@@ -2940,8 +_,14 @@ return this.entityData.get(DATA_CUSTOM_NAME_VISIBLE); } - public boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera) { +- Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, pitch, relativeMovements, TeleportTransition.DO_NOTHING)); + // CraftBukkit start + public final boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera) { + return this.teleportTo(level, x, y, z, relativeMovements, yaw, pitch, setCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.UNKNOWN); + } ++ + public boolean teleportTo(ServerLevel level, double x, double y, double z, Set relativeMovements, float yaw, float pitch, boolean setCamera, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) { + // CraftBukkit end - float f = Mth.clamp(pitch, -90.0F, 90.0F); -- Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, f, relativeMovements, TeleportTransition.DO_NOTHING)); -+ Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, f, relativeMovements, TeleportTransition.DO_NOTHING, cause)); // CraftBukkit ++ Entity entity = this.teleport(new TeleportTransition(level, new Vec3(x, y, z), Vec3.ZERO, yaw, pitch, relativeMovements, TeleportTransition.DO_NOTHING, cause)); // CraftBukkit return entity != null; } -@@ -3052,7 +_,26 @@ +@@ -3055,7 +_,26 @@ } public final void setBoundingBox(AABB bb) { @@ -1535,7 +1494,7 @@ } public final float getEyeHeight(Pose pose) { -@@ -3096,6 +_,12 @@ +@@ -3099,6 +_,12 @@ } public void stopSeenByPlayer(ServerPlayer serverPlayer) { @@ -1548,7 +1507,7 @@ } public float rotate(Rotation transformRotation) { -@@ -3129,7 +_,7 @@ +@@ -3132,7 +_,7 @@ } @Nullable @@ -1557,7 +1516,7 @@ return null; } -@@ -3161,21 +_,32 @@ +@@ -3164,21 +_,32 @@ } private Stream getIndirectPassengersStream() { @@ -1591,7 +1550,7 @@ } public int countPlayerPassengers() { -@@ -3183,6 +_,7 @@ +@@ -3186,6 +_,7 @@ } public boolean hasExactlyOnePlayerPassenger() { @@ -1599,7 +1558,7 @@ return this.countPlayerPassengers() == 1; } -@@ -3260,9 +_,38 @@ +@@ -3268,9 +_,38 @@ return 1; } @@ -1639,7 +1598,7 @@ ); } -@@ -3320,6 +_,11 @@ +@@ -3328,6 +_,11 @@ vec3 = vec3.add(flow); i++; } @@ -1651,7 +1610,7 @@ } } } -@@ -3417,7 +_,9 @@ +@@ -3425,7 +_,9 @@ } public void setDeltaMovement(Vec3 deltaMovement) { @@ -1661,7 +1620,7 @@ } public void addDeltaMovement(Vec3 addend) { -@@ -3480,9 +_,43 @@ +@@ -3488,9 +_,45 @@ return this.getZ((2.0 * this.random.nextDouble() - 1.0) * scale); } @@ -1677,12 +1636,14 @@ + } catch (Exception ex) { + entityInfo = "[Entity info unavailable] "; + } -+ LOGGER.error("New entity position is invalid! Tried to set invalid position ({},{},{}) for entity {} located at {}, entity info: {}", newX, newY, newZ, entity.getClass().getName(), entity.position, entityInfo, new Throwable()); ++ LOGGER.error("New entity position is invalid! Tried to set invalid position ({},{},{}) for entity {} located at {}, entity info: {}", newX, newY, newZ, entity.getClass().getName(), entity.position(), entityInfo, new Throwable()); + return false; + } ++ public final void setPosRaw(double x, double y, double z) { + this.setPosRaw(x, y, z, false); + } ++ + public final void setPosRaw(double x, double y, double z, boolean forceBoundingBoxUpdate) { + if (!checkPosition(this, x, y, z)) { + return; @@ -1691,7 +1652,7 @@ + // Paper start - Fix MC-4 + if (this instanceof ItemEntity) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().misc.fixEntityPositionDesync) { -+ // encode/decode from ClientboundMoveEntityPacket ++ // encode/decode from VecDeltaCodec todo computation changed? + x = Mth.lfloor(x * 4096.0) * (1 / 4096.0); + y = Mth.lfloor(y * 4096.0) * (1 / 4096.0); + z = Mth.lfloor(z * 4096.0) * (1 / 4096.0); @@ -1705,7 +1666,7 @@ int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); -@@ -3496,6 +_,12 @@ +@@ -3504,6 +_,12 @@ this.levelCallback.onMove(); } @@ -1718,23 +1679,31 @@ } public void checkDespawn() { -@@ -3583,6 +_,15 @@ +@@ -3543,6 +_,12 @@ + return this.getTicksFrozen() > 0; + } + ++ // CraftBukkit start ++ public float getBukkitYaw() { ++ return this.yRot; ++ } ++ // CraftBukkit end ++ + public float getYRot() { + return this.yRot; + } +@@ -3593,7 +_,9 @@ + } @Override - public final void setRemoved(Entity.RemovalReason removalReason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.setRemoved(removalReason, null); -+ } -+ -+ @Override -+ public final void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); -+ // CraftBukkit end +- public final void setRemoved(Entity.RemovalReason removalReason) { ++ public final void setRemoved(Entity.RemovalReason removalReason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause ++ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityRemoveEvent(this, cause); // CraftBukkit + final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { this.removalReason = removalReason; } -@@ -3594,12 +_,28 @@ +@@ -3605,12 +_,28 @@ this.getPassengers().forEach(Entity::stopRiding); this.levelCallback.onRemove(removalReason); this.onRemoval(removalReason); @@ -1763,7 +1732,7 @@ @Override public void setLevelCallback(EntityInLevelCallback levelCallback) { this.levelCallback = levelCallback; -@@ -3723,4 +_,14 @@ +@@ -3780,4 +_,14 @@ return this.save; } } @@ -1774,7 +1743,7 @@ + } + + public boolean isTicking() { -+ return ((ServerLevel) this.level).isPositionEntityTicking(this.blockPosition()); ++ return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition()); + } + // Paper end - Expose entity id counter } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityEquipment.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityEquipment.java.patch new file mode 100644 index 000000000..9542e0fd0 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityEquipment.java.patch @@ -0,0 +1,14 @@ +--- a/net/minecraft/world/entity/EntityEquipment.java ++++ b/net/minecraft/world/entity/EntityEquipment.java +@@ -71,4 +_,11 @@ + public void clear() { + this.items.replaceAll((equipmentSlot, itemStack) -> ItemStack.EMPTY); + } ++ ++ // Paper start - EntityDeathEvent ++ // Needed to not set ItemStack.EMPTY to not existent slot. ++ public boolean has(final EquipmentSlot slot) { ++ return this.items.containsKey(slot); ++ } ++ // Paper end - EntityDeathEvent + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch index dcb0fd0d6..8f2df071b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntitySelector.java.patch @@ -1,18 +1,17 @@ --- a/net/minecraft/world/entity/EntitySelector.java +++ b/net/minecraft/world/entity/EntitySelector.java -@@ -16,6 +_,23 @@ +@@ -17,6 +_,22 @@ public static final Predicate NO_SPECTATORS = entity -> !entity.isSpectator(); public static final Predicate CAN_BE_COLLIDED_WITH = NO_SPECTATORS.and(Entity::canBeCollidedWith); public static final Predicate CAN_BE_PICKED = NO_SPECTATORS.and(Entity::isPickable); + // Paper start - Ability to control player's insomnia and phantoms + public static Predicate IS_INSOMNIAC = (player) -> { -+ net.minecraft.server.level.ServerPlayer serverPlayer = (net.minecraft.server.level.ServerPlayer) player; -+ int playerInsomniaTicks = serverPlayer.level().paperConfig().entities.behavior.playerInsomniaStartTicks; -+ ++ int playerInsomniaTicks = player.level().paperConfig().entities.behavior.playerInsomniaStartTicks; + if (playerInsomniaTicks <= 0) { + return false; + } + ++ net.minecraft.server.level.ServerPlayer serverPlayer = (net.minecraft.server.level.ServerPlayer) player; + return net.minecraft.util.Mth.clamp(serverPlayer.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE) >= playerInsomniaTicks; + }; + // Paper end - Ability to control player's insomnia and phantoms @@ -24,13 +23,14 @@ private EntitySelector() { } -@@ -26,29 +_,34 @@ +@@ -27,18 +_,24 @@ } public static Predicate pushableBy(Entity entity) { + // Paper start - Climbing should not bypass cramming gamerule + return pushable(entity, false); + } ++ + public static Predicate pushable(Entity entity, boolean ignoreClimbing) { + // Paper end - Climbing should not bypass cramming gamerule Team team = entity.getTeam(); @@ -38,38 +38,15 @@ return (Predicate)(collisionRule == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : NO_SPECTATORS.and( -- pushedEntity -> { + pushedEntity -> { - if (!pushedEntity.isPushable()) { -+ pushedEntity -> { -+ if (!pushedEntity.isCollidable(ignoreClimbing) || !pushedEntity.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(pushedEntity)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule -+ return false; -+ } else if (!entity.level().isClientSide || pushedEntity instanceof Player && ((Player)pushedEntity).isLocalPlayer()) { -+ Team team1 = pushedEntity.getTeam(); -+ Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule(); -+ if (collisionRule1 == Team.CollisionRule.NEVER || (pushedEntity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions)) { // Paper - Configurable player collision ++ if (!pushedEntity.isCollidable(ignoreClimbing) || !pushedEntity.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(pushedEntity)) { // CraftBukkit - collidable API // Paper - Climbing should not bypass cramming gamerule return false; -- } else if (!entity.level().isClientSide || pushedEntity instanceof Player && ((Player)pushedEntity).isLocalPlayer()) { -- Team team1 = pushedEntity.getTeam(); -- Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule(); + } else if (!entity.level().isClientSide || pushedEntity instanceof Player player && player.isLocalPlayer()) { + Team team1 = pushedEntity.getTeam(); + Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule(); - if (collisionRule1 == Team.CollisionRule.NEVER) { -- return false; -- } else { -- boolean flag = team != null && team.isAlliedTo(team1); -- return (collisionRule != Team.CollisionRule.PUSH_OWN_TEAM && collisionRule1 != Team.CollisionRule.PUSH_OWN_TEAM || !flag) -- && (collisionRule != Team.CollisionRule.PUSH_OTHER_TEAMS && collisionRule1 != Team.CollisionRule.PUSH_OTHER_TEAMS || flag); -- } - } else { -- return false; -+ boolean flag = team != null && team.isAlliedTo(team1); -+ return (collisionRule != Team.CollisionRule.PUSH_OWN_TEAM && collisionRule1 != Team.CollisionRule.PUSH_OWN_TEAM || !flag) -+ && (collisionRule != Team.CollisionRule.PUSH_OTHER_TEAMS && collisionRule1 != Team.CollisionRule.PUSH_OTHER_TEAMS || flag); - } -+ } else { -+ return false; - } -- )); -+ } -+ )); - } - - public static Predicate notRiding(Entity entity) { ++ if (collisionRule1 == Team.CollisionRule.NEVER || (pushedEntity instanceof Player && !io.papermc.paper.configuration.GlobalConfiguration.get().collisions.enablePlayerCollisions)) { // Paper - Configurable player collision + return false; + } else { + boolean flag = team != null && team.isAlliedTo(team1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch index df8e7e81b..c07d1f48c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/EntityType.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -176,6 +_,7 @@ - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.phys.shapes.Shapes; - import net.minecraft.world.phys.shapes.VoxelShape; -+import org.bukkit.event.entity.CreatureSpawnEvent; - import org.slf4j.Logger; - - public class EntityType implements FeatureElement, EntityTypeTest { -@@ -215,7 +_,7 @@ +@@ -216,7 +_,7 @@ .fireImmune() .sized(6.0F, 0.5F) .clientTrackingRange(10) @@ -17,19 +9,19 @@ ); public static final EntityType ARMADILLO = register( "armadillo", EntityType.Builder.of(Armadillo::new, MobCategory.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10) -@@ -1132,6 +_,22 @@ +@@ -1145,6 +_,22 @@ boolean shouldOffsetY, boolean shouldOffsetYMore ) { + // CraftBukkit start -+ return this.spawn(level, spawnedFrom, player, pos, reason, shouldOffsetY, shouldOffsetYMore, reason == EntitySpawnReason.DISPENSER ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // Paper - use correct spawn reason for dispenser spawn eggs ++ return this.spawn(level, spawnedFrom, owner, pos, reason, shouldOffsetY, shouldOffsetYMore, reason == EntitySpawnReason.DISPENSER ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DISPENSE_EGG : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // Paper - use correct spawn reason for dispenser spawn eggs + } + + @Nullable + public T spawn( + ServerLevel level, + @Nullable ItemStack spawnedFrom, -+ @Nullable Player player, ++ @Nullable LivingEntity owner, + BlockPos pos, + EntitySpawnReason reason, + boolean shouldOffsetY, @@ -39,8 +31,8 @@ + // CraftBukkit end Consumer consumer; if (spawnedFrom != null) { - consumer = createDefaultStackConfig(level, spawnedFrom, player); -@@ -1139,7 +_,7 @@ + consumer = createDefaultStackConfig(level, spawnedFrom, owner); +@@ -1152,7 +_,7 @@ consumer = entity -> {}; } @@ -48,16 +40,16 @@ + return this.spawn(level, consumer, pos, reason, shouldOffsetY, shouldOffsetYMore, createSpawnReason); // CraftBukkit } - public static Consumer createDefaultStackConfig(Level level, ItemStack spawnedFrom, @Nullable Player player) { -@@ -1159,19 +_,54 @@ - Consumer consumer, Level level, ItemStack spawnedFrom, @Nullable Player player - ) { - CustomData customData = spawnedFrom.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); -- return !customData.isEmpty() ? consumer.andThen(entity -> updateCustomEntityTag(level, player, entity, customData)) : consumer; + public static Consumer createDefaultStackConfig(Level level, ItemStack stack, @Nullable LivingEntity owner) { +@@ -1169,19 +_,56 @@ + + public static Consumer appendCustomEntityStackConfig(Consumer consumer, Level level, ItemStack stack, @Nullable LivingEntity owner) { + CustomData customData = stack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY); +- return !customData.isEmpty() ? consumer.andThen(entity -> updateCustomEntityTag(level, owner, entity, customData)) : consumer; + // CraftBukkit start - SPIGOT-5665 + return !customData.isEmpty() ? consumer.andThen(entity -> { + try { -+ updateCustomEntityTag(level, player, entity, customData); ++ updateCustomEntityTag(level, owner, entity, customData); + } catch (Throwable t) { + EntityType.LOGGER.warn("Error loading spawn egg NBT", t); + } @@ -71,6 +63,7 @@ + // CraftBukkit start + return this.spawn(level, pos, reason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } ++ + @Nullable + public T spawn(ServerLevel level, BlockPos pos, EntitySpawnReason reason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + return this.spawn(level, null, pos, reason, false, false, creatureSpawnReason); @@ -82,12 +75,13 @@ + // CraftBukkit start + return this.spawn(level, consumer, pos, reason, shouldOffsetY, shouldOffsetYMore, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT); + } ++ + @Nullable + public T spawn(ServerLevel level, @Nullable Consumer consumer, BlockPos pos, EntitySpawnReason reason, boolean shouldOffsetY, boolean shouldOffsetYMore, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + // CraftBukkit end + // Paper start - PreCreatureSpawnEvent + com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(level, pos), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), + org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(this), + creatureSpawnReason + ); @@ -107,12 +101,12 @@ if (entity instanceof Mob mob) { mob.playAmbientSound(); } -@@ -1225,6 +_,15 @@ - EntityType entityType = customData.parseEntityType(server.registryAccess(), Registries.ENTITY_TYPE); - if (entity.getType() == entityType) { - if (level.isClientSide || !entity.getType().onlyOpCanSetNbt() || player != null && server.getPlayerList().isOp(player.getGameProfile())) { +@@ -1237,6 +_,15 @@ + if (level.isClientSide + || !entity.getType().onlyOpCanSetNbt() + || owner instanceof Player player && server.getPlayerList().isOp(player.getGameProfile())) { + // Paper start - filter out protected tags -+ if (player == null || !player.getBukkitEntity().hasPermission("minecraft.nbt.place")) { ++ if (owner == null || !owner.getBukkitEntity().hasPermission("minecraft.nbt.place")) { + customData = customData.update((compound) -> { + for (net.minecraft.commands.arguments.NbtPathArgument.NbtPath tag : level.paperConfig().entities.spawning.filteredEntityTagNbtPaths) { + tag.remove(compound); @@ -123,33 +117,25 @@ customData.loadInto(entity); } } -@@ -1296,9 +_,19 @@ +@@ -1308,9 +_,20 @@ } public static Optional create(CompoundTag tag, Level level, EntitySpawnReason spawnReason) { + // Paper start - Don't fire sync event during generation + return create(tag, level, spawnReason, false); + } ++ + public static Optional create(CompoundTag tag, Level level, EntitySpawnReason spawnReason, boolean generation) { + // Paper end - Don't fire sync event during generation return Util.ifElse( by(tag).map(entityType -> entityType.create(level, spawnReason)), - entity -> entity.load(tag), -+ // Paper start - Don't fire sync event during generation -+ entity -> { -+ if (generation) entity.generation = true; // Paper - Don't fire sync event during generation -+ entity.load(tag); -+ }, -+ // Paper end - Don't fire sync event during generation - () -> LOGGER.warn("Skipping Entity with id {}", tag.getString("id")) ++ // Paper start - Don't fire sync event during generation ++ entity -> { ++ if (generation) entity.generation = true; // Paper - Don't fire sync event during generation ++ entity.load(tag); ++ }, ++ // Paper end - Don't fire sync event during generation + () -> LOGGER.warn("Skipping Entity with id {}", tag.getStringOr("id", "[invalid]")) ); } -@@ -1325,7 +_,7 @@ - } - - public static Optional> by(CompoundTag tag) { -- return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.parse(tag.getString("id"))); -+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(tag.getString("id"))); // Paper - Validate ResourceLocation - } - - @Nullable diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch index 69d13b307..5640424cd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ExperienceOrb.java.patch @@ -1,102 +1,87 @@ --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -24,6 +_,14 @@ - import net.minecraft.world.phys.AABB; - import net.minecraft.world.phys.Vec3; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -+import org.bukkit.event.entity.EntityTargetEvent; -+import org.bukkit.event.player.PlayerExpCooldownChangeEvent; -+// CraftBukkit end -+ - public class ExperienceOrb extends Entity { - private static final int LIFETIME = 6000; - private static final int ENTITY_SCAN_PERIOD = 20; -@@ -35,9 +_,63 @@ - public int value; - public int count = 1; +@@ -41,9 +_,54 @@ + @Nullable private Player followingPlayer; + private final InterpolationHandler interpolation = new InterpolationHandler(this); - + // Paper start -+ @javax.annotation.Nullable ++ @Nullable + public java.util.UUID sourceEntityId; -+ @javax.annotation.Nullable ++ @Nullable + public java.util.UUID triggerEntityId; + public org.bukkit.entity.ExperienceOrb.SpawnReason spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + + private void loadPaperNBT(CompoundTag tag) { -+ if (!tag.contains("Paper.ExpData", net.minecraft.nbt.Tag.TAG_COMPOUND)) { ++ CompoundTag expData = tag.getCompoundOrEmpty("Paper.ExpData"); ++ if (expData.isEmpty()) { + return; + } -+ CompoundTag comp = tag.getCompound("Paper.ExpData"); -+ if (comp.hasUUID("source")) { -+ this.sourceEntityId = comp.getUUID("source"); -+ } -+ if (comp.hasUUID("trigger")) { -+ this.triggerEntityId = comp.getUUID("trigger"); -+ } -+ if (comp.contains("reason")) { -+ String reason = comp.getString("reason"); ++ ++ this.sourceEntityId = expData.read("source", net.minecraft.core.UUIDUtil.CODEC).orElse(null); ++ this.triggerEntityId = expData.read("trigger", net.minecraft.core.UUIDUtil.CODEC).orElse(null); ++ expData.getString("reason").ifPresent(reason -> { + try { + this.spawnReason = org.bukkit.entity.ExperienceOrb.SpawnReason.valueOf(reason); + } catch (Exception e) { + this.level().getCraftServer().getLogger().warning("Invalid spawnReason set for experience orb: " + e.getMessage() + " - " + reason); + } -+ } ++ }); + } + private void savePaperNBT(CompoundTag tag) { -+ CompoundTag comp = new CompoundTag(); -+ if (this.sourceEntityId != null) { -+ comp.putUUID("source", this.sourceEntityId); ++ CompoundTag expData = new CompoundTag(); ++ expData.storeNullable("source", net.minecraft.core.UUIDUtil.CODEC, this.sourceEntityId); ++ expData.storeNullable("trigger", net.minecraft.core.UUIDUtil.CODEC, this.triggerEntityId); ++ if (this.spawnReason != org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN) { ++ expData.putString("reason", this.spawnReason.name()); + } -+ if (this.triggerEntityId != null) { -+ comp.putUUID("trigger", triggerEntityId); -+ } -+ if (this.spawnReason != null && this.spawnReason != org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN) { -+ comp.putString("reason", this.spawnReason.name()); -+ } -+ tag.put("Paper.ExpData", comp); ++ tag.put("Paper.ExpData", expData); + } + -+ @io.papermc.paper.annotation.DoNotUse -+ @Deprecated ++ @Deprecated @io.papermc.paper.annotation.DoNotUse public ExperienceOrb(Level level, double x, double y, double z, int value) { + this(level, x, y, z, value, null, null); + } + -+ public ExperienceOrb(Level level, double x, double y, double z, int value, @javax.annotation.Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @javax.annotation.Nullable Entity triggerId) { ++ public ExperienceOrb(Level level, double x, double y, double z, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId) { + this(level, x, y, z, value, reason, triggerId, null); + } + -+ public ExperienceOrb(Level level, double x, double y, double z, int value, @javax.annotation.Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @javax.annotation.Nullable Entity triggerId, @javax.annotation.Nullable Entity sourceId) { ++ public ExperienceOrb(Level level, double x, double y, double z, int value, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { this(EntityType.EXPERIENCE_ORB, level); + this.sourceEntityId = sourceId != null ? sourceId.getUUID() : null; + this.triggerEntityId = triggerId != null ? triggerId.getUUID() : null; + this.spawnReason = reason != null ? reason : org.bukkit.entity.ExperienceOrb.SpawnReason.UNKNOWN; + // Paper end this.setPos(x, y, z); - this.setYRot((float)(this.random.nextDouble() * 360.0)); - this.setDeltaMovement( -@@ -67,6 +_,7 @@ - @Override - public void tick() { - super.tick(); -+ Player prevTarget = this.followingPlayer;// CraftBukkit - store old target - this.xo = this.getX(); - this.yo = this.getY(); - this.zo = this.getZ(); -@@ -92,7 +_,22 @@ - this.followingPlayer = null; + if (!this.level().isClientSide) { + this.setYRot((float)(this.random.nextDouble() * 360.0)); +@@ -119,12 +_,13 @@ + + this.age++; + if (this.age >= 6000) { +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause + } + } + } + + private void followNearbyPlayer() { ++ Player prevTarget = this.followingPlayer; // CraftBukkit - store old target + if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { + Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); + if (nearestPlayer != null && !nearestPlayer.isSpectator() && !nearestPlayer.isDeadOrDying()) { +@@ -134,7 +_,24 @@ + } } - if (this.followingPlayer != null) { + // CraftBukkit start + boolean cancelled = false; + if (this.followingPlayer != prevTarget) { -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, this.followingPlayer, (this.followingPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET); ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent( ++ this, this.followingPlayer, (this.followingPlayer != null) ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET ++ ); + LivingEntity target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); + cancelled = event.isCancelled(); + @@ -112,26 +97,19 @@ Vec3 vec3 = new Vec3( this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + this.followingPlayer.getEyeHeight() / 2.0 - this.getY(), -@@ -120,7 +_,7 @@ - - this.age++; - if (this.age >= 6000) { -- this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } - } - -@@ -143,16 +_,25 @@ +@@ -161,16 +_,27 @@ } public static void award(ServerLevel level, Vec3 pos, int amount) { + // Paper start - add reasons for orbs + award(level, pos, amount, null, null, null); + } -+ public static void award(ServerLevel level, Vec3 pos, int amount, org.bukkit.entity.ExperienceOrb.SpawnReason reason, Entity triggerId) { ++ ++ public static void award(ServerLevel level, Vec3 pos, int amount, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId) { + award(level, pos, amount, reason, triggerId, null); + } -+ public static void award(ServerLevel level, Vec3 pos, int amount, org.bukkit.entity.ExperienceOrb.SpawnReason reason, Entity triggerId, Entity sourceId) { ++ ++ public static void award(ServerLevel level, Vec3 pos, int amount, @Nullable org.bukkit.entity.ExperienceOrb.SpawnReason reason, @Nullable Entity triggerId, @Nullable Entity sourceId) { + // Paper end - add reasons for orbs while (amount > 0) { int experienceValue = getExperienceValue(amount); @@ -148,7 +126,7 @@ AABB aabb = AABB.ofSize(pos, 1.0, 1.0, 1.0); int randomInt = level.getRandom().nextInt(40); List entities = level.getEntities(EntityTypeTest.forClass(ExperienceOrb.class), aabb, orb -> canMerge(orb, randomInt, amount)); -@@ -175,9 +_,14 @@ +@@ -193,9 +_,14 @@ } private void merge(ExperienceOrb orb) { @@ -160,36 +138,36 @@ this.count = this.count + orb.count; this.age = Math.min(this.age, orb.age); - orb.discard(); -+ orb.discard(EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause ++ orb.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.MERGE); // CraftBukkit - add Bukkit remove cause } private void setUnderwaterMovement() { -@@ -202,7 +_,7 @@ +@@ -220,7 +_,7 @@ this.markHurt(); this.health = (int)(this.health - amount); if (this.health <= 0) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } return true; -@@ -213,32 +_,34 @@ +@@ -231,32 +_,34 @@ public void addAdditionalSaveData(CompoundTag compound) { compound.putShort("Health", (short)this.health); compound.putShort("Age", (short)this.age); -- compound.putShort("Value", (short)this.value); -+ compound.putInt("Value", this.value); // Paper - save as Integer +- compound.putShort("Value", (short)this.getValue()); ++ compound.putInt("Value", this.getValue()); // Paper - save as Integer compound.putInt("Count", this.count); + this.savePaperNBT(compound); // Paper } @Override public void readAdditionalSaveData(CompoundTag compound) { - this.health = compound.getShort("Health"); - this.age = compound.getShort("Age"); -- this.value = compound.getShort("Value"); -+ this.value = compound.getInt("Value"); // Paper - load as Integer - this.count = Math.max(compound.getInt("Count"), 1); + this.health = compound.getShortOr("Health", (short)5); + this.age = compound.getShortOr("Age", (short)0); +- this.setValue(compound.getShortOr("Value", (short)0)); ++ this.setValue(compound.getIntOr("Value", 0)); // Paper - load as Integer + this.count = compound.read("Count", ExtraCodecs.POSITIVE_INT).orElse(1); + this.loadPaperNBT(compound); // Paper } @@ -199,29 +177,29 @@ - if (entity.takeXpDelay == 0) { - entity.takeXpDelay = 2; + if (entity.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(serverPlayer.getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper - PlayerPickupExperienceEvent -+ entity.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entity, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; ++ entity.takeXpDelay = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerXpCooldownEvent(entity, 2, org.bukkit.event.player.PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2; entity.take(this, 1); - int i = this.repairPlayerItems(serverPlayer, this.value); + int i = this.repairPlayerItems(serverPlayer, this.getValue()); if (i > 0) { - entity.giveExperiencePoints(i); -+ entity.giveExperiencePoints(CraftEventFactory.callPlayerExpChangeEvent(entity, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object ++ entity.giveExperiencePoints(org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerExpChangeEvent(entity, this).getAmount()); // CraftBukkit - this.value -> event.getAmount() // Paper - supply experience orb object } this.count--; if (this.count == 0) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause } } } -@@ -252,10 +_,21 @@ +@@ -270,9 +_,19 @@ ItemStack itemStack = randomItemWith.get().itemStack(); int i = EnchantmentHelper.modifyDurabilityToRepairFromXp(player.serverLevel(), itemStack, value); int min = Math.min(i, itemStack.getDamageValue()); + // CraftBukkit start + // Paper start - mending event + final int consumedExperience = min > 0 ? min * value / i : 0; -+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(player, this, itemStack, randomItemWith.get().inSlot(), min, consumedExperience); ++ org.bukkit.event.player.PlayerItemMendEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerItemMendEvent(player, this, itemStack, randomItemWith.get().inSlot(), min, consumedExperience); + // Paper end - mending event + min = event.getRepairAmount(); + if (event.isCancelled()) { @@ -233,11 +211,9 @@ - int i1 = value - min * value / i; + int i1 = value - min * value / i; // Paper - diff on change - expand PlayerMendEvents if (i1 > 0) { -+ // this.value = l; // CraftBukkit - update exp value of orb for PlayerItemMendEvent calls // Paper - the value field should not be mutated here because it doesn't take "count" into account return this.repairPlayerItems(player, i1); } - } -@@ -295,6 +_,24 @@ +@@ -318,6 +_,24 @@ } public static int getExperienceValue(int expValue) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch new file mode 100644 index 000000000..a08696aff --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectApplier.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/entity/InsideBlockEffectApplier.java ++++ b/net/minecraft/world/entity/InsideBlockEffectApplier.java +@@ -32,7 +_,7 @@ + public static class StepBasedCollector implements InsideBlockEffectApplier { + private static final InsideBlockEffectType[] APPLY_ORDER = InsideBlockEffectType.values(); + private static final int NO_STEP = -1; +- private final Set effectsInStep = EnumSet.noneOf(InsideBlockEffectType.class); ++ private final Map> effectsInStep = new java.util.EnumMap<>(InsideBlockEffectType.class); // Paper - track position inside effect was triggered on + private final Map>> beforeEffectsInStep = Util.makeEnumMap( + InsideBlockEffectType.class, insideBlockEffectType -> new ArrayList<>() + ); +@@ -42,7 +_,8 @@ + private final List> finalEffects = new ArrayList<>(); + private int lastStep = -1; + +- public void advanceStep(int step) { ++ public void advanceStep(int step, net.minecraft.core.BlockPos pos) { // Paper - track position inside effect was triggered on ++ this.currentBlockPos = pos; // Paper - track position inside effect was triggered on + if (this.lastStep != step) { + this.lastStep = step; + this.flushStep(); +@@ -69,8 +_,8 @@ + List> list = this.beforeEffectsInStep.get(insideBlockEffectType); + this.finalEffects.addAll(list); + list.clear(); +- if (this.effectsInStep.remove(insideBlockEffectType)) { +- this.finalEffects.add(insideBlockEffectType.effect()); ++ if (this.effectsInStep.remove(insideBlockEffectType) instanceof final Consumer recordedEffect) { // Paper - track position inside effect was triggered on - better than null check to avoid diff. ++ this.finalEffects.add(recordedEffect); // Paper - track position inside effect was triggered on + } + + List> list1 = this.afterEffectsInStep.get(insideBlockEffectType); +@@ -81,7 +_,7 @@ + + @Override + public void apply(InsideBlockEffectType type) { +- this.effectsInStep.add(type); ++ this.effectsInStep.put(type, recorded(type)); // Paper - track position inside effect was triggered on + } + + @Override +@@ -93,5 +_,24 @@ + public void runAfter(InsideBlockEffectType type, Consumer effect) { + this.afterEffectsInStep.get(type).add(effect); + } ++ ++ // Paper start - track position inside effect was triggered on ++ private net.minecraft.core.BlockPos currentBlockPos; ++ ++ private Consumer recorded(final InsideBlockEffectType type) { ++ return new RecordedEffect(this.currentBlockPos, type.effect()); ++ } ++ ++ record RecordedEffect( ++ net.minecraft.core.BlockPos blockPos, ++ InsideBlockEffectType.Applier applier ++ ) implements Consumer { ++ ++ @Override ++ public void accept(final Entity entity) { ++ this.applier.affect(entity, blockPos); ++ } ++ } ++ // Paper end - track position inside effect was triggered on + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch new file mode 100644 index 000000000..57b806c66 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/InsideBlockEffectType.java.patch @@ -0,0 +1,41 @@ +--- a/net/minecraft/world/entity/InsideBlockEffectType.java ++++ b/net/minecraft/world/entity/InsideBlockEffectType.java +@@ -6,21 +_,34 @@ + public enum InsideBlockEffectType { + FREEZE(entity -> { + entity.setIsInPowderSnow(true); +- if (entity.canFreeze()) { ++ if (entity.canFreeze() && !entity.freezeLocked) { // Paper - Freeze Tick Lock API + entity.setTicksFrozen(Math.min(entity.getTicksRequiredToFreeze(), entity.getTicksFrozen() + 1)); + } + }), + FIRE_IGNITE(BaseFireBlock::fireIgnite), +- LAVA_IGNITE(Entity::lavaIgnite), ++ LAVA_IGNITE((entity, pos) -> entity.lavaIgnite(pos)), // Paper - track lava contact + EXTINGUISH(Entity::clearFire); + +- private final Consumer effect; ++ private final Applier effect; // Paper - track position inside effect was triggered on + + private InsideBlockEffectType(final Consumer effect) { ++ // Paper start - track position inside effect was triggered on ++ this((entity, block) -> effect.accept(entity)); ++ } ++ private InsideBlockEffectType(final Applier effect) { ++ // Paper end - track position inside effect was triggered on + this.effect = effect; + } + +- public Consumer effect() { ++ public Applier effect() { // Paper - track position inside effect was triggered on + return this.effect; + } ++ ++ // Paper start - track position inside effect was triggered on ++ // Use over biconsumer for less fqn spamming. ++ @FunctionalInterface ++ public interface Applier { ++ void affect(final Entity entity, final net.minecraft.core.BlockPos blockPos); ++ } ++ // Paper end - track position inside effect was triggered on + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch index 914667d8d..9da5f6880 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Interaction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/Interaction.java +++ b/net/minecraft/world/entity/Interaction.java -@@ -130,9 +_,16 @@ +@@ -100,9 +_,16 @@ @Override public boolean skipAttackInteraction(Entity entity) { if (entity instanceof Player player) { @@ -14,7 +14,7 @@ this.attack = new Interaction.PlayerAction(player.getUUID(), this.level().getGameTime()); if (player instanceof ServerPlayer serverPlayer) { - CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, player.damageSources().generic(), 1.0F, 1.0F, false); -+ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, source, 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit // Paper - use correct source and fix taken/dealt param order ++ CriteriaTriggers.PLAYER_HURT_ENTITY.trigger(serverPlayer, this, source, 1.0F, (float) event.getFinalDamage(), false); // CraftBukkit } return !this.getResponse(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch index cd34eb69a..49b9f128f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ItemBasedSteering.java.patch @@ -1,17 +1,15 @@ --- a/net/minecraft/world/entity/ItemBasedSteering.java +++ b/net/minecraft/world/entity/ItemBasedSteering.java -@@ -51,6 +_,14 @@ +@@ -47,4 +_,12 @@ + public int boostTimeTotal() { return this.entityData.get(this.boostTimeAccessor); } - -+ // CraftBukkit add setBoostTicks(int) ++ ++ // CraftBukkit start + public void setBoostTicks(int ticks) { + this.boosting = true; + this.boostTime = 0; + this.entityData.set(this.boostTimeAccessor, ticks); + } + // CraftBukkit end -+ - public void addAdditionalSaveData(CompoundTag nbt) { - nbt.putBoolean("Saddle", this.hasSaddle()); - } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch index 691174efb..e4ab3df08 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Leashable.java.patch @@ -1,33 +1,18 @@ --- a/net/minecraft/world/entity/Leashable.java +++ b/net/minecraft/world/entity/Leashable.java -@@ -56,7 +_,13 @@ - @Nullable - private static Leashable.LeashData readLeashDataInternal(CompoundTag tag) { - if (tag.contains("leash", 10)) { -- return new Leashable.LeashData(Either.left(tag.getCompound("leash").getUUID("UUID"))); -+ // Paper start -+ final CompoundTag leashTag = tag.getCompound("leash"); -+ if (!leashTag.hasUUID("UUID")) { -+ return null; -+ } -+ return new Leashable.LeashData(Either.left(leashTag.getUUID("UUID"))); -+ // Paper end - } else { - if (tag.contains("leash", 11)) { - Either either = NbtUtils.readBlockPos(tag, "leash").>map(Either::right).orElse(null); -@@ -72,6 +_,11 @@ +@@ -56,6 +_,11 @@ + } + default void writeLeashData(CompoundTag tag, @Nullable Leashable.LeashData leashData) { - if (leashData != null) { - Either either = leashData.delayedLeashInfo; -+ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin -+ if (leashData.leashHolder != null && leashData.leashHolder.pluginRemoved) { -+ return; -+ } -+ // CraftBukkit end - if (leashData.leashHolder instanceof LeashFenceKnotEntity leashFenceKnotEntity) { - either = Either.right(leashFenceKnotEntity.getPos()); - } else if (leashData.leashHolder != null) { -@@ -104,7 +_,9 @@ ++ // CraftBukkit start - SPIGOT-7487: Don't save (and possible drop) leash, when the holder was removed by a plugin ++ if (leashData != null && leashData.leashHolder != null && leashData.leashHolder.pluginRemoved) { ++ return; ++ } ++ // CraftBukkit end + tag.storeNullable("leash", Leashable.LeashData.CODEC, leashData); + } + +@@ -75,7 +_,9 @@ } if (entity.tickCount > 100) { @@ -37,7 +22,7 @@ entity.setLeashData(null); } } -@@ -128,7 +_,9 @@ +@@ -99,7 +_,9 @@ entity.onLeashRemoved(); if (entity.level() instanceof ServerLevel serverLevel) { if (dropItem) { @@ -47,7 +32,7 @@ } if (broadcastPacket) { -@@ -146,7 +_,15 @@ +@@ -117,7 +_,15 @@ if (leashData != null && leashData.leashHolder != null) { if (!entity.isAlive() || !leashData.leashHolder.isAlive()) { @@ -64,7 +49,7 @@ entity.dropLeash(); } else { entity.removeLeash(); -@@ -160,7 +_,7 @@ +@@ -131,7 +_,7 @@ return; } @@ -73,7 +58,7 @@ entity.leashTooFarBehaviour(); } else if (f > 6.0) { entity.elasticRangeLeashBehaviour(leashHolder, f); -@@ -177,7 +_,21 @@ +@@ -148,7 +_,21 @@ } default void leashTooFarBehaviour() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch index b5b67ef4e..ec4c7e172 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LightningBolt.java.patch @@ -40,7 +40,7 @@ } - if (this.life >= 0) { -+ if (this.life >= 0 && !this.isEffect) { // CraftBukkit - add !this.visualOnly // Paper - Properly handle lightning effects api ++ if (this.life >= 0 && !this.isEffect) { // Paper - Properly handle lightning effects api if (!(this.level() instanceof ServerLevel)) { this.level().setSkyFlashTime(2); - } else if (!this.visualOnly) { @@ -59,8 +59,8 @@ if (this.level().getBlockState(blockPos).isAir() && state.canSurvive(this.level(), blockPos)) { - this.level().setBlockAndUpdate(blockPos, state); - this.blocksSetOnFire++; -+ // CraftBukkit start - add "!visualOnly" -+ if (!this.visualOnly && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos, this).isCancelled()) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos, this).isCancelled()) { + this.level().setBlockAndUpdate(blockPos, state); + this.blocksSetOnFire++; + } @@ -73,8 +73,8 @@ if (this.level().getBlockState(blockPos1).isAir() && state.canSurvive(this.level(), blockPos1)) { - this.level().setBlockAndUpdate(blockPos1, state); - this.blocksSetOnFire++; -+ // CraftBukkit start - add "!visualOnly" -+ if (!this.visualOnly && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockPos1, this).isCancelled()) { + this.level().setBlockAndUpdate(blockPos1, state); + this.blocksSetOnFire++; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch index ed516d3b9..02b24b9ac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/LivingEntity.java.patch @@ -1,81 +1,56 @@ --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -42,6 +_,8 @@ - import net.minecraft.core.particles.ParticleOptions; - import net.minecraft.core.particles.ParticleTypes; - import net.minecraft.nbt.CompoundTag; -+import net.minecraft.nbt.FloatTag; -+import net.minecraft.nbt.IntTag; - import net.minecraft.nbt.ListTag; - import net.minecraft.nbt.NbtOps; - import net.minecraft.nbt.Tag; -@@ -136,6 +_,29 @@ - import net.minecraft.world.scores.Scoreboard; +@@ -135,6 +_,17 @@ + import org.jetbrains.annotations.Contract; import org.slf4j.Logger; +// CraftBukkit start -+import java.util.ArrayList; -+import java.util.HashSet; -+import java.util.Set; -+import java.util.LinkedList; -+import java.util.UUID; -+import net.minecraft.world.item.component.Consumable; +import org.bukkit.Location; -+import org.bukkit.craftbukkit.attribute.CraftAttributeMap; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.event.entity.ArrowBodyCountChangeEvent; +import org.bukkit.event.entity.EntityDamageEvent; +import org.bukkit.event.entity.EntityDamageEvent.DamageModifier; -+import org.bukkit.event.entity.EntityKnockbackEvent; +import org.bukkit.event.entity.EntityPotionEffectEvent; +import org.bukkit.event.entity.EntityRegainHealthEvent; -+import org.bukkit.event.entity.EntityRemoveEvent; +import org.bukkit.event.entity.EntityResurrectEvent; -+import org.bukkit.event.entity.EntityTeleportEvent; -+import org.bukkit.event.player.PlayerItemConsumeEvent; +// CraftBukkit end + public abstract class LivingEntity extends Entity implements Attackable { private static final Logger LOGGER = LogUtils.getLogger(); private static final String TAG_ACTIVE_EFFECTS = "active_effects"; -@@ -266,11 +_,29 @@ +@@ -251,11 +_,25 @@ EquipmentSlot.class ); - protected float appliedScale = 1.0F; + protected final EntityEquipment equipment; + // CraftBukkit start + public int expToDrop; -+ public ArrayList drops = new ArrayList<>(); // Paper - Restore vanilla drops behavior ++ public List drops = new java.util.ArrayList<>(); // Paper - Restore vanilla drops behavior + public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; + public boolean collides = true; -+ public Set collidableExemptions = new HashSet<>(); ++ public Set collidableExemptions = new java.util.HashSet<>(); + public boolean bukkitPickUpLoot; + public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper + public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API -+ -+ @Override -+ public float getBukkitYaw() { -+ return this.getYHeadRot(); -+ } ++ public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; // Paper - Make shield blocking delay configurable + // CraftBukkit end protected LivingEntity(EntityType entityType, Level level) { super(entityType, level); this.attributes = new AttributeMap(DefaultAttributes.getSupplier(entityType)); - this.setHealth(this.getMaxHealth()); -+ this.craftAttributes = new CraftAttributeMap(this.attributes); // CraftBukkit ++ this.craftAttributes = new org.bukkit.craftbukkit.attribute.CraftAttributeMap(this.attributes); // CraftBukkit + // CraftBukkit - this.setHealth(this.getMaxHealth()) inlined and simplified to skip the instanceof check for Player, as getBukkitEntity() is not initialized in constructor + this.entityData.set(LivingEntity.DATA_HEALTH_ID, this.getMaxHealth()); + this.equipment = this.createEquipment(); this.blocksBuilding = true; - this.rotA = (float)((Math.random() + 1.0) * 0.01F); this.reapplyPosition(); -@@ -360,7 +_,13 @@ - float f = Mth.ceil(this.fallDistance - attributeValue); - double min = Math.min((double)(0.2F + f / 15.0F), 2.5); - int i = (int)(150.0 * min); +@@ -350,7 +_,13 @@ + + double d1 = Math.min(0.2F + d / 15.0, 2.5); + int i = (int)(150.0 * d1); - serverLevel.sendParticles(new BlockParticleOption(ParticleTypes.BLOCK, state), x, y1, z, i, 0.0, 0.0, 0.0, 0.15F); -+ // CraftBukkit start - visiblity api ++ // CraftBukkit start - visibility api + if (this instanceof ServerPlayer) { + serverLevel.sendParticlesSource((ServerPlayer) this, new BlockParticleOption(ParticleTypes.BLOCK, state), false, false, x, y1, z, i, 0.0, 0.0, 0.0, 0.15F); + } else { @@ -85,16 +60,16 @@ } } -@@ -566,7 +_,7 @@ +@@ -535,7 +_,7 @@ this.deathTime++; if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) { this.level().broadcastEntityEvent(this, (byte)60); - this.remove(Entity.RemovalReason.KILLED); -+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause ++ this.remove(Entity.RemovalReason.KILLED, org.bukkit.event.entity.EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause } } -@@ -658,7 +_,7 @@ +@@ -640,7 +_,7 @@ } public boolean shouldDiscardFriction() { @@ -103,7 +78,7 @@ } public void setDiscardFriction(boolean discardFriction) { -@@ -670,11 +_,16 @@ +@@ -652,10 +_,15 @@ } public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { @@ -113,25 +88,19 @@ + public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem, boolean silent) { + // CraftBukkit end if (!this.level().isClientSide() && !this.isSpectator()) { - boolean flag = newItem.isEmpty() && oldItem.isEmpty(); - if (!flag && !ItemStack.isSameItemSameComponents(oldItem, newItem) && !this.firstTick) { + if (!ItemStack.isSameItemSameComponents(oldItem, newItem) && !this.firstTick) { Equippable equippable = newItem.get(DataComponents.EQUIPPABLE); - if (!this.isSilent() && equippable != null && slot == equippable.slot()) { + if (!this.isSilent() && equippable != null && slot == equippable.slot() && !silent) { // CraftBukkit this.level() .playSeededSound( - null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong() -@@ -690,11 +_,18 @@ + null, +@@ -682,12 +_,12 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, EntityRemoveEvent.Cause eventCause) { -+ // CraftBukkit end +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause if ((reason == Entity.RemovalReason.KILLED || reason == Entity.RemovalReason.DISCARDED) && this.level() instanceof ServerLevel serverLevel) { this.triggerOnDeathMobEffects(serverLevel, reason); } @@ -141,7 +110,7 @@ this.brain.clearMemories(); } -@@ -703,11 +_,17 @@ +@@ -696,11 +_,17 @@ mobEffectInstance.onMobRemoved(level, this, removalReason); } @@ -159,77 +128,121 @@ compound.putFloat("Health", this.getHealth()); compound.putShort("HurtTime", (short)this.hurtTime); compound.putInt("HurtByTimestamp", this.lastHurtByMobTimestamp); -@@ -736,7 +_,23 @@ +@@ -731,8 +_,15 @@ + } + } + +- @Nullable +- public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { ++ // Paper start - Extend dropItem API ++ @Nullable ++ public final ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower) { ++ return this.drop(stack, randomizeMotion, includeThrower, true, null); ++ } ++ ++ @Nullable ++ public ItemEntity drop(ItemStack stack, boolean randomizeMotion, boolean includeThrower, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { ++ // Paper end - Extend dropItem API + if (stack.isEmpty()) { + return null; + } else if (this.level().isClientSide) { +@@ -741,6 +_,31 @@ + } else { + ItemEntity itemEntity = this.createItemStackToDrop(stack, randomizeMotion, includeThrower); + if (itemEntity != null) { ++ // CraftBukkit start - fire PlayerDropItemEvent ++ if (entityOperation != null) entityOperation.accept((org.bukkit.entity.Item) itemEntity.getBukkitEntity()); ++ if (callEvent && this.getBukkitEntity() instanceof org.bukkit.entity.Player player) { ++ org.bukkit.entity.Item drop = (org.bukkit.entity.Item) itemEntity.getBukkitEntity(); ++ ++ org.bukkit.event.player.PlayerDropItemEvent event = new org.bukkit.event.player.PlayerDropItemEvent(player, drop); ++ this.level().getCraftServer().getPluginManager().callEvent(event); ++ ++ if (event.isCancelled()) { ++ org.bukkit.inventory.ItemStack inHandItem = player.getInventory().getItemInMainHand(); ++ if (includeThrower && inHandItem.getAmount() == 0) { ++ // The complete stack was dropped ++ player.getInventory().setItemInMainHand(drop.getItemStack()); ++ } else if (includeThrower && inHandItem.isSimilar(drop.getItemStack()) && inHandItem.getAmount() < inHandItem.getMaxStackSize() && drop.getItemStack().getAmount() == 1) { ++ // Only one item is dropped ++ inHandItem.setAmount(inHandItem.getAmount() + 1); ++ player.getInventory().setItemInMainHand(inHandItem); ++ } else { ++ // Fallback ++ player.getInventory().addItem(drop.getItemStack()); ++ } ++ return null; ++ } ++ } ++ // CraftBukkit end + this.level().addFreshEntity(itemEntity); + } + +@@ -750,7 +_,22 @@ @Override public void readAdditionalSaveData(CompoundTag compound) { -- this.internalSetAbsorptionAmount(compound.getFloat("AbsorptionAmount")); +- this.internalSetAbsorptionAmount(compound.getFloatOr("AbsorptionAmount", 0.0F)); + // Paper start - Check for NaN -+ float absorptionAmount = compound.getFloat("AbsorptionAmount"); ++ float absorptionAmount = compound.getFloatOr("AbsorptionAmount", 0.0F); + if (Float.isNaN(absorptionAmount)) { + absorptionAmount = 0; + } + this.internalSetAbsorptionAmount(absorptionAmount); + // Paper end - Check for NaN + // Paper start - Friction API -+ if (compound.contains("Paper.FrictionState")) { -+ String frictionState = compound.getString("Paper.FrictionState"); ++ compound.getString("Paper.FrictionState").ifPresent(frictionState -> { + try { + this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState); + } catch (Exception ignored) { -+ LOGGER.error("Unknown friction state " + frictionState + " for " + this); ++ LOGGER.error("Unknown friction state {} for {}", frictionState, this); + } -+ } ++ }); + // Paper end - Friction API - if (compound.contains("attributes", 9) && this.level() != null && !this.level().isClientSide) { - this.getAttributes().load(compound.getList("attributes", 10)); + if (this.level() != null && !this.level().isClientSide) { + compound.getList("attributes").ifPresent(this.getAttributes()::load); } -@@ -753,6 +_,16 @@ - } +@@ -763,6 +_,11 @@ + this.activeEffects.put(mobEffectInstance.getEffect(), mobEffectInstance); } + // CraftBukkit start -+ if (compound.contains("Bukkit.MaxHealth")) { -+ Tag maxHealthTag = compound.get("Bukkit.MaxHealth"); -+ if (maxHealthTag.getId() == 5) { -+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(((FloatTag) maxHealthTag).getAsDouble()); -+ } else if (maxHealthTag.getId() == 3) { -+ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(((IntTag) maxHealthTag).getAsDouble()); -+ } -+ } ++ compound.getDouble("Bukkit.MaxHealth").ifPresent(maxHealth -> { ++ this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(maxHealth); ++ }); + // CraftBukkit end - if (compound.contains("Health", 99)) { - this.setHealth(compound.getFloat("Health")); - } -@@ -764,6 +_,7 @@ - String string = compound.getString("Team"); + this.setHealth(compound.getFloatOr("Health", this.getMaxHealth())); + this.hurtTime = compound.getShortOr("HurtTime", (short)0); + this.deathTime = compound.getShortOr("DeathTime", (short)0); +@@ -770,6 +_,7 @@ + compound.getString("Team").ifPresent(string -> { Scoreboard scoreboard = this.level().getScoreboard(); PlayerTeam playerTeam = scoreboard.getPlayerTeam(string); + if (!this.level().paperConfig().scoreboards.allowNonPlayerEntitiesOnScoreboards && !(this instanceof net.minecraft.world.entity.player.Player)) { playerTeam = null; } // Paper - Perf: Disable Scoreboards for non players by default boolean flag = playerTeam != null && scoreboard.addPlayerToTeam(this.getStringUUID(), playerTeam); if (!flag) { LOGGER.warn("Unable to add mob to team \"{}\" (that team probably doesn't exist)", string); -@@ -776,11 +_,13 @@ - - if (compound.contains("SleepingX", 99) && compound.contains("SleepingY", 99) && compound.contains("SleepingZ", 99)) { - BlockPos blockPos = new BlockPos(compound.getInt("SleepingX"), compound.getInt("SleepingY"), compound.getInt("SleepingZ")); -+ if (this.position().distanceToSqr(blockPos.getX(), blockPos.getY(), blockPos.getZ()) < 16 * 16) { // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong +@@ -777,11 +_,13 @@ + }); + this.setSharedFlag(7, compound.getBooleanOr("FallFlying", false)); + compound.read("sleeping_pos", BlockPos.CODEC).ifPresentOrElse(blockPos -> { ++ if (this.position().distanceToSqr(blockPos.getX(), blockPos.getY(), blockPos.getZ()) < Mth.square(16)) { // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong this.setSleepingPos(blockPos); this.entityData.set(DATA_POSE, Pose.SLEEPING); if (!this.firstTick) { this.setPosToBed(blockPos); } + } // Paper - The sleeping pos will always also set the actual pos, so a desync suggests something is wrong - } - - if (compound.contains("Brain", 10)) { -@@ -788,15 +_,44 @@ - } + }, this::clearSleepingPos); + compound.getCompound("Brain").ifPresent(compoundTag -> this.brain = this.makeBrain(new Dynamic<>(NbtOps.INSTANCE, compoundTag))); + this.lastHurtByPlayer = EntityReference.read(compound, "last_hurt_by_player"); +@@ -791,15 +_,44 @@ + this.equipment.setAll(compound.read("equipment", EntityEquipment.CODEC, registryOps).orElseGet(EntityEquipment::new)); } + // CraftBukkit start + private boolean isTickingEffects = false; -+ private List effectsToProcess = Lists.newArrayList(); ++ private final List effectsToProcess = Lists.newArrayList(); + + private static class ProcessableEffect { + @@ -250,15 +263,15 @@ + // CraftBukkit end + protected void tickEffects() { - Iterator> iterator = this.activeEffects.keySet().iterator(); + if (this.level() instanceof ServerLevel serverLevel) { + Iterator> iterator = this.activeEffects.keySet().iterator(); -+ this.isTickingEffects = true; // CraftBukkit - try { - while (iterator.hasNext()) { - Holder holder = iterator.next(); - MobEffectInstance mobEffectInstance = this.activeEffects.get(holder); - if (!mobEffectInstance.tick(this, () -> this.onEffectUpdated(mobEffectInstance, true, null))) { - if (!this.level().isClientSide) { ++ this.isTickingEffects = true; // CraftBukkit + try { + while (iterator.hasNext()) { + Holder holder = iterator.next(); + MobEffectInstance mobEffectInstance = this.activeEffects.get(holder); + if (!mobEffectInstance.tickServer(serverLevel, this, () -> this.onEffectUpdated(mobEffectInstance, true, null))) { + // CraftBukkit start + EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobEffectInstance, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION); + if (event.isCancelled()) { @@ -267,26 +280,26 @@ + // CraftBukkit end iterator.remove(); this.onEffectsRemoved(List.of(mobEffectInstance)); - } -@@ -807,6 +_,17 @@ - } catch (ConcurrentModificationException var6) { - } + } else if (mobEffectInstance.getDuration() % 600 == 0) { +@@ -809,6 +_,17 @@ + } catch (ConcurrentModificationException var6) { + } -+ // CraftBukkit start -+ this.isTickingEffects = false; -+ for (ProcessableEffect effect : this.effectsToProcess) { -+ if (effect.effect != null) { -+ this.addEffect(effect.effect, effect.cause); -+ } else { -+ this.removeEffect(effect.type, effect.cause); ++ // CraftBukkit start ++ this.isTickingEffects = false; ++ for (ProcessableEffect effect : this.effectsToProcess) { ++ if (effect.effect != null) { ++ this.addEffect(effect.effect, effect.cause); ++ } else { ++ this.removeEffect(effect.type, effect.cause); ++ } + } -+ } -+ this.effectsToProcess.clear(); -+ // CraftBukkit end - if (this.effectsDirty) { - if (!this.level().isClientSide) { ++ this.effectsToProcess.clear(); ++ // CraftBukkit end + if (this.effectsDirty) { this.updateInvisibilityStatus(); -@@ -912,15 +_,33 @@ + this.updateGlowingStatus(); +@@ -916,15 +_,33 @@ } public boolean removeAllEffects() { @@ -305,7 +318,7 @@ - this.onEffectsRemoved(map.values()); - return true; + // CraftBukkit start -+ List toRemove = new LinkedList<>(); ++ List toRemove = new java.util.LinkedList<>(); + Iterator iterator = this.activeEffects.values().iterator(); + while (iterator.hasNext()) { + MobEffectInstance effect = iterator.next(); @@ -324,7 +337,7 @@ } } -@@ -942,21 +_,57 @@ +@@ -951,21 +_,57 @@ } public final boolean addEffect(MobEffectInstance effectInstance) { @@ -384,11 +397,11 @@ this.onEffectUpdated(mobEffectInstance, true, entity); flag = true; } -@@ -995,11 +_,37 @@ +@@ -1004,11 +_,37 @@ @Nullable - public MobEffectInstance removeEffectNoUpdate(Holder effect) { -+ // CraftBukkit start + public final MobEffectInstance removeEffectNoUpdate(Holder effect) { ++// CraftBukkit start + return this.removeEffectNoUpdate(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN); + } + @@ -408,7 +421,7 @@ + if (event.isCancelled()) { + return null; + } -+ ++// CraftBukkit end return this.activeEffects.remove(effect); } @@ -423,7 +436,7 @@ if (mobEffectInstance != null) { this.onEffectsRemoved(List.of(mobEffectInstance)); return true; -@@ -1080,17 +_,62 @@ +@@ -1092,17 +_,62 @@ } public void heal(float healAmount) { @@ -487,7 +500,7 @@ this.entityData.set(DATA_HEALTH_ID, Mth.clamp(health, 0.0F, this.getMaxHealth())); } -@@ -1102,7 +_,7 @@ +@@ -1114,7 +_,7 @@ public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { if (this.isInvulnerableTo(level, damageSource)) { return false; @@ -496,44 +509,30 @@ return false; } else if (damageSource.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) { return false; -@@ -1116,47 +_,71 @@ +@@ -1128,35 +_,59 @@ amount = 0.0F; } -- float f = amount; -- boolean flag = false; -+ float f = amount; final float originalAmount = amount; // Paper - revert to vanilla #hurt - OBFHELPER -+ boolean flag = amount > 0.0F && this.isDamageSourceBlocked(damageSource); // Copied from below; - float f1 = 0.0F; -- if (amount > 0.0F && this.isDamageSourceBlocked(damageSource)) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage -+ if (false && amount > 0.0F && this.isDamageSourceBlocked(damageSource)) { - this.hurtCurrentlyUsedShield(amount); - f1 = amount; - amount = 0.0F; -- if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity) { -+ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Check distance in entity interactions - this.blockUsingShield(livingEntity); - } - - flag = true; - } - +- float f1 = this.applyItemBlocking(level, damageSource, amount); +- amount -= f1; ++ final float originalAmount = amount; // Paper - revert to vanilla #hurt - OBFHELPER ++ float f1 = this.applyItemBlocking(level, damageSource, amount, true); // Paper ++ // Paper end + boolean flag = f1 > 0.0F; - if (damageSource.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f ++ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount + if (false && damageSource.is(DamageTypeTags.IS_FREEZING) && this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { amount *= 5.0F; } - if (damageSource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -+ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) for get f and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage ++ // CraftBukkit - Moved into handleEntityDamage(DamageSource, float) to get amount and actuallyHurt(DamageSource, float, EntityDamageEvent) for handle damage + if (false && damageSource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { this.hurtHelmet(damageSource, amount); amount *= 0.75F; } + EntityDamageEvent event; // CraftBukkit // Paper - move this into the actual invuln check.... - this.walkAnimation.setSpeed(1.5F); if (Float.isNaN(amount) || Float.isInfinite(amount)) { amount = Float.MAX_VALUE; } @@ -578,7 +577,7 @@ this.hurtDuration = 10; this.hurtTime = this.hurtDuration; } -@@ -1170,7 +_,7 @@ +@@ -1171,7 +_,7 @@ level.broadcastDamageEvent(this, damageSource); } @@ -587,7 +586,7 @@ this.markHurt(); } -@@ -1185,8 +_,16 @@ +@@ -1186,8 +_,16 @@ d = damageSource.getSourcePosition().x() - this.getX(); d1 = damageSource.getSourcePosition().z() - this.getZ(); } @@ -605,12 +604,13 @@ if (!flag) { this.indicateDamage(d, d1); } -@@ -1195,17 +_,18 @@ +@@ -1196,19 +_,19 @@ if (this.isDeadOrDying()) { if (!this.checkTotemDeathProtection(damageSource)) { - if (flag1) { - this.makeSound(this.getDeathSound()); +- this.playSecondaryHurtSound(damageSource); - } + // Paper start - moved into CraftEventFactory event caller for cancellable death event + this.silentDeath = !flag1; // mark entity as dying silently @@ -621,6 +621,7 @@ } } else if (flag1) { this.playHurtSound(damageSource); + this.playSecondaryHurtSound(damageSource); } - boolean flag2 = !flag || amount > 0.0F; @@ -628,13 +629,100 @@ if (flag2) { this.lastDamageSource = damageSource; this.lastDamageStamp = this.level().getGameTime(); -@@ -1259,12 +_,24 @@ +@@ -1234,6 +_,12 @@ + } + + public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount) { ++ // Paper start ++ return applyItemBlocking(level, damageSource, damageAmount, false); ++ } ++ ++ public float applyItemBlocking(ServerLevel level, DamageSource damageSource, float damageAmount, boolean dryRun) { ++ // Paper end + if (damageAmount <= 0.0F) { + return 0.0F; + } else { +@@ -1258,10 +_,12 @@ + } + + float f = blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); ++ if (!dryRun) { // Paper + blocksAttacks.hurtBlockingItem(this.level(), itemBlockingWith, this, this.getUsedItemHand(), f); +- if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity) { ++ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0D)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions + this.blockUsingItem(level, livingEntity); + } ++ } // Paper + + return f; + } +@@ -1272,6 +_,59 @@ } } ++ // Paper start - copied from above split by relevant part ++ public boolean canBlockAttack(DamageSource damageSource, float damageAmount) { ++ if (damageAmount <= 0.0F) { ++ return false; ++ } else { ++ ItemStack itemBlockingWith = this.getItemBlockingWith(); ++ if (itemBlockingWith == null) { ++ return false; ++ } else { ++ BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS); ++ if (blocksAttacks != null && !blocksAttacks.bypassedBy().map(damageSource::is).orElse(false)) { ++ if (damageSource.getDirectEntity() instanceof AbstractArrow abstractArrow && abstractArrow.getPierceLevel() > 0) { ++ return false; ++ } else { ++ return true; ++ } ++ } else { ++ return false; ++ } ++ } ++ } ++ } ++ ++ public float resolveBlockedDamage(DamageSource damageSource, float damageAmount) { ++ Vec3 sourcePosition = damageSource.getSourcePosition(); ++ double acos; ++ if (sourcePosition != null) { ++ Vec3 vec3 = this.calculateViewVector(0.0F, this.getYHeadRot()); ++ Vec3 vec31 = sourcePosition.subtract(this.position()); ++ vec31 = new Vec3(vec31.x, 0.0, vec31.z).normalize(); ++ acos = Math.acos(vec31.dot(vec3)); ++ } else { ++ acos = (float) Math.PI; ++ } ++ ++ BlocksAttacks blocksAttacks = this.getItemBlockingWith().get(DataComponents.BLOCKS_ATTACKS); ++ return blocksAttacks.resolveBlockedDamage(damageSource, damageAmount, acos); ++ } ++ ++ public void blockingItemEffects(ServerLevel level, DamageSource damageSource, float f) { ++ ItemStack itemBlockingWith = this.getItemBlockingWith(); ++ if (itemBlockingWith == null) return; ++ ++ BlocksAttacks blocksAttacks = itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS); ++ if (blocksAttacks == null) return; ++ ++ blocksAttacks.hurtBlockingItem(this.level(), itemBlockingWith, this, this.getUsedItemHand(), f); ++ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && damageSource.getDirectEntity() instanceof LivingEntity livingEntity && livingEntity.distanceToSqr(this) <= Mth.square(200.0D)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions ++ this.blockUsingItem(level, livingEntity); ++ } ++ } ++ // Paper end - copied from above split by relevant part ++ + public void playSecondaryHurtSound(DamageSource damageSource) { + if (damageSource.is(DamageTypes.THORNS)) { + SoundSource soundSource = this instanceof Player ? SoundSource.PLAYERS : SoundSource.HOSTILE; +@@ -1304,12 +_,24 @@ + return EntityReference.get(this.lastHurtByPlayer, this.level(), Player.class); + } + + // Paper start - only call damage event when actuallyHurt will be called - move out amount computation logic + private float computeAmountFromEntityDamageEvent(final EntityDamageEvent event) { -+ // Taken from hurt()'s craftbukkit diff. ++ // Taken from hurtServer()'s craftbukkit diff. + float amount = 0; + amount += (float) event.getDamage(DamageModifier.BASE); + amount += (float) event.getDamage(DamageModifier.BLOCKING); @@ -644,17 +732,17 @@ + } + // Paper end - only call damage event when actuallyHurt will be called - move out amount computation logic + - protected void blockUsingShield(LivingEntity attacker) { - attacker.blockedByShield(this); + protected void blockUsingItem(ServerLevel level, LivingEntity entity) { + entity.blockedByItem(this); } - protected void blockedByShield(LivingEntity defender) { -- defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ()); -+ defender.knockback(0.5, defender.getX() - this.getX(), defender.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events + protected void blockedByItem(LivingEntity entity) { +- entity.knockback(0.5, entity.getX() - this.getX(), entity.getZ() - this.getZ()); ++ entity.knockback(0.5, entity.getX() - this.getX(), entity.getZ() - this.getZ(), this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker & knockback events } private boolean checkTotemDeathProtection(DamageSource damageSource) { -@@ -1274,18 +_,39 @@ +@@ -1319,18 +_,39 @@ ItemStack itemStack = null; DeathProtection deathProtection = null; @@ -701,7 +789,7 @@ serverPlayer.awardStat(Stats.ITEM_USED.get(itemStack.getItem())); CriteriaTriggers.USED_TOTEM.trigger(serverPlayer, itemStack); this.gameEvent(GameEvent.ITEM_INTERACT_FINISH); -@@ -1364,6 +_,7 @@ +@@ -1389,6 +_,7 @@ if (!this.isRemoved() && !this.dead) { Entity entity = damageSource.getEntity(); LivingEntity killCredit = this.getKillCredit(); @@ -709,7 +797,7 @@ if (killCredit != null) { killCredit.awardKillScore(this, damageSource); } -@@ -1373,68 +_,142 @@ +@@ -1398,68 +_,141 @@ } if (!this.level().isClientSide && this.hasCustomName()) { @@ -783,7 +871,7 @@ if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { - this.level().setBlock(blockPos, blockState, 3); - var6 = true; -+ var6 = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this); // CraftBukkit - call EntityBlockFormEvent for Wither Rose ++ var6 = CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this); // CraftBukkit - call EntityBlockFormEvent for Wither Rose } } @@ -791,8 +879,7 @@ ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE)); + // CraftBukkit start + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) itemEntity.getBukkitEntity()); -+ CraftEventFactory.callEvent(event); -+ if (event.isCancelled()) { ++ if (!event.callEvent()) { + return; + } + // CraftBukkit end @@ -808,7 +895,7 @@ + protected Set clearedEquipmentSlots = new java.util.HashSet<>(); + protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(ServerLevel level, DamageSource damageSource) { + // Paper end - boolean flag = this.lastHurtByPlayerTime > 0; + boolean flag = this.lastHurtByPlayerMemoryTime > 0; + this.dropEquipment(level); // CraftBukkit - from below if (this.shouldDropLoot() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { this.dropFromLootTable(level, damageSource, flag); @@ -824,13 +911,13 @@ - this.dropEquipment(level); + // CraftBukkit start - Call death event // Paper start - call advancement triggers with correct entity equipment + org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, damageSource, this.drops, () -> { -+ final LivingEntity entityliving = this.getKillCredit(); -+ if (entityliving != null) { -+ entityliving.awardKillScore(this, damageSource); ++ final LivingEntity killer = this.getKillCredit(); ++ if (killer != null) { ++ killer.awardKillScore(this, damageSource); + } + }); // Paper end + this.postDeathDropItems(deathEvent); // Paper -+ this.drops = new ArrayList<>(); ++ this.drops = new java.util.ArrayList<>(); + // this.dropEquipment(level); // CraftBukkit - moved up + // CraftBukkit end this.dropExperience(level, damageSource.getEntity()); @@ -846,7 +933,7 @@ if (!this.wasExperienceConsumed() && ( this.isAlwaysExperienceDropper() - || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) + || this.lastHurtByPlayerMemoryTime > 0 && this.shouldDropExperience() && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT) )) { - ExperienceOrb.award(level, this.position(), this.getExperienceReward(level, entity)); - } @@ -865,7 +952,7 @@ } protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { -@@ -1513,9 +_,14 @@ +@@ -1539,9 +_,14 @@ } public void knockback(double strength, double x, double z) { @@ -882,7 +969,7 @@ Vec3 deltaMovement = this.getDeltaMovement(); while (x * x + z * z < 1.0E-5F) { -@@ -1524,11 +_,22 @@ +@@ -1550,11 +_,22 @@ } Vec3 vec3 = new Vec3(x, 0.0, z).normalize().scale(strength); @@ -906,28 +993,7 @@ } } -@@ -1584,6 +_,20 @@ - return new LivingEntity.Fallsounds(SoundEvents.GENERIC_SMALL_FALL, SoundEvents.GENERIC_BIG_FALL); - } - -+ // CraftBukkit start - Add delegate methods -+ public SoundEvent getHurtSound0(DamageSource damagesource) { -+ return this.getHurtSound(damagesource); -+ } -+ -+ public SoundEvent getDeathSound0() { -+ return this.getDeathSound(); -+ } -+ -+ public SoundEvent getFallDamageSound0(int fallHeight) { -+ return this.getFallDamageSound(fallHeight); -+ } -+ // CraftBukkit end -+ - public Optional getLastClimbablePos() { - return this.lastClimbablePos; - } -@@ -1617,7 +_,7 @@ +@@ -1639,7 +_,7 @@ @Override public boolean isAlive() { @@ -936,23 +1002,23 @@ } public boolean isLookingAtMe(LivingEntity entity, double tolerance, boolean scaleByDistance, boolean visual, double... yValues) { -@@ -1651,9 +_,14 @@ - boolean flag = super.causeFallDamage(fallDistance, multiplier, source); - int i = this.calculateFallDamage(fallDistance, multiplier); +@@ -1673,9 +_,14 @@ + boolean flag = super.causeFallDamage(fallDistance, damageMultiplier, damageSource); + int i = this.calculateFallDamage(fallDistance, damageMultiplier); if (i > 0) { + // CraftBukkit start -+ if (!this.hurtServer((ServerLevel) this.level(), source, (float) i)) { ++ if (!this.hurtServer((ServerLevel) this.level(), damageSource, (float) i)) { + return true; + } + // CraftBukkit end this.playSound(this.getFallDamageSound(i), 1.0F, 1.0F); this.playBlockFallSound(); -- this.hurt(source, i); -+ // this.hurt(source, i); // CraftBukkit - moved up +- this.hurt(damageSource, i); ++ // this.hurt(damageSource, i); // CraftBukkit - moved up return true; } else { return flag; -@@ -1718,7 +_,7 @@ +@@ -1740,7 +_,7 @@ protected float getDamageAfterArmorAbsorb(DamageSource damageSource, float damageAmount) { if (!damageSource.is(DamageTypeTags.BYPASSES_ARMOR)) { @@ -961,17 +1027,17 @@ damageAmount = CombatRules.getDamageAfterAbsorb( this, damageAmount, damageSource, this.getArmorValue(), (float)this.getAttributeValue(Attributes.ARMOR_TOUGHNESS) ); -@@ -1731,7 +_,8 @@ +@@ -1753,7 +_,8 @@ if (damageSource.is(DamageTypeTags.BYPASSES_EFFECTS)) { return damageAmount; } else { -- if (this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { +- if (this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + // CraftBukkit - Moved to handleEntityDamage(DamageSource, float) -+ if (false && this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { - int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; ++ if (false && this.hasEffect(MobEffects.RESISTANCE) && !damageSource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { + int i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5; int i1 = 25 - i; float f = damageAmount * i1; -@@ -1768,24 +_,219 @@ +@@ -1790,24 +_,201 @@ } } @@ -980,7 +1046,7 @@ + private EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float amount, final float invulnerabilityRelatedLastDamage) { // Paper - fix invulnerability reduction in EntityDamageEvent + float originalDamage = amount; + // Paper start - fix invulnerability reduction in EntityDamageEvent -+ final com.google.common.base.Function invulnerabilityReductionEquation = d -> { ++ final com.google.common.base.Function invulnerabilityReductionEquation = mod -> { + if (invulnerabilityRelatedLastDamage == 0) return 0D; // no last damage, no reduction + // last damage existed, this means the reduction *technically* is (new damage - last damage). + // If the event damage was changed to something less than invul damage, hard lock it at 0. @@ -988,85 +1054,67 @@ + // Cast the passed in double down to a float as double -> float -> double is lossy. + // If last damage is a (float) 3.2D (since the events use doubles), we cannot compare + // the new damage value of this damage instance by upcasting it again to a double as 3.2D != (double) (float) 3.2D. -+ if (d.floatValue() < invulnerabilityRelatedLastDamage) return 0D; ++ if (mod.floatValue() < invulnerabilityRelatedLastDamage) return 0D; + return (double) -invulnerabilityRelatedLastDamage; + }; + final float originalInvulnerabilityReduction = invulnerabilityReductionEquation.apply((double) amount).floatValue(); + amount += originalInvulnerabilityReduction; + // Paper end - fix invulnerability reduction in EntityDamageEvent + -+ com.google.common.base.Function freezing = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ if (damagesource.is(DamageTypeTags.IS_FREEZING) && LivingEntity.this.getType().is(EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { -+ return -(f - (f * 5.0F)); -+ } -+ return -0.0; ++ com.google.common.base.Function freezing = mod -> { ++ if (damagesource.is(net.minecraft.tags.DamageTypeTags.IS_FREEZING) && LivingEntity.this.getType().is(net.minecraft.tags.EntityTypeTags.FREEZE_HURTS_EXTRA_TYPES)) { ++ return -(mod - (mod * 5.0F)); + } ++ return -0.0; + }; + float freezingModifier = freezing.apply((double) amount).floatValue(); + amount += freezingModifier; + -+ com.google.common.base.Function hardHat = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !LivingEntity.this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -+ return -(f - (f * 0.75F)); -+ } -+ return -0.0; ++ com.google.common.base.Function hardHat = mod -> { ++ if (damagesource.is(net.minecraft.tags.DamageTypeTags.DAMAGES_HELMET) && !LivingEntity.this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { ++ return -(mod - (mod * 0.75F)); + } ++ return -0.0; + }; + float hardHatModifier = hardHat.apply((double) amount).floatValue(); + amount += hardHatModifier; + -+ com.google.common.base.Function blocking = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ return -((LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); ++ com.google.common.base.Function blocking = mod -> { ++ if (!LivingEntity.this.canBlockAttack(damagesource, mod.floatValue())) { ++ return 0D; + } ++ return (double) -LivingEntity.this.resolveBlockedDamage(damagesource, mod.floatValue()); + }; + float blockingModifier = blocking.apply((double) amount).floatValue(); + amount += blockingModifier; + -+ com.google.common.base.Function armor = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ return -(f - LivingEntity.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue())); -+ } ++ com.google.common.base.Function armor = mod -> { ++ return -(mod - LivingEntity.this.getDamageAfterArmorAbsorb(damagesource, mod.floatValue())); + }; + float armorModifier = armor.apply((double) amount).floatValue(); + amount += armorModifier; + -+ com.google.common.base.Function resistance = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && LivingEntity.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) { -+ int i = (LivingEntity.this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5; -+ int j = 25 - i; -+ float f1 = f.floatValue() * (float) j; ++ com.google.common.base.Function resistance = mod -> { ++ if (!damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_EFFECTS) && LivingEntity.this.hasEffect(net.minecraft.world.effect.MobEffects.RESISTANCE) && !damagesource.is(net.minecraft.tags.DamageTypeTags.BYPASSES_RESISTANCE)) { ++ int i = (LivingEntity.this.getEffect(net.minecraft.world.effect.MobEffects.RESISTANCE).getAmplifier() + 1) * 5; ++ int j = 25 - i; ++ float f1 = mod.floatValue() * (float) j; + -+ return -(f - Math.max(f1 / 25.0F, 0.0F)); -+ } -+ return -0.0; ++ return -(mod - Math.max(f1 / 25.0F, 0.0F)); + } ++ return -0.0; + }; + float resistanceModifier = resistance.apply((double) amount).floatValue(); + amount += resistanceModifier; + -+ com.google.common.base.Function magic = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ return -(f - LivingEntity.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue())); -+ } ++ com.google.common.base.Function magic = mod -> { ++ return -(mod - net.minecraft.world.entity.LivingEntity.this.getDamageAfterMagicAbsorb(damagesource, mod.floatValue())); + }; + float magicModifier = magic.apply((double) amount).floatValue(); + amount += magicModifier; + -+ com.google.common.base.Function absorption = new com.google.common.base.Function() { -+ @Override -+ public Double apply(Double f) { -+ return -(Math.max(f - Math.max(f - LivingEntity.this.getAbsorptionAmount(), 0.0F), 0.0F)); -+ } ++ com.google.common.base.Function absorption = mod -> { ++ return -(Math.max(mod - Math.max(mod - net.minecraft.world.entity.LivingEntity.this.getAbsorptionAmount(), 0.0F), 0.0F)); + }; + float absorptionModifier = absorption.apply((double) amount).floatValue(); + @@ -1117,7 +1165,11 @@ + + // Apply damage to helmet + if (damageSource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EquipmentSlot.HEAD).isEmpty()) { -+ this.hurtHelmet(damageSource, amount); ++ float helmetDamage = (float) event.getDamage(); ++ helmetDamage += (float) event.getDamage(DamageModifier.INVULNERABILITY_REDUCTION); ++ helmetDamage += (float) event.getDamage(DamageModifier.BLOCKING); ++ helmetDamage += (float) event.getDamage(DamageModifier.FREEZING); ++ this.hurtHelmet(damageSource, helmetDamage); + } + + // Apply damage to armor @@ -1125,18 +1177,14 @@ + float armorDamage = (float) event.getDamage(); + armorDamage += (float) event.getDamage(DamageModifier.INVULNERABILITY_REDUCTION); + armorDamage += (float) event.getDamage(DamageModifier.BLOCKING); ++ armorDamage += (float) event.getDamage(DamageModifier.FREEZING); + armorDamage += (float) event.getDamage(DamageModifier.HARD_HAT); + this.hurtArmor(damageSource, armorDamage); + } + -+ // Apply blocking code // PAIL: steal from above ++ // Apply blocking code + if (event.getDamage(DamageModifier.BLOCKING) < 0) { -+ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING)); -+ Entity entity = damageSource.getDirectEntity(); -+ -+ if (!damageSource.is(DamageTypeTags.IS_PROJECTILE) && entity instanceof LivingEntity && entity.distanceToSqr(this) <= (200.0D * 200.0D)) { // Paper - Fix shield disable inconsistency & Check distance in entity interactions -+ this.blockUsingShield((LivingEntity) entity); -+ } ++ this.blockingItemEffects(level, damageSource, (float) -event.getDamage(DamageModifier.BLOCKING)); + } + + boolean human = this instanceof net.minecraft.world.entity.player.Player; @@ -1201,7 +1249,7 @@ } public CombatTracker getCombatTracker() { -@@ -1814,7 +_,17 @@ +@@ -1836,7 +_,17 @@ } public final void setArrowCount(int count) { @@ -1211,7 +1259,7 @@ + } + + public final void setArrowCount(int count, boolean reset) { -+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), count, reset); ++ org.bukkit.event.entity.ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, this.getArrowCount(), count, reset); + if (event.isCancelled()) { + return; + } @@ -1220,7 +1268,7 @@ } public final int getStingerCount() { -@@ -1957,7 +_,7 @@ +@@ -1991,7 +_,7 @@ @Override protected void onBelowWorld() { @@ -1229,21 +1277,26 @@ } protected void updateSwingTime() { -@@ -2052,6 +_,12 @@ +@@ -2087,8 +_,15 @@ + } - public abstract ItemStack getItemBySlot(EquipmentSlot slot); - -+ // CraftBukkit start -+ public void setItemSlot(EquipmentSlot enumitemslot, ItemStack itemstack, boolean silent) { -+ this.setItemSlot(enumitemslot, itemstack); + public void setItemSlot(EquipmentSlot slot, ItemStack stack) { +- this.onEquipItem(slot, this.equipment.set(slot, stack), stack); +- } ++ // Paper start ++ this.setItemSlot(slot, stack, false); ++ } ++ // CraftBukkit start ++ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { ++ // Paper end ++ this.onEquipItem(slot, this.equipment.set(slot, stack), stack, silent); + } -+ // CraftBukkit end + - public abstract void setItemSlot(EquipmentSlot slot, ItemStack stack); - public Iterable getHandSlots() { -@@ -2158,14 +_,27 @@ - return this.hasEffect(MobEffects.JUMP) ? 0.1F * (this.getEffect(MobEffects.JUMP).getAmplifier() + 1.0F) : 0.0F; + public float getArmorCoverPercentage() { + int i = 0; +@@ -2180,14 +_,27 @@ + return this.hasEffect(MobEffects.JUMP_BOOST) ? 0.1F * (this.getEffect(MobEffects.JUMP_BOOST).getAmplifier() + 1.0F) : 0.0F; } + protected long lastJumpTime = 0L; // Paper - Prevent excessive velocity through repeated crits @@ -1270,7 +1323,18 @@ this.addDeltaMovement(new Vec3(-Mth.sin(f) * 0.2, 0.0, Mth.cos(f) * 0.2)); } -@@ -2425,7 +_,7 @@ +@@ -2327,8 +_,10 @@ + } + + public void stopFallFlying() { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { // Paper + this.setSharedFlag(7, true); + this.setSharedFlag(7, false); ++ } // Paper + } + + private Vec3 updateFallFlyingMovement(Vec3 deltaMovement) { +@@ -2454,7 +_,7 @@ } protected float getFlyingSpeed() { @@ -1279,16 +1343,7 @@ } public float getSpeed() { -@@ -2471,7 +_,7 @@ - } - } - -- this.detectEquipmentUpdates(); -+ this.detectEquipmentUpdatesPublic(); // CraftBukkit - if (this.tickCount % 20 == 0) { - this.getCombatTracker().recheckStatus(); - } -@@ -2519,37 +_,14 @@ +@@ -2538,37 +_,15 @@ profilerFiller.pop(); profilerFiller.push("rangeChecks"); @@ -1331,19 +1386,11 @@ + this.xRotO += Math.round((this.getXRot() - this.xRotO) / 360.0F) * 360.0F; + + this.yHeadRotO += Math.round((this.yHeadRot - this.yHeadRotO) / 360.0F) * 360.0F; ++ // Paper end - stop large pitch and yaw changes from crashing the server profilerFiller.pop(); - this.animStep += f2; -@@ -2573,7 +_,7 @@ - this.elytraAnimationState.tick(); - } - -- public void detectEquipmentUpdates() { -+ public void detectEquipmentUpdatesPublic() { // CraftBukkit - Map map = this.collectEquipmentChanges(); - if (map != null) { - this.handleHandSwap(map); -@@ -2586,6 +_,20 @@ + if (this.isFallFlying()) { +@@ -2598,16 +_,39 @@ @Nullable private Map collectEquipmentChanges() { Map map = null; @@ -1363,9 +1410,7 @@ + // Paper end - EntityEquipmentChangedEvent for (EquipmentSlot equipmentSlot : EquipmentSlot.VALUES) { - ItemStack itemStack = switch (equipmentSlot.getType()) { -@@ -2595,11 +_,20 @@ - }; + ItemStack itemStack = this.lastEquipmentItems.get(equipmentSlot); ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); if (this.equipmentHasChanged(itemStack, itemBySlot)) { + // Paper start - EntityEquipmentChangedEvent, PlayerArmorChangeEvent @@ -1385,7 +1430,7 @@ AttributeMap attributes = this.getAttributes(); if (!itemStack.isEmpty()) { this.stopLocationBasedEffects(itemStack, equipmentSlot, attributes); -@@ -2624,6 +_,8 @@ +@@ -2632,6 +_,8 @@ } } } @@ -1394,16 +1439,16 @@ } return map; -@@ -2664,7 +_,7 @@ - this.lastBodyItemStack = itemStack; - } +@@ -2663,7 +_,7 @@ + list.add(Pair.of(equipmentSlot, itemStack1)); + this.lastEquipmentItems.put(equipmentSlot, itemStack1); }); - ((ServerLevel)this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list)); + ((ServerLevel)this.level()).getChunkSource().broadcast(this, new ClientboundSetEquipmentPacket(this.getId(), list, true)); // Paper - data sanitization } - private ItemStack getLastArmorItem(EquipmentSlot slot) { -@@ -2765,8 +_,10 @@ + protected void tickHeadTurn(float yBodyRot) { +@@ -2749,8 +_,10 @@ if (!flag || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if (!this.isInLava() || this.onGround() && !(fluidHeight > fluidJumpThreshold)) { if ((this.onGround() || flag && fluidHeight <= fluidJumpThreshold) && this.noJumpDelay == 0) { @@ -1414,16 +1459,16 @@ } } else { this.jumpInLiquid(FluidTags.LAVA); -@@ -2805,7 +_,7 @@ - this.calculateEntityAnimation(this instanceof FlyingAnimal); +@@ -2791,7 +_,7 @@ profilerFiller.pop(); - profilerFiller.push("freezing"); -- if (!this.level().isClientSide && !this.isDeadOrDying()) { -+ if (!this.level().isClientSide && !this.isDeadOrDying() && !this.freezeLocked) { // Paper - Freeze Tick Lock API - int ticksFrozen = this.getTicksFrozen(); - if (this.isInPowderSnow && this.canFreeze()) { - this.setTicksFrozen(Math.min(this.getTicksRequiredToFreeze(), ticksFrozen + 1)); -@@ -2829,6 +_,20 @@ + if (this.level() instanceof ServerLevel serverLevel) { + profilerFiller.push("freezing"); +- if (!this.isInPowderSnow || !this.canFreeze()) { ++ if (!this.isInPowderSnow || !this.canFreeze() && !this.freezeLocked) { // Paper - Freeze Tick Lock API + this.setTicksFrozen(Math.max(0, this.getTicksFrozen() - 2)); + } + +@@ -2812,6 +_,20 @@ this.pushEntities(); profilerFiller.pop(); @@ -1434,17 +1479,17 @@ + Location to = new Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); + io.papermc.paper.event.entity.EntityMoveEvent event = new io.papermc.paper.event.entity.EntityMoveEvent(this.getBukkitLivingEntity(), from, to.clone()); + if (!event.callEvent()) { -+ this.absMoveTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); ++ this.absSnapTo(from.getX(), from.getY(), from.getZ(), from.getYaw(), from.getPitch()); + } else if (!to.equals(event.getTo())) { -+ this.absMoveTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); ++ this.absSnapTo(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ(), event.getTo().getYaw(), event.getTo().getPitch()); + } + } + } + // Paper end - Add EntityMoveEvent - if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { + if (this.level() instanceof ServerLevel serverLevel && this.isSensitiveToWater() && this.isInWaterOrRain()) { this.hurtServer(serverLevel, this.damageSources().drown(), 1.0F); } -@@ -2842,6 +_,7 @@ +@@ -2830,6 +_,7 @@ this.checkSlowFallDistance(); if (!this.level().isClientSide) { if (!this.canGlide()) { @@ -1452,51 +1497,51 @@ this.setSharedFlag(7, false); return; } -@@ -2881,9 +_,24 @@ - if (!(this.level() instanceof ServerLevel serverLevel)) { - this.level().getEntities(EntityTypeTest.forClass(Player.class), this.getBoundingBox(), EntitySelector.pushableBy(this)).forEach(this::doPush); - } else { -- List entities = this.level().getEntities(this, this.getBoundingBox(), EntitySelector.pushableBy(this)); -+ // Paper start - don't run getEntities if we're not going to use its result -+ if (!this.isPushable()) { -+ return; -+ } +@@ -2869,10 +_,25 @@ + } + + protected void pushEntities() { ++ // Paper start - don't run getEntities if we're not going to use its result ++ if (!this.isPushable()) { ++ return; ++ } + -+ net.minecraft.world.scores.Team team = this.getTeam(); -+ if (team != null && team.getCollisionRule() == net.minecraft.world.scores.Team.CollisionRule.NEVER) { -+ return; -+ } ++ net.minecraft.world.scores.Team team = this.getTeam(); ++ if (team != null && team.getCollisionRule() == net.minecraft.world.scores.Team.CollisionRule.NEVER) { ++ return; ++ } + -+ int _int = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); -+ if (_int <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { -+ return; -+ } -+ // Paper end - don't run getEntities if we're not going to use its result -+ List entities = this.level().getEntities(this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule - if (!entities.isEmpty()) { ++ int _int = ((ServerLevel) this.level()).getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); ++ if (_int <= 0 && this.level().paperConfig().collisions.maxEntityCollisions <= 0) { ++ return; ++ } ++ // Paper end - don't run getEntities if we're not going to use its result + List pushableEntities = this.level().getPushableEntities(this, this.getBoundingBox()); + if (!pushableEntities.isEmpty()) { + if (this.level() instanceof ServerLevel serverLevel) { - int _int = serverLevel.getGameRules().getInt(GameRules.RULE_MAX_ENTITY_CRAMMING); + // Paper - don't run getEntities if we're not going to use its result; moved up - if (_int > 0 && entities.size() > _int - 1 && this.random.nextInt(4) == 0) { + if (_int > 0 && pushableEntities.size() > _int - 1 && this.random.nextInt(4) == 0) { int i = 0; -@@ -2898,7 +_,16 @@ - } - } - -+ // Paper start - Cap entity collisions -+ this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); - for (Entity entity1 : entities) { -+ if (this.numCollisions >= this.level().paperConfig().collisions.maxEntityCollisions) { -+ break; -+ } -+ -+ entity1.numCollisions++; -+ this.numCollisions++; -+ // Paper end - Cap entity collisions - this.doPush(entity1); +@@ -2888,7 +_,16 @@ } } -@@ -2941,9 +_,16 @@ + ++ // Paper start - Cap entity collisions ++ this.numCollisions = Math.max(0, this.numCollisions - this.level().paperConfig().collisions.maxEntityCollisions); + for (Entity entity1 : pushableEntities) { ++ if (this.numCollisions >= this.level().paperConfig().collisions.maxEntityCollisions) { ++ break; ++ } ++ ++ entity1.numCollisions++; ++ this.numCollisions++; ++ // Paper end - Cap entity collisions + this.doPush(entity1); + } + } +@@ -2930,9 +_,16 @@ @Override public void stopRiding() { @@ -1515,7 +1560,7 @@ this.dismountVehicle(vehicle); } } -@@ -3007,7 +_,7 @@ +@@ -2959,7 +_,7 @@ } public void onItemPickup(ItemEntity itemEntity) { @@ -1524,7 +1569,7 @@ if (owner instanceof ServerPlayer) { CriteriaTriggers.THROWN_ITEM_PICKED_UP_BY_ENTITY.trigger((ServerPlayer)owner, itemEntity.getItem(), this); } -@@ -3017,7 +_,7 @@ +@@ -2969,7 +_,7 @@ if (!entity.isRemoved() && !this.level().isClientSide && (entity instanceof ItemEntity || entity instanceof AbstractArrow || entity instanceof ExperienceOrb)) { @@ -1533,7 +1578,7 @@ } } -@@ -3031,7 +_,8 @@ +@@ -2983,7 +_,8 @@ } else { Vec3 vec3 = new Vec3(this.getX(), this.getEyeY(), this.getZ()); Vec3 vec31 = new Vec3(entity.getX(), y, entity.getZ()); @@ -1543,7 +1588,7 @@ } } -@@ -3051,13 +_,27 @@ +@@ -3003,13 +_,27 @@ @Override public boolean isPickable() { @@ -1574,7 +1619,7 @@ @Override public float getYHeadRot() { -@@ -3088,7 +_,7 @@ +@@ -3040,7 +_,7 @@ } public final void setAbsorptionAmount(float absorptionAmount) { @@ -1583,7 +1628,7 @@ } protected void internalSetAbsorptionAmount(float absorptionAmount) { -@@ -3115,6 +_,15 @@ +@@ -3067,6 +_,15 @@ return (this.entityData.get(DATA_LIVING_ENTITY_FLAGS) & 2) > 0 ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } @@ -1599,7 +1644,19 @@ private void updatingUsingItem() { if (this.isUsingItem()) { if (ItemStack.isSameItem(this.getItemInHand(this.getUsedItemHand()), this.useItem)) { -@@ -3128,7 +_,12 @@ +@@ -3084,6 +_,11 @@ + return null; + } else { + double d = this.getEyeY() - 0.3F; ++ // Paper start ++ final ItemStack tmp = stack.copy(); ++ stack.setCount(0); ++ stack = tmp; ++ // Paper end + ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); + itemEntity.setPickUpDelay(40); + if (includeThrower) { +@@ -3115,7 +_,12 @@ protected void updateUsingItem(ItemStack usingItem) { usingItem.onUseTick(this.level(), this, this.getUseItemRemainingTicks()); @@ -1613,13 +1670,14 @@ this.completeUsingItem(); } } -@@ -3154,10 +_,18 @@ +@@ -3141,10 +_,19 @@ } public void startUsingItem(InteractionHand hand) { + // Paper start - Prevent consuming the wrong itemstack + this.startUsingItem(hand, false); + } ++ + public void startUsingItem(InteractionHand hand, boolean forceUpdate) { + // Paper end - Prevent consuming the wrong itemstack ItemStack itemInHand = this.getItemInHand(hand); @@ -1634,7 +1692,7 @@ if (!this.level().isClientSide) { this.setLivingEntityFlag(1, true); this.setLivingEntityFlag(2, hand == InteractionHand.OFF_HAND); -@@ -3181,7 +_,10 @@ +@@ -3168,7 +_,10 @@ } } else if (!this.isUsingItem() && !this.useItem.isEmpty()) { this.useItem = ItemStack.EMPTY; @@ -1646,7 +1704,7 @@ } } } -@@ -3220,12 +_,49 @@ +@@ -3207,12 +_,49 @@ this.releaseUsingItem(); } else { if (!this.useItem.isEmpty() && this.isUsingItem()) { @@ -1654,20 +1712,20 @@ + this.startUsingItem(this.getUsedItemHand(), true); // Paper - Prevent consuming the wrong itemstack + // CraftBukkit start - fire PlayerItemConsumeEvent + ItemStack itemStack; -+ PlayerItemConsumeEvent event = null; // Paper ++ org.bukkit.event.player.PlayerItemConsumeEvent event = null; // Paper + if (this instanceof ServerPlayer serverPlayer) { + org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem); + org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(usedItemHand); -+ event = new PlayerItemConsumeEvent((org.bukkit.entity.Player) this.getBukkitEntity(), craftItem, hand); // Paper ++ event = new org.bukkit.event.player.PlayerItemConsumeEvent((org.bukkit.entity.Player) this.getBukkitEntity(), craftItem, hand); // Paper + this.level().getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + // Update client -+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE); ++ net.minecraft.world.item.component.Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE); + if (consumable != null) { + consumable.cancelUsingItem(serverPlayer, this.useItem); + } -+ serverPlayer.getBukkitEntity().updateInventory(); ++ serverPlayer.containerMenu.sendAllDataToRemote(); + serverPlayer.getBukkitEntity().updateScaledHealth(); + this.stopUsingItem(); // Paper - event is using an item, clear active item to reset its use + return; @@ -1690,22 +1748,22 @@ this.stopUsingItem(); + // Paper start -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).getBukkitEntity().updateInventory(); ++ if (this instanceof Player player) { ++ player.containerMenu.sendAllDataToRemote(); + } + // Paper end } } } -@@ -3248,6 +_,7 @@ - - public void releaseUsingItem() { - if (!this.useItem.isEmpty()) { +@@ -3237,6 +_,7 @@ + ItemStack itemInHand = this.getItemInHand(this.getUsedItemHand()); + if (!this.useItem.isEmpty() && ItemStack.isSameItem(itemInHand, this.useItem)) { + this.useItem = itemInHand; + if (this instanceof ServerPlayer) new io.papermc.paper.event.player.PlayerStopUsingItemEvent((org.bukkit.entity.Player) getBukkitEntity(), useItem.asBukkitMirror(), getTicksUsingItem()).callEvent(); // Paper - Add PlayerStopUsingItemEvent this.useItem.releaseUsing(this.level(), this, this.getUseItemRemainingTicks()); if (this.useItem.useOnRelease()) { this.updatingUsingItem(); -@@ -3267,7 +_,10 @@ +@@ -3256,7 +_,10 @@ } this.useItem = ItemStack.EMPTY; @@ -1717,19 +1775,18 @@ } public boolean isBlocking() { -@@ -3281,12 +_,69 @@ - if (item.getUseAnimation(this.useItem) != ItemUseAnimation.BLOCK) { - return null; - } else { -- return item.getUseDuration(this.useItem, this) - this.useItemRemaining < 5 ? null : this.useItem; -+ return item.getUseDuration(this.useItem, this) - this.useItemRemaining < this.getShieldBlockingDelay() ? null : this.useItem; // Paper - Make shield blocking delay configurable - } - } else { - return null; +@@ -3280,6 +_,60 @@ } } + ++ // CraftBukkit start ++ @Override ++ public float getBukkitYaw() { ++ return this.getYHeadRot(); ++ } ++ // CraftBukkit end + -+ // Paper start - Make shield blocking delay configurable ++ // Paper start + public HitResult getRayTrace(int maxDistance, ClipContext.Fluid fluidCollisionOption) { + if (maxDistance < 1 || maxDistance > 120) { + throw new IllegalArgumentException("maxDistance must be between 1-120"); @@ -1758,7 +1815,7 @@ + net.minecraft.world.phys.EntityHitResult result = null; + + for (Entity entity : entityList) { -+ final double inflationAmount = (double) entity.getPickRadius(); ++ final double inflationAmount = entity.getPickRadius(); + AABB aabb = entity.getBoundingBox().inflate(inflationAmount, inflationAmount, inflationAmount); + Optional rayTraceResult = aabb.clip(start, end); + @@ -1774,21 +1831,12 @@ + + return result; + } ++ // Paper end + -+ public int shieldBlockingDelay = this.level().paperConfig().misc.shieldBlockingDelay; -+ -+ public int getShieldBlockingDelay() { -+ return shieldBlockingDelay; -+ } -+ -+ public void setShieldBlockingDelay(int shieldBlockingDelay) { -+ this.shieldBlockingDelay = shieldBlockingDelay; -+ } -+ // Paper end - Make shield blocking delay configurable - public boolean isSuppressingSlidingDownLadder() { return this.isShiftKeyDown(); -@@ -3306,6 +_,12 @@ + } +@@ -3298,6 +_,12 @@ } public boolean randomTeleport(double x, double y, double z, boolean broadcastTeleport) { @@ -1801,7 +1849,7 @@ double x1 = this.getX(); double y1 = this.getY(); double z1 = this.getZ(); -@@ -3328,16 +_,39 @@ +@@ -3320,16 +_,39 @@ } if (flag1) { @@ -1817,7 +1865,7 @@ + + if (flag) { + if (!(this instanceof ServerPlayer)) { -+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level().getWorld(), x1, y1, z1), new Location(this.level().getWorld(), x, d, z)); ++ org.bukkit.event.entity.EntityTeleportEvent teleport = new org.bukkit.event.entity.EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level().getWorld(), x1, y1, z1), new Location(this.level().getWorld(), x, d, z)); + this.level().getCraftServer().getPluginManager().callEvent(teleport); + if (!teleport.isCancelled() && teleport.getTo() != null) { // Paper + Location to = teleport.getTo(); @@ -1844,7 +1892,7 @@ } else { if (broadcastTeleport) { level.broadcastEntityEvent(this, (byte)46); -@@ -3347,7 +_,7 @@ +@@ -3339,7 +_,7 @@ pathfinderMob.getNavigation().stop(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch index deac63882..2b7c135d3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/Mob.java.patch @@ -1,19 +1,15 @@ --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -84,6 +_,18 @@ - import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +@@ -83,6 +_,14 @@ import net.minecraft.world.phys.AABB; + import net.minecraft.world.ticks.ContainerSingleItem; +// CraftBukkit start -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.event.entity.CreatureSpawnEvent; +import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; +import org.bukkit.event.entity.EntityTargetEvent; +import org.bukkit.event.entity.EntityTransformEvent; +import org.bukkit.event.entity.EntityUnleashEvent; -+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason; +// CraftBukkit end + public abstract class Mob extends LivingEntity implements EquipmentUser, Leashable, Targeting { @@ -23,11 +19,11 @@ private final BodyRotationControl bodyRotationControl; protected PathNavigation navigation; public GoalSelector goalSelector; -+ @Nullable public net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float ++ public @Nullable net.minecraft.world.entity.ai.goal.FloatGoal goalFloat; // Paper - Allow nerfed mobs to jump and float public GoalSelector targetSelector; @Nullable private LivingEntity target; -@@ -131,6 +_,7 @@ +@@ -126,6 +_,7 @@ private Leashable.LeashData leashData; private BlockPos restrictCenter = BlockPos.ZERO; private float restrictRadius = -1.0F; @@ -35,7 +31,7 @@ protected Mob(EntityType entityType, Level level) { super(entityType, level); -@@ -150,6 +_,12 @@ +@@ -142,6 +_,12 @@ } } @@ -48,37 +44,36 @@ protected void registerGoals() { } -@@ -230,7 +_,40 @@ +@@ -222,7 +_,39 @@ } public void setTarget(@Nullable LivingEntity target) { + // CraftBukkit start - fire event -+ this.setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN, true); ++ this.setTarget(target, EntityTargetEvent.TargetReason.UNKNOWN); + } + -+ public boolean setTarget(LivingEntity target, EntityTargetEvent.TargetReason reason, boolean fireEvent) { ++ public boolean setTarget(@Nullable LivingEntity target, @Nullable EntityTargetEvent.TargetReason reason) { + if (this.getTarget() == target) { + return false; + } -+ if (fireEvent) { ++ if (reason != null) { + if (reason == EntityTargetEvent.TargetReason.UNKNOWN && this.getTarget() != null && target == null) { + reason = this.getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED; + } + if (reason == EntityTargetEvent.TargetReason.UNKNOWN) { + this.level().getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception()); + } -+ CraftLivingEntity ctarget = null; ++ org.bukkit.craftbukkit.entity.CraftLivingEntity ctarget = null; + if (target != null) { -+ ctarget = (CraftLivingEntity) target.getBukkitEntity(); ++ ctarget = (org.bukkit.craftbukkit.entity.CraftLivingEntity) target.getBukkitEntity(); + } -+ EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = new org.bukkit.event.entity.EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason); ++ if (!event.callEvent()) { + return false; + } + + if (event.getTarget() != null) { -+ target = ((CraftLivingEntity) event.getTarget()).getHandle(); ++ target = ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle(); + } else { + target = null; + } @@ -89,20 +84,7 @@ } @Override -@@ -354,6 +_,12 @@ - return null; - } - -+ // CraftBukkit start - Add delegate method -+ public SoundEvent getAmbientSound0() { -+ return this.getAmbientSound(); -+ } -+ // CraftBukkit end -+ - @Override - public void addAdditionalSaveData(CompoundTag compound) { - super.addAdditionalSaveData(compound); -@@ -413,13 +_,25 @@ +@@ -358,13 +_,22 @@ if (this.isNoAi()) { compound.putBoolean("NoAI", this.isNoAi()); } @@ -112,45 +94,30 @@ @Override public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); -- this.setCanPickUpLoot(compound.getBoolean("CanPickUpLoot")); -- this.persistenceRequired = compound.getBoolean("PersistenceRequired"); +- this.setCanPickUpLoot(compound.getBooleanOr("CanPickUpLoot", false)); +- this.persistenceRequired = compound.getBooleanOr("PersistenceRequired", false); + // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it -+ if (compound.contains("CanPickUpLoot", 99)) { -+ boolean data = compound.getBoolean("CanPickUpLoot"); -+ if (isLevelAtLeast(compound, 1) || data) { -+ this.setCanPickUpLoot(data); -+ } ++ boolean canPickUpLoot = compound.getBooleanOr("CanPickUpLoot", false); ++ if (isLevelAtLeast(compound, 1) || canPickUpLoot) { ++ this.setCanPickUpLoot(canPickUpLoot); + } -+ -+ boolean data = compound.getBoolean("PersistenceRequired"); -+ if (isLevelAtLeast(compound, 1) || data) { -+ this.persistenceRequired = data; ++ boolean persistenceRequired = compound.getBooleanOr("PersistenceRequired", false); ++ if (isLevelAtLeast(compound, 1) || persistenceRequired) { ++ this.persistenceRequired = persistenceRequired; + } + // CraftBukkit end - if (compound.contains("ArmorItems", 9)) { - ListTag list = compound.getList("ArmorItems", 10); - -@@ -472,13 +_,18 @@ + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + this.dropChances = compound.read("drop_chances", DropChances.CODEC, registryOps).orElse(DropChances.DEFAULT); this.readLeashData(compound); - this.setLeftHanded(compound.getBoolean("LeftHanded")); - if (compound.contains("DeathLootTable", 8)) { -- this.lootTable = Optional.of(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(compound.getString("DeathLootTable")))); -+ this.lootTable = Optional.ofNullable(ResourceLocation.tryParse(compound.getString("DeathLootTable"))).map((rs) -> ResourceKey.create(Registries.LOOT_TABLE, rs)); // Paper - Validate ResourceLocation - } else { - this.lootTable = Optional.empty(); - } - - this.lootTableSeed = compound.getLong("DeathLootTableSeed"); - this.setNoAi(compound.getBoolean("NoAI")); -+ // CraftBukkit start -+ if (compound.contains("Bukkit.Aware")) { -+ this.aware = compound.getBoolean("Bukkit.Aware"); -+ } -+ // CraftBukkit end +@@ -372,6 +_,7 @@ + this.lootTable = compound.read("DeathLootTable", LootTable.KEY_CODEC); + this.lootTableSeed = compound.getLongOr("DeathLootTableSeed", 0L); + this.setNoAi(compound.getBooleanOr("NoAI", false)); ++ this.aware = compound.getBooleanOr("Bukkit.Aware", true); // CraftBukkit } @Override -@@ -540,6 +_,11 @@ +@@ -433,6 +_,11 @@ && !itemEntity.getItem().isEmpty() && !itemEntity.hasPickUpDelay() && this.wantsToPickUp(serverLevel, itemEntity.getItem())) { @@ -162,7 +129,7 @@ this.pickUpItem(serverLevel, itemEntity); } } -@@ -554,18 +_,24 @@ +@@ -447,18 +_,24 @@ protected void pickUpItem(ServerLevel level, ItemEntity entity) { ItemStack item = entity.getItem(); @@ -184,32 +151,32 @@ + return this.equipItemIfPossible(level, stack, null); + } + -+ public ItemStack equipItemIfPossible(ServerLevel level, ItemStack stack, ItemEntity entity) { ++ public ItemStack equipItemIfPossible(ServerLevel level, ItemStack stack, @Nullable ItemEntity entity) { + // CraftBukkit end EquipmentSlot equipmentSlotForItem = this.getEquipmentSlotForItem(stack); - ItemStack itemBySlot = this.getItemBySlot(equipmentSlotForItem); - boolean canReplaceCurrentItem = this.canReplaceCurrentItem(stack, itemBySlot, equipmentSlotForItem); -@@ -575,10 +_,18 @@ - canReplaceCurrentItem = itemBySlot.isEmpty(); - } - -- if (canReplaceCurrentItem && this.canHoldItem(stack)) { -+ // CraftBukkit start -+ boolean canPickup = canReplaceCurrentItem && this.canHoldItem(stack); -+ if (entity != null) { -+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entity, 0, !canPickup).isCancelled(); -+ } -+ if (canPickup) { -+ // CraftBukkit end - double d = this.getEquipmentDropChance(equipmentSlotForItem); - if (!itemBySlot.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d) { -+ this.forceDrops = true; // CraftBukkit - this.spawnAtLocation(level, itemBySlot); -+ this.forceDrops = false; // CraftBukkit + if (!this.isEquippableInSlot(stack, equipmentSlotForItem)) { + return ItemStack.EMPTY; +@@ -471,10 +_,18 @@ + canReplaceCurrentItem = itemBySlot.isEmpty(); } - ItemStack itemStack = equipmentSlotForItem.limit(stack); -@@ -703,22 +_,29 @@ +- if (canReplaceCurrentItem && this.canHoldItem(stack)) { ++ // CraftBukkit start ++ boolean canPickup = canReplaceCurrentItem && this.canHoldItem(stack); ++ if (entity != null) { ++ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entity, 0, !canPickup).isCancelled(); ++ } ++ if (canPickup) { ++ // CraftBukkit end + double d = this.dropChances.byEquipment(equipmentSlotForItem); + if (!itemBySlot.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d) { ++ this.forceDrops = true; // CraftBukkit + this.spawnAtLocation(level, itemBySlot); ++ this.forceDrops = false; // CraftBukkit + } + + ItemStack itemStack = equipmentSlotForItem.limit(stack); +@@ -591,22 +_,29 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { @@ -229,9 +196,9 @@ + final io.papermc.paper.configuration.WorldConfiguration.Entities.Spawning.DespawnRangePair despawnRangePair = this.level().paperConfig().entities.spawning.despawnRanges.get(this.getType().getCategory()); + final io.papermc.paper.configuration.type.DespawnRange.Shape shape = this.level().paperConfig().entities.spawning.despawnRangeShape; + final double dy = Math.abs(nearestPlayer.getY() - this.getY()); -+ final double dySqr = Math.pow(dy, 2); -+ final double dxSqr = Math.pow(nearestPlayer.getX() - this.getX(), 2); -+ final double dzSqr = Math.pow(nearestPlayer.getZ() - this.getZ(), 2); ++ final double dySqr = Mth.square(dy); ++ final double dxSqr = Mth.square(nearestPlayer.getX() - this.getX()); ++ final double dzSqr = Mth.square(nearestPlayer.getZ() - this.getZ()); + final double distanceSquared = dxSqr + dzSqr + dySqr; + // Despawn if hard/soft limit is exceeded + if (despawnRangePair.hard().shouldDespawn(shape, dxSqr, dySqr, dzSqr, dy) && this.removeWhenFarAway(distanceSquared)) { @@ -252,14 +219,14 @@ this.noActionTime = 0; } } -@@ -730,6 +_,15 @@ +@@ -618,6 +_,15 @@ @Override protected final void serverAiStep() { this.noActionTime++; + // Paper start - Allow nerfed mobs to jump and float + if (!this.aware) { -+ if (goalFloat != null) { -+ if (goalFloat.canUse()) goalFloat.tick(); ++ if (this.goalFloat != null) { ++ if (this.goalFloat.canUse()) this.goalFloat.tick(); + this.getJumpControl().tick(); + } + return; @@ -268,41 +235,67 @@ ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("sensing"); this.sensing.tick(); -@@ -908,26 +_,40 @@ - - @Override - public void setItemSlot(EquipmentSlot slot, ItemStack stack) { -+ // Paper start - Fix silent equipment change -+ setItemSlot(slot, stack, false); -+ } +@@ -793,14 +_,69 @@ + public boolean stillValid(Player player) { + return player.getVehicle() == Mob.this || player.canInteractWithEntity(Mob.this, 4.0); + } + -+ @Override -+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { -+ // Paper end - Fix silent equipment change - this.verifyEquippedItem(stack); - switch (slot.getType()) { - case HAND: -- this.onEquipItem(slot, this.handItems.set(slot.getIndex(), stack), stack); -+ this.onEquipItem(slot, this.handItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change - break; - case HUMANOID_ARMOR: -- this.onEquipItem(slot, this.armorItems.set(slot.getIndex(), stack), stack); -+ this.onEquipItem(slot, this.armorItems.set(slot.getIndex(), stack), stack, silent); // Paper - Fix silent equipment change - break; - case ANIMAL_ARMOR: - ItemStack itemStack = this.bodyArmorItem; - this.bodyArmorItem = stack; -- this.onEquipItem(slot, itemStack, stack); -+ this.onEquipItem(slot, itemStack, stack, silent); // Paper - Fix silent equipment change - } ++ // Paper start ++ private final List viewers = new java.util.ArrayList<>(); ++ private int maxStackSize = MAX_STACK; ++ ++ @Override ++ public int getMaxStackSize() { ++ return this.maxStackSize; ++ } ++ ++ @Override ++ public List getContents() { ++ return java.util.Arrays.asList(this.getTheItem()); ++ } ++ ++ @Override ++ public void onOpen(final org.bukkit.craftbukkit.entity.CraftHumanEntity player) { ++ this.viewers.add(player); ++ } ++ ++ @Override ++ public void onClose(final org.bukkit.craftbukkit.entity.CraftHumanEntity player) { ++ this.viewers.remove(player); ++ } ++ ++ @Override ++ public List getViewers() { ++ return this.viewers; ++ } ++ ++ @Override ++ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { ++ if (Mob.this.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder inventoryHolder) { ++ return inventoryHolder; ++ } ++ return null; ++ } ++ ++ @Override ++ public void setMaxStackSize(final int size) { ++ this.maxStackSize = size; ++ } ++ ++ @Override ++ public org.bukkit.Location getLocation() { ++ return Mob.this.getBukkitEntity().getLocation(); ++ } ++ // Paper end + }; } -+ + + // Paper start -+ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (i.e fox) ++ protected boolean shouldSkipLoot(EquipmentSlot slot) { // method to avoid to fallback into the global mob loot logic (e.g. the fox) + return false; + } + // Paper end - ++ @Override protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { super.dropCustomDeathLoot(level, damageSource, recentlyHit); @@ -310,9 +303,9 @@ for (EquipmentSlot equipmentSlot : EquipmentSlot.VALUES) { + if (this.shouldSkipLoot(equipmentSlot)) continue; // Paper ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); - float equipmentDropChance = this.getEquipmentDropChance(equipmentSlot); - if (equipmentDropChance != 0.0F) { -@@ -951,7 +_,13 @@ + float f = this.dropChances.byEquipment(equipmentSlot); + if (f != 0.0F) { +@@ -820,7 +_,13 @@ } this.spawnAtLocation(level, itemBySlot); @@ -326,40 +319,39 @@ } } } -@@ -981,7 +_,9 @@ - double d = this.getEquipmentDropChance(equipmentSlot); - if (d > 1.0) { - this.setItemSlot(equipmentSlot, ItemStack.EMPTY); -+ this.forceDrops = true; // Paper - Add missing forceDrop toggles - this.spawnAtLocation(level, itemBySlot); -+ this.forceDrops = false; // Paper - Add missing forceDrop toggles - } +@@ -844,7 +_,9 @@ + set.add(equipmentSlot); + } else if (this.dropChances.isPreserved(equipmentSlot)) { + this.setItemSlot(equipmentSlot, ItemStack.EMPTY); ++ this.forceDrops = true; // Paper - Add missing forceDrop toggles + this.spawnAtLocation(level, itemBySlot); ++ this.forceDrops = false; // Paper - Add missing forceDrop toggles } } -@@ -1269,6 +_,22 @@ + } +@@ -1122,6 +_,21 @@ public T convertTo( EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion ) { ++ // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entityType, conversionParams, spawnReason, afterConversion, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason + ) { -+ // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entityType, conversionParams, spawnReason, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } + @Nullable + public T convertTo( -+ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason ++ EntityType entityType, ConversionParams conversionParams, EntitySpawnReason spawnReason, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason + ) { + // Paper end - entity zap event - allow cancellation of conversion post creation -+ // CraftBukkit end if (this.isRemoved()) { return null; } else { -@@ -1277,13 +_,23 @@ +@@ -1130,13 +_,23 @@ return null; } else { conversionParams.type().convert(this, mob, conversionParams); @@ -371,7 +363,7 @@ + return mob; + } + -+ if (CraftEventFactory.callEntityTransformEvent(this, mob, transformReason).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, mob, transformReason).isCancelled()) { + return null; + } + // CraftBukkit end @@ -386,29 +378,27 @@ } return mob; -@@ -1293,7 +_,20 @@ +@@ -1146,7 +_,18 @@ @Nullable public T convertTo(EntityType entityType, ConversionParams coversionParams, ConversionParams.AfterConversion afterConversion) { - return this.convertTo(entityType, coversionParams, EntitySpawnReason.CONVERSION, afterConversion); -+ // CraftBukkit start ++ // Paper start - entity zap event - allow cancellation of conversion post creation + return this.convertTo(entityType, coversionParams, afterConversion, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT); + } + + @Nullable -+ public T convertTo(EntityType entityType, ConversionParams coversionParams, ConversionParams.AfterConversion afterConversion, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason) { -+ // Paper start - entity zap event - allow cancellation of conversion post creation ++ public T convertTo(EntityType entityType, ConversionParams coversionParams, ConversionParams.AfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, coversionParams, e -> { afterConversion.finalizeConversion(e); return true; }, transformReason, creatureSpawnReason); + } + @Nullable -+ public T convertTo(EntityType entityType, ConversionParams coversionParams, ConversionParams.CancellingAfterConversion afterConversion, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason creatureSpawnReason) { -+ // Paper start - entity zap event - allow cancellation of conversion post creation ++ public T convertTo(EntityType entityType, ConversionParams coversionParams, ConversionParams.CancellingAfterConversion afterConversion, @Nullable EntityTransformEvent.TransformReason transformReason, @Nullable CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + return this.convertTo(entityType, coversionParams, EntitySpawnReason.CONVERSION, afterConversion, transformReason, creatureSpawnReason); -+ // CraftBukkit end ++ // Paper end - entity zap event - allow cancellation of conversion post creation } @Nullable -@@ -1329,7 +_,17 @@ +@@ -1182,7 +_,17 @@ public boolean startRiding(Entity entity, boolean force) { boolean flag = super.startRiding(entity, force); if (flag && this.isLeashed()) { @@ -427,7 +417,7 @@ } return flag; -@@ -1412,7 +_,7 @@ +@@ -1270,7 +_,7 @@ float knockback = this.getKnockback(source, damageSource); if (knockback > 0.0F && source instanceof LivingEntity livingEntity) { livingEntity.knockback( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch index 06fd0f09c..ab85a3a71 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/NeutralMob.java.patch @@ -1,43 +1,34 @@ --- a/net/minecraft/world/entity/NeutralMob.java +++ b/net/minecraft/world/entity/NeutralMob.java -@@ -39,18 +_,11 @@ - } else { - UUID uuid = tag.getUUID("AngryAt"); - this.setPersistentAngerTarget(uuid); -- Entity entity = ((ServerLevel)level).getEntity(uuid); -- if (entity != null) { -- if (entity instanceof Mob mob) { -- this.setTarget(mob); -- this.setLastHurtByMob(mob); -- } -- -- if (entity instanceof Player player) { -- this.setTarget(player); -- this.setLastHurtByPlayer(player); -- } -- } -+ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method -+ // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively -+ // tick the initial persistent anger. -+ // If not, let the first tick on the baseTick call the method later down the line. -+ if (this instanceof Entity entity && !entity.firstTick) this.tickInitialPersistentAnger(level); - } +@@ -35,9 +_,11 @@ + if (level instanceof ServerLevel serverLevel) { + UUID uuid = tag.read("AngryAt", UUIDUtil.CODEC).orElse(null); + this.setPersistentAngerTarget(uuid); +- if ((uuid != null ? serverLevel.getEntity(uuid) : null) instanceof LivingEntity livingEntity) { +- this.setTarget(livingEntity); +- } ++ // Paper - Prevent entity loading causing async lookups; Moved diff to separate method ++ // If this entity already survived its first tick, e.g. is loaded and ticked in sync, actively ++ // tick the initial persistent anger. ++ // If not, let the first tick on the baseTick call the method later down the line. ++ if (this instanceof Entity entity && !entity.firstTick) this.tickInitialPersistentAnger(level); } } -@@ -104,7 +_,7 @@ + +@@ -90,7 +_,7 @@ default void stopBeingAngry() { this.setLastHurtByMob(null); this.setPersistentAngerTarget(null); - this.setTarget(null); -+ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit ++ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit this.setRemainingPersistentAngerTime(0); } -@@ -117,8 +_,33 @@ +@@ -101,8 +_,24 @@ void setTarget(@Nullable LivingEntity livingEntity); -+ boolean setTarget(@Nullable LivingEntity entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit ++ boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason); // CraftBukkit + boolean canAttack(LivingEntity entity); @@ -52,17 +43,8 @@ + return; + } + -+ Entity entity = ((ServerLevel)level).getEntity(uuid); -+ if (entity != null) { -+ if (entity instanceof Mob mob) { -+ this.setTarget(mob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit -+ this.setLastHurtByMob(mob); -+ } -+ -+ if (entity instanceof Player player) { -+ this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, false); // CraftBukkit -+ this.setLastHurtByPlayer(player); -+ } ++ if (level.getEntity(uuid) instanceof net.minecraft.world.entity.LivingEntity livingEntity) { ++ this.setTarget(livingEntity, null); + } + } + // Paper end - Prevent entity loading causing async lookups diff --git a/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch index 10e7665ce..1911584df 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/OminousItemSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/OminousItemSpawner.java +++ b/net/minecraft/world/entity/OminousItemSpawner.java -@@ -76,7 +_,7 @@ +@@ -79,7 +_,7 @@ entity = this.spawnProjectile(serverLevel, projectileItem, item); } else { entity = new ItemEntity(serverLevel, this.getX(), this.getY(), this.getZ(), item); @@ -9,7 +9,7 @@ } serverLevel.levelEvent(3021, this.blockPosition(), 1); -@@ -90,7 +_,7 @@ +@@ -93,7 +_,7 @@ ProjectileItem.DispenseConfig dispenseConfig = projectileItem.createDispenseConfig(); dispenseConfig.overrideDispenseEvent().ifPresent(i -> level.levelEvent(i, this.blockPosition(), 0)); Direction direction = Direction.DOWN; @@ -18,7 +18,7 @@ projectileItem.asProjectile(level, this.position(), stack, direction), level, stack, -@@ -99,7 +_,7 @@ +@@ -102,7 +_,7 @@ direction.getStepZ(), dispenseConfig.power(), dispenseConfig.uncertainty() diff --git a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch index b00c96d54..1c01a87d0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/TamableAnimal.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/TamableAnimal.java +++ b/net/minecraft/world/entity/TamableAnimal.java -@@ -84,7 +_,7 @@ +@@ -77,7 +_,7 @@ } - this.orderedToSit = compound.getBoolean("Sitting"); + this.orderedToSit = compound.getBooleanOr("Sitting", false); - this.setInSittingPose(this.orderedToSit); + this.setInSittingPose(this.orderedToSit, false); // Paper - Add EntityToggleSitEvent } @Override -@@ -95,8 +_,16 @@ +@@ -88,8 +_,16 @@ @Override public boolean handleLeashAtDistance(Entity leashHolder, float distance) { if (this.isInSittingPose()) { @@ -28,20 +28,21 @@ } return false; -@@ -155,6 +_,12 @@ +@@ -148,6 +_,13 @@ } public void setInSittingPose(boolean sitting) { + // Paper start - Add EntityToggleSitEvent + this.setInSittingPose(sitting, true); + } ++ + public void setInSittingPose(boolean sitting, boolean callEvent) { + if (callEvent && !new io.papermc.paper.event.entity.EntityToggleSitEvent(this.getBukkitEntity(), sitting).callEvent()) return; + // Paper end - Add EntityToggleSitEvent byte b = this.entityData.get(DATA_FLAGS_ID); if (sitting) { this.entityData.set(DATA_FLAGS_ID, (byte)(b | 1)); -@@ -227,7 +_,12 @@ +@@ -230,7 +_,12 @@ if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES) && this.getOwner() instanceof ServerPlayer serverPlayer) { @@ -55,18 +56,18 @@ } super.die(cause); -@@ -270,7 +_,14 @@ +@@ -273,7 +_,14 @@ if (!this.canTeleportTo(new BlockPos(x, y, z))) { return false; } else { -- this.moveTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot()); +- this.snapTo(x + 0.5, y, z + 0.5, this.getYRot(), this.getXRot()); + // CraftBukkit start + org.bukkit.event.entity.EntityTeleportEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTeleportEvent(this, x + 0.5, y, z + 0.5); -+ if (event.isCancelled() || event.getTo() == null) { // Paper - prevent NP on null event to location ++ if (event.isCancelled() || event.getTo() == null) { + return false; + } + org.bukkit.Location to = event.getTo(); -+ this.moveTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); ++ this.snapTo(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch()); + // CraftBukkit end this.navigation.stop(); return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch index c315956cf..6b9c2bc8e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeInstance.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeInstance.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeInstance.java -@@ -153,20 +_,20 @@ +@@ -155,20 +_,20 @@ double baseValue = this.getBaseValue(); for (AttributeModifier attributeModifier : this.getModifiersOrEmpty(AttributeModifier.Operation.ADD_VALUE)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch index f685d112e..180c8aadf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/attributes/AttributeMap.java.patch @@ -1,7 +1,7 @@ --- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -162,4 +_,12 @@ - } +@@ -148,4 +_,12 @@ + .ifPresent(attributeInstance -> attributeInstance.load(compoundOrEmpty)); } } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch index 60e6ed37a..43404a071 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/AssignProfessionFromJobSite.java.patch @@ -3,15 +3,15 @@ @@ -38,7 +_,14 @@ .findFirst() ) - .ifPresent(profession -> { -- villager.setVillagerData(villager.getVillagerData().setProfession(profession)); + .ifPresent(reference -> { +- villager.setVillagerData(villager.getVillagerData().withProfession(reference)); + // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed -+ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(villager, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftToBukkit(profession), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.EMPLOYED); ++ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(villager, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftHolderToBukkit(reference), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.EMPLOYED); + if (event.isCancelled()) { + return; + } + -+ villager.setVillagerData(villager.getVillagerData().setProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); ++ villager.setVillagerData(villager.getVillagerData().withProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); + // CraftBukkit end villager.refreshBrain(level); }); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch index 0f29b936e..dc1f5963b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/RamTarget.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/behavior/RamTarget.java +++ b/net/minecraft/world/entity/ai/behavior/RamTarget.java -@@ -89,7 +_,7 @@ - float f = 0.25F * (i - i1); - float f1 = Mth.clamp(owner.getSpeed() * 1.65F, 0.2F, 3.0F) + f; - float f2 = livingEntity.isDamageSourceBlocked(level.damageSources().mobAttack(owner)) ? 0.5F : 1.0F; -- livingEntity.knockback(f2 * f1 * this.getKnockbackForce.applyAsDouble(owner), this.ramDirection.x(), this.ramDirection.z()); -+ livingEntity.knockback(f2 * f1 * this.getKnockbackForce.applyAsDouble(owner), this.ramDirection.x(), this.ramDirection.z(), owner, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent +@@ -92,7 +_,7 @@ + DamageSource damageSource1 = level.damageSources().mobAttack(owner); + float f3 = livingEntity.applyItemBlocking(level, damageSource1, f); + float f4 = f3 > 0.0F ? 0.5F : 1.0F; +- livingEntity.knockback(f4 * f2 * this.getKnockbackForce.applyAsDouble(owner), this.ramDirection.x(), this.ramDirection.z()); ++ livingEntity.knockback(f4 * f2 * this.getKnockbackForce.applyAsDouble(owner), this.ramDirection.x(), this.ramDirection.z(), owner, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.ENTITY_ATTACK); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent this.finishRam(level, owner); level.playSound(null, owner, this.getImpactSound.apply(owner), SoundSource.NEUTRAL, 1.0F, 1.0F); } else if (this.hasRammedHornBreakingBlock(level, owner)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch index 580871ed5..00704ac69 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/ResetProfession.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/entity/ai/behavior/ResetProfession.java +++ b/net/minecraft/world/entity/ai/behavior/ResetProfession.java -@@ -18,7 +_,14 @@ - && villagerData.getProfession() != VillagerProfession.NITWIT - && villager.getVillagerXp() == 0 - && villagerData.getLevel() <= 1) { -- villager.setVillagerData(villager.getVillagerData().setProfession(VillagerProfession.NONE)); -+ // CraftBukkit start -+ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(villager, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftToBukkit(VillagerProfession.NONE), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); -+ if (event.isCancelled()) { -+ return false; -+ } +@@ -13,7 +_,14 @@ + VillagerData villagerData = villager.getVillagerData(); + boolean flag = !villagerData.profession().is(VillagerProfession.NONE) && !villagerData.profession().is(VillagerProfession.NITWIT); + if (flag && villager.getVillagerXp() == 0 && villagerData.level() <= 1) { +- villager.setVillagerData(villager.getVillagerData().withProfession(level.registryAccess(), VillagerProfession.NONE)); ++ // CraftBukkit start ++ org.bukkit.event.entity.VillagerCareerChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callVillagerCareerChangeEvent(villager, org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.minecraftHolderToBukkit(level.registryAccess().getOrThrow(VillagerProfession.NONE)), org.bukkit.event.entity.VillagerCareerChangeEvent.ChangeReason.LOSING_JOB); ++ if (event.isCancelled()) { ++ return false; ++ } + -+ villager.setVillagerData(villager.getVillagerData().setProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraft(event.getProfession()))); -+ // CraftBukkit end - villager.refreshBrain(level); - return true; - } else { ++ villager.setVillagerData(villager.getVillagerData().withProfession(org.bukkit.craftbukkit.entity.CraftVillager.CraftProfession.bukkitToMinecraftHolder(event.getProfession()))); ++ // CraftBukkit end + villager.refreshBrain(level); + return true; + } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java.patch index cac317166..a9528bead 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java +++ b/net/minecraft/world/entity/ai/behavior/VillagerGoalPackages.java -@@ -42,7 +_,7 @@ +@@ -45,7 +_,7 @@ Pair.of(1, new MoveToTargetSink()), Pair.of(2, PoiCompetitorScan.create()), Pair.of(3, new LookAndFollowTradingPlayerSink(speedModifier)), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch index 592af079e..bd2ded975 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/behavior/VillagerMakeLove.java.patch @@ -7,13 +7,13 @@ - parent.setAge(6000); - partner.setAge(6000); breedOffspring.setAge(-24000); - breedOffspring.moveTo(parent.getX(), parent.getY(), parent.getZ(), 0.0F, 0.0F); ++ // Paper - Move age setting down + breedOffspring.snapTo(parent.getX(), parent.getY(), parent.getZ(), 0.0F, 0.0F); - level.addFreshEntityWithPassengers(breedOffspring); + // CraftBukkit start - call EntityBreedEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(breedOffspring, parent, partner, null, null, 0).isCancelled()) { + return Optional.empty(); + } -+ // Move age setting down + parent.setAge(6000); + partner.setAge(6000); + level.addFreshEntityWithPassengers(breedOffspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch index 8cc09baa9..f9fc01b41 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/EatBlockGoal.java.patch @@ -16,10 +16,10 @@ this.eatAnimationTick = Math.max(0, this.eatAnimationTick - 1); if (this.eatAnimationTick == this.adjustedTickDelay(4)) { BlockPos blockPos = this.mob.blockPosition(); -- if (IS_TALL_GRASS.test(this.level.getBlockState(blockPos))) { +- if (IS_EDIBLE.test(this.level.getBlockState(blockPos))) { - if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + final BlockState blockState = this.level.getBlockState(blockPos); // Paper - fix wrong block state -+ if (IS_TALL_GRASS.test(blockState)) { // Paper - fix wrong block state ++ if (IS_EDIBLE.test(blockState)) { // Paper - fix wrong block state + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockPos, blockState.getFluidState().createLegacyBlock(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit // Paper - fix wrong block state this.level.destroyBlock(blockPos, false); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch index 8760a911a..e64289b68 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/Goal.java.patch @@ -23,13 +23,13 @@ } + // Paper start - Mob goal api -+ private com.destroystokyo.paper.entity.ai.PaperVanillaGoal vanillaGoal; -+ public com.destroystokyo.paper.entity.ai.Goal asPaperVanillaGoal() { -+ if (this.vanillaGoal == null) { -+ this.vanillaGoal = new com.destroystokyo.paper.entity.ai.PaperVanillaGoal<>(this); ++ private com.destroystokyo.paper.entity.ai.PaperGoal paperGoal; ++ public com.destroystokyo.paper.entity.ai.Goal asPaperGoal() { ++ if (this.paperGoal == null) { ++ this.paperGoal = new com.destroystokyo.paper.entity.ai.PaperGoal<>(this); + } + //noinspection unchecked -+ return (com.destroystokyo.paper.entity.ai.Goal) this.vanillaGoal; ++ return (com.destroystokyo.paper.entity.ai.Goal) this.paperGoal; + } + // Paper end - Mob goal api + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch deleted file mode 100644 index d467f6a9a..000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java -+++ b/net/minecraft/world/entity/ai/goal/SitWhenOrderedToGoal.java -@@ -20,7 +_,7 @@ - @Override - public boolean canUse() { - if (!this.mob.isTame()) { -- return false; -+ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals - } else if (this.mob.isInWaterOrBubble()) { - return false; - } else if (!this.mob.onGround()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch index 8144be0e4..2635d672a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java +++ b/net/minecraft/world/entity/ai/goal/target/DefendVillageTargetGoal.java -@@ -48,7 +_,7 @@ +@@ -47,7 +_,7 @@ @Override public void start() { - this.golem.setTarget(this.potentialTarget); -+ this.golem.setTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason ++ this.golem.setTarget(this.potentialTarget, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE); // CraftBukkit - reason super.start(); } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch index 1fd9b780b..6c395ee1f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/HurtByTargetGoal.java.patch @@ -5,7 +5,7 @@ @Override public void start() { - this.mob.setTarget(this.mob.getLastHurtByMob()); -+ this.mob.setTarget(this.mob.getLastHurtByMob(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason ++ this.mob.setTarget(this.mob.getLastHurtByMob(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit - reason this.targetMob = this.mob.getTarget(); this.timestamp = this.mob.getLastHurtByMobTimestamp(); this.unseenMemoryTicks = 300; @@ -14,6 +14,6 @@ protected void alertOther(Mob mob, LivingEntity target) { - mob.setTarget(target); -+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason ++ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY); // CraftBukkit - reason } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch index a6474a3a6..3a53b1a47 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/NearestAttackableTargetGoal.java.patch @@ -5,7 +5,7 @@ @Override public void start() { - this.mob.setTarget(this.target); -+ this.mob.setTarget(this.target, this.target instanceof ServerPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason ++ this.mob.setTarget(this.target, this.target instanceof ServerPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); // CraftBukkit - reason super.start(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch index e411caa1e..4af8cccaf 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtByTargetGoal.java.patch @@ -5,7 +5,7 @@ @Override public void start() { - this.mob.setTarget(this.ownerLastHurtBy); -+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER); // CraftBukkit - reason LivingEntity owner = this.tameAnimal.getOwner(); if (owner != null) { this.timestamp = owner.getLastHurtByMobTimestamp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch index d7274fc9a..d95340aab 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/OwnerHurtTargetGoal.java.patch @@ -5,7 +5,7 @@ @Override public void start() { - this.mob.setTarget(this.ownerLastHurt); -+ this.mob.setTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason ++ this.mob.setTarget(this.ownerLastHurt, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET); // CraftBukkit - reason LivingEntity owner = this.tameAnimal.getOwner(); if (owner != null) { this.timestamp = owner.getLastHurtMobTimestamp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch index 68b320d4d..a452b371f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/goal/target/TargetGoal.java.patch @@ -5,7 +5,7 @@ } - this.mob.setTarget(target); -+ this.mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit ++ this.mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY); // CraftBukkit return true; } } @@ -14,7 +14,7 @@ @Override public void stop() { - this.mob.setTarget(null); -+ this.mob.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit ++ this.mob.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit this.targetMob = null; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/gossip/GossipContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/gossip/GossipContainer.java.patch index 1a74963cd..72a27d8f5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/gossip/GossipContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/gossip/GossipContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/gossip/GossipContainer.java +++ b/net/minecraft/world/entity/ai/gossip/GossipContainer.java -@@ -216,6 +_,44 @@ +@@ -220,6 +_,44 @@ public void remove(GossipType gossipType) { this.entries.removeInt(gossipType); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch index 5cc08f5dc..5ed233032 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/navigation/PathNavigation.java.patch @@ -51,7 +51,7 @@ + boolean copiedSet = false; + for (BlockPos possibleTarget : targets) { + if (!this.mob.level().getWorldBorder().isWithinBounds(possibleTarget) || !new com.destroystokyo.paper.event.entity.EntityPathfindEvent(this.mob.getBukkitEntity(), // Paper - don't path out of world border -+ io.papermc.paper.util.MCUtil.toLocation(this.mob.level(), possibleTarget), target == null ? null : target.getBukkitEntity()).callEvent()) { ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(possibleTarget, this.mob.level()), target == null ? null : target.getBukkitEntity()).callEvent()) { + if (!copiedSet) { + copiedSet = true; + targets = new java.util.HashSet<>(targets); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch index 7ec237343..0a3a0a535 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/sensing/TemptingSensor.java.patch @@ -1,32 +1,19 @@ --- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java +++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java -@@ -16,6 +_,14 @@ - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.ItemStack; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.event.entity.EntityTargetEvent; -+import org.bukkit.event.entity.EntityTargetLivingEntityEvent; -+// CraftBukkit end -+ - public class TemptingSensor extends Sensor { - private static final TargetingConditions TEMPT_TARGETING = TargetingConditions.forNonCombat().ignoreLineOfSight(); - private final Predicate temptations; -@@ -38,7 +_,17 @@ +@@ -38,7 +_,19 @@ .collect(Collectors.toList()); if (!list.isEmpty()) { Player player = list.get(0); - brain.setMemory(MemoryModuleType.TEMPTING_PLAYER, player); + // CraftBukkit start -+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(entity, player, EntityTargetEvent.TargetReason.TEMPT); ++ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent( ++ entity, player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TEMPT ++ ); + if (event.isCancelled()) { + return; + } -+ if (event.getTarget() instanceof HumanEntity) { -+ brain.setMemory(MemoryModuleType.TEMPTING_PLAYER, ((CraftHumanEntity) event.getTarget()).getHandle()); ++ if (event.getTarget() instanceof org.bukkit.craftbukkit.entity.CraftHumanEntity target) { ++ brain.setMemory(MemoryModuleType.TEMPTING_PLAYER, target.getHandle()); + } else { + brain.eraseMemory(MemoryModuleType.TEMPTING_PLAYER); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch index 983754df6..5d20e026f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ai/village/VillageSiege.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ai/village/VillageSiege.java +++ b/net/minecraft/world/entity/ai/village/VillageSiege.java -@@ -101,11 +_,12 @@ +@@ -95,11 +_,12 @@ zombie.finalizeSpawn(level, level.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.EVENT, null); } catch (Exception var5) { LOGGER.warn("Failed to create zombie for village siege at {}", vec3, var5); @@ -8,7 +8,7 @@ return; } - zombie.moveTo(vec3.x, vec3.y, vec3.z, level.random.nextFloat() * 360.0F, 0.0F); + zombie.snapTo(vec3.x, vec3.y, vec3.z, level.random.nextFloat() * 360.0F, 0.0F); - level.addFreshEntityWithPassengers(zombie); + level.addFreshEntityWithPassengers(zombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch index 2b20441f4..68b4b71bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/ambient/Bat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/ambient/Bat.java +++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -85,7 +_,7 @@ +@@ -86,7 +_,7 @@ } @Override @@ -9,7 +9,7 @@ return false; } -@@ -139,13 +_,13 @@ +@@ -140,13 +_,13 @@ this.yHeadRot = this.random.nextInt(360); } @@ -25,7 +25,7 @@ this.setResting(false); if (!isSilent) { level.levelEvent(null, 1025, blockPos, 0); -@@ -178,7 +_,7 @@ +@@ -179,7 +_,7 @@ float f1 = Mth.wrapDegrees(f - this.getYRot()); this.zza = 0.5F; this.setYRot(this.getYRot() + f1); @@ -34,7 +34,7 @@ this.setResting(true); } } -@@ -203,7 +_,7 @@ +@@ -204,7 +_,7 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch similarity index 81% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Cow.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch index a5059e85d..b66d5d65f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractCow.java.patch @@ -1,11 +1,11 @@ ---- a/net/minecraft/world/entity/animal/Cow.java -+++ b/net/minecraft/world/entity/animal/Cow.java -@@ -88,8 +_,15 @@ +--- a/net/minecraft/world/entity/animal/AbstractCow.java ++++ b/net/minecraft/world/entity/animal/AbstractCow.java +@@ -84,8 +_,15 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand); ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand); + if (event.isCancelled()) { + player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync + return InteractionResult.PASS; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch index f837f2d73..7563c46eb 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Animal.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/animal/Animal.java +++ b/net/minecraft/world/entity/animal/Animal.java -@@ -39,6 +_,7 @@ - public int inLove; +@@ -41,6 +_,7 @@ + public int inLove = 0; @Nullable public UUID loveCause; -+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable ++ public @Nullable ItemStack breedItem; // CraftBukkit - Add breedItem variable protected Animal(EntityType entityType, Level level) { super(entityType, level); -@@ -78,9 +_,13 @@ +@@ -80,9 +_,13 @@ } @Override @@ -35,7 +35,7 @@ this.playEatingSound(); return InteractionResult.SUCCESS_SERVER; } -@@ -176,11 +_,26 @@ +@@ -176,8 +_,23 @@ return this.inLove <= 0; } @@ -45,6 +45,7 @@ + // Paper start - Fix EntityBreedEvent copying + this.setInLove(player, null); + } ++ + public void setInLove(@Nullable Player player, @Nullable ItemStack breedItemCopy) { + if (breedItemCopy != null) this.breedItem = breedItemCopy; + // Paper end - Fix EntityBreedEvent copying @@ -59,17 +60,13 @@ if (player != null) { this.loveCause = player.getUUID(); } -+ // Paper - Fix EntityBreedEvent copying; set breed item in better place - - this.level().broadcastEntityEvent(this, (byte)18); - } -@@ -220,23 +_,44 @@ +@@ -220,23 +_,45 @@ if (breedOffspring != null) { breedOffspring.setBaby(true); - breedOffspring.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); + breedOffspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F); - this.finalizeSpawnChildFromBreeding(level, mate, breedOffspring); - level.addFreshEntityWithPassengers(breedOffspring); -+ // CraftBukkit start - call EntityBreedEvent ++ // CraftBukkit start - Call EntityBreedEvent + ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(mate.getLoveCause())).orElse(null); + int experience = this.getRandom().nextInt(7) + 1; + org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(breedOffspring, this, mate, breeder, this.breedItem, experience); @@ -79,29 +76,30 @@ + return; + } + experience = entityBreedEvent.getExperience(); ++ + this.finalizeSpawnChildFromBreeding(level, mate, breedOffspring, experience); + level.addFreshEntityWithPassengers(breedOffspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); -+ // CraftBukkit end - call EntityBreedEvent ++ // CraftBukkit end - Call EntityBreedEvent } } public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby) { - Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(animal.getLoveCause())).ifPresent(player -> { -+ // CraftBukkit start - call EntityBreedEvent ++ // CraftBukkit start - Call EntityBreedEvent + this.finalizeSpawnChildFromBreeding(level, animal, baby, this.getRandom().nextInt(7) + 1); + } + + public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby, int experience) { -+ // CraftBukkit end - call EntityBreedEvent -+ // Paper start - call EntityBreedEvent ++ // CraftBukkit end - Call EntityBreedEvent ++ // Paper start - Call EntityBreedEvent + ServerPlayer player = this.getLoveCause(); + if (player == null) player = animal.getLoveCause(); + if (player != null) { -+ // Paper end - call EntityBreedEvent ++ // Paper end - Call EntityBreedEvent player.awardStat(Stats.ANIMALS_BRED); CriteriaTriggers.BRED_ANIMALS.trigger(player, this, animal, baby); - }); -+ } // Paper - call EntityBreedEvent ++ } // Paper - Call EntityBreedEvent this.setAge(6000); animal.setAge(6000); this.resetLove(); @@ -109,8 +107,8 @@ level.broadcastEntityEvent(this, (byte)18); - if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1)); -+ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent -+ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - call EntityBreedEvent, add spawn context ++ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - Call EntityBreedEvent ++ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - Call EntityBreedEvent, add spawn context } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch index 94a18bec6..95a582301 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bee.java +++ b/net/minecraft/world/entity/animal/Bee.java -@@ -141,10 +_,26 @@ +@@ -145,10 +_,26 @@ Bee.BeeGoToHiveGoal goToHiveGoal; private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal; private int underWaterTicks; @@ -28,7 +28,7 @@ this.lookControl = new Bee.BeeLookControl(this); this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F); this.setPathfindingMalus(PathType.WATER, -1.0F); -@@ -191,12 +_,19 @@ +@@ -195,9 +_,18 @@ @Override public void addAdditionalSaveData(CompoundTag compound) { @@ -37,20 +37,17 @@ + } + + @Override -+ public void addAdditionalSaveData(CompoundTag compound, boolean includeAll) { ++ public void addAdditionalSaveData(CompoundTag compound, boolean saveAll) { + // CraftBukkit end super.addAdditionalSaveData(compound); -- if (this.hasHive()) { -+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive - compound.put("hive_pos", NbtUtils.writeBlockPos(this.getHivePos())); - } - -- if (this.hasSavedFlowerPos()) { -+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save hive - compound.put("flower_pos", NbtUtils.writeBlockPos(this.getSavedFlowerPos())); - } - -@@ -237,7 +_,7 @@ ++ if (saveAll) { // Paper + compound.storeNullable("hive_pos", BlockPos.CODEC, this.hivePos); + compound.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); ++ } // Paper + compound.putBoolean("HasNectar", this.hasNectar()); + compound.putBoolean("HasStung", this.hasStung()); + compound.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive); +@@ -235,7 +_,7 @@ } if (i > 0) { @@ -59,7 +56,7 @@ } } -@@ -492,7 +_,11 @@ +@@ -490,7 +_,11 @@ if (this.hivePos == null) { return null; } else { @@ -72,7 +69,7 @@ } } -@@ -525,6 +_,7 @@ +@@ -523,6 +_,7 @@ } public void setRolling(boolean isRolling) { @@ -80,7 +77,7 @@ this.setFlag(2, isRolling); } -@@ -581,7 +_,7 @@ +@@ -579,7 +_,7 @@ if (beeInteractionEffect != null) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide) { @@ -89,7 +86,7 @@ } return InteractionResult.SUCCESS; -@@ -650,8 +_,9 @@ +@@ -648,8 +_,9 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -100,7 +97,7 @@ } } -@@ -772,7 +_,7 @@ +@@ -770,7 +_,7 @@ @VisibleForDebug public class BeeGoToHiveGoal extends Bee.BaseBeeGoal { public static final int MAX_TRAVELLING_TICKS = 2400; @@ -109,7 +106,7 @@ private static final int MAX_BLACKLISTED_TARGETS = 3; final List blacklistedTargets = Lists.newArrayList(); @Nullable -@@ -888,7 +_,7 @@ +@@ -886,7 +_,7 @@ public class BeeGoToKnownFlowerGoal extends Bee.BaseBeeGoal { private static final int MAX_TRAVELLING_TICKS = 2400; @@ -118,7 +115,7 @@ BeeGoToKnownFlowerGoal() { this.setFlags(EnumSet.of(Goal.Flag.MOVE)); -@@ -986,7 +_,7 @@ +@@ -983,7 +_,7 @@ } } @@ -127,16 +124,16 @@ Bee.this.level().levelEvent(2011, blockPos, 15); Bee.this.level().setBlockAndUpdate(blockPos, blockState1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1010,7 +_,7 @@ +@@ -1007,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { - mob.setTarget(target); -+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason ++ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit - reason } } } -@@ -1168,7 +_,7 @@ +@@ -1165,7 +_,7 @@ Bee.this.dropFlower(); this.pollinating = false; Bee.this.remainingCooldownBeforeLocatingNewFlower = 200; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch index 7d0041cf6..c28cc0e15 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bucketable.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Bucketable.java +++ b/net/minecraft/world/entity/animal/Bucketable.java -@@ -88,9 +_,19 @@ +@@ -71,9 +_,19 @@ static Optional bucketMobPickup(Player player, InteractionHand hand, T entity) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.getItem() == Items.WATER_BUCKET && entity.isAlive()) { @@ -21,7 +21,7 @@ ItemStack itemStack = ItemUtils.createFilledResult(itemInHand, player, bucketItemStack, false); player.setItemInHand(hand, itemStack); Level level = entity.level(); -@@ -98,7 +_,7 @@ +@@ -81,7 +_,7 @@ CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, bucketItemStack); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch index f475fefe0..a4c4e2b82 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Cat.java.patch @@ -1,15 +1,6 @@ --- a/net/minecraft/world/entity/animal/Cat.java +++ b/net/minecraft/world/entity/animal/Cat.java -@@ -342,7 +_,7 @@ - TagKey tagKey = flag ? CatVariantTags.FULL_MOON_SPAWNS : CatVariantTags.DEFAULT_SPAWNS; - BuiltInRegistries.CAT_VARIANT.getRandomElementOf(tagKey, level.getRandom()).ifPresent(this::setVariant); - ServerLevel level1 = level.getLevel(); -- if (level1.structureManager().getStructureWithPieceAt(this.blockPosition(), StructureTags.CATS_SPAWN_AS_BLACK).isValid()) { -+ if (level1.structureManager().getStructureWithPieceAt(this.blockPosition(), StructureTags.CATS_SPAWN_AS_BLACK, level).isValid()) { // Paper - Fix swamp hut cat generation deadlock - this.setVariant(BuiltInRegistries.CAT_VARIANT.getOrThrow(CatVariant.ALL_BLACK)); - this.setPersistenceRequired(); - } -@@ -359,6 +_,11 @@ +@@ -372,6 +_,11 @@ if (item instanceof DyeItem dyeItem) { DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -21,7 +12,7 @@ if (!this.level().isClientSide()) { this.setCollarColor(dyeColor); itemInHand.consume(1, player); -@@ -371,7 +_,7 @@ +@@ -384,7 +_,7 @@ if (!this.level().isClientSide()) { this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); @@ -30,7 +21,7 @@ this.playEatingSound(); } -@@ -433,7 +_,7 @@ +@@ -446,7 +_,7 @@ } private void tryToTame(Player player) { @@ -39,32 +30,32 @@ this.tame(player); this.setOrderedToSit(true); this.level().broadcastEntityEvent(this, (byte)7); -@@ -567,15 +_,20 @@ +@@ -580,15 +_,20 @@ .dropFromGiftLootTable( getServerLevel(this.cat), BuiltInLootTables.CAT_MORNING_GIFT, -- (serverLevel, itemStack) -> serverLevel.addFreshEntity( +- (level, stack) -> level.addFreshEntity( - new ItemEntity( -+ (serverLevel, itemStack) -> { -+ // CraftBukkit start -+ ItemEntity item = new ItemEntity( - serverLevel, ++ // CraftBukkit start ++ (level, stack) -> { ++ final ItemEntity item = new ItemEntity( + level, (double)mutableBlockPos.getX() - Mth.sin(this.cat.yBodyRot * (float) (Math.PI / 180.0)), mutableBlockPos.getY(), (double)mutableBlockPos.getZ() + Mth.cos(this.cat.yBodyRot * (float) (Math.PI / 180.0)), - itemStack + stack - ) - ) + ); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) item.getBukkitEntity()); + if (!event.callEvent()) return; -+ serverLevel.addFreshEntity(item); -+ // CraftBukkit end ++ level.addFreshEntity(item); + } ++ // CraftBukkit end ); } -@@ -602,7 +_,7 @@ +@@ -615,7 +_,7 @@ static class CatTemptGoal extends TemptGoal { @Nullable diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch index a95bdb667..994a2e508 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Chicken.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Chicken.java +++ b/net/minecraft/world/entity/animal/Chicken.java -@@ -91,10 +_,12 @@ +@@ -111,10 +_,12 @@ this.flap = this.flap + this.flapping * 2.0F; if (this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch index f0e77a24b..f8650c2b3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Dolphin.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Dolphin.java +++ b/net/minecraft/world/entity/animal/Dolphin.java -@@ -96,6 +_,13 @@ +@@ -98,6 +_,13 @@ return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING); } @@ -14,7 +14,7 @@ @Override public float getAgeScale() { return this.isBaby() ? 0.65F : 1.0F; -@@ -196,7 +_,7 @@ +@@ -182,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -23,7 +23,7 @@ } @Override -@@ -229,11 +_,15 @@ +@@ -215,11 +_,15 @@ if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) { ItemStack item = entity.getItem(); if (this.canHoldItem(item)) { @@ -40,7 +40,7 @@ } } } -@@ -497,7 +_,7 @@ +@@ -486,7 +_,7 @@ @Override public void start() { @@ -49,7 +49,7 @@ } @Override -@@ -516,7 +_,7 @@ +@@ -505,7 +_,7 @@ } if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) { @@ -58,7 +58,7 @@ } } } -@@ -586,7 +_,7 @@ +@@ -575,7 +_,7 @@ 0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0)) + Mth.sin(f1) * f2 ); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch index e2b7f5326..ea7e36b5a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Fox.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/Fox.java +++ b/net/minecraft/world/entity/animal/Fox.java -@@ -413,7 +_,7 @@ - - this.setSleeping(compound.getBoolean("Sleeping")); - this.setVariant(Fox.Variant.byName(compound.getString("Type"))); -- this.setSitting(compound.getBoolean("Sitting")); -+ this.setSitting(compound.getBoolean("Sitting"), false); // Paper - Add EntityToggleSitEvent - this.setIsCrouching(compound.getBoolean("Crouching")); +@@ -429,7 +_,7 @@ + compound.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity); + this.setSleeping(compound.getBooleanOr("Sleeping", false)); + this.setVariant(compound.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT)); +- this.setSitting(compound.getBooleanOr("Sitting", false)); ++ this.setSitting(compound.getBooleanOr("Sitting", false), false); // Paper - Add EntityToggleSitEvent + this.setIsCrouching(compound.getBooleanOr("Crouching", false)); if (this.level() instanceof ServerLevel) { this.setTargetGoals(); -@@ -425,6 +_,12 @@ +@@ -446,6 +_,12 @@ } public void setSitting(boolean sitting) { @@ -22,7 +22,7 @@ this.setFlag(1, sitting); } -@@ -484,19 +_,20 @@ +@@ -505,19 +_,20 @@ itemEntity.setPickUpDelay(40); itemEntity.setThrower(this); this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F); @@ -46,7 +46,7 @@ int count = item.getCount(); if (count > 1) { this.dropItemStack(item.split(count - 1)); -@@ -507,7 +_,7 @@ +@@ -528,7 +_,7 @@ this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1)); this.setGuaranteedDrop(EquipmentSlot.MAINHAND); this.take(entity, item.getCount()); @@ -55,8 +55,23 @@ this.ticksSinceEaten = 0; } } -@@ -671,15 +_,33 @@ - return this.getTrustedUUIDs().contains(uuid); +@@ -623,12 +_,12 @@ + } + + @Override +- public void setTarget(@Nullable LivingEntity livingEntity) { ++ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit + if (this.isDefending() && livingEntity == null) { + this.setDefending(false); + } + +- super.setTarget(livingEntity); ++ return super.setTarget(livingEntity, reason); // CraftBukkit + } + + void wakeUp() { +@@ -692,15 +_,33 @@ + return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity)); } - @Override @@ -93,13 +108,13 @@ } public static boolean isPathClear(Fox fox, LivingEntity livingEntity) { -@@ -853,6 +_,18 @@ - if (loveCause1 != null && loveCause != loveCause1) { - fox.addTrustedUUID(loveCause1.getUUID()); +@@ -876,6 +_,19 @@ + fox.addTrustedEntity(loveCause1); } + + // CraftBukkit start - call EntityBreedEvent + fox.setAge(-24000); -+ fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); ++ fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); + int experience = this.animal.getRandom().nextInt(7) + 1; + org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(fox, this.animal, this.partner, loveCause, this.animal.breedItem, experience); + if (entityBreedEvent.isCancelled()) { @@ -109,15 +124,16 @@ + } + experience = entityBreedEvent.getExperience(); + // CraftBukkit end - call EntityBreedEvent - ++ if (serverPlayer != null) { serverPlayer.awardStat(Stats.ANIMALS_BRED); -@@ -863,14 +_,12 @@ + CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox); +@@ -885,14 +_,12 @@ this.partner.setAge(6000); this.animal.resetLove(); this.partner.resetLove(); - fox.setAge(-24000); -- fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); +- fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F); - serverLevel.addFreshEntityWithPassengers(fox); + serverLevel.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason this.level.broadcastEntityEvent(this.animal, (byte)18); @@ -130,10 +146,10 @@ ); } } -@@ -934,6 +_,7 @@ +@@ -956,6 +_,7 @@ private void pickSweetBerries(BlockState state) { int ageValue = state.getValue(SweetBerryBushBlock.AGE); - state.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1)); + state.setValue(SweetBerryBushBlock.AGE, 1); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.blockPos, state.setValue(SweetBerryBushBlock.AGE, 1))) return; // CraftBukkit - call EntityChangeBlockEvent int i = 1 + Fox.this.level().random.nextInt(2) + (ageValue == 3 ? 1 : 0); ItemStack itemBySlot = Fox.this.getItemBySlot(EquipmentSlot.MAINHAND); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch index 3af59e7fb..99afa7baa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/IronGolem.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/animal/IronGolem.java +++ b/net/minecraft/world/entity/animal/IronGolem.java -@@ -104,7 +_,7 @@ +@@ -105,7 +_,7 @@ @Override protected void doPush(Entity entity) { if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) { - this.setTarget((LivingEntity)entity); -+ this.setTarget((LivingEntity)entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason ++ this.setTarget((LivingEntity)entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION); // CraftBukkit - set reason } super.doPush(entity); -@@ -303,7 +_,7 @@ +@@ -304,7 +_,7 @@ BlockPos blockPos = this.blockPosition(); BlockPos blockPos1 = blockPos.below(); BlockState blockState = level.getBlockState(blockPos1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch index adb68967c..e86dfd8dd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/MushroomCow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/MushroomCow.java +++ b/net/minecraft/world/entity/animal/MushroomCow.java -@@ -110,7 +_,17 @@ +@@ -116,7 +_,17 @@ return InteractionResult.SUCCESS; } else if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -19,7 +19,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); } -@@ -163,15 +_,31 @@ +@@ -169,15 +_,31 @@ @Override public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) { @@ -40,11 +40,11 @@ + public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears, java.util.List drops) { + // Paper end level.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, soundSource, 1.0F, 1.0F); - this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), mob -> { + this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), cow -> { level.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0); -- this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_MOOSHROOM, shears, (serverLevel, itemStack) -> { -- for (int i = 0; i < itemStack.getCount(); i++) { -- serverLevel.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), itemStack.copyWithCount(1))); +- this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_MOOSHROOM, shears, (serverLevel, stack) -> { +- for (int i = 0; i < stack.getCount(); i++) { +- serverLevel.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), stack.copyWithCount(1))); - } + // Paper start - custom shear drops; moved drop generation to separate method + drops.forEach(drop -> { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch index 0d5245ce2..78611a089 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Ocelot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Ocelot.java +++ b/net/minecraft/world/entity/animal/Ocelot.java -@@ -125,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override public boolean removeWhenFarAway(double distanceToClosestPlayer) { @@ -9,7 +9,7 @@ } public static AttributeSupplier.Builder createAttributes() { -@@ -159,7 +_,7 @@ +@@ -160,7 +_,7 @@ if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) { this.usePlayerItem(player, hand, itemInHand); if (!this.level().isClientSide) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch index 3e9a85088..1b200435d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Panda.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Panda.java +++ b/net/minecraft/world/entity/animal/Panda.java -@@ -127,6 +_,7 @@ +@@ -128,6 +_,7 @@ } public void sit(boolean sitting) { @@ -8,7 +8,7 @@ this.setFlag(8, sitting); } -@@ -516,24 +_,28 @@ +@@ -517,24 +_,28 @@ for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) { if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) { @@ -39,7 +39,7 @@ } } -@@ -624,8 +_,9 @@ +@@ -625,8 +_,9 @@ this.usePlayerItem(player, hand, itemInHand); this.ageUp((int)(-this.getAge() / 20 * 0.1F), true); } else if (!this.level().isClientSide && this.getAge() == 0 && this.canFallInLove()) { @@ -50,7 +50,7 @@ } else { if (!(this.level() instanceof ServerLevel serverLevel) || this.isSitting() || this.isInWater()) { return InteractionResult.PASS; -@@ -635,7 +_,9 @@ +@@ -636,7 +_,9 @@ this.eat(true); ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty() && !player.hasInfiniteMaterials()) { @@ -60,16 +60,16 @@ } this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1)); -@@ -861,7 +_,7 @@ +@@ -858,7 +_,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Panda && mob.isAggressive()) { - mob.setTarget(target); -+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit ++ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit } } } -@@ -1090,7 +_,9 @@ +@@ -1087,7 +_,9 @@ public void stop() { ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND); if (!itemBySlot.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch index 863d2bcb9..055daec24 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Parrot.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Parrot.java +++ b/net/minecraft/world/entity/animal/Parrot.java -@@ -257,7 +_,7 @@ +@@ -262,7 +_,7 @@ } if (!this.level().isClientSide) { @@ -9,7 +9,7 @@ this.tame(player); this.level().broadcastEntityEvent(this, (byte)7); } else { -@@ -278,7 +_,7 @@ +@@ -283,7 +_,7 @@ } } else { this.usePlayerItem(player, hand, itemInHand); @@ -18,7 +18,7 @@ if (player.isCreative() || !this.isInvulnerable()) { this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE); } -@@ -373,8 +_,8 @@ +@@ -378,8 +_,8 @@ } @Override @@ -29,7 +29,7 @@ } @Override -@@ -389,8 +_,13 @@ +@@ -394,8 +_,13 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch index bd25f044b..953de330e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Pufferfish.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Pufferfish.java +++ b/net/minecraft/world/entity/animal/Pufferfish.java -@@ -95,24 +_,36 @@ +@@ -96,24 +_,36 @@ public void tick() { if (!this.level().isClientSide && this.isAlive() && this.isEffectiveAi()) { if (this.inflateCounter > 0) { @@ -37,7 +37,7 @@ this.deflateTimer++; } } -@@ -136,7 +_,7 @@ +@@ -137,7 +_,7 @@ private void touch(ServerLevel level, Mob mob) { int puffState = this.getPuffState(); if (mob.hurtServer(level, this.damageSources().mobAttack(this), 1 + puffState)) { @@ -46,7 +46,7 @@ this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F); } } -@@ -151,7 +_,7 @@ +@@ -152,7 +_,7 @@ serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F)); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch index d5d3f133b..0c050dea5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Rabbit.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Rabbit.java +++ b/net/minecraft/world/entity/animal/Rabbit.java -@@ -88,7 +_,7 @@ +@@ -95,7 +_,7 @@ super(entityType, level); this.jumpControl = new Rabbit.RabbitJumpControl(this); this.moveControl = new Rabbit.RabbitMoveControl(this); @@ -9,7 +9,7 @@ } @Override -@@ -561,9 +_,11 @@ +@@ -588,9 +_,11 @@ if (this.canRaid && block instanceof CarrotBlock) { int ageValue = blockState.getValue(CarrotBlock.AGE); if (ageValue == 0) { @@ -18,6 +18,6 @@ level.destroyBlock(blockPos, true, this.rabbit); } else { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1))) return; // CraftBukkit // Paper - fix wrong block state - level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, Integer.valueOf(ageValue - 1)), 2); + level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1), 2); level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(this.rabbit)); level.levelEvent(2001, blockPos, Block.getId(blockState)); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch index ab7a9f125..b83921020 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/SnowGolem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/SnowGolem.java +++ b/net/minecraft/world/entity/animal/SnowGolem.java -@@ -92,7 +_,7 @@ +@@ -91,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel) { if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { @@ -9,16 +9,16 @@ } if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { -@@ -107,7 +_,7 @@ +@@ -106,7 +_,7 @@ int floor2 = Mth.floor(this.getZ() + (i / 2 % 2 * 2 - 1) * 0.25F); BlockPos blockPos = new BlockPos(floor, floor1, floor2); if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) { - this.level().setBlockAndUpdate(blockPos, blockState); -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, this)) continue; // CraftBukkit ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this)) continue; // CraftBukkit this.level().gameEvent(GameEvent.BLOCK_PLACE, blockPos, GameEvent.Context.of(this, blockState)); } } -@@ -135,7 +_,19 @@ +@@ -134,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -39,7 +39,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); } -@@ -148,11 +_,29 @@ +@@ -147,11 +_,29 @@ @Override public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch index 608d6617d..0f161b3e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Turtle.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/Turtle.java +++ b/net/minecraft/world/entity/animal/Turtle.java -@@ -303,7 +_,9 @@ +@@ -259,7 +_,9 @@ protected void ageBoundaryReached() { super.ageBoundaryReached(); if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -10,7 +10,7 @@ } } -@@ -328,7 +_,7 @@ +@@ -284,7 +_,7 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { @@ -19,7 +19,7 @@ } @Override -@@ -355,6 +_,10 @@ +@@ -311,6 +_,10 @@ if (loveCause == null && this.partner.getLoveCause() != null) { loveCause = this.partner.getLoveCause(); } @@ -30,7 +30,7 @@ if (loveCause != null) { loveCause.awardStat(Stats.ANIMALS_BRED); -@@ -368,7 +_,7 @@ +@@ -324,7 +_,7 @@ this.partner.resetLove(); RandomSource random = this.animal.getRandom(); if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { @@ -39,34 +39,32 @@ } } } -@@ -392,7 +_,7 @@ +@@ -347,7 +_,7 @@ + && ( this.turtle.hasEgg() - || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 - && !this.turtle.getHomePos().closerToCenterThan(this.turtle.position(), 64.0) + || this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0) - ); + ) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper - Turtle API } @Override -@@ -500,16 +_,22 @@ +@@ -455,14 +_,20 @@ BlockPos blockPos = this.turtle.blockPosition(); if (!this.turtle.isInWater() && this.isReachedTarget()) { if (this.turtle.layEggCounter < 1) { - this.turtle.setLayingEgg(true); -+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos)).callEvent()); // Paper - Turtle API ++ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.blockPos, this.turtle.level())).callEvent()); // Paper - Turtle API } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { + // Paper start - Turtle API + int eggCount = this.turtle.random.nextInt(4) + 1; -+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos.above()), eggCount); ++ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.blockPos.above(), this.turtle.level()), eggCount); + if (layEggEvent.callEvent() && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()))) { + // Paper end - Turtle API Level level = this.turtle.level(); level.playSound(null, blockPos, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + level.random.nextFloat() * 0.2F); BlockPos blockPos1 = this.blockPos.above(); - BlockState blockState = Blocks.TURTLE_EGG - .defaultBlockState() -- .setValue(TurtleEggBlock.EGGS, Integer.valueOf(this.turtle.random.nextInt(4) + 1)); -+ .setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()); // Paper +- BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1); ++ BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()); // Paper level.setBlock(blockPos1, blockState, 3); level.gameEvent(GameEvent.BLOCK_PLACE, blockPos1, GameEvent.Context.of(this.turtle, blockState)); + } // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch index f871cf255..d274fbeac 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/WaterAnimal.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/WaterAnimal.java +++ b/net/minecraft/world/entity/animal/WaterAnimal.java -@@ -70,6 +_,10 @@ +@@ -72,6 +_,10 @@ ) { int seaLevel = level.getSeaLevel(); int i = seaLevel - 13; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch index 8653998f8..07430fe6a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/allay/Allay.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/allay/Allay.java +++ b/net/minecraft/world/entity/animal/allay/Allay.java -@@ -118,6 +_,7 @@ +@@ -116,6 +_,7 @@ private float dancingAnimationTicks; private float spinningAnimationTicks; private float spinningAnimationTicks0; @@ -8,7 +8,7 @@ public Allay(EntityType entityType, Level level) { super(entityType, level); -@@ -131,6 +_,12 @@ +@@ -129,6 +_,12 @@ ); } @@ -21,7 +21,7 @@ @Override protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); -@@ -252,7 +_,7 @@ +@@ -248,7 +_,7 @@ public void aiStep() { super.aiStep(); if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) { @@ -30,7 +30,7 @@ } if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) { -@@ -320,7 +_,12 @@ +@@ -316,7 +_,12 @@ ItemStack itemInHand = player.getItemInHand(hand); ItemStack itemInHand1 = this.getItemInHand(InteractionHand.MAIN_HAND); if (this.isDancing() && itemInHand.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) { @@ -44,7 +44,7 @@ this.level().broadcastEntityEvent(this, (byte)18); this.level().playSound(player, this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F); this.removeInteractionItem(player, itemInHand); -@@ -425,6 +_,7 @@ +@@ -421,6 +_,7 @@ } private boolean shouldStopDancing() { @@ -52,24 +52,24 @@ return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX); -@@ -489,7 +_,7 @@ - .ifPresent(data -> this.vibrationData = data); - } - -- this.duplicationCooldown = compound.getInt("DuplicationCooldown"); -+ this.duplicationCooldown = compound.getLong("DuplicationCooldown"); // Paper - Load as long - this.entityData.set(DATA_CAN_DUPLICATE, compound.getBoolean("CanDuplicate")); +@@ -475,7 +_,7 @@ + this.readInventoryFromTag(compound, this.registryAccess()); + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + this.vibrationData = compound.read("listener", VibrationSystem.Data.CODEC, registryOps).orElseGet(VibrationSystem.Data::new); +- this.setDuplicationCooldown(compound.getIntOr("DuplicationCooldown", 0)); ++ this.setDuplicationCooldown(compound.getLongOr("DuplicationCooldown", 0)); // Paper - Load as long } -@@ -508,15 +_,17 @@ - } + @Override +@@ -494,15 +_,17 @@ + this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L); } - public void duplicateAllay() { + @Nullable public Allay duplicateAllay() { // CraftBukkit - return allay Allay allay = EntityType.ALLAY.create(this.level(), EntitySpawnReason.BREEDING); if (allay != null) { - allay.moveTo(this.position()); + allay.snapTo(this.position()); allay.setPersistenceRequired(); allay.resetDuplicationCooldown(); this.resetDuplicationCooldown(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch index 28a059aba..39350fabe 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/armadillo/Armadillo.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -141,10 +_,12 @@ +@@ -142,10 +_,12 @@ ArmadilloAi.updateActivity(this); profilerFiller.pop(); if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) { @@ -13,7 +13,7 @@ this.scuteTime = this.pickNextScuteDropTime(); } -@@ -283,8 +_,11 @@ +@@ -282,8 +_,11 @@ } @Override @@ -27,7 +27,7 @@ if (!this.isNoAi() && !this.isDeadOrDying()) { if (damageSource.getEntity() instanceof LivingEntity) { this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L); -@@ -295,6 +_,7 @@ +@@ -294,6 +_,7 @@ this.rollOut(); } } @@ -35,7 +35,7 @@ } @Override -@@ -313,7 +_,9 @@ +@@ -312,7 +_,9 @@ return false; } else { if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch index b39c81cfb..d3630a4f3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/axolotl/Axolotl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -226,7 +_,7 @@ +@@ -231,7 +_,7 @@ @Override public int getMaxAirSupply() { @@ -8,8 +8,8 @@ + return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() } - @Override -@@ -426,10 +_,10 @@ + public Axolotl.Variant getVariant() { +@@ -449,10 +_,10 @@ if (effect == null || effect.endsWithin(2399)) { int i = effect != null ? effect.getDuration() : 0; int min = Math.min(2400, 100 + i); @@ -17,12 +17,12 @@ + player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, min, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit } -- player.removeEffect(MobEffects.DIG_SLOWDOWN); -+ player.removeEffect(MobEffects.DIG_SLOWDOWN, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper - Add missing effect cause +- player.removeEffect(MobEffects.MINING_FATIGUE); ++ player.removeEffect(MobEffects.MINING_FATIGUE, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper - Add missing effect cause } @Override -@@ -521,6 +_,13 @@ +@@ -544,6 +_,13 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON); } @@ -30,7 +30,7 @@ + // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir() + @Override + public int getDefaultMaxAirSupply() { -+ return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY; ++ return AXOLOTL_TOTAL_AIR_SUPPLY; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch index 2b76781cb..5bf2254e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/camel/Camel.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/camel/Camel.java +++ b/net/minecraft/world/entity/animal/camel/Camel.java -@@ -386,12 +_,12 @@ +@@ -398,12 +_,12 @@ } else { boolean flag = this.getHealth() < this.getMaxHealth(); if (flag) { @@ -15,7 +15,7 @@ } boolean isBaby = this.isBaby(); -@@ -451,9 +_,13 @@ +@@ -463,9 +_,13 @@ } @Override @@ -31,7 +31,7 @@ } @Override -@@ -554,7 +_,7 @@ +@@ -566,7 +_,7 @@ } public void sitDown() { @@ -40,7 +40,7 @@ this.makeSound(SoundEvents.CAMEL_SIT); this.setPose(Pose.SITTING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -563,7 +_,7 @@ +@@ -575,7 +_,7 @@ } public void standUp() { @@ -49,7 +49,7 @@ this.makeSound(SoundEvents.CAMEL_STAND); this.setPose(Pose.STANDING); this.gameEvent(GameEvent.ENTITY_ACTION); -@@ -572,6 +_,7 @@ +@@ -584,6 +_,7 @@ } public void standUpInstantly() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch index f46b1c8ba..a2d12511c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Frog.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Frog.java +++ b/net/minecraft/world/entity/animal/frog/Frog.java -@@ -270,7 +_,12 @@ +@@ -287,7 +_,12 @@ @Override public void spawnChildFromBreeding(ServerLevel level, Animal mate) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index 215b78b19..df2b8ef34 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -62,6 +_,7 @@ +@@ -63,6 +_,7 @@ MemoryModuleType.BREED_TARGET, MemoryModuleType.IS_PANICKING ); @@ -8,7 +8,7 @@ public Tadpole(EntityType entityType, Level level) { super(entityType, level); -@@ -113,7 +_,7 @@ +@@ -114,7 +_,7 @@ @Override public void aiStep() { super.aiStep(); @@ -17,7 +17,7 @@ this.setAge(this.age + 1); } } -@@ -122,12 +_,14 @@ +@@ -123,12 +_,14 @@ public void addAdditionalSaveData(CompoundTag compound) { super.addAdditionalSaveData(compound); compound.putInt("Age", this.age); @@ -27,12 +27,12 @@ @Override public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); - this.setAge(compound.getInt("Age")); -+ this.ageLocked = compound.getBoolean("AgeLocked"); // Paper + this.setAge(compound.getIntOr("Age", 0)); ++ this.ageLocked = compound.getBooleanOr("AgeLocked", false); // Paper } @Nullable -@@ -177,7 +_,12 @@ +@@ -178,13 +_,19 @@ @Override public void saveToBucketTag(ItemStack stack) { Bucketable.saveDefaultDataToBucketTag(this, stack); @@ -46,15 +46,14 @@ } @Override -@@ -186,6 +_,7 @@ - if (tag.contains("Age")) { - this.setAge(tag.getInt("Age")); - } -+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper + public void loadFromBucketTag(CompoundTag tag) { + Bucketable.loadDefaultDataFromBucketTag(this, tag); + tag.getInt("Age").ifPresent(this::setAge); ++ this.ageLocked = tag.getBooleanOr("AgeLocked", false); // Paper } @Override -@@ -217,6 +_,7 @@ +@@ -216,6 +_,7 @@ } private void ageUp(int offset) { @@ -62,7 +61,7 @@ this.setAge(this.age + offset * 20); } -@@ -229,12 +_,17 @@ +@@ -228,12 +_,17 @@ private void ageUp() { if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch index 1f19c91cf..64ee2102f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/goat/Goat.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/animal/goat/Goat.java +++ b/net/minecraft/world/entity/animal/goat/Goat.java -@@ -231,13 +_,22 @@ +@@ -234,13 +_,22 @@ public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.BUCKET) && !this.isBaby()) { + // CraftBukkit start - Got milk? -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand); ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand); + + if (event.isCancelled()) { + player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync @@ -25,7 +25,7 @@ this.playEatingSound(); } -@@ -349,8 +_,7 @@ +@@ -352,8 +_,7 @@ double d1 = Mth.randomBetween(this.random, 0.3F, 0.7F); double d2 = Mth.randomBetween(this.random, -0.2F, 0.2F); ItemEntity itemEntity = new ItemEntity(this.level(), vec3.x(), vec3.y(), vec3.z(), itemStack, d, d1, d2); @@ -35,7 +35,7 @@ } } -@@ -381,4 +_,15 @@ +@@ -384,4 +_,15 @@ ) { return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch index 9fbe146a0..968d8c59d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java -@@ -69,6 +_,12 @@ +@@ -70,6 +_,12 @@ super.dropEquipment(level); if (this.hasChest()) { this.spawnAtLocation(level, Blocks.CHEST); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 2679d4439..b30638aa7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -1,78 +1,14 @@ --- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java +++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -77,6 +_,17 @@ - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.ticks.ContainerSingleItem; - -+// CraftBukkit start -+import java.util.Arrays; -+import java.util.List; -+import org.bukkit.Location; -+import org.bukkit.craftbukkit.entity.CraftHumanEntity; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.entity.HumanEntity; -+import org.bukkit.event.entity.EntityRegainHealthEvent; -+import org.bukkit.inventory.InventoryHolder; -+// CraftBukkit end -+ - public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable { - public static final int EQUIPMENT_SLOT_OFFSET = 400; - public static final int CHEST_SLOT_OFFSET = 499; -@@ -145,7 +_,53 @@ - public boolean stillValid(Player player) { - return player.getVehicle() == AbstractHorse.this || player.canInteractWithEntity(AbstractHorse.this, 4.0); - } -+ -+ // CraftBukkit start - add fields and methods -+ public final List transaction = new java.util.ArrayList<>(); -+ private int maxStack = MAX_STACK; -+ -+ @Override -+ public List getContents() { -+ return Arrays.asList(this.getTheItem()); -+ } -+ -+ @Override -+ public void onOpen(CraftHumanEntity player) { -+ this.transaction.add(player); -+ } -+ -+ @Override -+ public void onClose(CraftHumanEntity player) { -+ this.transaction.remove(player); -+ } -+ -+ @Override -+ public List getViewers() { -+ return this.transaction; -+ } -+ -+ @Override -+ public int getMaxStackSize() { -+ return this.maxStack; -+ } -+ -+ @Override -+ public void setMaxStackSize(int size) { -+ this.maxStack = size; -+ } -+ -+ @Override -+ public InventoryHolder getOwner() { -+ return (org.bukkit.entity.AbstractHorse) AbstractHorse.this.getBukkitEntity(); -+ } -+ -+ @Override -+ public Location getLocation() { -+ return AbstractHorse.this.getBukkitEntity().getLocation(); -+ } -+ // CraftBukkit end - }; +@@ -122,6 +_,7 @@ + protected int gallopSoundCounter; + @Nullable + public EntityReference owner; + public int maxDomestication = 100; // CraftBukkit - store max domestication value protected AbstractHorse(EntityType entityType, Level level) { super(entityType, level); -@@ -284,7 +_,7 @@ +@@ -250,7 +_,7 @@ } @Override @@ -81,25 +17,25 @@ return !this.isVehicle(); } -@@ -340,7 +_,7 @@ +@@ -301,7 +_,7 @@ public void createInventory() { SimpleContainer simpleContainer = this.inventory; - this.inventory = new SimpleContainer(this.getInventorySize()); + this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit if (simpleContainer != null) { - simpleContainer.removeListener(this); int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -@@ -448,7 +_,7 @@ + +@@ -395,7 +_,7 @@ } public int getMaxTemper() { - return 100; -+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100 ++ return this.maxDomestication; // CraftBukkit - return stored max domestication instead } @Override -@@ -503,7 +_,7 @@ +@@ -450,7 +_,7 @@ i1 = 5; if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -108,7 +44,7 @@ } } else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) { f = 10.0F; -@@ -511,12 +_,12 @@ +@@ -458,12 +_,12 @@ i1 = 10; if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) { flag = true; @@ -119,20 +55,20 @@ if (this.getHealth() < this.getMaxHealth() && f > 0.0F) { - this.heal(f); -+ this.heal(f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit ++ this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit flag = true; } -@@ -587,7 +_,7 @@ +@@ -534,7 +_,7 @@ super.aiStep(); if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) { if (this.random.nextInt(900) == 0 && this.deathTime == 0) { - this.heal(1.0F); -+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit ++ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit } if (this.canEatGrass()) { -@@ -690,6 +_,16 @@ +@@ -637,6 +_,16 @@ } } @@ -149,7 +85,7 @@ @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { if (this.isVehicle() || this.isBaby()) { -@@ -727,6 +_,12 @@ +@@ -674,6 +_,12 @@ this.setFlag(16, eating); } @@ -162,27 +98,23 @@ public void setStanding(boolean standing) { if (standing) { this.setEating(false); -@@ -838,6 +_,7 @@ - if (this.getOwnerUUID() != null) { - compound.putUUID("Owner", this.getOwnerUUID()); +@@ -785,6 +_,7 @@ + if (this.owner != null) { + this.owner.store(compound, "Owner"); } -+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit ++ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // Paper - max domestication + } - if (!this.inventory.getItem(0).isEmpty()) { - compound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess())); -@@ -862,6 +_,11 @@ - if (uuid != null) { - this.setOwnerUUID(uuid); - } -+ // CraftBukkit start -+ if (compound.contains("Bukkit.MaxDomestication")) { -+ this.maxDomestication = compound.getInt("Bukkit.MaxDomestication"); -+ } -+ // CraftBukkit end + @Override +@@ -795,6 +_,7 @@ + this.setTemper(compound.getIntOr("Temper", 0)); + this.setTamed(compound.getBooleanOr("Tame", false)); + this.owner = EntityReference.readWithOldOwnerConversion(compound, "Owner", this.level()); ++ this.maxDomestication = compound.getIntOr("Bukkit.MaxDomestication", this instanceof Llama ? 30 : 100); // Paper - max domestication + } - if (compound.contains("SaddleItem", 10)) { - ItemStack itemStack = ItemStack.parse(this.registryAccess(), compound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY); -@@ -959,6 +_,17 @@ + @Override +@@ -883,6 +_,17 @@ @Override public void handleStartJump(int jumpPower) { @@ -193,7 +125,7 @@ + } else { + power = 0.4F + 0.4F * (float) jumpPower / 90.0F; + } -+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power)) { + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch index 86290f169..25ab74cc3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/Llama.java +++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -71,17 +_,23 @@ +@@ -76,17 +_,23 @@ @Nullable private Llama caravanHead; @Nullable @@ -25,7 +25,7 @@ private void setStrength(int strength) { this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength))); } -@@ -168,12 +_,12 @@ +@@ -193,12 +_,12 @@ f = 10.0F; if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) { flag = true; @@ -40,7 +40,7 @@ flag = true; } -@@ -295,7 +_,7 @@ +@@ -312,7 +_,7 @@ @Override public int getMaxTemper() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch index cdbce96d9..06a4c2869 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonHorse.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java +++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java -@@ -122,7 +_,7 @@ +@@ -124,7 +_,7 @@ public void aiStep() { super.aiStep(); if (this.isTrap() && this.trapTime++ >= 18000) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch index 6d15d96e1..bd666de5d 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java.patch @@ -25,7 +25,7 @@ this.horse.setTamed(true); @@ -39,11 +_,11 @@ if (lightningBolt != null) { - lightningBolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); + lightningBolt.snapTo(this.horse.getX(), this.horse.getY(), this.horse.getZ()); lightningBolt.setVisualOnly(true); - serverLevel.addFreshEntity(lightningBolt); + serverLevel.strikeLightning(lightningBolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch index 83a979d52..d499f9f39 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/TraderLlama.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/animal/horse/TraderLlama.java +++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java -@@ -89,7 +_,7 @@ +@@ -88,7 +_,7 @@ this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1; if (this.despawnDelay <= 0) { this.removeLeash(); @@ -9,12 +9,12 @@ } } } -@@ -148,7 +_,7 @@ +@@ -147,7 +_,7 @@ @Override public void start() { - this.mob.setTarget(this.ownerLastHurtBy); -+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit ++ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER); // CraftBukkit Entity leashHolder = this.llama.getLeashHolder(); if (leashHolder instanceof WanderingTrader) { this.timestamp = ((WanderingTrader)leashHolder).getLastHurtByMobTimestamp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Sheep.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch similarity index 95% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Sheep.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch index 2a1505ea5..4fe05450c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Sheep.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/sheep/Sheep.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Sheep.java -+++ b/net/minecraft/world/entity/animal/Sheep.java -@@ -158,7 +_,19 @@ +--- a/net/minecraft/world/entity/animal/sheep/Sheep.java ++++ b/net/minecraft/world/entity/animal/sheep/Sheep.java +@@ -161,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS)) { if (this.level() instanceof ServerLevel serverLevel && this.readyForShearing()) { @@ -21,7 +21,7 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); return InteractionResult.SUCCESS_SERVER; -@@ -172,14 +_,28 @@ +@@ -175,14 +_,28 @@ @Override public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) { @@ -57,7 +57,7 @@ if (itemEntity != null) { itemEntity.setDeltaMovement( itemEntity.getDeltaMovement() -@@ -287,6 +_,7 @@ +@@ -302,6 +_,7 @@ @Override public void ate() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Wolf.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch similarity index 92% rename from paper-server/patches/sources/net/minecraft/world/entity/animal/Wolf.java.patch rename to paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch index 6df46dcff..795babca8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Wolf.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/wolf/Wolf.java.patch @@ -1,6 +1,6 @@ ---- a/net/minecraft/world/entity/animal/Wolf.java -+++ b/net/minecraft/world/entity/animal/Wolf.java -@@ -344,8 +_,9 @@ +--- a/net/minecraft/world/entity/animal/wolf/Wolf.java ++++ b/net/minecraft/world/entity/animal/wolf/Wolf.java +@@ -400,16 +_,18 @@ if (this.isInvulnerableTo(level, damageSource)) { return false; } else { @@ -11,9 +11,6 @@ } } -@@ -355,10 +_,11 @@ - } - @Override - protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) { + public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) { // CraftBukkit - void -> boolean @@ -25,7 +22,7 @@ ItemStack bodyArmorItem = this.getBodyArmorItem(); int damageValue = bodyArmorItem.getDamageValue(); int maxDamage = bodyArmorItem.getMaxDamage(); -@@ -378,6 +_,7 @@ +@@ -429,6 +_,7 @@ ); } } @@ -33,7 +30,7 @@ } private boolean canArmorAbsorb(DamageSource damageSource) { -@@ -388,7 +_,7 @@ +@@ -439,7 +_,7 @@ protected void applyTamingSideEffects() { if (this.isTame()) { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0); @@ -42,7 +39,7 @@ } else { this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0); } -@@ -408,7 +_,7 @@ +@@ -459,7 +_,7 @@ this.usePlayerItem(player, hand, itemInHand); FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD); float f = foodProperties != null ? foodProperties.nutrition() : 1.0F; @@ -51,16 +48,16 @@ return InteractionResult.SUCCESS; } -@@ -441,7 +_,7 @@ +@@ -492,7 +_,7 @@ this.setOrderedToSit(!this.isOrderedToSit()); this.jumping = false; this.navigation.stop(); - this.setTarget(null); -+ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason ++ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit - reason return InteractionResult.SUCCESS.withoutItem(); } -@@ -453,7 +_,9 @@ +@@ -504,7 +_,9 @@ ItemStack bodyArmorItem = this.getBodyArmorItem(); this.setBodyArmorItem(ItemStack.EMPTY); if (this.level() instanceof ServerLevel serverLevel) { @@ -70,7 +67,7 @@ } return InteractionResult.SUCCESS; -@@ -461,6 +_,13 @@ +@@ -512,6 +_,13 @@ DyeColor dyeColor = dyeItem.getDyeColor(); if (dyeColor != this.getCollarColor()) { @@ -84,7 +81,7 @@ this.setCollarColor(dyeColor); itemInHand.consume(1, player); return InteractionResult.SUCCESS; -@@ -475,7 +_,7 @@ +@@ -526,7 +_,7 @@ } private void tryToTame(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch index f318988a0..a7a9b5e99 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java @@ -25,6 +_,7 @@ - ); private static final EntityDataAccessor DATA_SHOW_BOTTOM = SynchedEntityData.defineId(EndCrystal.class, EntityDataSerializers.BOOLEAN); + private static final boolean DEFAULT_SHOW_BOTTOM = true; public int time; + public boolean generatedByDragonFight = false; // Paper - Fix invulnerable end crystals public EndCrystal(EntityType entityType, Level level) { super(entityType, level); -@@ -56,9 +_,23 @@ +@@ -56,21 +_,37 @@ if (this.level() instanceof ServerLevel) { BlockPos blockPos = this.blockPosition(); if (((ServerLevel)this.level()).getDragonFight() != null && this.level().getBlockState(blockPos).isAir()) { @@ -22,7 +22,7 @@ + + // Paper start - Fix invulnerable end crystals + if (this.level().paperConfig().unsupportedSettings.fixInvulnerableEndCrystalExploit && this.generatedByDragonFight && this.isInvulnerable()) { -+ if (!java.util.Objects.equals(((ServerLevel) this.level()).uuid, this.getOriginWorld()) ++ if (!java.util.Objects.equals(((ServerLevel) this.level()).uuid, this.originWorld) + || ((ServerLevel) this.level()).getDragonFight() == null + || ((ServerLevel) this.level()).getDragonFight().respawnStage == null + || ((ServerLevel) this.level()).getDragonFight().respawnStage.ordinal() > net.minecraft.world.level.dimension.end.DragonRespawnAnimation.SUMMONING_DRAGON.ordinal()) { @@ -34,23 +34,21 @@ } @Override -@@ -68,6 +_,7 @@ - } - + protected void addAdditionalSaveData(CompoundTag compound) { + compound.storeNullable("beam_target", BlockPos.CODEC, this.getBeamTarget()); compound.putBoolean("ShowBottom", this.showsBottom()); -+ if (this.generatedByDragonFight) compound.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals ++ compound.putBoolean("Paper.GeneratedByDragonFight", this.generatedByDragonFight); // Paper - Fix invulnerable end crystals } @Override -@@ -76,6 +_,7 @@ - if (compound.contains("ShowBottom", 1)) { - this.setShowBottom(compound.getBoolean("ShowBottom")); - } -+ if (compound.contains("Paper.GeneratedByDragonFight", 1)) this.generatedByDragonFight = compound.getBoolean("Paper.GeneratedByDragonFight"); // Paper - Fix invulnerable end crystals + protected void readAdditionalSaveData(CompoundTag compound) { + this.setBeamTarget(compound.read("beam_target", BlockPos.CODEC).orElse(null)); + this.setShowBottom(compound.getBooleanOr("ShowBottom", true)); ++ this.generatedByDragonFight = compound.getBooleanOr("Paper.GeneratedByDragonFight", false); // Paper - Fix invulnerable end crystals } @Override -@@ -96,10 +_,24 @@ +@@ -91,10 +_,24 @@ return false; } else { if (!this.isRemoved()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index bb629ff9a..1fd4c7ef0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java +++ b/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java -@@ -86,6 +_,10 @@ +@@ -87,6 +_,10 @@ private final Node[] nodes = new Node[24]; private final int[] nodeAdjacency = new int[24]; private final BinaryHeap openSet = new BinaryHeap(); @@ -11,7 +11,7 @@ public EnderDragon(EntityType entityType, Level level) { super(EntityType.ENDER_DRAGON, level); -@@ -101,6 +_,7 @@ +@@ -102,6 +_,7 @@ this.setHealth(this.getMaxHealth()); this.noPhysics = true; this.phaseManager = new EnderDragonPhaseManager(this); @@ -19,7 +19,7 @@ } public void setDragonFight(EndDragonFight dragonFight) { -@@ -119,6 +_,19 @@ +@@ -120,6 +_,19 @@ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 200.0); } @@ -39,7 +39,7 @@ @Override public boolean isFlapping() { float cos = Mth.cos(this.flapTime * (float) (Math.PI * 2)); -@@ -210,7 +_,7 @@ +@@ -211,7 +_,7 @@ } Vec3 flyTargetLocation = currentPhase.getFlyTargetLocation(); @@ -48,7 +48,7 @@ double d = flyTargetLocation.x - this.getX(); double d1 = flyTargetLocation.y - this.getY(); double d2 = flyTargetLocation.z - this.getZ(); -@@ -369,7 +_,12 @@ +@@ -366,7 +_,12 @@ if (this.nearestCrystal.isRemoved()) { this.nearestCrystal = null; } else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) { @@ -62,7 +62,7 @@ } } -@@ -400,7 +_,7 @@ +@@ -396,7 +_,7 @@ double d2 = entity.getX() - d; double d3 = entity.getZ() - d1; double max = Math.max(d2 * d2 + d3 * d3, 0.1); @@ -71,7 +71,7 @@ if (!this.phaseManager.getCurrentPhase().isSitting() && livingEntity.getLastHurtByMobTimestamp() < entity.tickCount - 2) { DamageSource damageSource = this.damageSources().mobAttack(this); entity.hurtServer(level, damageSource, 5.0F); -@@ -433,6 +_,7 @@ +@@ -429,6 +_,7 @@ int floor5 = Mth.floor(box.maxZ); boolean flag = false; boolean flag1 = false; @@ -79,7 +79,7 @@ for (int i = floor; i <= floor3; i++) { for (int i1 = floor1; i1 <= floor4; i1++) { -@@ -441,7 +_,11 @@ +@@ -437,7 +_,11 @@ BlockState blockState = level.getBlockState(blockPos); if (!blockState.isAir() && !blockState.is(BlockTags.DRAGON_TRANSPARENT)) { if (level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !blockState.is(BlockTags.DRAGON_IMMUNE)) { @@ -92,7 +92,7 @@ } else { flag = true; } -@@ -450,6 +_,58 @@ +@@ -446,6 +_,58 @@ } } @@ -151,7 +151,7 @@ if (flag1) { BlockPos blockPos1 = new BlockPos( floor + this.random.nextInt(floor3 - floor + 1), -@@ -507,7 +_,15 @@ +@@ -503,7 +_,15 @@ @Override public void kill(ServerLevel level) { @@ -168,7 +168,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); if (this.dragonFight != null) { this.dragonFight.updateDragon(this); -@@ -529,18 +_,41 @@ +@@ -525,18 +_,41 @@ this.level().addParticle(ParticleTypes.EXPLOSION_EMITTER, this.getX() + f, this.getY() + 2.0 + f1, this.getZ() + f2, 0.0, 0.0, 0.0); } @@ -186,7 +186,7 @@ - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F)); + if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp -+ ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper ++ ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.Optionull.map(this.lastHurtByPlayer, lastHurtByPlayer -> lastHurtByPlayer.getEntity(this.level(), Player.class)), this); // Paper } if (this.dragonDeathTime == 1 && !this.isSilent()) { @@ -213,14 +213,14 @@ } } -@@ -553,15 +_,15 @@ +@@ -549,15 +_,15 @@ } if (this.dragonDeathTime == 200 && this.level() instanceof ServerLevel serverLevel1) { - if (serverLevel1.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - ExperienceOrb.award(serverLevel1, this.position(), Mth.floor(i * 0.2F)); + if (true) { // Paper - SPIGOT-2420: Already checked for the game rule when calculating the xp -+ ExperienceOrb.award(serverLevel1, this.position(), Mth.floor(i * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper ++ ExperienceOrb.award(serverLevel1, this.position(), Mth.floor(i * 0.2F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, net.minecraft.Optionull.map(this.lastHurtByPlayer, lastHurtByPlayer -> lastHurtByPlayer.getEntity(this.level(), Player.class)), this); // Paper } if (this.dragonFight != null) { @@ -232,7 +232,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } } -@@ -743,6 +_,7 @@ +@@ -739,6 +_,7 @@ super.addAdditionalSaveData(compound); compound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId()); compound.putInt("DragonDeathTime", this.dragonDeathTime); @@ -240,20 +240,15 @@ } @Override -@@ -755,6 +_,12 @@ - if (compound.contains("DragonDeathTime")) { - this.dragonDeathTime = compound.getInt("DragonDeathTime"); - } -+ -+ // CraftBukkit start - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts -+ if (compound.contains("Bukkit.expToDrop")) { -+ this.expToDrop = compound.getInt("Bukkit.expToDrop"); -+ } -+ // CraftBukkit end +@@ -746,6 +_,7 @@ + super.readAdditionalSaveData(compound); + compound.getInt("DragonPhase").ifPresent(integer -> this.phaseManager.setPhase(EnderDragonPhase.getById(integer))); + this.dragonDeathTime = compound.getIntOr("DragonDeathTime", 0); ++ this.expToDrop = compound.getIntOr("Bukkit.expToDrop", 0); // CraftBukkit - SPIGOT-2420: The ender dragon drops xp over time which can also happen between server starts } @Override -@@ -795,7 +_,7 @@ +@@ -786,7 +_,7 @@ EnderDragonPhase phase = currentPhase.getPhase(); Vec3 viewVector; if (phase == EnderDragonPhase.LANDING || phase == EnderDragonPhase.TAKEOFF) { @@ -262,16 +257,16 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -883,4 +_,19 @@ +@@ -874,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } + + // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time. + @Override -+ public int getExpReward(ServerLevel worldserver, Entity entity) { ++ public int getExpReward(ServerLevel level, Entity entity) { + // CraftBukkit - Moved from #tickDeath method -+ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); ++ boolean flag = level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); + int i = 500; + + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch index 61de7efb5..918ba8a95 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java +++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonSittingFlamingPhase.java -@@ -82,7 +_,13 @@ - this.flame.setDuration(200); +@@ -83,7 +_,13 @@ this.flame.setParticle(ParticleTypes.DRAGON_BREATH); - this.flame.addEffect(new MobEffectInstance(MobEffects.HARM)); + this.flame.setPotionDurationScale(0.25F); + this.flame.addEffect(new MobEffectInstance(MobEffects.INSTANT_DAMAGE)); + if (new com.destroystokyo.paper.event.entity.EnderDragonFlameEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.AreaEffectCloud) this.flame.getBukkitEntity()).callEvent()) { // Paper - EnderDragon Events level.addFreshEntity(this.flame); + // Paper start - EnderDragon Events @@ -14,7 +14,7 @@ } } -@@ -95,7 +_,7 @@ +@@ -96,7 +_,7 @@ @Override public void end() { if (this.flame != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch index 86f2d47cd..ae6a97fb1 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/phases/DragonStrafePlayerPhase.java.patch @@ -5,7 +5,7 @@ DragonFireball dragonFireball = new DragonFireball(level, this.dragon, vec32.normalize()); + dragonFireball.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported - dragonFireball.moveTo(d2, d3, d4, 0.0F, 0.0F); + dragonFireball.snapTo(d2, d3, d4, 0.0F, 0.0F); + if (new com.destroystokyo.paper.event.entity.EnderDragonShootFireballEvent((org.bukkit.entity.EnderDragon) this.dragon.getBukkitEntity(), (org.bukkit.entity.DragonFireball) dragonFireball.getBukkitEntity()).callEvent()) // Paper - EnderDragon Events level.addFreshEntity(dragonFireball); + else dragonFireball.discard(null); // Paper - EnderDragon Events diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index 936e924c0..ca0712d6a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/net/minecraft/world/entity/boss/wither/WitherBoss.java -@@ -69,6 +_,7 @@ +@@ -70,6 +_,7 @@ private final int[] nextHeadUpdate = new int[2]; private final int[] idleHeadUpdates = new int[2]; private int destroyBlocksTick; @@ -8,7 +8,7 @@ public final ServerBossEvent bossEvent = (ServerBossEvent)new ServerBossEvent( this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS ) -@@ -260,15 +_,40 @@ +@@ -261,15 +_,40 @@ int i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - i / 220.0F); if (i <= 0) { @@ -52,7 +52,7 @@ } } else { super.customServerAiStep(level); -@@ -305,6 +_,7 @@ +@@ -306,6 +_,7 @@ ); if (!nearbyEntities.isEmpty()) { LivingEntity livingEntity1 = nearbyEntities.get(this.random.nextInt(nearbyEntities.size())); @@ -60,7 +60,7 @@ this.setAlternativeTarget(ix, livingEntity1.getId()); } } -@@ -334,6 +_,11 @@ +@@ -335,6 +_,11 @@ )) { BlockState blockState = level.getBlockState(blockPos); if (canDestroy(blockState)) { @@ -72,7 +72,7 @@ flag = level.destroyBlock(blockPos, true, this) || flag; } } -@@ -345,7 +_,7 @@ +@@ -346,7 +_,7 @@ } if (this.tickCount % 20 == 0) { @@ -81,7 +81,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -483,16 +_,16 @@ +@@ -484,16 +_,16 @@ @Override protected void dropCustomDeathLoot(ServerLevel level, DamageSource damageSource, boolean recentlyHit) { super.dropCustomDeathLoot(level, damageSource, recentlyHit); @@ -101,7 +101,7 @@ } else { this.noActionTime = 0; } -@@ -547,12 +_,18 @@ +@@ -548,12 +_,18 @@ @Override public boolean canUsePortal(boolean allowPassengers) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch index 36711a918..4e881f2b4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ArmorStand.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java -@@ -86,9 +_,17 @@ +@@ -88,9 +_,17 @@ public Rotations rightArmPose = DEFAULT_RIGHT_ARM_POSE; public Rotations leftLegPose = DEFAULT_LEFT_LEG_POSE; public Rotations rightLegPose = DEFAULT_RIGHT_LEG_POSE; @@ -18,7 +18,7 @@ } public ArmorStand(Level level, double x, double y, double z) { -@@ -100,6 +_,13 @@ +@@ -102,6 +_,13 @@ return createLivingAttributes().add(Attributes.STEP_HEIGHT, 0.0); } @@ -32,32 +32,22 @@ @Override public void refreshDimensions() { double x = this.getX(); -@@ -159,14 +_,22 @@ - - @Override - public void setItemSlot(EquipmentSlot slot, ItemStack stack) { -+ // CraftBukkit start -+ this.setItemSlot(slot, stack, false); -+ } -+ -+ @Override -+ public void setItemSlot(net.minecraft.world.entity.EquipmentSlot slot, ItemStack stack, boolean silent) { -+ // CraftBukkit end - this.verifyEquippedItem(stack); - switch (slot.getType()) { - case HAND: -- this.onEquipItem(slot, this.handItems.set(slot.getIndex(), stack), stack); -+ this.onEquipItem(slot, this.handItems.set(slot.getIndex(), stack), stack, silent); // CraftBukkit - break; - case HUMANOID_ARMOR: -- this.onEquipItem(slot, this.armorItems.set(slot.getIndex(), stack), stack); -+ this.onEquipItem(slot, this.armorItems.set(slot.getIndex(), stack), stack, silent); // CraftBukkit - } -+ this.noTickEquipmentDirty = true; // Paper - Allow ArmorStands not to tick; Still update equipment +@@ -137,6 +_,14 @@ + return slot != EquipmentSlot.BODY && slot != EquipmentSlot.SADDLE && !this.isDisabled(slot); } ++ // Paper - Allow ArmorStands not to tick; Still update equipment ++ @Override ++ public void setItemSlot(net.minecraft.world.entity.EquipmentSlot slot, ItemStack stack, boolean silent) { ++ super.setItemSlot(slot, stack, silent); ++ this.noTickEquipmentDirty = true; ++ } ++ // Paper - Allow ArmorStands not to tick; Still update equipment ++ @Override -@@ -196,6 +_,7 @@ + public void addAdditionalSaveData(CompoundTag compound) { + super.addAdditionalSaveData(compound); +@@ -150,6 +_,7 @@ } compound.put("Pose", this.writePose()); @@ -65,20 +55,20 @@ } @Override -@@ -226,6 +_,12 @@ - this.setNoBasePlate(compound.getBoolean("NoBasePlate")); - this.setMarker(compound.getBoolean("Marker")); +@@ -163,6 +_,12 @@ + this.setMarker(compound.getBooleanOr("Marker", false)); this.noPhysics = !this.hasPhysics(); + this.readPose(compound.getCompoundOrEmpty("Pose")); + // Paper start - Allow ArmorStands not to tick -+ if (compound.contains("Paper.CanTickOverride")) { -+ this.canTick = compound.getBoolean("Paper.CanTickOverride"); ++ compound.getBoolean("Paper.CanTickOverride").ifPresent(canTick -> { ++ this.canTick = canTick; + this.canTickSetByAPI = true; -+ } ++ }); + // Paper end - Allow ArmorStands not to tick - CompoundTag compound2 = compound.getCompound("Pose"); - this.readPose(compound2); } -@@ -275,7 +_,7 @@ + + private void readPose(CompoundTag compound) { +@@ -204,7 +_,7 @@ } @Override @@ -87,7 +77,7 @@ return false; } -@@ -285,6 +_,7 @@ +@@ -214,6 +_,7 @@ @Override protected void pushEntities() { @@ -95,7 +85,7 @@ for (Entity entity : this.level().getEntities(this, this.getBoundingBox(), RIDABLE_MINECARTS)) { if (this.distanceToSqr(entity) <= 0.2) { entity.push(this); -@@ -357,7 +_,25 @@ +@@ -286,7 +_,25 @@ return false; } else if (itemBySlot.isEmpty() && (this.disabledSlots & 1 << slot.getFilterBit(16)) != 0) { return false; @@ -122,7 +112,7 @@ this.setItemSlot(slot, stack.copyWithCount(1)); return true; } else if (stack.isEmpty() || stack.getCount() <= 1) { -@@ -370,6 +_,7 @@ +@@ -299,6 +_,7 @@ this.setItemSlot(slot, stack.split(1)); return true; } @@ -130,7 +120,7 @@ } @Override -@@ -379,15 +_,32 @@ +@@ -308,15 +_,32 @@ } else if (!level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damageSource.getEntity() instanceof Mob) { return false; } else if (damageSource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) { @@ -167,7 +157,7 @@ if (this.isOnFire()) { this.causeDamage(level, damageSource, 0.15F); } else { -@@ -396,9 +_,19 @@ +@@ -325,9 +_,19 @@ return false; } else if (damageSource.is(DamageTypeTags.BURNS_ARMOR_STANDS) && this.getHealth() > 0.5F) { @@ -187,7 +177,7 @@ boolean isCanBreakArmorStand = damageSource.is(DamageTypeTags.CAN_BREAK_ARMOR_STAND); boolean isAlwaysKillsArmorStands = damageSource.is(DamageTypeTags.ALWAYS_KILLS_ARMOR_STANDS); if (!isCanBreakArmorStand && !isAlwaysKillsArmorStands) { -@@ -408,7 +_,7 @@ +@@ -337,7 +_,7 @@ } else if (damageSource.isCreativePlayer()) { this.playBrokenSound(); this.showBreakingParticles(); @@ -196,7 +186,7 @@ return true; } else { long gameTime = level.getGameTime(); -@@ -417,9 +_,9 @@ +@@ -346,9 +_,9 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE, damageSource.getEntity()); this.lastHit = gameTime; } else { @@ -208,10 +198,11 @@ } return true; -@@ -472,28 +_,31 @@ +@@ -400,31 +_,34 @@ + float health = this.getHealth(); health -= damageAmount; if (health <= 0.5F) { - this.brokenByAnything(level, damageSource); +- this.brokenByAnything(level, damageSource); - this.kill(level); + // Paper start - avoid duplicate event call + org.bukkit.event.entity.EntityDeathEvent event = this.brokenByAnything(level, damageSource); @@ -239,28 +230,18 @@ - this.dropAllDeathLoot(level, damageSource); + // this.dropAllDeathLoot(level, damageSource); // CraftBukkit - moved down - for (int i = 0; i < this.handItems.size(); i++) { - ItemStack itemStack = this.handItems.get(i); + for (EquipmentSlot equipmentSlot : EquipmentSlot.VALUES) { + ItemStack itemStack = this.equipment.set(equipmentSlot, ItemStack.EMPTY); if (!itemStack.isEmpty()) { - Block.popResource(this.level(), this.blockPosition().above(), itemStack); -+ this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly - this.handItems.set(i, ItemStack.EMPTY); - } - } -@@ -501,10 +_,11 @@ - for (int ix = 0; ix < this.armorItems.size(); ix++) { - ItemStack itemStack = this.armorItems.get(ix); - if (!itemStack.isEmpty()) { -- Block.popResource(this.level(), this.blockPosition().above(), itemStack); -+ this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly - this.armorItems.set(ix, ItemStack.EMPTY); ++ this.drops.add(new DefaultDrop(itemStack, stack -> Block.popResource(this.level(), this.blockPosition().above(), stack))); // CraftBukkit - add to drops // Paper - Restore vanilla drops behavior; mirror so we can destroy it later - though this call site was safe & spawn drops correctly} } } + return this.dropAllDeathLoot(level, damageSource); // CraftBukkit - moved from above // Paper } private void playBrokenSound() { -@@ -539,7 +_,28 @@ +@@ -458,7 +_,28 @@ @Override public void tick() { @@ -273,7 +254,7 @@ + + if (this.noTickEquipmentDirty) { + this.noTickEquipmentDirty = false; -+ this.detectEquipmentUpdatesPublic(); ++ this.detectEquipmentUpdates(); + } + + return; @@ -289,14 +270,14 @@ Rotations rotations = this.entityData.get(DATA_HEAD_POSE); if (!this.headPose.equals(rotations)) { this.setHeadPose(rotations); -@@ -587,9 +_,32 @@ +@@ -506,9 +_,32 @@ return this.isSmall(); } + // CraftBukkit start + @Override + public boolean shouldDropExperience() { -+ return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop ++ return true; // MC-157395, SPIGOT-5193 even small armor stands should drop + } + // CraftBukkit end + @@ -323,7 +304,7 @@ this.gameEvent(GameEvent.ENTITY_DIE); } -@@ -653,31 +_,37 @@ +@@ -572,31 +_,37 @@ public void setHeadPose(Rotations headPose) { this.headPose = headPose; this.entityData.set(DATA_HEAD_POSE, headPose); @@ -361,7 +342,7 @@ } public Rotations getHeadPose() { -@@ -809,4 +_,13 @@ +@@ -728,4 +_,13 @@ public boolean canBeSeenByAnyone() { return !this.isInvisible() && !this.isMarker(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch index f6480c2be..ae6ec12cc 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/ItemFrame.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -49,6 +_,7 @@ - private static final float HEIGHT = 0.75F; +@@ -56,6 +_,7 @@ + private static final boolean DEFAULT_FIXED = false; public float dropChance = 1.0F; - public boolean fixed; + public boolean fixed = false; + public @Nullable MapId cachedMapId; // Paper - Perf: Cache map ids on item frames public ItemFrame(EntityType entityType, Level level) { super(entityType, level); -@@ -88,6 +_,12 @@ +@@ -97,6 +_,12 @@ @Override protected AABB calculateBoundingBox(BlockPos pos, Direction direction) { @@ -21,7 +21,7 @@ float f = 0.46875F; Vec3 vec3 = Vec3.atCenterOf(pos).relative(direction, -0.46875); Direction.Axis axis = direction.getAxis(); -@@ -118,9 +_,9 @@ +@@ -127,9 +_,9 @@ } @Override @@ -33,7 +33,7 @@ } } -@@ -149,6 +_,18 @@ +@@ -158,6 +_,18 @@ if (this.isInvulnerableToBase(damageSource)) { return false; } else if (this.shouldDamageDropItem(damageSource)) { @@ -52,7 +52,7 @@ this.dropItem(level, damageSource.getEntity(), false); this.gameEvent(GameEvent.BLOCK_CHANGE, damageSource.getEntity()); this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F); -@@ -234,6 +_,14 @@ +@@ -243,6 +_,14 @@ return this.getEntityData().get(DATA_ITEM); } @@ -67,7 +67,7 @@ @Nullable public MapId getFramedMapId(ItemStack stack) { return stack.get(DataComponents.MAP_ID); -@@ -248,13 +_,19 @@ +@@ -257,13 +_,19 @@ } public void setItem(ItemStack stack, boolean updateNeighbours) { @@ -88,7 +88,7 @@ this.playSound(this.getAddItemSound(), 1.0F, 1.0F); } -@@ -280,6 +_,7 @@ +@@ -289,6 +_,7 @@ } private void onItemChanged(ItemStack item) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch index 97a17e6cd..5c59868f0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/Painting.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/decoration/Painting.java +++ b/net/minecraft/world/entity/decoration/Painting.java -@@ -129,21 +_,31 @@ +@@ -146,21 +_,31 @@ @Override protected AABB calculateBoundingBox(BlockPos pos, Direction direction) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 96b38cb9d..408a05cd3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -1,18 +1,6 @@ --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -49,6 +_,11 @@ - import net.minecraft.world.phys.Vec3; - import org.slf4j.Logger; - -+// CraftBukkit start -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityRemoveEvent; -+// CraftBukkit end -+ - public class FallingBlockEntity extends Entity { - private static final Logger LOGGER = LogUtils.getLogger(); - public BlockState blockState = Blocks.SAND.defaultBlockState(); -@@ -62,6 +_,7 @@ +@@ -69,6 +_,7 @@ public CompoundTag blockData; public boolean forceTickAfterTeleportToDuplicate; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); @@ -20,20 +8,20 @@ public FallingBlockEntity(EntityType entityType, Level level) { super(entityType, level); -@@ -89,6 +_,7 @@ - ? blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(false)) - : blockState +@@ -94,6 +_,7 @@ + pos.getZ() + 0.5, + blockState.hasProperty(BlockStateProperties.WATERLOGGED) ? blockState.setValue(BlockStateProperties.WATERLOGGED, false) : blockState ); -+ if (!CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(fallingBlockEntity, pos, blockState.getFluidState().createLegacyBlock())) return fallingBlockEntity; // CraftBukkit level.setBlock(pos, blockState.getFluidState().createLegacyBlock(), 3); level.addFreshEntity(fallingBlockEntity); return fallingBlockEntity; -@@ -139,13 +_,22 @@ +@@ -144,13 +_,22 @@ @Override public void tick() { if (this.blockState.isAir()) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { Block block = this.blockState.getBlock(); this.time++; @@ -45,14 +33,14 @@ + if (this.dropItem && this.level() instanceof final ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + this.spawnAtLocation(serverLevel, block); + } -+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.OUT_OF_WORLD); + return; + } + // Paper end - Configurable falling blocks height nerf this.handlePortal(); if (this.level() instanceof ServerLevel serverLevel && (this.isAlive() || this.forceTickAfterTeleportToDuplicate)) { BlockPos blockPos = this.blockPosition(); -@@ -166,12 +_,12 @@ +@@ -171,12 +_,12 @@ } if (!this.onGround() && !flag1) { @@ -63,17 +51,17 @@ } - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause } } else { BlockState blockState = this.level().getBlockState(blockPos); -@@ -189,12 +_,18 @@ - this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, Boolean.valueOf(true)); +@@ -194,12 +_,18 @@ + this.blockState = this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } + // CraftBukkit start -+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockPos, this.blockState)) { -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockPos, this.blockState)) { ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions + return; + } + // CraftBukkit end @@ -83,22 +71,22 @@ .chunkMap .broadcast(this, new ClientboundBlockUpdatePacket(blockPos, this.level().getBlockState(blockPos))); - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause if (block instanceof Fallable) { ((Fallable)block).onLand(this.level(), blockPos, this.blockState, blockState, this); } -@@ -218,19 +_,19 @@ +@@ -220,19 +_,19 @@ } } } else if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause this.callOnBrokenAfterFall(block, blockPos); this.spawnAtLocation(serverLevel, block); } } else { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause if (this.dropItem && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { this.callOnBrokenAfterFall(block, blockPos); this.spawnAtLocation(serverLevel, block); @@ -106,11 +94,11 @@ } } else { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause this.callOnBrokenAfterFall(block, blockPos); } } -@@ -290,6 +_,7 @@ +@@ -293,6 +_,7 @@ } compound.putBoolean("CancelDrop", this.cancelDrop); @@ -118,29 +106,18 @@ } @Override -@@ -308,7 +_,7 @@ - this.dropItem = compound.getBoolean("DropItem"); - } - -- if (compound.contains("TileEntityData", 10)) { -+ if (compound.contains("TileEntityData", 10) && !(this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock)) { // Paper - Filter bad block entity nbt data from falling blocks - this.blockData = compound.getCompound("TileEntityData").copy(); - } - -@@ -316,6 +_,12 @@ - if (this.blockState.isAir()) { - this.blockState = Blocks.SAND.defaultBlockState(); - } -+ -+ // Paper start - Expand FallingBlock API -+ if (compound.contains("Paper.AutoExpire")) { -+ this.autoExpire = compound.getBoolean("Paper.AutoExpire"); -+ } -+ // Paper end - Expand FallingBlock API +@@ -305,8 +_,9 @@ + this.fallDamagePerDistance = compound.getFloatOr("FallHurtAmount", 0.0F); + this.fallDamageMax = compound.getIntOr("FallHurtMax", 40); + this.dropItem = compound.getBooleanOr("DropItem", true); +- this.blockData = compound.getCompound("TileEntityData").map(CompoundTag::copy).orElse(null); ++ this.blockData = compound.getCompound("TileEntityData").map(blockData -> this.level().paperConfig().entities.spawning.filterBadTileEntityNbtFromFallingBlocks && this.blockState.getBlock() instanceof net.minecraft.world.level.block.GameMasterBlock ? null : blockData).map(CompoundTag::copy).orElse(null); // Paper - Filter bad block entity nbt data from falling blocks + this.cancelDrop = compound.getBooleanOr("CancelDrop", false); ++ this.autoExpire = compound.getBooleanOr("Paper.AutoExpire", true); // Paper - Expand FallingBlock API } public void setHurtsEntities(float fallDamagePerDistance, int fallDamageMax) { -@@ -372,7 +_,7 @@ +@@ -363,7 +_,7 @@ ResourceKey resourceKey1 = this.level().dimension(); boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey; Entity entity = super.teleport(teleportTransition); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index 22c2ed163..6f1d0c32b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -49,6 +_,9 @@ +@@ -56,6 +_,9 @@ @Nullable public UUID target; public final float bobOffs; @@ -10,7 +10,7 @@ public ItemEntity(EntityType entityType, Level level) { super(entityType, level); -@@ -57,7 +_,12 @@ +@@ -64,7 +_,12 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack itemStack) { @@ -24,7 +24,7 @@ } public ItemEntity(Level level, double posX, double posY, double posZ, ItemStack itemStack, double deltaX, double deltaY, double deltaZ) { -@@ -119,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override public void tick() { if (this.getItem().isEmpty()) { @@ -33,7 +33,7 @@ } else { super.tick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { -@@ -147,11 +_,15 @@ +@@ -154,11 +_,15 @@ } } @@ -44,14 +44,14 @@ float f = 0.98F; - if (this.onGround()) { + // Paper start - Friction API -+ if (frictionState == net.kyori.adventure.util.TriState.FALSE) { ++ if (this.frictionState == net.kyori.adventure.util.TriState.FALSE) { + f = 1F; + } else if (this.onGround()) { + // Paper end - Friction API f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -184,8 +_,14 @@ +@@ -191,8 +_,14 @@ } } @@ -68,7 +68,7 @@ } } } -@@ -210,9 +_,18 @@ +@@ -217,9 +_,18 @@ private void mergeWithNeighbours() { if (this.isMergable()) { @@ -88,7 +88,7 @@ this.tryToMerge(itemEntity); if (this.isRemoved()) { break; -@@ -224,14 +_,14 @@ +@@ -231,7 +_,7 @@ private boolean isMergable() { ItemStack item = this.getItem(); @@ -97,15 +97,7 @@ } private void tryToMerge(ItemEntity itemEntity) { - ItemStack item = this.getItem(); - ItemStack item1 = itemEntity.getItem(); - if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) { -- if (item1.getCount() < item.getCount()) { -+ if (true || item1.getCount() < item.getCount()) { // Spigot - merge(this, item, itemEntity, item1); - } else { - merge(itemEntity, item1, this, item); -@@ -257,11 +_,16 @@ +@@ -264,11 +_,16 @@ } private static void merge(ItemEntity destinationEntity, ItemStack destinationStack, ItemEntity originEntity, ItemStack originStack) { @@ -123,7 +115,7 @@ } } -@@ -289,12 +_,17 @@ +@@ -296,12 +_,17 @@ } else if (!this.getItem().canBeHurtBy(damageSource)) { return false; } else { @@ -142,9 +134,9 @@ } return true; -@@ -322,6 +_,11 @@ - if (!this.getItem().isEmpty()) { - compound.put("Item", this.getItem().save(this.registryAccess())); +@@ -324,6 +_,11 @@ + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + compound.store("Item", ItemStack.CODEC, registryOps, this.getItem()); } + // Paper start - Friction API + if (this.frictionState != net.kyori.adventure.util.TriState.NOT_SET) { @@ -154,28 +146,28 @@ } @Override -@@ -347,9 +_,19 @@ - } else { - this.setItem(ItemStack.EMPTY); - } +@@ -336,8 +_,19 @@ + this.cachedThrower = null; + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + this.setItem(compound.read("Item", ItemStack.CODEC, registryOps).orElse(ItemStack.EMPTY)); ++ + // Paper start - Friction API -+ if (compound.contains("Paper.FrictionState")) { -+ String fs = compound.getString("Paper.FrictionState"); ++ compound.getString("Paper.FrictionState").ifPresent(frictionState -> { + try { -+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs); ++ this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState); + } catch (Exception ignored) { -+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", fs, this); ++ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", frictionState, this); + } -+ } ++ }); + // Paper end - Friction API - ++ if (this.getItem().isEmpty()) { - this.discard(); + this.discard(null); // CraftBukkit - add Bukkit remove cause } } -@@ -359,10 +_,73 @@ +@@ -347,10 +_,73 @@ ItemStack item = this.getItem(); Item item1 = item.getItem(); int count = item.getCount(); @@ -250,7 +242,7 @@ item.setCount(count); } -@@ -400,6 +_,7 @@ +@@ -388,6 +_,7 @@ public void setItem(ItemStack stack) { this.getEntityData().set(DATA_ITEM, stack); @@ -258,7 +250,7 @@ } @Override -@@ -453,7 +_,7 @@ +@@ -441,7 +_,7 @@ public void makeFakeItem() { this.setNeverPickUp(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch index 45ed0bc03..2908b32d6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/PrimedTnt.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java -@@ -27,6 +_,12 @@ +@@ -29,6 +_,12 @@ import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.portal.TeleportTransition; @@ -13,15 +13,15 @@ public class PrimedTnt extends Entity implements TraceableEntity { private static final EntityDataAccessor DATA_FUSE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_BLOCK_STATE_ID = SynchedEntityData.defineId(PrimedTnt.class, EntityDataSerializers.BLOCK_STATE); -@@ -50,6 +_,7 @@ +@@ -53,6 +_,7 @@ public LivingEntity owner; private boolean usedPortal; public float explosionPower = 4.0F; -+ public boolean isIncendiary = false; // CraftBukkit - add field ++ public boolean isIncendiary = false; // CraftBukkit public PrimedTnt(EntityType entityType, Level level) { super(entityType, level); -@@ -59,7 +_,7 @@ +@@ -62,7 +_,7 @@ public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { this(EntityType.TNT, level); this.setPos(x, y, z); @@ -30,7 +30,7 @@ this.setDeltaMovement(-Math.sin(d) * 0.02, 0.2F, -Math.cos(d) * 0.02); this.setFuse(80); this.xo = x; -@@ -91,10 +_,17 @@ +@@ -94,10 +_,17 @@ @Override public void tick() { @@ -48,7 +48,7 @@ this.setDeltaMovement(this.getDeltaMovement().scale(0.98)); if (this.onGround()) { this.setDeltaMovement(this.getDeltaMovement().multiply(0.7, -0.5, 0.7)); -@@ -103,19 +_,49 @@ +@@ -106,20 +_,50 @@ int i = this.getFuse() - 1; this.setFuse(i); if (i <= 0) { @@ -90,27 +90,28 @@ } private void explode() { -+ // CraftBukkit start -+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ if (event.isCancelled()) { -+ return; -+ } -+ // CraftBukkit end - this.level() - .explode( - this, -@@ -124,8 +_,8 @@ - this.getX(), - this.getY(0.0625), - this.getZ(), -- this.explosionPower, -- false, -+ event.getRadius(), // CraftBukkit -+ event.getFire(), // CraftBukkit - Level.ExplosionInteraction.TNT - ); - } -@@ -200,4 +_,11 @@ + if (this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { ++ // CraftBukkit start ++ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); ++ if (event.isCancelled()) { ++ return; ++ } ++ // CraftBukkit end + this.level() + .explode( + this, +@@ -128,8 +_,8 @@ + this.getX(), + this.getY(0.0625), + this.getZ(), +- this.explosionPower, +- false, ++ event.getRadius(), // CraftBukkit ++ event.getFire(), // CraftBukkit + Level.ExplosionInteraction.TNT + ); + } +@@ -202,4 +_,11 @@ public final boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 50e3f4e66..685060419 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -48,7 +48,7 @@ double squareRoot = Math.sqrt(d * d + d2 * d2); if (this.level() instanceof ServerLevel serverLevel) { + // CraftBukkit start -+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), arrow.getPickupItem(), arrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper - improve entity shhot bow event - add arrow stack to event ++ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), arrow.getPickupItem(), arrow, net.minecraft.world.InteractionHand.MAIN_HAND, 0.8F, true); // Paper - improve entity shoot bow event, add arrow stack to event + if (event.isCancelled()) { + event.getProjectile().remove(); + return; @@ -63,17 +63,18 @@ } this.playSound(SoundEvents.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F)); -@@ -222,11 +_,23 @@ +@@ -222,11 +_,22 @@ public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); this.reassessWeaponGoal(); - } -+ // Paper start - shouldBurnInDay API -+ if (compound.contains("Paper.ShouldBurnInDay")) { -+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay"); -+ } -+ // Paper end - shouldBurnInDay API +- +- @Override +- public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem) { +- super.onEquipItem(slot, oldItem, newItem); ++ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - shouldBurnInDay API + } ++ + // Paper start - shouldBurnInDay API + @Override + public void addAdditionalSaveData(final net.minecraft.nbt.CompoundTag nbt) { @@ -81,12 +82,12 @@ + nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); + } + // Paper end - shouldBurnInDay API - - @Override -- public void setItemSlot(EquipmentSlot slot, ItemStack stack) { -- super.setItemSlot(slot, stack); -+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { // Paper - Fix silent equipment change -+ super.setItemSlot(slot, stack, silent); // Paper - Fix silent equipment change ++ ++ // Paper start - silent equipping ++ @Override ++ public void onEquipItem(EquipmentSlot slot, ItemStack oldItem, ItemStack newItem, boolean silent) { ++ super.onEquipItem(slot, oldItem, newItem, silent); ++ // Paper end - silent equipping if (!this.level().isClientSide) { this.reassessWeaponGoal(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch index 63ee02e6c..860b3734c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Bogged.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Bogged.java +++ b/net/minecraft/world/entity/monster/Bogged.java -@@ -72,7 +_,19 @@ +@@ -73,7 +_,19 @@ ItemStack itemInHand = player.getItemInHand(hand); if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) { if (this.level() instanceof ServerLevel serverLevel) { @@ -21,11 +21,11 @@ this.gameEvent(GameEvent.SHEAR, player); itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); } -@@ -125,15 +_,33 @@ +@@ -126,15 +_,33 @@ @Override public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) { -+ // Paper start - custom shear drops ++ // Paper start - custom shear drops + this.shear(level, soundSource, shears, this.generateDefaultDrops(level, shears)); + } + @@ -40,7 +40,7 @@ + + @Override + public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears, java.util.List drops) { -+ // Paper end - custom shear drops ++ // Paper end - custom shear drops level.playSound(null, this, SoundEvents.BOGGED_SHEAR, soundSource, 1.0F, 1.0F); - this.spawnShearedMushrooms(level, shears); + this.spawnShearedMushrooms(level, shears, drops); // Paper - custom shear drops diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch index 6a3c83769..752d2aaf6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Creeper.java.patch @@ -1,23 +1,37 @@ --- a/net/minecraft/world/entity/monster/Creeper.java +++ b/net/minecraft/world/entity/monster/Creeper.java -@@ -49,6 +_,7 @@ +@@ -53,6 +_,7 @@ public int maxSwell = 30; public int explosionRadius = 3; private int droppedSkulls; -+ public Entity entityIgniter; // CraftBukkit ++ public @Nullable Entity entityIgniter; // CraftBukkit public Creeper(EntityType entityType, Level level) { super(entityType, level); -@@ -121,7 +_,7 @@ - } - - if (compound.getBoolean("ignited")) { +@@ -116,7 +_,7 @@ + this.maxSwell = compound.getShortOr("Fuse", (short)30); + this.explosionRadius = compound.getByteOr("ExplosionRadius", (byte)3); + if (compound.getBooleanOr("ignited", false)) { - this.ignite(); + this.entityData.set(DATA_IS_IGNITED, true); // Paper - set directly to avoid firing event } } -@@ -204,8 +_,19 @@ +@@ -149,10 +_,11 @@ + } + + @Override +- public void setTarget(@Nullable LivingEntity target) { ++ public boolean setTarget(@Nullable LivingEntity target, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit + if (!(target instanceof Goat)) { +- super.setTarget(target); ++ return super.setTarget(target, reason); // CraftBukkit + } ++ return false; // CraftBukkit + } + + @Override +@@ -199,9 +_,20 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { super.thunderHit(level, lightning); @@ -28,16 +42,17 @@ + // CraftBukkit end this.entityData.set(DATA_IS_POWERED, true); } + + // CraftBukkit start + public void setPowered(boolean powered) { -+ this.entityData.set(Creeper.DATA_IS_POWERED, powered); ++ this.entityData.set(DATA_IS_POWERED, powered); + } + // CraftBukkit end + - @Override protected InteractionResult mobInteract(Player player, InteractionHand hand) { -@@ -215,8 +_,9 @@ + ItemStack itemInHand = player.getItemInHand(hand); +@@ -210,8 +_,9 @@ this.level() .playSound(player, this.getX(), this.getY(), this.getZ(), soundEvent, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F); if (!this.level().isClientSide) { @@ -48,7 +63,7 @@ itemInHand.shrink(1); } else { itemInHand.hurtAndBreak(1, player, getSlotForHand(hand)); -@@ -232,18 +_,29 @@ +@@ -227,18 +_,29 @@ public void explodeCreeper() { if (this.level() instanceof ServerLevel serverLevel) { float f = this.isPowered() ? 2.0F : 1.0F; @@ -81,7 +96,7 @@ areaEffectCloud.setRadius(2.5F); areaEffectCloud.setRadiusOnUse(-0.5F); areaEffectCloud.setWaitTime(10); -@@ -254,16 +_,27 @@ +@@ -250,16 +_,27 @@ areaEffectCloud.addEffect(new MobEffectInstance(mobEffectInstance)); } @@ -92,7 +107,7 @@ + } + } + -+ // Paper start - CreeperIgniteEvent ++ // Paper start - Call CreeperIgniteEvent + public void setIgnited(boolean ignited) { + if (isIgnited() != ignited) { + com.destroystokyo.paper.event.entity.CreeperIgniteEvent event = new com.destroystokyo.paper.event.entity.CreeperIgniteEvent((org.bukkit.entity.Creeper) getBukkitEntity(), ignited); @@ -101,7 +116,7 @@ + } + } + } -+ // Paper end - CreeperIgniteEvent ++ // Paper end - Call CreeperIgniteEvent public boolean isIgnited() { return this.entityData.get(DATA_IS_IGNITED); @@ -109,7 +124,7 @@ public void ignite() { - this.entityData.set(DATA_IS_IGNITED, true); -+ setIgnited(true); // Paper - CreeperIgniteEvent ++ setIgnited(true); // Paper - Call CreeperIgniteEvent } public boolean canDropMobsSkull() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch index c15aa5deb..c3d2fb477 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ElderGuardian.java.patch @@ -3,7 +3,7 @@ @@ -65,7 +_,7 @@ super.customServerAiStep(level); if ((this.tickCount + this.getId()) % 1200 == 0) { - MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DIG_SLOWDOWN, 6000, 2); + MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.MINING_FATIGUE, 6000, 2); - List list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200); + List list = MobEffectUtil.addEffectToPlayersAround(level, this, this.position(), 50.0, mobEffectInstance, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK, (player) -> new io.papermc.paper.event.entity.ElderGuardianAppearanceEvent((org.bukkit.entity.ElderGuardian) this.getBukkitEntity(), player.getBukkitEntity()).callEvent()); // CraftBukkit // Paper - Add ElderGuardianAppearanceEvent list.forEach( diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index d68e68e4c..9b52c7669 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -1,23 +1,21 @@ --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -117,7 +_,23 @@ +@@ -116,9 +_,20 @@ + .add(Attributes.STEP_HEIGHT, 1.0); + } - @Override - public void setTarget(@Nullable LivingEntity livingEntity) { -- super.setTarget(livingEntity); -+ // CraftBukkit start - fire event -+ this.setTarget(livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true); -+ } -+ + // Paper start - EndermanEscapeEvent + private boolean tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason reason) { + return new com.destroystokyo.paper.event.entity.EndermanEscapeEvent((org.bukkit.craftbukkit.entity.CraftEnderman) this.getBukkitEntity(), reason).callEvent(); + } + // Paper end - EndermanEscapeEvent + -+ @Override -+ public boolean setTarget(LivingEntity livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { -+ if (!super.setTarget(livingEntity, reason, fireEvent)) { + @Override +- public void setTarget(@Nullable LivingEntity livingEntity) { +- super.setTarget(livingEntity); ++ // CraftBukkit start - fire event ++ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { ++ if (!super.setTarget(livingEntity, reason)) { + return false; + } + livingEntity = this.getTarget(); @@ -25,7 +23,7 @@ AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); if (livingEntity == null) { this.targetChangeTime = 0; -@@ -131,6 +_,7 @@ +@@ -132,6 +_,7 @@ attribute.addTransientModifier(SPEED_MODIFIER_ATTACKING); } } @@ -33,22 +31,23 @@ } @Override -@@ -212,6 +_,14 @@ +@@ -207,6 +_,15 @@ } boolean isBeingStaredBy(Player player) { + // Paper start - EndermanAttackPlayerEvent -+ final boolean shouldAttack = isBeingStaredBy0(player); ++ final boolean shouldAttack = this.isBeingStaredBy0(player); + final com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent event = new com.destroystokyo.paper.event.entity.EndermanAttackPlayerEvent((org.bukkit.entity.Enderman) getBukkitEntity(), (org.bukkit.entity.Player) player.getBukkitEntity()); + event.setCancelled(!shouldAttack); + return event.callEvent(); + } -+ private boolean isBeingStaredBy0(Player player) { ++ ++ boolean isBeingStaredBy0(Player player) { + // Paper end - EndermanAttackPlayerEvent return LivingEntity.PLAYER_NOT_WEARING_DISGUISE_ITEM.test(player) && this.isLookingAtMe(player, 0.025, true, false, new double[]{this.getEyeY()}); } -@@ -251,7 +_,7 @@ +@@ -246,7 +_,7 @@ float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(); if (lightLevelDependentMagicValue > 0.5F && level.canSeeSky(this.blockPosition()) @@ -57,9 +56,9 @@ this.setTarget(null); this.teleport(); } -@@ -372,11 +_,13 @@ +@@ -369,11 +_,13 @@ } else { - boolean flag1 = flag && this.hurtWithCleanWater(level, damageSource, (ThrownPotion)damageSource.getDirectEntity(), amount); + boolean flag = abstractThrownPotion1 != null && this.hurtWithCleanWater(level, damageSource, abstractThrownPotion1, amount); + if (this.tryEscape(com.destroystokyo.paper.event.entity.EndermanEscapeEvent.Reason.INDIRECT)) { // Paper - EndermanEscapeEvent for (int i = 0; i < 64; i++) { @@ -69,9 +68,9 @@ } + } // Paper - EndermanEscapeEvent - return flag1; + return flag; } -@@ -401,6 +_,16 @@ +@@ -398,6 +_,16 @@ this.entityData.set(DATA_STARED_AT, true); } @@ -88,7 +87,7 @@ @Override public boolean requiresCustomPersistence() { return super.requiresCustomPersistence() || this.getCarriedBlock() != null; -@@ -460,16 +_,19 @@ +@@ -457,16 +_,19 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0); int floor2 = Mth.floor(this.enderman.getZ() - 1.0 + random.nextDouble() * 2.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); @@ -109,7 +108,7 @@ } } } -@@ -567,7 +_,7 @@ +@@ -564,7 +_,7 @@ } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player)this.target)) { @@ -118,7 +117,7 @@ this.enderman.teleport(); } -@@ -606,15 +_,18 @@ +@@ -603,15 +_,18 @@ int floor1 = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0); int floor2 = Mth.floor(this.enderman.getZ() - 2.0 + random.nextDouble() * 4.0); BlockPos blockPos = new BlockPos(floor, floor1, floor2); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch index 4677099a1..c7ee828a8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Endermite.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Endermite.java +++ b/net/minecraft/world/entity/monster/Endermite.java -@@ -121,7 +_,7 @@ +@@ -122,7 +_,7 @@ } if (this.life >= 2400) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch index 20e8a59f9..b6a241646 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ghast.java +++ b/net/minecraft/world/entity/monster/Ghast.java -@@ -63,6 +_,12 @@ +@@ -64,6 +_,12 @@ return this.explosionPower; } @@ -13,7 +13,7 @@ @Override protected boolean shouldDespawnInPeaceful() { return true; -@@ -277,6 +_,7 @@ +@@ -276,6 +_,7 @@ } LargeFireball largeFireball = new LargeFireball(level, this.ghast, vec3.normalize(), this.ghast.getExplosionPower()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch index 3b9061d83..8f0a28625 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Phantom.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -47,6 +_,11 @@ - Vec3 moveTargetPoint = Vec3.ZERO; - public BlockPos anchorPoint = BlockPos.ZERO; +@@ -48,6 +_,11 @@ + @Nullable + public BlockPos anchorPoint; Phantom.AttackPhase attackPhase = Phantom.AttackPhase.CIRCLE; + // Paper start + @Nullable @@ -12,7 +12,7 @@ public Phantom(EntityType entityType, Level level) { super(entityType, level); -@@ -141,7 +_,7 @@ +@@ -142,7 +_,7 @@ @Override public void aiStep() { @@ -21,42 +21,35 @@ this.igniteForSeconds(8.0F); } -@@ -165,6 +_,15 @@ - } - - this.setPhantomSize(compound.getInt("Size")); -+ +@@ -163,6 +_,10 @@ + super.readAdditionalSaveData(compound); + this.anchorPoint = compound.read("anchor_pos", BlockPos.CODEC).orElse(null); + this.setPhantomSize(compound.getIntOr("size", 0)); + // Paper start -+ if (compound.hasUUID("Paper.SpawningEntity")) { -+ this.spawningEntity = compound.getUUID("Paper.SpawningEntity"); -+ } -+ if (compound.contains("Paper.ShouldBurnInDay")) { -+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay"); -+ } ++ this.spawningEntity = compound.read("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null); ++ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true); + // Paper end } @Override -@@ -174,6 +_,12 @@ - compound.putInt("AY", this.anchorPoint.getY()); - compound.putInt("AZ", this.anchorPoint.getZ()); - compound.putInt("Size", this.getPhantomSize()); +@@ -170,6 +_,10 @@ + super.addAdditionalSaveData(compound); + compound.storeNullable("anchor_pos", BlockPos.CODEC, this.anchorPoint); + compound.putInt("size", this.getPhantomSize()); + // Paper start -+ if (this.spawningEntity != null) { -+ compound.putUUID("Paper.SpawningEntity", this.spawningEntity); -+ } ++ compound.storeNullable("Paper.SpawningEntity", net.minecraft.core.UUIDUtil.CODEC, this.spawningEntity); + compound.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); + // Paper end } @Override -@@ -247,7 +_,8 @@ +@@ -243,7 +_,8 @@ for (Player player : nearbyPlayers) { if (Phantom.this.canAttack(serverLevel, player, TargetingConditions.DEFAULT)) { - Phantom.this.setTarget(player); + if (!level().paperConfig().entities.behavior.phantomsOnlyAttackInsomniacs || EntitySelector.IS_INSOMNIAC.test(player)) // Paper - Add phantom creative and insomniac controls -+ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason ++ Phantom.this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit - reason return true; } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch index 00100011e..08ac93679 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ravager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Ravager.java +++ b/net/minecraft/world/entity/monster/Ravager.java -@@ -151,12 +_,19 @@ +@@ -154,12 +_,19 @@ BlockState blockState = serverLevel.getBlockState(blockPos); Block block = blockState.getBlock(); if (block instanceof LeavesBlock) { @@ -20,7 +20,7 @@ } } -@@ -257,7 +_,7 @@ +@@ -260,7 +_,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double max = Math.max(d * d + d1 * d1, 0.001); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch index 8bd9da369..ce2d73c67 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Shulker.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Shulker.java +++ b/net/minecraft/world/entity/monster/Shulker.java -@@ -274,7 +_,13 @@ +@@ -277,7 +_,13 @@ @Override public void stopRiding() { @@ -15,7 +15,7 @@ if (this.level().isClientSide) { this.clientOldAttachPosition = this.blockPosition(); } -@@ -387,6 +_,14 @@ +@@ -390,6 +_,14 @@ && this.level().getWorldBorder().isWithinBounds(blockPos1) && this.level().noCollision(this, new AABB(blockPos1).deflate(1.0E-6))) { Direction direction = this.findAttachableSurface(blockPos1); @@ -30,16 +30,16 @@ if (direction != null) { this.unRide(); this.setAttachFace(direction); -@@ -453,7 +_,12 @@ +@@ -454,7 +_,12 @@ if (shulker != null) { shulker.setVariant(this.getVariant()); - shulker.moveTo(vec3); + shulker.snapTo(vec3); - this.level().addFreshEntity(shulker); -+ // Paper start - Shulker duplicate event ++ // Paper start - Call ShulkerDuplicateEvent + if (!new io.papermc.paper.event.entity.ShulkerDuplicateEvent((org.bukkit.entity.Shulker) shulker.getBukkitEntity(), (org.bukkit.entity.Shulker) this.getBukkitEntity()).callEvent()) { + return; + } -+ // Paper end - Shulker duplicate event ++ // Paper end - Call ShulkerDuplicateEvent + this.level().addFreshEntity(shulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch index 49812bbee..15552624c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Skeleton.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Skeleton.java +++ b/net/minecraft/world/entity/monster/Skeleton.java -@@ -89,11 +_,17 @@ +@@ -93,11 +_,17 @@ } protected void doFreezeConversion() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index 07a1abbee..5a707b3b6 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java -@@ -56,6 +_,7 @@ +@@ -57,6 +_,7 @@ public float squish; public float oSquish; - private boolean wasOnGround; + private boolean wasOnGround = false; + private boolean canWander = true; // Paper - Slime pathfinder events public Slime(EntityType entityType, Level level) { super(entityType, level); -@@ -110,6 +_,7 @@ +@@ -111,6 +_,7 @@ super.addAdditionalSaveData(compound); compound.putInt("Size", this.getSize() - 1); compound.putBoolean("wasOnGround", this.wasOnGround); @@ -16,47 +16,37 @@ } @Override -@@ -117,6 +_,11 @@ - this.setSize(compound.getInt("Size") + 1, false); +@@ -118,6 +_,7 @@ + this.setSize(compound.getIntOr("Size", 0) + 1, false); super.readAdditionalSaveData(compound); - this.wasOnGround = compound.getBoolean("wasOnGround"); -+ // Paper start -+ if (compound.contains("Paper.canWander")) { -+ this.canWander = compound.getBoolean("Paper.canWander"); -+ } -+ // Paper end + this.wasOnGround = compound.getBooleanOr("wasOnGround", false); ++ this.canWander = compound.getBooleanOr("Paper.canWander", true); // Paper } public boolean isTiny() { -@@ -197,6 +_,13 @@ +@@ -197,7 +_,7 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { -+ // CraftBukkit end +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause int size = this.getSize(); if (!this.level().isClientSide && size > 1 && this.isDeadOrDying()) { float width = this.getDimensions(this.getPose()).width(); -@@ -204,18 +_,45 @@ +@@ -205,18 +_,43 @@ int i = size / 2; int i1 = 2 + this.random.nextInt(3); PlayerTeam team = this.getTeam(); + // CraftBukkit start + org.bukkit.event.entity.SlimeSplitEvent event = new org.bukkit.event.entity.SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), i1); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled() && event.getCount() > 0) { ++ if (event.callEvent() && event.getCount() > 0) { + i1 = event.getCount(); + } else { + super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause + return; + } -+ java.util.List slimes = new java.util.ArrayList<>(i1); ++ ++ java.util.List slimes = new java.util.ArrayList<>(i1); + // CraftBukkit end for (int i2 = 0; i2 < i1; i2++) { @@ -64,9 +54,8 @@ float f2 = (i2 / 2 - 0.5F) * f; - this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, mob -> { + Slime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, team), EntitySpawnReason.TRIGGERED, (mob) -> { // CraftBukkit -+ mob.aware = this.aware; // Paper - Fix nerfed slime when splitting mob.setSize(i, true); - mob.moveTo(this.getX() + f1, this.getY() + 0.5, this.getZ() + f2, this.random.nextFloat() * 360.0F, 0.0F); + mob.snapTo(this.getX() + f1, this.getY() + 0.5, this.getZ() + f2, this.random.nextFloat() * 360.0F, 0.0F); - }); - } + // CraftBukkit start @@ -78,11 +67,11 @@ + } + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, slimes, org.bukkit.event.entity.EntityTransformEvent.TransformReason.SPLIT).isCancelled()) { -+ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause ++ super.remove(reason, eventCause); // add Bukkit remove cause + return; + } + for (LivingEntity living : slimes) { -+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason ++ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); + } + // CraftBukkit end } @@ -92,29 +81,29 @@ } @Override -@@ -281,9 +_,13 @@ +@@ -282,9 +_,13 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } -+ // Paper start - Replace rules for Height in Swamp Biome ++ // Paper start - Replace rules for Height in Swamp Biomes + final double maxHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.maximum; + final double minHeightSwamp = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.surfaceBiome.minimum; -+ // Paper end ++ // Paper end - Replace rules for Height in Swamp Biomes if (level.getBiome(pos).is(BiomeTags.ALLOWS_SURFACE_SLIME_SPAWNS) - && pos.getY() > 50 - && pos.getY() < 70 -+ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biome -+ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biome ++ && pos.getY() > minHeightSwamp // Paper - Replace rules for Height in Swamp Biomes ++ && pos.getY() < maxHeightSwamp // Paper - Replace rules for Height in Swamp Biomes && random.nextFloat() < 0.5F && random.nextFloat() < level.getMoonBrightness() && level.getMaxLocalRawBrightness(pos) <= random.nextInt(8)) { -@@ -295,8 +_,11 @@ +@@ -296,8 +_,11 @@ } ChunkPos chunkPos = new ChunkPos(pos); - boolean flag = WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel)level).getSeed(), 987234911L).nextInt(10) == 0; - if (random.nextInt(10) == 0 && flag && pos.getY() < 40) { -+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper ++ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Paper + // Paper start - Replace rules for Height in Slime Chunks + final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum; + if (random.nextInt(10) == 0 && flag && pos.getY() < maxHeightSlimeChunk) { @@ -122,7 +111,7 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } -@@ -355,6 +_,16 @@ +@@ -356,6 +_,16 @@ return super.getDefaultDimensions(pose).scale(this.getSize()); } @@ -139,7 +128,7 @@ static class SlimeAttackGoal extends Goal { private final Slime slime; private int growTiredTimer; -@@ -367,7 +_,16 @@ +@@ -368,7 +_,16 @@ @Override public boolean canUse() { LivingEntity target = this.slime.getTarget(); @@ -157,7 +146,7 @@ } @Override -@@ -379,7 +_,16 @@ +@@ -380,7 +_,16 @@ @Override public boolean canContinueToUse() { LivingEntity target = this.slime.getTarget(); @@ -175,7 +164,7 @@ } @Override -@@ -398,6 +_,13 @@ +@@ -399,6 +_,13 @@ slimeMoveControl.setDirection(this.slime.getYRot(), this.slime.isDealsDamage()); } } @@ -189,7 +178,7 @@ } static class SlimeFloatGoal extends Goal { -@@ -411,7 +_,7 @@ +@@ -412,7 +_,7 @@ @Override public boolean canUse() { @@ -198,7 +187,7 @@ } @Override -@@ -441,7 +_,7 @@ +@@ -442,7 +_,7 @@ @Override public boolean canUse() { @@ -207,7 +196,7 @@ } @Override -@@ -519,7 +_,7 @@ +@@ -520,7 +_,7 @@ @Override public boolean canUse() { @@ -216,7 +205,7 @@ && (this.slime.onGround() || this.slime.isInWater() || this.slime.isInLava() || this.slime.hasEffect(MobEffects.LEVITATION)) && this.slime.getMoveControl() instanceof Slime.SlimeMoveControl; } -@@ -529,6 +_,11 @@ +@@ -530,6 +_,11 @@ if (--this.nextRandomizeTime <= 0) { this.nextRandomizeTime = this.adjustedTickDelay(40 + this.slime.getRandom().nextInt(60)); this.chosenDegrees = this.slime.getRandom().nextInt(360); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch index 24fa757b5..37a4f010c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/SpellcasterIllager.java +++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java -@@ -208,6 +_,11 @@ +@@ -209,6 +_,11 @@ public void tick() { this.attackWarmupDelay--; if (this.attackWarmupDelay == 0) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch index 63f135a7c..146c0cc62 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Strider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Strider.java +++ b/net/minecraft/world/entity/monster/Strider.java -@@ -309,7 +_,14 @@ +@@ -295,7 +_,14 @@ || blockStateOnLegacy.is(BlockTags.STRIDER_WARM_BLOCKS) || this.getFluidHeight(FluidTags.LAVA) > 0.0; boolean flag1 = this.getVehicle() instanceof Strider strider && strider.isSuffocating(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch index 415806e46..fe70c2af7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vex.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/entity/monster/Vex.java +++ b/net/minecraft/world/entity/monster/Vex.java -@@ -296,7 +_,7 @@ +@@ -286,7 +_,7 @@ @Override public void start() { - Vex.this.setTarget(Vex.this.owner.getTarget()); -+ Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit ++ Vex.this.setTarget(Vex.this.owner.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET); // CraftBukkit super.start(); } } -@@ -355,7 +_,10 @@ +@@ -345,7 +_,10 @@ for (int i = 0; i < 3; i++) { BlockPos blockPos = boundOrigin.offset(Vex.this.random.nextInt(15) - 7, Vex.this.random.nextInt(11) - 5, Vex.this.random.nextInt(15) - 7); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch index 70543fd76..3d00b8fa8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Vindicator.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/Vindicator.java +++ b/net/minecraft/world/entity/monster/Vindicator.java -@@ -184,7 +_,7 @@ +@@ -183,7 +_,7 @@ static class VindicatorBreakDoorGoal extends BreakDoorGoal { public VindicatorBreakDoorGoal(Mob mob) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch index d7a8e9a59..ce92fe45c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch @@ -11,8 +11,8 @@ + } + // Paper end - WitchConsumePotionEvent if (mainHandItem.is(Items.POTION) && potionContents != null) { -- potionContents.forEachEffect(this::addEffect); -+ potionContents.forEachEffect((effect) -> this.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK)); // CraftBukkit +- potionContents.forEachEffect(this::addEffect, mainHandItem.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F)); ++ potionContents.forEachEffect(effect -> this.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK), mainHandItem.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F)); // CraftBukkit } this.gameEvent(GameEvent.DRINK); @@ -79,6 +79,6 @@ + } + itemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getPotion()); + // Paper end - WitchThrowPotionEven - Projectile.spawnProjectileUsingShoot(ThrownPotion::new, serverLevel, itemStack, this, d, d1 + squareRoot * 0.2, d2, 0.75F, 8.0F); + Projectile.spawnProjectileUsingShoot(ThrownSplashPotion::new, serverLevel, itemStack, this, d, d1 + squareRoot * 0.2, d2, 0.75F, 8.0F); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 4732375eb..2d2f46e63 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -11,14 +11,14 @@ private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE -@@ -87,13 +_,15 @@ - private static final EntityDimensions BABY_DIMENSIONS = EntityType.ZOMBIE.getDimensions().scale(0.5F).withEyeHeight(0.93F); - private static final float BREAK_DOOR_CHANCE = 0.1F; - public static final Predicate DOOR_BREAKING_PREDICATE = difficulty -> difficulty == Difficulty.HARD; +@@ -91,13 +_,15 @@ + private static final boolean DEFAULT_BABY = false; + private static final boolean DEFAULT_CAN_BREAK_DOORS = false; + private static final int DEFAULT_IN_WATER_TIME = 0; - private final BreakDoorGoal breakDoorGoal = new BreakDoorGoal(this, DOOR_BREAKING_PREDICATE); + private final BreakDoorGoal breakDoorGoal; // Paper - move down - private boolean canBreakDoors; - private int inWaterTime; + private boolean canBreakDoors = false; + private int inWaterTime = 0; public int conversionTime; + private boolean shouldBurnInDay = true; // Paper - Add more Zombie API @@ -28,7 +28,7 @@ } public Zombie(Level level) { -@@ -102,7 +_,7 @@ +@@ -106,7 +_,7 @@ @Override protected void registerGoals() { @@ -37,7 +37,7 @@ this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F)); this.goalSelector.addGoal(8, new RandomLookAroundGoal(this)); this.addBehaviourGoals(); -@@ -114,7 +_,7 @@ +@@ -118,7 +_,7 @@ this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers(ZombifiedPiglin.class)); this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true)); @@ -46,7 +46,7 @@ this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true)); this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Turtle.class, 10, true, false, Turtle.BABY_ON_LAND_SELECTOR)); } -@@ -168,11 +_,16 @@ +@@ -172,11 +_,16 @@ @Override protected int getBaseExperienceReward(ServerLevel level) { @@ -64,7 +64,7 @@ } @Override -@@ -180,9 +_,9 @@ +@@ -184,9 +_,9 @@ this.getEntityData().set(DATA_BABY_ID, childZombie); if (this.level() != null && !this.level().isClientSide) { AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); @@ -76,22 +76,21 @@ } } } -@@ -251,7 +_,14 @@ +@@ -255,6 +_,13 @@ super.aiStep(); } + // Paper start - Add more Zombie API + public void stopDrowning() { + this.conversionTime = -1; -+ this.getEntityData().set(Zombie.DATA_DROWNED_CONVERSION_ID, false); ++ this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); + } + // Paper end - Add more Zombie API ++ public void startUnderWaterConversion(int conversionTime) { -+ // this.lastTick = MinecraftServer.currentTick; // CraftBukkit // Paper - remove anti tick skipping measures / wall tim this.conversionTime = conversionTime; this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, true); - } -@@ -264,31 +_,49 @@ +@@ -268,31 +_,50 @@ } protected void convertToZombieType(EntityType entityType) { @@ -113,15 +112,15 @@ @VisibleForTesting public boolean convertVillagerToZombieVillager(ServerLevel level, Villager villager) { + // CraftBukkit start -+ return Zombie.convertVillagerToZombieVillager(level, villager, this.blockPosition(), this.isSilent(), org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION) != null; ++ return convertVillagerToZombieVillager(level, villager, this.blockPosition(), this.isSilent(), org.bukkit.event.entity.EntityTransformEvent.TransformReason.INFECTION, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.INFECTION) != null; + } + -+ public static ZombieVillager convertVillagerToZombieVillager(ServerLevel level, Villager villager, net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { ++ public static @Nullable ZombieVillager convertVillagerToZombieVillager(ServerLevel level, Villager villager, net.minecraft.core.BlockPos blockPosition, boolean silent, org.bukkit.event.entity.EntityTransformEvent.TransformReason transformReason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason creatureSpawnReason) { + // CraftBukkit end ZombieVillager zombieVillager = villager.convertTo(EntityType.ZOMBIE_VILLAGER, ConversionParams.single(villager, true, true), mob -> { mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, new Zombie.ZombieGroupData(false, true)); mob.setVillagerData(villager.getVillagerData()); - mob.setGossips(villager.getGossips().store(NbtOps.INSTANCE)); + mob.setGossips(villager.getGossips().copy()); mob.setTradeOffers(villager.getOffers().copy()); mob.setVillagerXp(villager.getVillagerXp()); - if (!this.isSilent()) { @@ -142,6 +141,7 @@ - } + return this.shouldBurnInDay; // Paper - Add more Zombie API + } ++ + // Paper start - Add more Zombie API + public void setShouldBurnInDay(boolean shouldBurnInDay) { + this.shouldBurnInDay = shouldBurnInDay; @@ -150,7 +150,7 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { -@@ -321,13 +_,13 @@ +@@ -325,13 +_,13 @@ if (SpawnPlacements.isSpawnPositionOk(type, level, blockPos) && SpawnPlacements.checkSpawnRules(type, level, EntitySpawnReason.REINFORCEMENT, blockPos, level.random)) { zombie.setPos(i1, i2, i3); @@ -160,30 +160,28 @@ && level.noCollision(zombie) && (zombie.canSpawnInLiquids() || !level.containsAnyLiquid(zombie.getBoundingBox()))) { - zombie.setTarget(target); -+ zombie.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit ++ zombie.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET); // CraftBukkit zombie.finalizeSpawn(level, level.getCurrentDifficultyAt(zombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, null); - level.addFreshEntityWithPassengers(zombie); + level.addFreshEntityWithPassengers(zombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit AttributeInstance attribute = this.getAttribute(Attributes.SPAWN_REINFORCEMENTS_CHANCE); AttributeModifier modifier = attribute.getModifier(REINFORCEMENT_CALLER_CHARGE_ID); double d = modifier != null ? modifier.amount() : 0.0; -@@ -352,7 +_,14 @@ +@@ -356,7 +_,12 @@ if (flag) { float effectiveDifficulty = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty(); if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < effectiveDifficulty * 0.3F) { - source.igniteForSeconds(2 * (int)effectiveDifficulty); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustByEntityEvent event = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), source.getBukkitEntity(), (float) (2 * (int)effectiveDifficulty)); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { ++ if (event.callEvent()) { + source.igniteForSeconds(event.getDuration(), false); + } + // CraftBukkit end } } -@@ -412,6 +_,7 @@ +@@ -416,6 +_,7 @@ compound.putBoolean("CanBreakDoors", this.canBreakDoors()); compound.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); compound.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); @@ -191,15 +189,11 @@ } @Override -@@ -423,13 +_,19 @@ - if (compound.contains("DrownedConversionTime", 99) && compound.getInt("DrownedConversionTime") > -1) { - this.startUnderWaterConversion(compound.getInt("DrownedConversionTime")); +@@ -430,13 +_,15 @@ + } else { + this.getEntityData().set(DATA_DROWNED_CONVERSION_ID, false); } -+ // Paper start - Add more Zombie API -+ if (compound.contains("Paper.ShouldBurnInDay")) { -+ this.shouldBurnInDay = compound.getBoolean("Paper.ShouldBurnInDay"); -+ } -+ // Paper end - Add more Zombie API ++ this.shouldBurnInDay = compound.getBooleanOr("Paper.ShouldBurnInDay", true); // Paper - Add more Zombie API } @Override @@ -213,7 +207,7 @@ return flag; } -@@ -465,7 +_,7 @@ +@@ -472,7 +_,7 @@ spawnGroupData = super.finalizeSpawn(level, difficulty, spawnReason, spawnGroupData); float specialMultiplier = difficulty.getSpecialMultiplier(); if (spawnReason != EntitySpawnReason.CONVERSION) { @@ -222,7 +216,7 @@ } if (spawnGroupData == null) { -@@ -492,7 +_,7 @@ +@@ -499,7 +_,7 @@ chicken1.finalizeSpawn(level, difficulty, EntitySpawnReason.JOCKEY, null); chicken1.setChickenJockey(true); this.startRiding(chicken1); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch index 220356954..abef56c21 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -1,78 +1,54 @@ --- a/net/minecraft/world/entity/monster/ZombieVillager.java +++ b/net/minecraft/world/entity/monster/ZombieVillager.java -@@ -33,6 +_,7 @@ - import net.minecraft.world.entity.SlotAccess; - import net.minecraft.world.entity.SpawnGroupData; - import net.minecraft.world.entity.ai.village.ReputationEventType; -+import net.minecraft.world.entity.npc.Villager; - import net.minecraft.world.entity.npc.VillagerData; - import net.minecraft.world.entity.npc.VillagerDataHolder; - import net.minecraft.world.entity.npc.VillagerProfession; -@@ -68,6 +_,7 @@ - @Nullable - private MerchantOffers tradeOffers; - private int villagerXp; -+ private int lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - add field - - public ZombieVillager(EntityType entityType, Level level) { - super(entityType, level); -@@ -147,6 +_,7 @@ - } - - super.tick(); -+ this.lastTick = net.minecraft.server.MinecraftServer.currentTick; // CraftBukkit - } - - @Override -@@ -183,12 +_,20 @@ +@@ -160,12 +_,20 @@ } public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime) { -+ // Paper start - missing entity behaviour api - converting without entity event ++ // Paper start - missing entity behaviour api - converting without entity event + this.startConverting(conversionStarter, villagerConversionTime, true); + } + + public void startConverting(@Nullable UUID conversionStarter, int villagerConversionTime, boolean broadcastEntityEvent) { -+ // Paper end - missing entity behaviour api - converting without entity event ++ // Paper end - missing entity behaviour api - converting without entity event this.conversionStarter = conversionStarter; this.villagerConversionTime = villagerConversionTime; this.getEntityData().set(DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); -- this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0))); +- this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0))); - this.level().broadcastEntityEvent(this, (byte)16); + // CraftBukkit start + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); -+ this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); ++ this.addEffect(new MobEffectInstance(MobEffects.STRENGTH, villagerConversionTime, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end + if (broadcastEntityEvent) this.level().broadcastEntityEvent(this, (byte)16); // Paper - missing entity behaviour api - converting without entity event } @Override -@@ -213,7 +_,7 @@ +@@ -190,7 +_,7 @@ } - private void finishConversion(ServerLevel serverLevel) { + private void finishConversion(ServerLevel level) { - this.convertTo( + Villager converted = this.convertTo( // CraftBukkit EntityType.VILLAGER, ConversionParams.single(this, false, false), villager -> { -@@ -237,19 +_,24 @@ - villager.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(villager.blockPosition()), EntitySpawnReason.CONVERSION, null); - villager.refreshBrain(serverLevel); +@@ -214,19 +_,24 @@ + villager.finalizeSpawn(level, level.getCurrentDifficultyAt(villager.blockPosition()), EntitySpawnReason.CONVERSION, null); + villager.refreshBrain(level); if (this.conversionStarter != null) { -- Player playerByUuid = serverLevel.getPlayerByUUID(this.conversionStarter); -+ Player playerByUuid = serverLevel.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate +- Player playerByUuid = level.getPlayerByUUID(this.conversionStarter); ++ Player playerByUuid = level.getGlobalPlayerByUUID(this.conversionStarter); // Paper - check global player list where appropriate if (playerByUuid instanceof ServerPlayer) { CriteriaTriggers.CURED_ZOMBIE_VILLAGER.trigger((ServerPlayer)playerByUuid, this, villager); - serverLevel.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager); + level.onReputationEvent(ReputationEventType.ZOMBIE_VILLAGER_CURED, playerByUuid, villager); } } -- villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)); -+ villager.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit +- villager.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)); ++ villager.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit if (!this.isSilent()) { - serverLevel.levelEvent(null, 1027, this.blockPosition(), 0); + level.levelEvent(null, 1027, this.blockPosition(), 0); } - } + // CraftBukkit start diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch index ea135560b..d01e31242 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -4,7 +4,7 @@ private static final int ALERT_RANGE_Y = 10; private static final UniformInt ALERT_INTERVAL = TimeUtil.rangeOfSeconds(4, 6); private int ticksUntilNextAlert; -+ private HurtByTargetGoal pathfinderGoalHurtByTarget; // Paper - fix PigZombieAngerEvent cancellation ++ private HurtByTargetGoal hurtByTargetGoal; // Paper - fix PigZombieAngerEvent cancellation public ZombifiedPiglin(EntityType entityType, Level level) { super(entityType, level); @@ -13,46 +13,43 @@ this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); - this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); -+ this.targetSelector.addGoal(1, this.pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation ++ this.targetSelector.addGoal(1, this.hurtByTargetGoal = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); } -@@ -148,7 +_,7 @@ +@@ -144,7 +_,7 @@ .filter(zombifiedPiglin -> zombifiedPiglin != this) .filter(zombifiedPiglin -> zombifiedPiglin.getTarget() == null) .filter(zombifiedPiglin -> !zombifiedPiglin.isAlliedTo(this.getTarget())) - .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget())); -+ .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true)); // CraftBukkit ++ .forEach(zombifiedPiglin -> zombifiedPiglin.setTarget(this.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY)); // CraftBukkit } private void playAngerSound() { -@@ -156,7 +_,7 @@ +@@ -152,18 +_,27 @@ } @Override - public void setTarget(@Nullable LivingEntity livingEntity) { -+ public boolean setTarget(@Nullable LivingEntity livingEntity, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature ++ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit - signature if (this.getTarget() == null && livingEntity != null) { this.playFirstAngerSoundIn = FIRST_ANGER_SOUND_DELAY.sample(this.random); this.ticksUntilNextAlert = ALERT_INTERVAL.sample(this.random); -@@ -166,12 +_,22 @@ - this.setLastHurtByPlayer((Player)livingEntity); } - super.setTarget(livingEntity); -+ return super.setTarget(livingEntity, reason, fireEvent); // CraftBukkit ++ return super.setTarget(livingEntity, reason); // CraftBukkit } @Override public void startPersistentAngerTimer() { - this.setRemainingPersistentAngerTime(PERSISTENT_ANGER_TIME.sample(this.random)); + // CraftBukkit start -+ net.minecraft.world.entity.Entity entity = ((ServerLevel) this.level()).getEntity(this.getPersistentAngerTarget()); -+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), ZombifiedPiglin.PERSISTENT_ANGER_TIME.sample(this.random)); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ if (event.isCancelled()) { ++ net.minecraft.world.entity.Entity entity = this.level().getEntity(this.getPersistentAngerTarget()); ++ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), PERSISTENT_ANGER_TIME.sample(this.random)); ++ if (!event.callEvent()) { + this.setPersistentAngerTarget(null); -+ this.pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation ++ this.hurtByTargetGoal.stop(); + return; + } + this.setRemainingPersistentAngerTime(event.getNewAnger()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch index 3c8cc3d16..6637f43a8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/creaking/Creaking.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/creaking/Creaking.java +++ b/net/minecraft/world/entity/monster/creaking/Creaking.java -@@ -190,9 +_,9 @@ +@@ -191,9 +_,9 @@ } @Override @@ -12,7 +12,7 @@ } } -@@ -317,7 +_,7 @@ +@@ -318,7 +_,7 @@ } this.makeSound(this.getDeathSound()); @@ -21,7 +21,7 @@ } public void creakingDeathEffects(DamageSource damageSource) { -@@ -480,9 +_,9 @@ +@@ -471,9 +_,9 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch index a7f4ebaae..1f8045297 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/hoglin/Hoglin.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/entity/monster/hoglin/Hoglin.java +++ b/net/minecraft/world/entity/monster/hoglin/Hoglin.java -@@ -262,7 +_,12 @@ +@@ -265,7 +_,12 @@ } private void finishConversion() { -- this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0))); -+ final Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons +- this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0))); ++ final Entity converted = this.convertTo(EntityType.ZOGLIN, ConversionParams.single(this, true, false), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons + // Paper start - Fix issues with mob conversion; reset to prevent event spam + if (converted == null) { + this.timeInOverworld = 0; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch index d17978051..e9702e112 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java +++ b/net/minecraft/world/entity/monster/piglin/AbstractPiglin.java -@@ -99,9 +_,14 @@ +@@ -102,9 +_,14 @@ } protected void finishConversion(ServerLevel serverLevel) { - this.convertTo( -- EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0)) +- EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0)) + net.minecraft.world.entity.Entity converted = this.convertTo( // Paper - Fix issues with mob conversion; reset to prevent event spam -+ EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.CONFUSION, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons ++ EntityType.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), mob -> {mob.addEffect(new MobEffectInstance(MobEffects.NAUSEA, 200, 0));}, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED // CraftBukkit - add spawn and transform reasons ); + // Paper start - Fix issues with mob conversion; reset to prevent event spam + if (converted == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch index 1178c733b..30f18c374 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/Piglin.java.patch @@ -1,69 +1,41 @@ --- a/net/minecraft/world/entity/monster/piglin/Piglin.java +++ b/net/minecraft/world/entity/monster/piglin/Piglin.java -@@ -59,6 +_,25 @@ - import net.minecraft.world.level.ServerLevelAccessor; - import net.minecraft.world.level.block.Blocks; - import net.minecraft.world.level.block.state.BlockState; -+// CraftBukkit start -+import java.util.stream.Collectors; -+import java.util.HashSet; -+import java.util.Set; -+import net.minecraft.core.BlockPos; -+import net.minecraft.core.registries.BuiltInRegistries; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.nbt.ListTag; -+import net.minecraft.nbt.StringTag; -+import net.minecraft.nbt.Tag; -+import net.minecraft.network.syncher.EntityDataAccessor; -+import net.minecraft.network.syncher.EntityDataSerializers; -+import net.minecraft.network.syncher.SynchedEntityData; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.server.level.ServerLevel; -+import net.minecraft.sounds.SoundEvent; -+import net.minecraft.sounds.SoundEvents; -+import net.minecraft.world.item.Item; -+// CraftBukkit end - - public class Piglin extends AbstractPiglin implements CrossbowAttackMob, InventoryCarrier { - private static final EntityDataAccessor DATA_BABY_ID = SynchedEntityData.defineId(Piglin.class, EntityDataSerializers.BOOLEAN); -@@ -122,6 +_,10 @@ +@@ -124,6 +_,12 @@ MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT ); + // CraftBukkit start - Custom bartering and interest list -+ public Set allowedBarterItems = new HashSet<>(); -+ public Set interestItems = new HashSet<>(); ++ public java.util.Set allowedBarterItems = new java.util.HashSet<>(); ++ public java.util.Set interestItems = new java.util.HashSet<>(); ++ private static final com.mojang.serialization.Codec> ITEM_SET_CODEC = net.minecraft.core.registries.BuiltInRegistries.ITEM ++ .byNameCodec().listOf().xmap(java.util.HashSet::new, List::copyOf); + // CraftBukkit end public Piglin(EntityType entityType, Level level) { super(entityType, level); -@@ -140,6 +_,14 @@ - } - +@@ -136,6 +_,10 @@ + compound.putBoolean("IsBaby", this.isBaby()); + compound.putBoolean("CannotHunt", this.cannotHunt); this.writeInventoryToTag(compound, this.registryAccess()); + // CraftBukkit start -+ ListTag barterList = new ListTag(); -+ this.allowedBarterItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(barterList::add); -+ compound.put("Bukkit.BarterList", barterList); -+ ListTag interestList = new ListTag(); -+ this.interestItems.stream().map(BuiltInRegistries.ITEM::getKey).map(ResourceLocation::toString).map(StringTag::valueOf).forEach(interestList::add); -+ compound.put("Bukkit.InterestList", interestList); ++ compound.store("Bukkit.BarterList", ITEM_SET_CODEC, this.allowedBarterItems); ++ compound.store("Bukkit.InterestList", ITEM_SET_CODEC, this.interestItems); + // CraftBukkit end } @Override -@@ -148,6 +_,10 @@ - this.setBaby(compound.getBoolean("IsBaby")); - this.setCannotHunt(compound.getBoolean("CannotHunt")); +@@ -144,6 +_,10 @@ + this.setBaby(compound.getBooleanOr("IsBaby", false)); + this.setCannotHunt(compound.getBooleanOr("CannotHunt", false)); this.readInventoryFromTag(compound, this.registryAccess()); + // CraftBukkit start -+ this.allowedBarterItems = compound.getList("Bukkit.BarterList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); -+ this.interestItems = compound.getList("Bukkit.InterestList", 8).stream().map(Tag::getAsString).map(ResourceLocation::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new)); ++ this.allowedBarterItems = compound.read("Bukkit.BarterList", ITEM_SET_CODEC).orElseGet(java.util.HashSet::new); ++ this.interestItems = compound.read("Bukkit.InterestList", ITEM_SET_CODEC).orElseGet(java.util.HashSet::new); + // CraftBukkit end } @VisibleForDebug -@@ -325,7 +_,9 @@ +@@ -321,7 +_,9 @@ @Override protected void finishConversion(ServerLevel serverLevel) { PiglinAi.cancelAdmiring(serverLevel, this); @@ -73,7 +45,7 @@ super.finishConversion(serverLevel); } -@@ -400,7 +_,7 @@ +@@ -397,7 +_,7 @@ } protected void holdInOffHand(ItemStack stack) { @@ -82,7 +54,7 @@ this.setItemSlot(EquipmentSlot.OFFHAND, stack); this.setGuaranteedDrop(EquipmentSlot.OFFHAND); } else { -@@ -425,15 +_,15 @@ +@@ -422,15 +_,15 @@ return false; } else { TagKey preferredWeaponType = this.getPreferredWeaponType(); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 467622eb8..eb8eb6322 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -1,20 +1,6 @@ --- a/net/minecraft/world/entity/monster/piglin/PiglinAi.java +++ b/net/minecraft/world/entity/monster/piglin/PiglinAi.java -@@ -70,6 +_,13 @@ - import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets; - import net.minecraft.world.level.storage.loot.parameters.LootContextParams; - import net.minecraft.world.phys.Vec3; -+// CraftBukkit start -+import java.util.stream.Collectors; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.craftbukkit.inventory.CraftItemStack; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.PiglinBarterEvent; -+// CraftBukkit end - - public class PiglinAi { - public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8; -@@ -328,23 +_,32 @@ +@@ -330,23 +_,32 @@ protected static void pickUpItem(ServerLevel level, Piglin piglin, ItemEntity itemEntity) { stopWalking(piglin); ItemStack item; @@ -29,7 +15,7 @@ item = itemEntity.getItem(); - itemEntity.discard(); - } else { -+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause ++ itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause + } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, itemEntity, itemEntity.getItem().getCount() - 1, false).isCancelled()) { + piglin.onItemPickup(itemEntity); // Paper - EntityPickupItemEvent fixes; moved from Piglin#pickUpItem - call prior to item entity modification piglin.take(itemEntity, 1); @@ -52,7 +38,7 @@ if (!flag) { putInInventory(piglin, item); } -@@ -353,7 +_,9 @@ +@@ -355,7 +_,9 @@ private static void holdInOffhand(ServerLevel level, Piglin piglin, ItemStack stack) { if (isHoldingItemInOffHand(piglin)) { @@ -62,16 +48,16 @@ } piglin.holdInOffHand(stack); -@@ -363,7 +_,7 @@ +@@ -365,7 +_,7 @@ ItemStack item = itemEntity.getItem(); ItemStack itemStack = item.split(1); if (item.isEmpty()) { - itemEntity.discard(); -+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause ++ itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause } else { itemEntity.setItem(item); } -@@ -375,9 +_,14 @@ +@@ -377,9 +_,14 @@ ItemStack itemInHand = piglin.getItemInHand(InteractionHand.OFF_HAND); piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); if (piglin.isAdult()) { @@ -80,15 +66,15 @@ if (barter && isBarterCurrency) { - throwItems(piglin, getBarterResponseItems(piglin)); + // CraftBukkit start -+ PiglinBarterEvent event = CraftEventFactory.callPiglinBarterEvent(piglin, getBarterResponseItems(piglin), itemInHand); ++ org.bukkit.event.entity.PiglinBarterEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPiglinBarterEvent(piglin, getBarterResponseItems(piglin), itemInHand); + if (!event.isCancelled()) { -+ throwItems(piglin, event.getOutcome().stream().map(CraftItemStack::asNMSCopy).collect(Collectors.toList())); ++ throwItems(piglin, event.getOutcome().stream().map(org.bukkit.craftbukkit.inventory.CraftItemStack::asNMSCopy).collect(java.util.stream.Collectors.toList())); + } + // CraftBukkit end } else if (!isBarterCurrency) { boolean flag = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!flag) { -@@ -388,7 +_,7 @@ +@@ -390,7 +_,7 @@ boolean isBarterCurrency = !piglin.equipItemIfPossible(level, itemInHand).isEmpty(); if (!isBarterCurrency) { ItemStack mainHandItem = piglin.getMainHandItem(); @@ -97,7 +83,7 @@ putInInventory(piglin, mainHandItem); } else { throwItems(piglin, Collections.singletonList(mainHandItem)); -@@ -401,7 +_,9 @@ +@@ -403,7 +_,9 @@ protected static void cancelAdmiring(ServerLevel level, Piglin piglin) { if (isAdmiringItem(piglin) && !piglin.getOffhandItem().isEmpty()) { @@ -107,7 +93,7 @@ piglin.setItemInHand(InteractionHand.OFF_HAND, ItemStack.EMPTY); } } -@@ -457,7 +_,7 @@ +@@ -459,7 +_,7 @@ return false; } else if (isAdmiringDisabled(piglin) && piglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) { return false; @@ -116,7 +102,7 @@ return isNotHoldingLovedItemInOffHand(piglin); } else { boolean canAddToInventory = piglin.canAddToInventory(stack); -@@ -466,11 +_,16 @@ +@@ -468,11 +_,16 @@ } else if (isFood(stack)) { return !hasEatenRecently(piglin) && canAddToInventory; } else { @@ -134,7 +120,7 @@ protected static boolean isLovedItem(ItemStack item) { return item.is(ItemTags.PIGLIN_LOVED); } -@@ -522,6 +_,7 @@ +@@ -524,6 +_,7 @@ } public static void angerNearbyPiglins(ServerLevel level, Player player, boolean requireLineOfSight) { @@ -142,7 +128,7 @@ List entitiesOfClass = player.level().getEntitiesOfClass(Piglin.class, player.getBoundingBox().inflate(16.0)); entitiesOfClass.stream().filter(PiglinAi::isIdle).filter(piglin -> !requireLineOfSight || BehaviorUtils.canSee(piglin, player)).forEach(piglin -> { if (level.getGameRules().getBoolean(GameRules.RULE_UNIVERSAL_ANGER)) { -@@ -546,7 +_,7 @@ +@@ -548,7 +_,7 @@ } protected static boolean canAdmire(Piglin piglin, ItemStack stack) { @@ -151,7 +137,7 @@ } protected static void wasHurtBy(ServerLevel level, Piglin piglin, LivingEntity entity) { -@@ -794,6 +_,11 @@ +@@ -796,6 +_,11 @@ return piglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM); } @@ -163,7 +149,7 @@ private static boolean isBarterCurrency(ItemStack stack) { return stack.is(BARTERING_ITEM); } -@@ -831,7 +_,7 @@ +@@ -833,7 +_,7 @@ } private static boolean isNotHoldingLovedItemInOffHand(Piglin piglin) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch index f6da9a7ec..6818c28f8 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/warden/Warden.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/monster/warden/Warden.java +++ b/net/minecraft/world/entity/monster/warden/Warden.java -@@ -407,7 +_,7 @@ +@@ -404,7 +_,7 @@ public static void applyDarknessAround(ServerLevel level, Vec3 pos, @Nullable Entity source, int radius) { MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.DARKNESS, 260, 0, false, false); @@ -9,7 +9,7 @@ } @Override -@@ -469,6 +_,15 @@ +@@ -450,6 +_,15 @@ @VisibleForTesting public void increaseAngerAt(@Nullable Entity entity, int offset, boolean playListeningSound) { if (!this.isNoAi() && this.canTargetEntity(entity)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 06aabb0b2..144856991 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -1,27 +1,6 @@ --- a/net/minecraft/world/entity/npc/AbstractVillager.java +++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -37,7 +_,20 @@ - import net.minecraft.world.phys.Vec3; - import org.slf4j.Logger; - -+// CraftBukkit start -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.inventory.CraftMerchant; -+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; -+import org.bukkit.event.entity.VillagerAcquireTradeEvent; -+// CraftBukkit end -+ - public abstract class AbstractVillager extends AgeableMob implements InventoryCarrier, Npc, Merchant { -+ // CraftBukkit start -+ @Override -+ public CraftMerchant getCraftMerchant() { -+ return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity(); -+ } -+ // CraftBukkit end - private static final EntityDataAccessor DATA_UNHAPPY_COUNTER = SynchedEntityData.defineId(AbstractVillager.class, EntityDataSerializers.INT); - private static final Logger LOGGER = LogUtils.getLogger(); - public static final int VILLAGER_SLOT_OFFSET = 300; -@@ -46,7 +_,7 @@ +@@ -42,7 +_,7 @@ private Player tradingPlayer; @Nullable protected MerchantOffers offers; @@ -30,10 +9,17 @@ public AbstractVillager(EntityType entityType, Level level) { super(entityType, level); -@@ -99,6 +_,13 @@ +@@ -95,6 +_,20 @@ return this.tradingPlayer != null; } ++ // CraftBukkit start ++ @Override ++ public org.bukkit.craftbukkit.inventory.CraftMerchant getCraftMerchant() { ++ return (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity(); ++ } ++ // CraftBukkit end ++ + // Paper start - Villager#resetOffers + public void resetOffers() { + this.offers = new MerchantOffers(); @@ -44,7 +30,7 @@ @Override public MerchantOffers getOffers() { if (this.level().isClientSide) { -@@ -121,11 +_,24 @@ +@@ -117,11 +_,24 @@ public void overrideXp(int xp) { } @@ -71,20 +57,20 @@ if (this.tradingPlayer instanceof ServerPlayer) { CriteriaTriggers.TRADE.trigger((ServerPlayer)this.tradingPlayer, this, offer.getResult()); } -@@ -236,7 +_,20 @@ +@@ -226,7 +_,20 @@ while (i < maxNumbers && !list.isEmpty()) { MerchantOffer offer = list.remove(this.random.nextInt(list.size())).getOffer(this, this.random); if (offer != null) { - givenMerchantOffers.add(offer); + // CraftBukkit start -+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((org.bukkit.entity.AbstractVillager) this.getBukkitEntity(), offer.asBukkit()); ++ org.bukkit.event.entity.VillagerAcquireTradeEvent event = new org.bukkit.event.entity.VillagerAcquireTradeEvent((org.bukkit.entity.AbstractVillager) this.getBukkitEntity(), offer.asBukkit()); + // Suppress during worldgen + if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); ++ event.callEvent(); + } + if (!event.isCancelled()) { + // Paper start - Fix crash from invalid ingredient list -+ final CraftMerchantRecipe craftMerchantRecipe = CraftMerchantRecipe.fromBukkit(event.getRecipe()); ++ final org.bukkit.craftbukkit.inventory.CraftMerchantRecipe craftMerchantRecipe = org.bukkit.craftbukkit.inventory.CraftMerchantRecipe.fromBukkit(event.getRecipe()); + if (craftMerchantRecipe.getIngredients().isEmpty()) return; + givenMerchantOffers.add(craftMerchantRecipe.toMinecraft()); + // Paper end - Fix crash from invalid ingredient list diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch index 1c1335c6b..8c43eb33b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/CatSpawner.java.patch @@ -1,12 +1,16 @@ --- a/net/minecraft/world/entity/npc/CatSpawner.java +++ b/net/minecraft/world/entity/npc/CatSpawner.java -@@ -82,8 +_,8 @@ - if (cat == null) { - return 0; - } else { -+ cat.moveTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659 - cat.finalizeSpawn(serverLevel, serverLevel.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null); -- cat.moveTo(pos, 0.0F, 0.0F); - serverLevel.addFreshEntityWithPassengers(cat); - return 1; +@@ -68,12 +_,12 @@ + private void spawnCat(BlockPos pos, ServerLevel level, boolean persistent) { + Cat cat = EntityType.CAT.create(level, EntitySpawnReason.NATURAL); + if (cat != null) { ++ cat.snapTo(pos, 0.0F, 0.0F); // Paper - move up - Fix MC-147659 + cat.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.NATURAL, null); + if (persistent) { + cat.setPersistenceRequired(); + } + +- cat.snapTo(pos, 0.0F, 0.0F); + level.addFreshEntityWithPassengers(cat); } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch index 7728954a0..d6e113263 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/InventoryCarrier.java.patch @@ -1,16 +1,5 @@ --- a/net/minecraft/world/entity/npc/InventoryCarrier.java +++ b/net/minecraft/world/entity/npc/InventoryCarrier.java -@@ -8,6 +_,10 @@ - import net.minecraft.world.entity.item.ItemEntity; - import net.minecraft.world.item.ItemStack; - -+// CraftBukkit start -+import org.bukkit.event.entity.EntityRemoveEvent; -+// CraftBukkit end -+ - public interface InventoryCarrier { - String TAG_INVENTORY = "Inventory"; - @@ -22,12 +_,19 @@ return; } @@ -28,7 +17,7 @@ mob.take(itemEntity, count - itemStack.getCount()); if (itemStack.isEmpty()) { - itemEntity.discard(); -+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause ++ itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause } else { item.setCount(itemStack.getCount()); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index a3b4672db..cfe727be2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -1,21 +1,6 @@ --- a/net/minecraft/world/entity/npc/Villager.java +++ b/net/minecraft/world/entity/npc/Villager.java -@@ -90,6 +_,14 @@ - import net.minecraft.world.phys.AABB; - import org.slf4j.Logger; - -+// CraftBukkit start -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.event.CraftEventFactory; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.EntityTransformEvent; -+import org.bukkit.event.entity.VillagerReplenishTradeEvent; -+// CraftBukkit end -+ - public class Villager extends AbstractVillager implements ReputationEventHandler, VillagerDataHolder { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final EntityDataAccessor DATA_VILLAGER_DATA = SynchedEntityData.defineId(Villager.class, EntityDataSerializers.VILLAGER_DATA); -@@ -275,7 +_,7 @@ +@@ -286,7 +_,7 @@ this.increaseProfessionLevelOnUpdate = false; } @@ -24,37 +9,35 @@ } } -@@ -384,7 +_,13 @@ +@@ -395,7 +_,12 @@ this.updateDemand(); for (MerchantOffer merchantOffer : this.getOffers()) { - merchantOffer.resetUses(); + // CraftBukkit start -+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantOffer.asBukkit()); -+ Bukkit.getPluginManager().callEvent(event); -+ if (!event.isCancelled()) { ++ org.bukkit.event.entity.VillagerReplenishTradeEvent event = new org.bukkit.event.entity.VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantOffer.asBukkit()); ++ if (event.callEvent()) { + merchantOffer.resetUses(); + } + // CraftBukkit end } this.resendOffersToTradingPlayer(); -@@ -445,7 +_,13 @@ +@@ -456,7 +_,12 @@ int i = 2 - this.numberOfRestocksToday; if (i > 0) { for (MerchantOffer merchantOffer : this.getOffers()) { - merchantOffer.resetUses(); + // CraftBukkit start -+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantOffer.asBukkit()); -+ Bukkit.getPluginManager().callEvent(event); -+ if (!event.isCancelled()) { ++ org.bukkit.event.entity.VillagerReplenishTradeEvent event = new org.bukkit.event.entity.VillagerReplenishTradeEvent((org.bukkit.entity.Villager) this.getBukkitEntity(), merchantOffer.asBukkit()); ++ if (event.callEvent()) { + merchantOffer.resetUses(); + } + // CraftBukkit end } } -@@ -466,6 +_,7 @@ +@@ -477,6 +_,7 @@ int playerReputation = this.getPlayerReputation(player); if (playerReputation != 0) { for (MerchantOffer merchantOffer : this.getOffers()) { @@ -62,7 +45,7 @@ merchantOffer.addToSpecialPriceDiff(-Mth.floor(playerReputation * merchantOffer.getPriceMultiplier())); } } -@@ -475,6 +_,7 @@ +@@ -486,6 +_,7 @@ int amplifier = effect.getAmplifier(); for (MerchantOffer merchantOffer1 : this.getOffers()) { @@ -88,55 +71,56 @@ Entity entity = cause.getEntity(); if (entity != null) { this.tellWitnessesThatIWasMurdered(entity); -@@ -782,12 +_,19 @@ +@@ -780,12 +_,19 @@ @Override public void thunderHit(ServerLevel level, LightningBolt lightning) { if (level.getDifficulty() != Difficulty.PEACEFUL) { - LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); + // Paper - Add EntityZapEvent; move log down, event can cancel - Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), mob -> { + Witch witch = this.convertTo(EntityType.WITCH, ConversionParams.single(this, false, false), witch1 -> { + // Paper start - Add EntityZapEvent -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, mob).isCancelled()) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityZapEvent(this, lightning, witch1).isCancelled()) { + return false; + } -+ if (org.spigotmc.SpigotConfig.logVillagerDeaths) Villager.LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down ++ if (org.spigotmc.SpigotConfig.logVillagerDeaths) LOGGER.info("Villager {} was struck by lightning {}.", this, lightning); // Move down + // Paper end - Add EntityZapEvent - mob.finalizeSpawn(level, level.getCurrentDifficultyAt(mob.blockPosition()), EntitySpawnReason.CONVERSION, null); - mob.setPersistenceRequired(); + witch1.finalizeSpawn(level, level.getCurrentDifficultyAt(witch1.blockPosition()), EntitySpawnReason.CONVERSION, null); + witch1.setPersistenceRequired(); this.releaseAllPois(); - }); + return true; // Paper start - Add EntityZapEvent -+ }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit ++ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit if (witch == null) { super.thunderHit(level, lightning); } -@@ -827,6 +_,12 @@ +@@ -825,6 +_,12 @@ @Override protected void updateTrades() { + // Paper start - More vanilla friendly methods to update trades -+ updateTrades(TRADES_PER_LEVEL); ++ this.updateTrades(TRADES_PER_LEVEL); + } + + public boolean updateTrades(int amount) { + // Paper end - More vanilla friendly methods to update trades VillagerData villagerData = this.getVillagerData(); - Int2ObjectMap map1; - if (this.level().enabledFeatures().contains(FeatureFlags.TRADE_REBALANCE)) { -@@ -840,9 +_,11 @@ - VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.getLevel()); - if (itemListings != null) { - MerchantOffers offers = this.getOffers(); -- this.addOffersFromItemListings(offers, itemListings, 2); -+ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades -+ return true; // Paper - More vanilla friendly methods to update trades + ResourceKey resourceKey = villagerData.profession().unwrapKey().orElse(null); + if (resourceKey != null) { +@@ -840,10 +_,12 @@ + VillagerTrades.ItemListing[] itemListings = map1.get(villagerData.level()); + if (itemListings != null) { + MerchantOffers offers = this.getOffers(); +- this.addOffersFromItemListings(offers, itemListings, 2); ++ this.addOffersFromItemListings(offers, itemListings, amount); // Paper - More vanilla friendly methods to update trades ++ return true; // Paper - More vanilla friendly methods to update trades + } } } + return false; // Paper - More vanilla friendly methods to update trades } public void gossip(ServerLevel serverLevel, Villager target, long gameTime) { -@@ -871,7 +_,7 @@ +@@ -872,7 +_,7 @@ List entitiesOfClass = serverLevel.getEntitiesOfClass(Villager.class, aabb); List list = entitiesOfClass.stream().filter(villager -> villager.wantsToSpawnGolem(gameTime)).limit(5L).toList(); if (list.size() >= minVillagerAmount) { @@ -145,7 +129,7 @@ EntityType.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, serverLevel, -@@ -880,9 +_,11 @@ +@@ -881,9 +_,11 @@ 8, 6, SpawnUtil.Strategy.LEGACY_IRON_GOLEM, diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch index 9aed42eb7..08fa52754 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/VillagerTrades.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/npc/VillagerTrades.java +++ b/net/minecraft/world/entity/npc/VillagerTrades.java -@@ -1844,7 +_,8 @@ - return null; - } else { - ServerLevel serverLevel = (ServerLevel)trader.level(); +@@ -1747,7 +_,8 @@ + @Override + public MerchantOffer getOffer(Entity trader, RandomSource random) { + if (trader.level() instanceof ServerLevel serverLevel) { - BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, true); + if (!serverLevel.paperConfig().environment.treasureMaps.enabled) return null; // Paper - Configurable cartographer treasure maps + BlockPos blockPos = serverLevel.findNearestMapStructure(this.destination, trader.blockPosition(), 100, !serverLevel.paperConfig().environment.treasureMaps.findAlreadyDiscoveredVillager); // Paper - Configurable cartographer treasure maps diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch index 6c74e0007..bc4d784f7 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTrader.java.patch @@ -1,23 +1,15 @@ --- a/net/minecraft/world/entity/npc/WanderingTrader.java +++ b/net/minecraft/world/entity/npc/WanderingTrader.java -@@ -47,11 +_,23 @@ +@@ -45,11 +_,15 @@ import net.minecraft.world.phys.Vec3; import org.apache.commons.lang3.tuple.Pair; -public class WanderingTrader extends AbstractVillager implements Consumable.OverrideConsumeSound { -+// CraftBukkit start -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; -+import org.bukkit.entity.AbstractVillager; -+import org.bukkit.event.entity.EntityRemoveEvent; -+import org.bukkit.event.entity.VillagerAcquireTradeEvent; -+// CraftBukkit end -+ -+public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVillager implements Consumable.OverrideConsumeSound { - private static final int NUMBER_OF_TRADE_OFFERS = 5; ++public class WanderingTrader extends net.minecraft.world.entity.npc.AbstractVillager implements Consumable.OverrideConsumeSound { // CraftBukkit + private static final int DEFAULT_DESPAWN_DELAY = 0; @Nullable private BlockPos wanderTarget; - private int despawnDelay; + private int despawnDelay = 0; + // Paper start - Add more WanderingTrader API + public boolean canDrinkPotion = true; + public boolean canDrinkMilk = true; @@ -25,43 +17,25 @@ public WanderingTrader(EntityType entityType, Level level) { super(entityType, level); -@@ -67,7 +_,7 @@ +@@ -65,7 +_,7 @@ this, PotionContents.createItemStack(Items.POTION, Potions.INVISIBILITY), SoundEvents.WANDERING_TRADER_DISAPPEARED, -- wanderingTrader -> this.level().isNight() && !wanderingTrader.isInvisible() -+ wanderingTrader -> this.canDrinkPotion && this.level().isNight() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API +- wanderingTrader -> this.level().isDarkOutside() && !wanderingTrader.isInvisible() ++ wanderingTrader -> this.canDrinkPotion && this.level().isDarkOutside() && !wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API ) ); this.goalSelector -@@ -77,7 +_,7 @@ +@@ -75,7 +_,7 @@ this, new ItemStack(Items.MILK_BUCKET), SoundEvents.WANDERING_TRADER_REAPPEARED, -- wanderingTrader -> this.level().isDay() && wanderingTrader.isInvisible() -+ wanderingTrader -> this.canDrinkMilk && this.level().isDay() && wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API +- wanderingTrader -> this.level().isBrightOutside() && wanderingTrader.isInvisible() ++ wanderingTrader -> this.canDrinkMilk && this.level().isBrightOutside() && wanderingTrader.isInvisible() // Paper - Add more WanderingTrader API ) ); this.goalSelector.addGoal(1, new TradeWithPlayerGoal(this)); -@@ -145,7 +_,16 @@ - VillagerTrades.ItemListing itemListing = itemListings1[randomInt]; - MerchantOffer offer = itemListing.getOffer(this, this.random); - if (offer != null) { -- offers.add(offer); -+ // CraftBukkit start -+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) this.getBukkitEntity(), offer.asBukkit()); -+ // Suppress during worldgen -+ if (this.valid) { -+ Bukkit.getPluginManager().callEvent(event); -+ } -+ if (!event.isCancelled()) { -+ offers.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft()); -+ } -+ // CraftBukkit end - } - } - } -@@ -189,7 +_,7 @@ +@@ -163,7 +_,7 @@ protected void rewardTradeXp(MerchantOffer offer) { if (offer.shouldRewardExp()) { int i = 3 + this.random.nextInt(4); @@ -70,12 +44,12 @@ } } -@@ -241,7 +_,7 @@ +@@ -215,7 +_,7 @@ private void maybeDespawn() { if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) { - this.discard(); -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch index 032bfcb48..2b63aabd0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/npc/WanderingTraderSpawner.java +++ b/net/minecraft/world/entity/npc/WanderingTraderSpawner.java -@@ -38,41 +_,51 @@ +@@ -38,38 +_,47 @@ public WanderingTraderSpawner(ServerLevelData serverLevelData) { this.serverLevelData = serverLevelData; @@ -27,49 +27,46 @@ } @Override - public int tick(ServerLevel level, boolean spawnHostiles, boolean spawnPassives) { + public void tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { + // Paper start - Add Wandering Trader spawn rate config options + if (this.tickDelay == Integer.MIN_VALUE) { + this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength; + this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength; + this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin; + } - if (!level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) { - return 0; -- } else if (--this.tickDelay > 0) { -+ } else if (--this.tickDelay - 1 > 0) { -+ this.tickDelay = this.tickDelay - 1; - return 0; - } else { -- this.tickDelay = 1200; -- this.spawnDelay -= 1200; -- this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); -+ this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength; -+ this.spawnDelay = this.spawnDelay - level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength; -+ //this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways - if (this.spawnDelay > 0) { - return 0; - } else { -- this.spawnDelay = 24000; -+ this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength; - if (!level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { - return 0; - } else { - int i = this.spawnChance; -- this.spawnChance = Mth.clamp(this.spawnChance + 25, 25, 75); -- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); -+ this.spawnChance = Mth.clamp(this.spawnChance + level.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax); -+ //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways - if (this.random.nextInt(100) > i) { - return 0; - } else if (this.spawn(level)) { -- this.spawnChance = 25; -+ this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin; -+ // Paper end - Add Wandering Trader spawn rate config options - return 1; - } else { - return 0; -@@ -100,14 +_,14 @@ + if (level.getGameRules().getBoolean(GameRules.RULE_DO_TRADER_SPAWNING)) { +- if (--this.tickDelay <= 0) { +- this.tickDelay = 1200; +- this.spawnDelay -= 1200; +- this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); ++ if (this.tickDelay - 1 <= 0) { // Paper - Prevent tickDelay going below 0 ++ this.tickDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength; ++ this.spawnDelay = this.spawnDelay - level.paperConfig().entities.spawning.wanderingTrader.spawnMinuteLength; ++ //this.serverLevelData.setWanderingTraderSpawnDelay(this.spawnDelay); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways + if (this.spawnDelay <= 0) { +- this.spawnDelay = 24000; ++ this.spawnDelay = level.paperConfig().entities.spawning.wanderingTrader.spawnDayLength; + if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { + int i = this.spawnChance; +- this.spawnChance = Mth.clamp(this.spawnChance + 25, 25, 75); +- this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); ++ this.spawnChance = Mth.clamp(this.spawnChance + level.paperConfig().entities.spawning.wanderingTrader.spawnChanceFailureIncrement, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin, level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMax); ++ //this.serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); // Paper - We don't need to save this value to disk if it gets set back to a hardcoded value anyways + if (this.random.nextInt(100) <= i) { + if (this.spawn(level)) { +- this.spawnChance = 25; ++ this.spawnChance = level.paperConfig().entities.spawning.wanderingTrader.spawnChanceMin; ++ // Paper end - Add Wandering Trader spawn rate config options + } + } + } + } +- } ++ } else { this.tickDelay--; } // Paper - Prevent tickDelay going below 0 + } + } + +@@ -91,14 +_,14 @@ return false; } @@ -86,7 +83,7 @@ wanderingTrader.setWanderTarget(blockPos1); wanderingTrader.restrictTo(blockPos1, 16); return true; -@@ -121,7 +_,7 @@ +@@ -112,7 +_,7 @@ private void tryToSpawnLlamaFor(ServerLevel serverLevel, WanderingTrader trader, int maxDistance) { BlockPos blockPos = this.findSpawnPositionNear(serverLevel, trader.blockPosition(), maxDistance); if (blockPos != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Inventory.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Inventory.java.patch index af826eead..fe6d389be 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Inventory.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Inventory.java.patch @@ -1,38 +1,50 @@ --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -36,6 +_,54 @@ +@@ -49,6 +_,66 @@ public final Player player; + public final EntityEquipment equipment; private int timesChanged; - + // CraftBukkit start - add fields and methods -+ public List transaction = new java.util.ArrayList<>(); ++ public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + -+ public List getContents() { -+ List combined = new java.util.ArrayList<>(this.items.size() + this.armor.size() + this.offhand.size()); -+ for (List sub : this.compartments) { -+ combined.addAll(sub); -+ } -+ ++ @Override ++ public java.util.List getContents() { ++ java.util.List combined = new java.util.ArrayList<>(this.items.size() + EQUIPMENT_SLOT_MAPPING.size()); ++ combined.addAll(this.items); ++ EQUIPMENT_SLOT_MAPPING.int2ObjectEntrySet().forEach(entry -> { ++ ItemStack itemStack = this.equipment.get(entry.getValue()); ++ combined.add(itemStack); // Include empty items ++ }); + return combined; + } + -+ public List getArmorContents() { -+ return this.armor; ++ public java.util.List getArmorContents() { ++ java.util.List items = new java.util.ArrayList<>(); ++ EQUIPMENT_SLOT_MAPPING.int2ObjectEntrySet().forEach(entry -> { ++ if (entry.getValue().isArmor()) { ++ items.add(this.equipment.get(entry.getValue())); ++ } ++ }); ++ return items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + -+ public List getViewers() { ++ @Override ++ public java.util.List getViewers() { + return this.transaction; + } + ++ @Override + public org.bukkit.inventory.InventoryHolder getOwner() { + return this.player.getBukkitEntity(); + } @@ -42,6 +54,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } @@ -51,11 +64,10 @@ + return this.player.getBukkitEntity().getLocation(); + } + // CraftBukkit end -+ - public Inventory(Player player) { + + public Inventory(Player player, EntityEquipment equipment) { this.player = player; - } -@@ -50,10 +_,39 @@ +@@ -85,10 +_,39 @@ private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) { return !destination.isEmpty() @@ -84,7 +96,7 @@ + } + } + -+ ItemStack itemInOffhand = this.getItem(this.items.size() + this.armor.size()); ++ ItemStack itemInOffhand = this.equipment.get(EquipmentSlot.OFFHAND); + if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) { + remains -= (itemInOffhand.getMaxStackSize() < this.getMaxStackSize() ? itemInOffhand.getMaxStackSize() : this.getMaxStackSize()) - itemInOffhand.getCount(); + } @@ -98,27 +110,29 @@ public int getFreeSlot() { for (int i = 0; i < this.items.size(); i++) { -@@ -65,7 +_,10 @@ +@@ -100,8 +_,10 @@ return -1; } - public void addAndPickItem(ItemStack stack) { +- this.setSelectedSlot(this.getSuitableHotbarSlot()); + // Paper start - Add PlayerPickItemEvent + public void addAndPickItem(ItemStack stack, final int targetSlot) { -+ this.selected = targetSlot; ++ this.setSelectedSlot(targetSlot); + // Paper end - Add PlayerPickItemEvent - this.selected = this.getSuitableHotbarSlot(); if (!this.items.get(this.selected).isEmpty()) { int freeSlot = this.getFreeSlot(); -@@ -77,7 +_,10 @@ + if (freeSlot != -1) { +@@ -112,8 +_,10 @@ this.items.set(this.selected, stack); } - public void pickSlot(int index) { +- this.setSelectedSlot(this.getSuitableHotbarSlot()); + // Paper start - Add PlayerPickItemEvent + public void pickSlot(int index, final int targetSlot) { -+ this.selected = targetSlot; -+ // Paper end - Add PlayerPickItemEvent - this.selected = this.getSuitableHotbarSlot(); ++ this.setSelectedSlot(targetSlot); ++ // Paper end - Add PlayerPickItemEvent ItemStack itemStack = this.items.get(this.selected); this.items.set(this.selected, this.items.get(index)); + this.items.set(index, itemStack); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch index 597b6bda1..fec8afea5 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/Player.java.patch @@ -1,26 +1,18 @@ --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -159,7 +_,7 @@ - public static final int CLIENT_LOADED_TIMEOUT_TIME = 60; +@@ -169,7 +_,7 @@ + private static final int DEFAULT_CURRENT_IMPULSE_CONTEXT_RESET_GRACE_TIME = 0; private long timeEntitySatOnShoulder; - final Inventory inventory = new Inventory(this); + final Inventory inventory; - protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(); + protected PlayerEnderChestContainer enderChestInventory = new PlayerEnderChestContainer(this); // CraftBukkit - add "this" to constructor public final InventoryMenu inventoryMenu; public AbstractContainerMenu containerMenu; protected FoodData foodData = new FoodData(); -@@ -191,13 +_,25 @@ - private Optional lastDeathLocation = Optional.empty(); - @Nullable - public FishingHook fishing; -- protected float hurtDir; -+ public float hurtDir; // Paper - protected -> public - @Nullable - public Vec3 currentImpulseImpactPos; - @Nullable +@@ -208,6 +_,18 @@ public Entity currentExplosionCause; - private boolean ignoreFallDamageFromCurrentImpulse; - private int currentImpulseContextResetGraceTime; + private boolean ignoreFallDamageFromCurrentImpulse = false; + private int currentImpulseContextResetGraceTime = 0; + public boolean affectsSpawning = true; // Paper - Affects Spawning API + public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage + @@ -36,7 +28,7 @@ public Player(Level level, BlockPos pos, float yRot, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -261,6 +_,13 @@ +@@ -276,6 +_,13 @@ if (this.isSleeping()) { this.sleepCounter++; @@ -50,7 +42,7 @@ if (this.sleepCounter > 100) { this.sleepCounter = 100; } -@@ -278,7 +_,7 @@ +@@ -293,7 +_,7 @@ this.updateIsUnderwater(); super.tick(); if (!this.level().isClientSide && this.containerMenu != null && !this.containerMenu.stillValid(this)) { @@ -59,7 +51,7 @@ this.containerMenu = this.inventoryMenu; } -@@ -365,7 +_,7 @@ +@@ -380,7 +_,7 @@ } private void turtleHelmetTick() { @@ -68,7 +60,7 @@ } private boolean isEquipped(Item item) { -@@ -512,6 +_,18 @@ +@@ -527,6 +_,18 @@ } } @@ -87,7 +79,7 @@ public void closeContainer() { this.containerMenu = this.inventoryMenu; } -@@ -523,8 +_,14 @@ +@@ -538,8 +_,14 @@ public void rideTick() { if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) { this.stopRiding(); @@ -104,34 +96,15 @@ super.rideTick(); this.oBob = this.bob; this.bob = 0.0F; -@@ -588,6 +_,7 @@ +@@ -598,6 +_,7 @@ this.playShoulderEntityAmbientSound(this.getShoulderEntityLeft()); this.playShoulderEntityAmbientSound(this.getShoulderEntityRight()); - if (!this.level().isClientSide && (this.fallDistance > 0.5F || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) { + if (!this.level().isClientSide && (this.fallDistance > 0.5 || this.isInWater()) || this.abilities.flying || this.isSleeping() || this.isInPowderSnow) { + if (!this.level().paperConfig().entities.behavior.parrotsAreUnaffectedByPlayerMovement) // Paper - Add option to make parrots stay this.removeEntitiesOnShoulder(); } } -@@ -717,6 +_,18 @@ - - @Nullable - public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean includeThrowerName) { -+ // CraftBukkit start - SPIGOT-2942: Add boolean to call event -+ return this.drop(droppedItem, dropAround, includeThrowerName, true, null); -+ } -+ -+ @Nullable -+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean includeThrowerName, boolean callEvent) { -+ return this.drop(droppedItem, dropAround, includeThrowerName, callEvent, null); -+ } -+ -+ @Nullable -+ public ItemEntity drop(ItemStack droppedItem, boolean dropAround, boolean includeThrowerName, boolean callEvent, @Nullable java.util.function.Consumer entityOperation) { -+ // CraftBukkit end - if (!droppedItem.isEmpty() && this.level().isClientSide) { - this.swing(InteractionHand.MAIN_HAND); - } -@@ -867,10 +_,10 @@ +@@ -841,10 +_,10 @@ if (this.isDeadOrDying()) { return false; } else { @@ -144,7 +117,7 @@ } if (level.getDifficulty() == Difficulty.EASY) { -@@ -882,7 +_,14 @@ +@@ -856,7 +_,14 @@ } } @@ -160,16 +133,16 @@ } } } -@@ -892,7 +_,7 @@ - super.blockUsingShield(entity); - ItemStack itemBlockingWith = this.getItemBlockingWith(); - if (entity.canDisableShield() && itemBlockingWith != null) { -- this.disableShield(itemBlockingWith); -+ this.disableShield(itemBlockingWith, entity); // Paper - Add PlayerShieldDisableEvent +@@ -868,7 +_,7 @@ + BlocksAttacks blocksAttacks = itemBlockingWith != null ? itemBlockingWith.get(DataComponents.BLOCKS_ATTACKS) : null; + float secondsToDisableBlocking = entity.getSecondsToDisableBlocking(); + if (secondsToDisableBlocking > 0.0F && blocksAttacks != null) { +- blocksAttacks.disable(level, this, secondsToDisableBlocking, itemBlockingWith); ++ blocksAttacks.disable(level, this, secondsToDisableBlocking, itemBlockingWith, entity); // Paper - Add PlayerShieldDisableEvent } } -@@ -902,9 +_,29 @@ +@@ -878,9 +_,29 @@ } public boolean canHarmPlayer(Player other) { @@ -202,7 +175,7 @@ } @Override -@@ -943,7 +_,12 @@ +@@ -894,7 +_,12 @@ } @Override @@ -216,7 +189,7 @@ if (!this.isInvulnerableTo(level, damageSource)) { amount = this.getDamageAfterArmorAbsorb(damageSource, amount); amount = this.getDamageAfterMagicAbsorb(damageSource, amount); -@@ -955,7 +_,7 @@ +@@ -906,7 +_,7 @@ } if (var8 != 0.0F) { @@ -225,7 +198,7 @@ this.getCombatTracker().recordDamage(damageSource, var8); this.setHealth(this.getHealth() - var8); if (var8 < 3.4028235E37F) { -@@ -965,6 +_,7 @@ +@@ -916,6 +_,7 @@ this.gameEvent(GameEvent.ENTITY_DAMAGE); } } @@ -233,7 +206,7 @@ } public boolean isTextFilteringEnabled() { -@@ -1040,13 +_,19 @@ +@@ -997,13 +_,19 @@ @Override public void removeVehicle() { @@ -255,7 +228,7 @@ } @Override -@@ -1125,8 +_,17 @@ +@@ -1082,8 +_,17 @@ } public void attack(Entity target) { @@ -275,7 +248,7 @@ float f = this.isAutoSpinAttack() ? this.autoSpinAttackDmg : (float)this.getAttributeValue(Attributes.ATTACK_DAMAGE); ItemStack weaponItem = this.getWeaponItem(); DamageSource damageSource = Optional.ofNullable(weaponItem.getItem().getDamageSource(this)).orElse(this.damageSources().playerAttack(this)); -@@ -1134,18 +_,25 @@ +@@ -1091,18 +_,25 @@ float attackStrengthScale = this.getAttackStrengthScale(0.5F); f *= 0.2F + attackStrengthScale * attackStrengthScale * 0.8F; f1 *= attackStrengthScale; @@ -308,7 +281,7 @@ flag1 = true; } else { flag1 = false; -@@ -1161,7 +_,9 @@ +@@ -1118,7 +_,9 @@ && !this.isPassenger() && target instanceof LivingEntity && !this.isSprinting(); @@ -318,7 +291,7 @@ f *= 1.5F; } -@@ -1188,17 +_,23 @@ +@@ -1145,17 +_,23 @@ if (target instanceof LivingEntity livingEntity1) { livingEntity1.knockback( f4 * 0.5F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) @@ -342,24 +315,19 @@ } if (flag3) { -@@ -1212,43 +_,64 @@ - && (!(livingEntity2 instanceof ArmorStand) || !((ArmorStand)livingEntity2).isMarker()) +@@ -1169,42 +_,59 @@ + && !(livingEntity2 instanceof ArmorStand armorStand && armorStand.isMarker()) && this.distanceToSqr(livingEntity2) < 9.0) { float f6 = this.getEnchantedDamage(livingEntity2, f5, damageSource) * attackStrengthScale; -+ // CraftBukkit start - Only apply knockback if the event is not cancelled +- if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource, f6)) { ++ // Paper start - Only apply knockback if the event is not cancelled + livingEntity2.lastDamageCancelled = false; -+ livingEntity2.hurtServer((ServerLevel) this.level(), damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6); -+ if (livingEntity2.lastDamageCancelled) { -+ continue; -+ } -+ // CraftBukkit end - livingEntity2.knockback( - 0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) -+ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // CraftBukkit // Paper - knockback events - ); -- livingEntity2.hurt(damageSource, f6); -+ // CraftBukkit - moved up - if (this.level() instanceof ServerLevel serverLevel) { ++ if (this.level() instanceof ServerLevel serverLevel && livingEntity2.hurtServer(serverLevel, damageSource.knownCause(org.bukkit.event.entity.EntityDamageEvent.DamageCause.ENTITY_SWEEP_ATTACK), f6) && !livingEntity2.lastDamageCancelled) { ++ // Paper end - Only apply knockback if the event is not cancelled + livingEntity2.knockback( + 0.4F, Mth.sin(this.getYRot() * (float) (Math.PI / 180.0)), -Mth.cos(this.getYRot() * (float) (Math.PI / 180.0)) ++ , this, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.SWEEP_ATTACK // Paper - knockback events + ); EnchantmentHelper.doPostAttackEffects(serverLevel, livingEntity2, damageSource); } } @@ -367,7 +335,7 @@ - this.level() - .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); -+ this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility ++ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_SWEEP, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility this.sweepAttack(); } @@ -397,7 +365,7 @@ if (flag2) { - this.level() - .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); -+ this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility ++ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_CRIT, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility this.crit(target); } @@ -406,19 +374,19 @@ - this.level() - .playSound( - null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F -+ this.sendSoundEffect( ++ sendSoundEffect( + this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_STRONG, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility ); } else { - this.level() - .playSound( - null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F -+ this.sendSoundEffect( ++ sendSoundEffect( + this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_WEAK, this.getSoundSource(), 1.0F, 1.0F // Paper - send while respecting visibility ); } } -@@ -1296,10 +_,14 @@ +@@ -1252,10 +_,11 @@ } } @@ -427,55 +395,24 @@ } else { - this.level() - .playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); -+ this.sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility -+ // CraftBukkit start - resync on cancelled event -+ if (this instanceof ServerPlayer) { -+ ((ServerPlayer) this).getBukkitEntity().updateInventory(); -+ } ++ sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility ++ this.containerMenu.sendAllDataToRemote(); // CraftBukkit - resync on cancelled event + // CraftBukkit end } } } -@@ -1316,8 +_,21 @@ - this.attack(target); +@@ -1290,8 +_,8 @@ } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerShieldDisableEvent - public void disableShield(ItemStack stack) { -- this.getCooldowns().addCooldown(stack, 100); -+ // Paper start - Add PlayerShieldDisableEvent -+ this.disableShield(stack, null); -+ } -+ public void disableShield(ItemStack stack, @Nullable LivingEntity attacker) { -+ final org.bukkit.entity.Entity finalAttacker = attacker != null ? attacker.getBukkitEntity() : null; -+ if (finalAttacker != null) { -+ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) getBukkitEntity(), finalAttacker, 100); -+ if (!shieldDisableEvent.callEvent()) return; -+ this.getCooldowns().addCooldown(stack, shieldDisableEvent.getCooldown()); -+ } else { -+ this.getCooldowns().addCooldown(stack, 100); -+ } -+ // Paper end - Add PlayerShieldDisableEvent - this.stopUsingItem(); - this.level().broadcastEntityEvent(this, (byte)30); - } -@@ -1341,7 +_,14 @@ - @Override - public void remove(Entity.RemovalReason reason) { +- public void remove(Entity.RemovalReason reason) { - super.remove(reason); -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { -+ super.remove(reason, eventCause); -+ // CraftBukkit end ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause ++ super.remove(reason, eventCause); // CraftBukkit - add Bukkit remove cause this.inventoryMenu.removed(this); if (this.containerMenu != null && this.hasContainerOpen()) { this.doCloseContainer(); -@@ -1381,6 +_,12 @@ +@@ -1355,6 +_,12 @@ } public Either startSleepInBed(BlockPos bedPos) { @@ -488,16 +425,16 @@ this.startSleeping(bedPos); this.sleepCounter = 0; return Either.right(Unit.INSTANCE); -@@ -1492,7 +_,7 @@ +@@ -1466,7 +_,7 @@ @Override - public boolean causeFallDamage(float fallDistance, float multiplier, DamageSource source) { + public boolean causeFallDamage(double fallDistance, float damageMultiplier, DamageSource damageSource) { - if (this.abilities.mayfly) { + if (this.abilities.mayfly && !this.flyingFallDamage.toBooleanOrElse(false)) { // Paper - flying fall damage return false; } else { - if (fallDistance >= 2.0F) { -@@ -1532,12 +_,24 @@ + if (fallDistance >= 2.0) { +@@ -1507,7 +_,15 @@ } public void startFallFlying() { @@ -513,17 +450,8 @@ + // CraftBukkit end } - public void stopFallFlying() { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) { - this.setSharedFlag(7, true); - this.setSharedFlag(7, false); -+ } -+ // CraftBukkit end - } - @Override -@@ -1643,15 +_,35 @@ +@@ -1613,15 +_,35 @@ public int getXpNeededForNextLevel() { if (this.experienceLevel >= 30) { return 112 + (this.experienceLevel - 30) * 9; @@ -561,31 +489,7 @@ } } } -@@ -1736,13 +_,20 @@ - - @Override - public void setItemSlot(EquipmentSlot slot, ItemStack stack) { -+ // CraftBukkit start -+ this.setItemSlot(slot, stack, false); -+ } -+ -+ @Override -+ public void setItemSlot(EquipmentSlot slot, ItemStack stack, boolean silent) { -+ // CraftBukkit end - this.verifyEquippedItem(stack); - if (slot == EquipmentSlot.MAINHAND) { -- this.onEquipItem(slot, this.inventory.items.set(this.inventory.selected, stack), stack); -+ this.onEquipItem(slot, this.inventory.items.set(this.inventory.selected, stack), stack, silent); // CraftBukkit - } else if (slot == EquipmentSlot.OFFHAND) { -- this.onEquipItem(slot, this.inventory.offhand.set(0, stack), stack); -+ this.onEquipItem(slot, this.inventory.offhand.set(0, stack), stack, silent); // CraftBukkit - } else if (slot.getType() == EquipmentSlot.Type.HUMANOID_ARMOR) { -- this.onEquipItem(slot, this.inventory.armor.set(slot.getIndex(), stack), stack); -+ this.onEquipItem(slot, this.inventory.armor.set(slot.getIndex(), stack), stack, silent); // CraftBukkit - } - } - -@@ -1783,24 +_,53 @@ +@@ -1715,24 +_,53 @@ public void removeEntitiesOnShoulder() { if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) { @@ -631,8 +535,8 @@ if (!this.level().isClientSide && !entityCompound.isEmpty()) { - EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).ifPresent(entity -> { + return EntityType.create(entityCompound, this.level(), EntitySpawnReason.LOAD).map((entity) -> { // CraftBukkit - if (entity instanceof TamableAnimal) { - ((TamableAnimal)entity).setOwnerUUID(this.uuid); + if (entity instanceof TamableAnimal tamableAnimal) { + tamableAnimal.setOwner(this); } entity.setPos(this.getX(), this.getY() + 0.7F, this.getZ()); @@ -644,8 +548,8 @@ + return null; // Paper - return null } - @Override -@@ -1988,17 +_,32 @@ + @Nullable +@@ -1926,17 +_,32 @@ return ImmutableList.of(Pose.STANDING, Pose.CROUCHING, Pose.SWIMMING); } @@ -680,15 +584,15 @@ for (int i = 0; i < this.inventory.getContainerSize(); i++) { ItemStack item = this.inventory.getItem(i); -@@ -2007,6 +_,7 @@ +@@ -1945,6 +_,7 @@ } } + if (anyEventCancelled.booleanValue() && !this.abilities.instabuild && this instanceof final ServerPlayer player) this.resyncUsingItem(player); // Paper - resync if no item matched the Predicate - return this.abilities.instabuild ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; + return this.hasInfiniteMaterials() ? new ItemStack(Items.ARROW) : ItemStack.EMPTY; } } -@@ -2089,12 +_,20 @@ +@@ -2027,12 +_,20 @@ } public boolean hasClientLoaded() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/player/ProfilePublicKey.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/player/ProfilePublicKey.java.patch index 31a265cc6..1290b7263 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/player/ProfilePublicKey.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/player/ProfilePublicKey.java.patch @@ -9,16 +9,18 @@ } else { return new ProfilePublicKey(data); } -@@ -88,8 +_,16 @@ +@@ -88,8 +_,18 @@ } public static class ValidationException extends ThrowingComponent { + public final org.bukkit.event.player.PlayerKickEvent.Cause kickCause; // Paper -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper ++ ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper public ValidationException(Component component) { + // Paper start + this(component, org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); + } ++ + public ValidationException(Component component, org.bukkit.event.player.PlayerKickEvent.Cause kickCause) { + // Paper end super(component); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index 6bb662ba7..f677c94f3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -1,49 +1,21 @@ --- a/net/minecraft/world/entity/projectile/AbstractArrow.java +++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -33,6 +_,7 @@ - import net.minecraft.world.entity.OminousItemSpawner; - import net.minecraft.world.entity.SlotAccess; - import net.minecraft.world.entity.ai.attributes.Attributes; -+import net.minecraft.world.entity.item.ItemEntity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.Item; - import net.minecraft.world.item.ItemStack; -@@ -63,16 +_,16 @@ - protected int inGroundTime; - public AbstractArrow.Pickup pickup = AbstractArrow.Pickup.DISALLOWED; - public int shakeTime; -- private int life; -+ public int life; // Paper - private -> public - private double baseDamage = 2.0; -- private SoundEvent soundEvent = this.getDefaultHitGroundSoundEvent(); -+ public SoundEvent soundEvent = this.getDefaultHitGroundSoundEvent(); // Paper - private -> public - @Nullable - private IntOpenHashSet piercingIgnoreEntityIds; - @Nullable - private List piercedAndKilledEntities; -- private ItemStack pickupItemStack = this.getDefaultPickupItem(); -+ public ItemStack pickupItemStack = this.getDefaultPickupItem(); // Paper - private -> public - @Nullable -- private ItemStack firedFromWeapon = null; -+ public ItemStack firedFromWeapon = null; // Paper - private -> public - - protected AbstractArrow(EntityType entityType, Level level) { - super(entityType, level); -@@ -87,7 +_,13 @@ +@@ -93,7 +_,14 @@ ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { + // CraftBukkit start - handle the owner before the rest of things + this(entityType, x, y, z, level, pickupItemStack, firedFromWeapon, null); + } ++ + protected AbstractArrow(EntityType entityType, double x, double y, double z, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon, @Nullable LivingEntity ownerEntity) { this(entityType, level); + this.setOwner(ownerEntity); + // CraftBukkit end this.pickupItemStack = pickupItemStack.copy(); - this.setCustomName(pickupItemStack.get(DataComponents.CUSTOM_NAME)); + this.applyComponentsFromItemStack(pickupItemStack); Unit unit = pickupItemStack.remove(DataComponents.INTANGIBLE_PROJECTILE); -@@ -112,8 +_,8 @@ +@@ -118,8 +_,8 @@ protected AbstractArrow( EntityType entityType, LivingEntity owner, Level level, ItemStack pickupItemStack, @Nullable ItemStack firedFromWeapon ) { @@ -54,15 +26,15 @@ } public void setSoundEvent(SoundEvent soundEvent) { -@@ -209,6 +_,7 @@ - this.applyEffectsFromBlocks(); +@@ -214,6 +_,7 @@ + this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); } } else { -+ if (this.tickCount > 200) this.tickDespawn(); // Paper - tick despawnCounter regardless after 10 seconds ++ if (this.tickCount > 200) this.tickDespawn(); // Paper - tick life regardless after 10 seconds this.inGroundTime = 0; Vec3 vec31 = this.position(); if (this.isInWater()) { -@@ -275,12 +_,12 @@ +@@ -280,12 +_,12 @@ if (entityHitResult == null) { if (this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -77,7 +49,7 @@ this.hasImpulse = true; if (this.getPierceLevel() > 0 && projectileDeflection == ProjectileDeflection.NONE) { continue; -@@ -313,13 +_,26 @@ +@@ -318,13 +_,26 @@ } } @@ -105,16 +77,7 @@ } private void startFalling() { -@@ -329,7 +_,7 @@ - this.life = 0; - } - -- protected boolean isInGround() { -+ public boolean isInGround() { // Paper - protected -> public - return this.entityData.get(IN_GROUND); - } - -@@ -347,8 +_,8 @@ +@@ -357,8 +_,8 @@ protected void tickDespawn() { this.life++; @@ -125,7 +88,7 @@ } } -@@ -375,9 +_,9 @@ +@@ -392,9 +_,9 @@ } @Override @@ -137,7 +100,7 @@ } } -@@ -404,7 +_,7 @@ +@@ -421,7 +_,7 @@ } if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) { @@ -146,7 +109,7 @@ return; } -@@ -420,10 +_,17 @@ +@@ -437,10 +_,16 @@ livingEntity.setLastHurtMob(entity); } @@ -157,15 +120,14 @@ - entity.igniteForSeconds(5.0F); + // CraftBukkit start + org.bukkit.event.entity.EntityCombustByEntityEvent combustEvent = new org.bukkit.event.entity.EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5.0F); -+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent); -+ if (!combustEvent.isCancelled()) { ++ if (combustEvent.callEvent()) { + entity.igniteForSeconds(combustEvent.getDuration(), false); + } + // CraftBukkit end } if (entity.hurtOrSimulate(damageSource, ceil)) { -@@ -461,7 +_,7 @@ +@@ -478,7 +_,7 @@ this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F)); if (this.getPierceLevel() <= 0) { @@ -174,7 +136,7 @@ } } else { entity.setRemainingFireTicks(remainingFireTicks); -@@ -472,7 +_,7 @@ +@@ -489,7 +_,7 @@ this.spawnAtLocation(serverLevel2, this.getPickupItem(), 0.1F); } @@ -183,7 +145,7 @@ } } } -@@ -485,7 +_,7 @@ +@@ -502,7 +_,7 @@ double max = Math.max(0.0, 1.0 - entity.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE)); Vec3 vec3 = this.getDeltaMovement().multiply(1.0, 0.0, 1.0).normalize().scale(d * 0.6 * max); if (vec3.lengthSqr() > 0.0) { @@ -192,16 +154,7 @@ } } } -@@ -597,7 +_,7 @@ - this.setPierceLevel(compound.getByte("PierceLevel")); - if (compound.contains("SoundEvent", 8)) { - this.soundEvent = BuiltInRegistries.SOUND_EVENT -- .getOptional(ResourceLocation.parse(compound.getString("SoundEvent"))) -+ .getOptional(ResourceLocation.tryParse(compound.getString("SoundEvent"))) // Paper - Validate resource location - .orElse(this.getDefaultHitGroundSoundEvent()); - } - -@@ -616,7 +_,14 @@ +@@ -610,7 +_,14 @@ @Override public void setOwner(@Nullable Entity entity) { @@ -216,7 +169,7 @@ this.pickup = switch (entity) { case Player player when this.pickup == AbstractArrow.Pickup.DISALLOWED -> AbstractArrow.Pickup.ALLOWED; -@@ -628,9 +_,24 @@ +@@ -622,9 +_,22 @@ @Override public void playerTouch(Player entity) { if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) { @@ -224,12 +177,10 @@ + // CraftBukkit start + ItemStack itemstack = this.getPickupItem(); + if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && entity.getInventory().canHold(itemstack) > 0) { -+ ItemEntity item = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); ++ net.minecraft.world.entity.item.ItemEntity item = new net.minecraft.world.entity.item.ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); + org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) item.getBukkitEntity(), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); + // event.setCancelled(!entityhuman.canPickUpLoot); TODO -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { ++ if (!event.callEvent()) { + return; + } + itemstack = item.getItem(); @@ -243,34 +194,3 @@ } } } -@@ -643,7 +_,7 @@ - }; - } - -- protected ItemStack getPickupItem() { -+ public ItemStack getPickupItem() { // Paper - protected -> public - return this.pickupItemStack.copy(); - } - -@@ -675,7 +_,7 @@ - this.setFlag(1, critArrow); - } - -- private void setPierceLevel(byte pierceLevel) { -+ public void setPierceLevel(byte pierceLevel) { // Paper - private -> public - this.entityData.set(PIERCE_LEVEL, pierceLevel); - } - -@@ -687,6 +_,12 @@ - this.entityData.set(ID_FLAGS, (byte)(b & ~id)); - } - } -+ -+ // Paper start -+ public void setPickupItemStackPublic(final ItemStack pickupItemStack) { -+ this.setPickupItemStack(pickupItemStack); -+ } -+ // Paper end - - protected void setPickupItemStack(ItemStack pickupItemStack) { - if (!pickupItemStack.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch new file mode 100644 index 000000000..3423029d7 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractThrownPotion.java.patch @@ -0,0 +1,109 @@ +--- a/net/minecraft/world/entity/projectile/AbstractThrownPotion.java ++++ b/net/minecraft/world/entity/projectile/AbstractThrownPotion.java +@@ -70,54 +_,95 @@ + @Override + protected void onHit(HitResult result) { + super.onHit(result); ++ // Paper start - More projectile API ++ this.splash(result); ++ } ++ ++ public void splash(@Nullable HitResult result) { ++ // Paper end - More projectile API + if (this.level() instanceof ServerLevel serverLevel) { + ItemStack item = this.getItem(); + PotionContents potionContents = item.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); ++ boolean showParticles = true; // Paper - Fix potions splash events + if (potionContents.is(Potions.WATER)) { +- this.onHitAsWater(serverLevel); +- } else if (potionContents.hasEffects()) { +- this.onHitAsPotion(serverLevel, item, result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null); ++ showParticles = this.onHitAsWater(serverLevel, result); // Paper - Fix potions splash events ++ } else if (true || potionContents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply ++ showParticles = this.onHitAsPotion(serverLevel, item, result != null && result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null, result); // Paper - pass HitResult + } + ++ if (showParticles) { // Paper - Fix potions splash events + int i = potionContents.potion().isPresent() && potionContents.potion().get().value().hasInstantEffects() ? 2007 : 2002; + serverLevel.levelEvent(i, this.blockPosition(), potionContents.getColor()); +- this.discard(); ++ } // Paper - Fix potions splash events ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause + } + } + +- private void onHitAsWater(ServerLevel level) { ++ private static final Predicate APPLY_WATER_GET_ENTITIES_PREDICATE = AbstractThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper - Fix potions splash events ++ ++ private boolean onHitAsWater(ServerLevel level, @Nullable HitResult result) { // Paper - Fix potions splash events + AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0); + +- for (LivingEntity livingEntity : this.level().getEntitiesOfClass(LivingEntity.class, aabb, WATER_SENSITIVE_OR_ON_FIRE)) { ++ // Paper start - Fix potions splash events ++ java.util.Map affected = new java.util.HashMap<>(); ++ java.util.Set rehydrate = new java.util.HashSet<>(); ++ java.util.Set extinguish = new java.util.HashSet<>(); ++ for (LivingEntity livingEntity : this.level().getEntitiesOfClass(LivingEntity.class, aabb, APPLY_WATER_GET_ENTITIES_PREDICATE)) { ++ if (livingEntity instanceof Axolotl axolotl) { ++ rehydrate.add(((org.bukkit.entity.Axolotl) axolotl.getBukkitEntity())); ++ } ++ // Paper end - Fix potions splash events + double d = this.distanceToSqr(livingEntity); + if (d < 16.0) { + if (livingEntity.isSensitiveToWater()) { +- livingEntity.hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F); ++ affected.put(livingEntity.getBukkitLivingEntity(), 1.0); // Paper - Fix potions splash events + } + + if (livingEntity.isOnFire() && livingEntity.isAlive()) { +- livingEntity.extinguishFire(); ++ extinguish.add(livingEntity.getBukkitLivingEntity()); // Paper - Fix potions splash events + } + } + } + +- for (Axolotl axolotl : this.level().getEntitiesOfClass(Axolotl.class, aabb)) { +- axolotl.rehydrate(); ++ // Paper start - Fix potions splash events ++ io.papermc.paper.event.entity.WaterBottleSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callWaterBottleSplashEvent( ++ this, result, affected, rehydrate, extinguish ++ ); ++ if (!event.isCancelled()) { ++ for (org.bukkit.entity.LivingEntity affectedEntity : event.getToDamage()) { ++ ((org.bukkit.craftbukkit.entity.CraftLivingEntity) affectedEntity).getHandle().hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F); ++ } ++ for (org.bukkit.entity.LivingEntity toExtinguish : event.getToExtinguish()) { ++ ((org.bukkit.craftbukkit.entity.CraftLivingEntity) toExtinguish).getHandle().extinguishFire(); ++ } ++ for (org.bukkit.entity.LivingEntity toRehydrate : event.getToRehydrate()) { ++ if (((org.bukkit.craftbukkit.entity.CraftLivingEntity) toRehydrate).getHandle() instanceof Axolotl axolotl) { ++ axolotl.rehydrate(); ++ } ++ } ++ // Paper end - Fix potions splash events + } ++ return !event.isCancelled(); // Paper - Fix potions splash events + } + +- protected abstract void onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity); ++ protected abstract boolean onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity, @Nullable HitResult hitResult); // Paper - Pass HitResult // Paper - Fix potions splash events & More Projectile API + + private void dowseFire(BlockPos pos) { + BlockState blockState = this.level().getBlockState(pos); + if (blockState.is(BlockTags.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state + this.level().destroyBlock(pos, false, this); ++ } // CraftBukkit + } else if (AbstractCandleBlock.isLit(blockState)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(AbstractCandleBlock.LIT, false))) { // CraftBukkit + AbstractCandleBlock.extinguish(null, blockState, this.level(), pos); ++ } // CraftBukkit + } else if (CampfireBlock.isLitCampfire(blockState)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(CampfireBlock.LIT, false))) { // CraftBukkit + this.level().levelEvent(null, 1009, pos, 0); + CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState); + this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, false)); ++ } // CraftBukkit + } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch index f23f9c6a7..75bdee06a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Arrow.java.patch @@ -1,17 +1,11 @@ --- a/net/minecraft/world/entity/projectile/Arrow.java +++ b/net/minecraft/world/entity/projectile/Arrow.java -@@ -121,12 +_,13 @@ - mobEffectInstance.isVisible() - ), - effectSource -+ , org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW // CraftBukkit - ); - } - } - - for (MobEffectInstance mobEffectInstance : potionContents.customEffects()) { -- living.addEffect(mobEffectInstance, effectSource); -+ living.addEffect(mobEffectInstance, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW); // CraftBukkit - } +@@ -115,7 +_,7 @@ + Entity effectSource = this.getEffectSource(); + PotionContents potionContents = this.getPotionContents(); + float potionDurationScale = this.getPotionDurationScale(); +- potionContents.forEachEffect(mobEffectInstance -> living.addEffect(mobEffectInstance, effectSource), potionDurationScale); ++ potionContents.forEachEffect(mobEffectInstance -> living.addEffect(mobEffectInstance, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ARROW), potionDurationScale); // CraftBukkit } + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch index b04695ec1..90943d1f4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/DragonFireball.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/DragonFireball.java +++ b/net/minecraft/world/entity/projectile/DragonFireball.java -@@ -52,9 +_,11 @@ +@@ -53,9 +_,11 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch index a28c202eb..61eaaa3aa 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EvokerFangs.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/EvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EvokerFangs.java -@@ -109,7 +_,7 @@ +@@ -107,7 +_,7 @@ } if (--this.lifeTicks < 0) { @@ -9,12 +9,12 @@ } } } -@@ -118,7 +_,7 @@ +@@ -116,7 +_,7 @@ LivingEntity owner = this.getOwner(); if (target.isAlive() && !target.isInvulnerable() && target != owner) { if (owner == null) { - target.hurt(this.damageSources().magic(), 6.0F); -+ target.hurt(this.damageSources().magic().eventEntityDamager(this), 6.0F); // CraftBukkit // Paper - fix DamageSource API ++ target.hurt(this.damageSources().magic().eventEntityDamager(this), 6.0F); // CraftBukkit } else { if (owner.isAlliedTo(target)) { return; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch index 450c900de..573bb6f99 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/EyeOfEnder.java.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/world/entity/projectile/EyeOfEnder.java +++ b/net/minecraft/world/entity/projectile/EyeOfEnder.java -@@ -70,6 +_,11 @@ +@@ -73,6 +_,12 @@ } public void signalTo(BlockPos pos) { + // Paper start - Change EnderEye target without changing other things + this.signalTo(pos, true); + } ++ + public void signalTo(BlockPos pos, boolean update) { + // Paper end - Change EnderEye target without changing other things double d = pos.getX(); int y = pos.getY(); double d1 = pos.getZ(); -@@ -86,8 +_,10 @@ +@@ -89,8 +_,10 @@ this.tz = d1; } @@ -23,7 +24,7 @@ } @Override -@@ -161,7 +_,7 @@ +@@ -164,7 +_,7 @@ this.life++; if (this.life > 80 && !this.level().isClientSide) { this.playSound(SoundEvents.ENDER_EYE_DEATH, 1.0F, 1.0F); @@ -32,17 +33,3 @@ if (this.surviveAfterDeath) { this.level().addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem())); } else { -@@ -181,7 +_,12 @@ - @Override - public void readAdditionalSaveData(CompoundTag compound) { - if (compound.contains("Item", 10)) { -- this.setItem(ItemStack.parse(this.registryAccess(), compound.getCompound("Item")).orElse(this.getDefaultItem())); -+ // CraftBukkit start - SPIGOT-6103 summon, see also SPIGOT-5474 -+ ItemStack itemStack = ItemStack.parse(this.registryAccess(), compound.getCompound("Item")).orElse(this.getDefaultItem()); -+ if (!itemStack.isEmpty()) { -+ this.setItem(itemStack); -+ } -+ // CraftBukkit end - } else { - this.setItem(this.getDefaultItem()); - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Fireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Fireball.java.patch deleted file mode 100644 index 96bac378a..000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Fireball.java.patch +++ /dev/null @@ -1,16 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/Fireball.java -+++ b/net/minecraft/world/entity/projectile/Fireball.java -@@ -60,7 +_,12 @@ - public void readAdditionalSaveData(CompoundTag compound) { - super.readAdditionalSaveData(compound); - if (compound.contains("Item", 10)) { -- this.setItem(ItemStack.parse(this.registryAccess(), compound.getCompound("Item")).orElse(this.getDefaultItem())); -+ // CraftBukkit start - SPIGOT-5474 probably came from bugged earlier versions -+ final ItemStack itemStack = ItemStack.parse(this.registryAccess(), compound.getCompound("Item")).orElse(this.getDefaultItem()); -+ if (!itemStack.isEmpty()) { -+ this.setItem(itemStack); -+ } -+ // CraftBukkit end - } else { - this.setItem(this.getDefaultItem()); - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch index b776903e2..12bdfc47b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FireworkRocketEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -43,6 +_,7 @@ - public int lifetime; +@@ -50,6 +_,7 @@ + public int lifetime = 0; @Nullable public LivingEntity attachedToEntity; + @Nullable public java.util.UUID spawningEntity; // Paper public FireworkRocketEntity(EntityType entityType, Level level) { super(entityType, level); -@@ -158,7 +_,7 @@ +@@ -165,7 +_,7 @@ } if (!this.noPhysics && this.isAlive() && hitResultOnMoveVector.getType() != HitResult.Type.MISS) { @@ -17,7 +17,7 @@ this.hasImpulse = true; } -@@ -182,7 +_,11 @@ +@@ -189,7 +_,11 @@ } if (this.life > this.lifetime && this.level() instanceof ServerLevel serverLevel) { @@ -30,7 +30,7 @@ } } -@@ -190,14 +_,18 @@ +@@ -197,14 +_,18 @@ level.broadcastEntityEvent(this, (byte)17); this.gameEvent(GameEvent.EXPLODE, this.getOwner()); this.dealExplosionDamage(level); @@ -51,9 +51,9 @@ } } -@@ -206,7 +_,11 @@ +@@ -213,7 +_,11 @@ BlockPos blockPos = new BlockPos(result.getBlockPos()); - this.level().getBlockState(blockPos).entityInside(this.level(), blockPos, this); + this.level().getBlockState(blockPos).entityInside(this.level(), blockPos, this, InsideBlockEffectApplier.NOOP); if (this.level() instanceof ServerLevel serverLevel && this.hasExplosion()) { - this.explode(serverLevel); + // Paper start - Call FireworkExplodeEvent @@ -64,27 +64,19 @@ } super.onHitBlock(result); -@@ -278,6 +_,11 @@ - compound.putInt("LifeTime", this.lifetime); - compound.put("FireworksItem", this.getItem().save(this.registryAccess())); +@@ -286,6 +_,7 @@ + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + compound.store("FireworksItem", ItemStack.CODEC, registryOps, this.getItem()); compound.putBoolean("ShotAtAngle", this.entityData.get(DATA_SHOT_AT_ANGLE)); -+ // Paper start -+ if (this.spawningEntity != null) { -+ compound.putUUID("SpawningEntity", this.spawningEntity); -+ } -+ // Paper end ++ compound.storeNullable("SpawningEntity", net.minecraft.core.UUIDUtil.CODEC, this.spawningEntity); // Paper } @Override -@@ -298,6 +_,11 @@ - if (compound.contains("ShotAtAngle")) { - this.entityData.set(DATA_SHOT_AT_ANGLE, compound.getBoolean("ShotAtAngle")); - } -+ // Paper start -+ if (compound.hasUUID("SpawningEntity")) { -+ this.spawningEntity = compound.getUUID("SpawningEntity"); -+ } -+ // Paper end +@@ -296,6 +_,7 @@ + RegistryOps registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE); + this.entityData.set(DATA_ID_FIREWORKS_ITEM, compound.read("FireworksItem", ItemStack.CODEC, registryOps).orElse(getDefaultItem())); + this.entityData.set(DATA_SHOT_AT_ANGLE, compound.getBooleanOr("ShotAtAngle", false)); ++ this.spawningEntity = compound.read("SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null); // Paper } private List getExplosions() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch index b433002c9..96b211d39 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/FishingHook.java.patch @@ -27,7 +27,7 @@ } public FishingHook(EntityType entityType, Level level) { -@@ -147,12 +_,12 @@ +@@ -143,12 +_,12 @@ super.tick(); Player playerOwner = this.getPlayerOwner(); if (playerOwner == null) { @@ -42,7 +42,7 @@ return; } } else { -@@ -251,14 +_,14 @@ +@@ -247,14 +_,14 @@ if (!player.isRemoved() && player.isAlive() && (isFishingRod || isFishingRod1) && !(this.distanceToSqr(player) > 1024.0)) { return false; } else { @@ -59,7 +59,7 @@ } @Override -@@ -289,11 +_,11 @@ +@@ -285,11 +_,11 @@ ServerLevel serverLevel = (ServerLevel)this.level(); int i = 1; BlockPos blockPos = pos.above(); @@ -73,32 +73,31 @@ i--; } -@@ -303,6 +_,10 @@ +@@ -299,6 +_,10 @@ this.timeUntilLured = 0; this.timeUntilHooked = 0; this.getEntityData().set(DATA_BITING, false); + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) this.getPlayerOwner().getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.FAILED_ATTEMPT); -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); ++ playerFishEvent.callEvent(); + // CraftBukkit end } } else if (this.timeUntilHooked > 0) { this.timeUntilHooked -= i; -@@ -326,6 +_,13 @@ +@@ -322,6 +_,12 @@ serverLevel.sendParticles(ParticleTypes.FISHING, d, d1, d2, 0, -f2, 0.01, f1, 1.0); } } else { + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) this.getPlayerOwner().getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.event.player.PlayerFishEvent.State.BITE); -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ if (playerFishEvent.isCancelled()) { ++ if (!playerFishEvent.callEvent()) { + return; + } + // CraftBukkit end this.playSound(SoundEvents.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F); double d3 = this.getY() + 0.5; serverLevel.sendParticles( -@@ -377,14 +_,33 @@ +@@ -373,14 +_,31 @@ } if (this.timeUntilLured <= 0) { @@ -121,9 +120,7 @@ } else { - this.timeUntilLured = Mth.nextInt(this.random, 100, 600); - this.timeUntilLured = this.timeUntilLured - this.lureSpeed; -+ // CraftBukkit start - logic to modify fishing wait time + this.resetTimeUntilLured(); // Paper - more projectile api - extract time until lured reset logic -+ // CraftBukkit end } } + @@ -136,19 +133,18 @@ public boolean calculateOpenWater(BlockPos pos) { FishingHook.OpenWaterType openWaterType = FishingHook.OpenWaterType.INVALID; -@@ -443,15 +_,34 @@ +@@ -439,15 +_,31 @@ public void readAdditionalSaveData(CompoundTag compound) { } + + // Paper start - Add hand parameter to PlayerFishEvent -+ @Deprecated -+ @io.papermc.paper.annotation.DoNotUse ++ @Deprecated @io.papermc.paper.annotation.DoNotUse public int retrieve(ItemStack stack) { -+ return this.retrieve(net.minecraft.world.InteractionHand.MAIN_HAND, stack); ++ return this.retrieve(stack, net.minecraft.world.InteractionHand.MAIN_HAND); + } + -+ public int retrieve(net.minecraft.world.InteractionHand hand, ItemStack stack) { ++ public int retrieve(ItemStack stack, net.minecraft.world.InteractionHand hand) { + // Paper end - Add hand parameter to PlayerFishEvent Player playerOwner = this.getPlayerOwner(); if (!this.level().isClientSide && playerOwner != null && !this.shouldStopFishing(playerOwner)) { @@ -156,9 +152,7 @@ if (this.hookedIn != null) { + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.CAUGHT_ENTITY); // Paper - Add hand parameter to PlayerFishEvent -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ -+ if (playerFishEvent.isCancelled()) { ++ if (!playerFishEvent.callEvent()) { + return 0; + } + if (this.hookedIn != null) { // Paper - re-check to see if there is a hooked entity @@ -171,16 +165,14 @@ } else if (this.nibble > 0) { LootParams lootParams = new LootParams.Builder((ServerLevel)this.level()) .withParameter(LootContextParams.ORIGIN, this.position()) -@@ -465,18 +_,32 @@ +@@ -461,18 +_,27 @@ for (ItemStack itemStack : randomItems) { ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemStack); + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), itemEntity.getBukkitEntity(), (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.CAUGHT_FISH); // Paper - itemEntity may be null // Paper - Add hand parameter to PlayerFishEvent + playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1); -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ -+ if (playerFishEvent.isCancelled()) { ++ if (!playerFishEvent.callEvent()) { + return 0; + } + // CraftBukkit end @@ -196,8 +188,7 @@ - playerOwner.level(), playerOwner.getX(), playerOwner.getY() + 0.5, playerOwner.getZ() + 0.5, this.random.nextInt(6) + 1 - ) - ); -+ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop() -+ if (playerFishEvent.getExpToDrop() > 0) { ++ if (playerFishEvent.getExpToDrop() > 0) { // CraftBukkit - custom exp + playerOwner.level() + .addFreshEntity( + new ExperienceOrb( @@ -205,20 +196,16 @@ + ) + ); + } -+ // CraftBukkit end -+ if (itemStack.is(ItemTags.FISHES)) { playerOwner.awardStat(Stats.FISH_CAUGHT, 1); } -@@ -486,10 +_,27 @@ +@@ -482,10 +_,24 @@ } if (this.onGround()) { + // CraftBukkit start + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.IN_GROUND); // Paper - Add hand parameter to PlayerFishEvent -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ -+ if (playerFishEvent.isCancelled()) { ++ if (!playerFishEvent.callEvent()) { + return 0; + } + // CraftBukkit end @@ -227,8 +214,7 @@ + // CraftBukkit start + if (i == 0) { + org.bukkit.event.player.PlayerFishEvent playerFishEvent = new org.bukkit.event.player.PlayerFishEvent((org.bukkit.entity.Player) playerOwner.getBukkitEntity(), null, (org.bukkit.entity.FishHook) this.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand), org.bukkit.event.player.PlayerFishEvent.State.REEL_IN); // Paper - Add hand parameter to PlayerFishEvent -+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent); -+ if (playerFishEvent.isCancelled()) { ++ if (!playerFishEvent.callEvent()) { + return 0; + } + } @@ -239,24 +225,19 @@ return i; } else { return 0; -@@ -520,8 +_,15 @@ +@@ -515,9 +_,9 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { -+ // CraftBukkit end +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause this.updateOwnerInfo(null); - super.remove(reason); + super.remove(reason, cause); // CraftBukkit - add Bukkit remove cause } @Override -@@ -570,7 +_,7 @@ +@@ -565,7 +_,7 @@ if (this.getPlayerOwner() == null) { int data = packet.getData(); LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(data), data); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch index d484e6d4e..d38248aed 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LargeFireball.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/LargeFireball.java +++ b/net/minecraft/world/entity/projectile/LargeFireball.java -@@ -18,11 +_,13 @@ +@@ -19,11 +_,13 @@ public LargeFireball(EntityType entityType, Level level) { super(entityType, level); @@ -14,7 +14,7 @@ } @Override -@@ -30,8 +_,16 @@ +@@ -31,8 +_,13 @@ super.onHit(result); if (this.level() instanceof ServerLevel serverLevel) { boolean _boolean = serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); @@ -22,24 +22,19 @@ - this.discard(); + // CraftBukkit start - fire ExplosionPrimeEvent + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity()); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { -+ // give 'this' instead of (Entity) null so we know what causes the damage ++ if (event.callEvent()) { + this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); + } -+ // CraftBukkit end ++ // CraftBukkit end - fire ExplosionPrimeEvent + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } } -@@ -57,7 +_,8 @@ +@@ -57,6 +_,6 @@ + @Override public void readAdditionalSaveData(CompoundTag compound) { super.readAdditionalSaveData(compound); - if (compound.contains("ExplosionPower", 99)) { -- this.explosionPower = compound.getByte("ExplosionPower"); -+ // CraftBukkit - set bukkitYield when setting explosionpower -+ this.bukkitYield = this.explosionPower = compound.getByte("ExplosionPower"); - } +- this.explosionPower = compound.getByteOr("ExplosionPower", (byte)1); ++ this.bukkitYield = this.explosionPower = compound.getByteOr("ExplosionPower", (byte)1); // CraftBukkit - set bukkitYield when setting explosionPower } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch index 1e27f667a..4abcab857 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/LlamaSpit.java.patch @@ -14,7 +14,7 @@ if (this.level().getBlockStates(this.getBoundingBox()).noneMatch(BlockBehaviour.BlockStateBase::isAir)) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause - } else if (this.isInWaterOrBubble()) { + } else if (this.isInWater()) { - this.discard(); + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch index 01591a830..bb7fe41e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/Projectile.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/projectile/Projectile.java +++ b/net/minecraft/world/entity/projectile/Projectile.java -@@ -43,6 +_,7 @@ - public boolean hasBeenShot; +@@ -47,6 +_,7 @@ + public boolean hasBeenShot = false; @Nullable private Entity lastDeflectedBy; + protected boolean hitCancelled = false; // CraftBukkit Projectile(EntityType entityType, Level level) { super(entityType, level); -@@ -53,15 +_,36 @@ +@@ -57,15 +_,36 @@ this.ownerUUID = owner.getUUID(); this.cachedOwner = owner; } @@ -47,14 +47,14 @@ } else { return null; @@ -98,6 +_,7 @@ + @Override protected void readAdditionalSaveData(CompoundTag compound) { - if (compound.hasUUID("Owner")) { - this.setOwnerThroughUUID(compound.getUUID("Owner")); -+ if (this instanceof ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit - } - - this.leftOwner = compound.getBoolean("LeftOwner"); -@@ -175,13 +_,25 @@ + this.setOwnerThroughUUID(compound.read("Owner", UUIDUtil.CODEC).orElse(null)); ++ if (this instanceof ThrownEnderpearl && this.level().paperConfig().fixes.disableUnloadedChunkEnderpearlExploit && this.level().paperConfig().misc.legacyEnderPearlBehavior) { this.ownerUUID = null; } // Paper - Reset pearls when they stop being ticked; Don't store shooter name for pearls to block enderpearl travel exploit + this.leftOwner = compound.getBooleanOr("LeftOwner", false); + this.hasBeenShot = compound.getBooleanOr("HasBeenShot", false); + } +@@ -173,7 +_,14 @@ float f2 = Mth.cos(y * (float) (Math.PI / 180.0)) * Mth.cos(x * (float) (Math.PI / 180.0)); this.shoot(f, f1, f2, velocity, inaccuracy); Vec3 knownMovement = shooter.getKnownMovement(); @@ -68,6 +68,8 @@ + // Paper end - allow disabling relative velocity } + @Override +@@ -193,7 +_,12 @@ public static T spawnProjectileFromRotation( Projectile.ProjectileFactory factory, ServerLevel level, ItemStack spawnedFrom, LivingEntity owner, float z, float velocity, float innaccuracy ) { @@ -81,27 +83,29 @@ factory.create(level, owner, spawnedFrom), level, spawnedFrom, -@@ -206,7 +_,12 @@ +@@ -218,7 +_,13 @@ public static T spawnProjectileUsingShoot( T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy ) { - return spawnProjectile(projectile, level, spawnedFrom, projectile1 -> projectile.shoot(x, y, z, velocity, inaccuracy)); -+ // Paper start - fixes and addition to spawn reason API ++ // Paper start - fixes and addition to spawn reason API + return spawnProjectileUsingShootDelayed(projectile, level, spawnedFrom, x, y, z, velocity, inaccuracy).spawn(); + } ++ + public static Delayed spawnProjectileUsingShootDelayed(T projectile, ServerLevel level, ItemStack spawnedFrom, double x, double y, double z, float velocity, float inaccuracy) { + return spawnProjectileDelayed(projectile, level, spawnedFrom, projectile1 -> projectile.shoot(x, y, z, velocity, inaccuracy)); -+ // Paper end - fixes and addition to spawn reason API ++ // Paper end - fixes and addition to spawn reason API } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack spawnedFrom) { -@@ -214,11 +_,45 @@ +@@ -226,11 +_,46 @@ } public static T spawnProjectile(T projectile, ServerLevel level, ItemStack stack, Consumer adapter) { + // Paper start - delayed projectile spawning + return spawnProjectileDelayed(projectile, level, stack, adapter).spawn(); + } ++ + public static Delayed spawnProjectileDelayed(T projectile, ServerLevel level, ItemStack stack, Consumer adapter) { + // Paper end - delayed projectile spawning adapter.accept(projectile); @@ -145,12 +149,12 @@ public void applyOnProjectileSpawned(ServerLevel level, ItemStack spawnedFrom) { EnchantmentHelper.onProjectileSpawned(level, spawnedFrom, this, item -> {}); -@@ -230,6 +_,17 @@ +@@ -242,6 +_,17 @@ } } + // CraftBukkit start - call projectile hit event -+ public ProjectileDeflection preHitTargetOrDeflectSelf(HitResult hitResult) { // Paper - protected -> public ++ public ProjectileDeflection preHitTargetOrDeflectSelf(HitResult hitResult) { + org.bukkit.event.entity.ProjectileHitEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this, hitResult); + this.hitCancelled = event != null && event.isCancelled(); + if (hitResult.getType() == HitResult.Type.BLOCK || !this.hitCancelled) { @@ -163,7 +167,7 @@ protected ProjectileDeflection hitTargetOrDeflectSelf(HitResult hitResult) { if (hitResult.getType() == HitResult.Type.ENTITY) { EntityHitResult entityHitResult = (EntityHitResult)hitResult; -@@ -261,7 +_,13 @@ +@@ -273,7 +_,13 @@ public boolean deflect(ProjectileDeflection deflection, @Nullable Entity entity, @Nullable Entity owner, boolean deflectedByPlayer) { deflection.deflect(this, entity, this.random); if (!this.level().isClientSide) { @@ -178,7 +182,7 @@ this.onDeflection(entity, deflectedByPlayer); } -@@ -297,15 +_,35 @@ +@@ -309,15 +_,35 @@ } protected void onHitBlock(BlockHitResult result) { @@ -214,7 +218,7 @@ return owner == null || this.leftOwner || !owner.isPassengerOfSameVehicle(target); } } -@@ -318,13 +_,7 @@ +@@ -330,13 +_,7 @@ } protected static float lerpRotation(float currentRotation, float targetRotation) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch index 8f79e335e..82901360f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ShulkerBullet.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ShulkerBullet.java +++ b/net/minecraft/world/entity/projectile/ShulkerBullet.java -@@ -57,7 +_,21 @@ +@@ -58,7 +_,21 @@ this.finalTarget = finalTarget; this.currentMoveDirection = Direction.UP; this.selectNextMoveDirection(axis); @@ -14,7 +14,7 @@ + return this.finalTarget; + } + -+ public void setTarget(Entity finalTarget) { ++ public void setTarget(@Nullable Entity finalTarget) { + this.finalTarget = finalTarget; + this.currentMoveDirection = Direction.UP; + this.selectNextMoveDirection(Direction.Axis.X); @@ -23,7 +23,7 @@ @Override public SoundSource getSoundSource() { -@@ -187,7 +_,7 @@ +@@ -180,7 +_,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL) { @@ -32,7 +32,7 @@ } } -@@ -233,7 +_,7 @@ +@@ -226,7 +_,7 @@ } if (hitResult != null && this.isAlive() && hitResult.getType() != HitResult.Type.MISS) { @@ -41,7 +41,7 @@ } ProjectileUtil.rotateTowardsMovement(this, 0.5F); -@@ -301,7 +_,7 @@ +@@ -299,7 +_,7 @@ } if (entity instanceof LivingEntity livingEntity1) { @@ -50,7 +50,7 @@ } } } -@@ -314,14 +_,20 @@ +@@ -312,14 +_,20 @@ } private void destroy() { @@ -59,7 +59,7 @@ + this.destroy(null); + } + -+ private void destroy(org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { ++ private void destroy(@Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { + this.discard(cause); + // CraftBukkit end this.level().gameEvent(GameEvent.ENTITY_DAMAGE, this.position(), GameEvent.Context.of(this)); @@ -73,7 +73,7 @@ } @Override -@@ -336,9 +_,14 @@ +@@ -334,9 +_,14 @@ @Override public boolean hurtServer(ServerLevel level, DamageSource damageSource, float amount) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch index e7c4ff58e..9aefb48e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/SpectralArrow.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/SpectralArrow.java +++ b/net/minecraft/world/entity/projectile/SpectralArrow.java -@@ -38,7 +_,7 @@ +@@ -39,7 +_,7 @@ protected void doPostHurtEffects(LivingEntity living) { super.doPostHurtEffects(living); MobEffectInstance mobEffectInstance = new MobEffectInstance(MobEffects.GLOWING, this.duration, 0); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch deleted file mode 100644 index bd84b5d13..000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java -+++ b/net/minecraft/world/entity/projectile/ThrowableItemProjectile.java -@@ -35,6 +_,12 @@ - - protected abstract Item getDefaultItem(); - -+ // CraftBukkit start -+ public Item getDefaultItemPublic() { -+ return this.getDefaultItem(); -+ } -+ // CraftBukkit end -+ - @Override - public ItemStack getItem() { - return this.getEntityData().get(DATA_ITEM_STACK); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch index 3a35555ec..c46b5f9bd 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrowableProjectile.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -59,7 +_,7 @@ +@@ -60,7 +_,7 @@ this.applyEffectsFromBlocks(); super.tick(); if (hitResultOnMoveVector.getType() != HitResult.Type.MISS && this.isAlive()) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch index a19b02d29..eb860455a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/net/minecraft/world/entity/projectile/ThrownEgg.java -@@ -59,28 +_,62 @@ +@@ -61,31 +_,66 @@ protected void onHit(HitResult result) { super.onHit(result); if (!this.level().isClientSide) { @@ -8,29 +8,25 @@ + // CraftBukkit start + boolean hatching = this.random.nextInt(8) == 0; + if (true) { -+ // CraftBukkit end ++ // CraftBukkit end int i = 1; if (this.random.nextInt(32) == 0) { i = 4; } + // CraftBukkit start -+ org.bukkit.entity.EntityType hatchingType = org.bukkit.entity.EntityType.CHICKEN; -+ -+ net.minecraft.world.entity.Entity shooter = this.getOwner(); + if (!hatching) { + i = 0; + } ++ ++ net.minecraft.world.entity.Entity shooter = this.getOwner(); ++ org.bukkit.entity.EntityType hatchingType = org.bukkit.entity.EntityType.CHICKEN; + if (shooter instanceof net.minecraft.server.level.ServerPlayer) { + org.bukkit.event.player.PlayerEggThrowEvent event = new org.bukkit.event.player.PlayerEggThrowEvent((org.bukkit.entity.Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) i, hatchingType); -+ this.level().getCraftServer().getPluginManager().callEvent(event); ++ event.callEvent(); + -+ i = event.getNumHatches(); + hatching = event.isHatching(); ++ i = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0 + hatchingType = event.getHatchingType(); -+ // If hatching is set to false, ensure child count is 0 -+ if (!hatching) { -+ i = 0; -+ } + } + // CraftBukkit end + // Paper start - Add ThrownEggHatchEvent @@ -39,11 +35,12 @@ + hatching = event.isHatching(); + i = hatching ? event.getNumHatches() : 0; // If hatching is set to false, ensure child count is 0 + hatchingType = event.getHatchingType(); ++ EntityType newEntityType = org.bukkit.craftbukkit.entity.CraftEntityType.bukkitToMinecraft(hatchingType); + // Paper end - Add ThrownEggHatchEvent for (int i1 = 0; i1 < i; i1++) { - Chicken chicken = EntityType.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED); -+ net.minecraft.world.entity.Entity chicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit ++ net.minecraft.world.entity.Entity chicken = newEntityType.create(this.level(), net.minecraft.world.entity.EntitySpawnReason.TRIGGERED); // CraftBukkit if (chicken != null) { - chicken.setAge(-24000); + // CraftBukkit start @@ -51,7 +48,17 @@ + ageable.setBaby(); + } + // CraftBukkit end - chicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); + chicken.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F); +- Optional.ofNullable(this.getItem().get(DataComponents.CHICKEN_VARIANT)) +- .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess())) +- .ifPresent(chicken::setVariant); ++ // CraftBukkit start ++ if (chicken instanceof Chicken realChicken) { ++ Optional.ofNullable(this.getItem().get(DataComponents.CHICKEN_VARIANT)) ++ .flatMap(eitherHolder -> eitherHolder.unwrap(this.registryAccess())) ++ .ifPresent(realChicken::setVariant); ++ } ++ // CraftBukkit end if (!chicken.fudgePositionAfterSizeChange(ZERO_SIZED_DIMENSIONS)) { break; } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch index 10a6491ba..93f24a1db 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEnderpearl.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEnderpearl.java +++ b/net/minecraft/world/entity/projectile/ThrownEnderpearl.java -@@ -126,11 +_,18 @@ +@@ -122,11 +_,18 @@ Vec3 vec3 = this.oldPosition(); if (owner instanceof ServerPlayer serverPlayer) { if (serverPlayer.connection.isAcceptingMessages()) { @@ -14,13 +14,13 @@ if (this.random.nextFloat() < 0.05F && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) { Endermite endermite = EntityType.ENDERMITE.create(serverLevel, EntitySpawnReason.TRIGGERED); if (endermite != null) { - endermite.moveTo(owner.getX(), owner.getY(), owner.getZ(), owner.getYRot(), owner.getXRot()); + endermite.snapTo(owner.getX(), owner.getY(), owner.getZ(), owner.getYRot(), owner.getXRot()); - serverLevel.addFreshEntity(endermite); + serverLevel.addFreshEntity(endermite, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.ENDER_PEARL); } } -@@ -138,15 +_,17 @@ +@@ -134,15 +_,17 @@ owner.setPortalCooldown(); } @@ -44,7 +44,7 @@ } this.playSound(serverLevel, vec3); -@@ -162,9 +_,9 @@ +@@ -158,9 +_,9 @@ this.playSound(serverLevel, vec3); } @@ -56,7 +56,7 @@ } } } -@@ -185,7 +_,7 @@ +@@ -181,7 +_,7 @@ if (owner instanceof ServerPlayer serverPlayer && !owner.isAlive() && serverPlayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) { @@ -65,7 +65,7 @@ } else { super.tick(); } -@@ -212,7 +_,7 @@ +@@ -208,7 +_,7 @@ public Entity teleport(TeleportTransition teleportTransition) { Entity entity = super.teleport(teleportTransition); if (entity != null) { @@ -74,7 +74,7 @@ } return entity; -@@ -220,7 +_,7 @@ +@@ -216,7 +_,7 @@ @Override public boolean canTeleport(Level fromLevel, Level toLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch index e560b1ef1..81432d05e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownExperienceBottle.java.patch @@ -7,7 +7,7 @@ - this.level().levelEvent(2002, this.blockPosition(), -13083194); + // CraftBukkit - moved to after event int i = 3 + this.level().random.nextInt(5) + this.level().random.nextInt(5); -- ExperienceOrb.award((ServerLevel)this.level(), this.position(), i); +- ExperienceOrb.award((ServerLevel)this.level(), result.getLocation(), i); - this.discard(); + // CraftBukkit start + org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, result, i); @@ -16,7 +16,7 @@ + this.level().levelEvent(net.minecraft.world.level.block.LevelEvent.PARTICLES_SPELL_POTION_SPLASH, this.blockPosition(), net.minecraft.world.item.alchemy.PotionContents.BASE_POTION_COLOR); + } + // CraftBukkit end -+ ExperienceOrb.award((ServerLevel)this.level(), this.position(), i, org.bukkit.entity.ExperienceOrb.SpawnReason.EXP_BOTTLE, this.getOwner(), this); // Paper ++ ExperienceOrb.award((ServerLevel)this.level(), result.getLocation(), i, org.bukkit.entity.ExperienceOrb.SpawnReason.EXP_BOTTLE, this.getOwner(), this); // Paper + this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch new file mode 100644 index 000000000..f945feb01 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java ++++ b/net/minecraft/world/entity/projectile/ThrownLingeringPotion.java +@@ -30,7 +_,7 @@ + } + + @Override +- public void onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity) { ++ public boolean onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity, @Nullable net.minecraft.world.phys.HitResult hitResult) { // Paper - Pass HitResult // Paper - More projectile API + AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); + if (this.getOwner() instanceof LivingEntity livingEntity) { + areaEffectCloud.setOwner(livingEntity); +@@ -42,6 +_,15 @@ + areaEffectCloud.setWaitTime(10); + areaEffectCloud.setRadiusPerTick(-areaEffectCloud.getRadius() / areaEffectCloud.getDuration()); + areaEffectCloud.applyComponentsFromItemStack(stack); ++ boolean noEffects = this.getItem().getOrDefault(net.minecraft.core.component.DataComponents.POTION_CONTENTS, net.minecraft.world.item.alchemy.PotionContents.EMPTY).hasEffects(); // Paper - Fix potions splash events ++ // CraftBukkit start ++ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, hitResult, areaEffectCloud); ++ if (!(event.isCancelled() || areaEffectCloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !areaEffectCloud.potionContents.hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling + level.addFreshEntity(areaEffectCloud); ++ } else { ++ areaEffectCloud.discard(null); ++ } ++ // CraftBukkit end ++ return !event.isCancelled(); // Paper - Fix potions splash events + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch deleted file mode 100644 index 8c092de10..000000000 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownPotion.java.patch +++ /dev/null @@ -1,193 +0,0 @@ ---- a/net/minecraft/world/entity/projectile/ThrownPotion.java -+++ b/net/minecraft/world/entity/projectile/ThrownPotion.java -@@ -82,51 +_,86 @@ - @Override - protected void onHit(HitResult result) { - super.onHit(result); -+ // Paper start - More projectile API -+ this.splash(result); -+ } -+ public void splash(@Nullable HitResult result) { -+ // Paper end - More projectile API - if (this.level() instanceof ServerLevel serverLevel) { - ItemStack item = this.getItem(); - PotionContents potionContents = item.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); -+ boolean showParticles = true; // Paper - Fix potions splash events - if (potionContents.is(Potions.WATER)) { -- this.applyWater(serverLevel); -- } else if (potionContents.hasEffects()) { -+ showParticles = this.applyWater(serverLevel, result); // Paper - Fix potions splash events -+ } else if (true || potionContents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply - if (this.isLingering()) { -- this.makeAreaOfEffectCloud(potionContents); -+ showParticles = this.makeAreaOfEffectCloud(potionContents, result); // CraftBukkit - Pass HitResult // Paper - } else { -- this.applySplash( -- serverLevel, potionContents.getAllEffects(), result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null -+ showParticles = this.applySplash( // Paper - Fix potions splash events -+ serverLevel, potionContents.getAllEffects(), result != null && result.getType() == HitResult.Type.ENTITY ? ((EntityHitResult)result).getEntity() : null, result // CraftBukkit - Pass HitResult // Paper - More projectile API - ); - } - } - -+ if (showParticles) { // Paper - Fix potions splash events - int i = potionContents.potion().isPresent() && potionContents.potion().get().value().hasInstantEffects() ? 2007 : 2002; - serverLevel.levelEvent(i, this.blockPosition(), potionContents.getColor()); -- this.discard(); -+ } // Paper - Fix potions splash events -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause - } - } - -- private void applyWater(ServerLevel level) { -+ private static final Predicate APPLY_WATER_GET_ENTITIES_PREDICATE = ThrownPotion.WATER_SENSITIVE_OR_ON_FIRE.or(Axolotl.class::isInstance); // Paper - Fix potions splash events -+ -+ private boolean applyWater(ServerLevel level, @Nullable HitResult result) { // Paper - Fix potions splash events - AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0); - -- for (LivingEntity livingEntity : this.level().getEntitiesOfClass(LivingEntity.class, aabb, WATER_SENSITIVE_OR_ON_FIRE)) { -+ // Paper start - Fix potions splash events -+ java.util.Map affected = new java.util.HashMap<>(); -+ java.util.Set rehydrate = new java.util.HashSet<>(); -+ java.util.Set extinguish = new java.util.HashSet<>(); -+ for (LivingEntity livingEntity : this.level().getEntitiesOfClass(LivingEntity.class, aabb, APPLY_WATER_GET_ENTITIES_PREDICATE)) { -+ if (livingEntity instanceof Axolotl axolotl) { -+ rehydrate.add(((org.bukkit.entity.Axolotl) axolotl.getBukkitEntity())); -+ } -+ // Paper end - Fix potions splash events - double d = this.distanceToSqr(livingEntity); - if (d < 16.0) { - if (livingEntity.isSensitiveToWater()) { -- livingEntity.hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F); -+ affected.put(livingEntity.getBukkitLivingEntity(), 1.0); // Paper - Fix potions splash events - } - - if (livingEntity.isOnFire() && livingEntity.isAlive()) { -- livingEntity.extinguishFire(); -+ extinguish.add(livingEntity.getBukkitLivingEntity()); // Paper - Fix potions splash events - } - } - } - -- for (Axolotl axolotl : this.level().getEntitiesOfClass(Axolotl.class, aabb)) { -- axolotl.rehydrate(); -+ // Paper start - Fix potions splash events -+ io.papermc.paper.event.entity.WaterBottleSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callWaterBottleSplashEvent( -+ this, result, affected, rehydrate, extinguish -+ ); -+ if (!event.isCancelled()) { -+ for (org.bukkit.entity.LivingEntity affectedEntity : event.getToDamage()) { -+ ((org.bukkit.craftbukkit.entity.CraftLivingEntity) affectedEntity).getHandle().hurtServer(level, this.damageSources().indirectMagic(this, this.getOwner()), 1.0F); -+ } -+ for (org.bukkit.entity.LivingEntity toExtinguish : event.getToExtinguish()) { -+ ((org.bukkit.craftbukkit.entity.CraftLivingEntity) toExtinguish).getHandle().extinguishFire(); -+ } -+ for (org.bukkit.entity.LivingEntity toRehydrate : event.getToRehydrate()) { -+ if (((org.bukkit.craftbukkit.entity.CraftLivingEntity) toRehydrate).getHandle() instanceof Axolotl axolotl) { -+ axolotl.rehydrate(); -+ } -+ } -+ // Paper end - Fix potions splash events - } -+ return !event.isCancelled(); // Paper - Fix potions splash events - } - -- private void applySplash(ServerLevel level, Iterable effects, @Nullable Entity entity) { -+ private boolean applySplash(ServerLevel level, Iterable effects, @Nullable Entity entity, @Nullable HitResult result) { // CraftBukkit - Pass HitResult // Paper - Fix potions splash events & More projectile API - AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0); - List entitiesOfClass = level.getEntitiesOfClass(LivingEntity.class, aabb); -+ java.util.Map affected = new java.util.HashMap<>(); // CraftBukkit - if (!entitiesOfClass.isEmpty()) { - Entity effectSource = this.getEffectSource(); - -@@ -135,12 +_,31 @@ - double d = this.distanceToSqr(livingEntity); - if (d < 16.0) { - double d1; -+ // Paper - diff on change, used when calling the splash event for water splash potions - if (livingEntity == entity) { - d1 = 1.0; - } else { - d1 = 1.0 - Math.sqrt(d) / 4.0; - } - -+ affected.put(livingEntity.getBukkitLivingEntity(), d1); -+ // CraftBukkit start -+ } -+ } -+ } -+ } -+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, result, affected); -+ if (!event.isCancelled() && !entitiesOfClass.isEmpty()) { // do not process effects if there are no effects to process -+ Entity effectSource = this.getEffectSource(); -+ for (org.bukkit.entity.LivingEntity victim : event.getAffectedEntities()) { -+ if (!(victim instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity craftLivingEntity)) { -+ continue; -+ } -+ LivingEntity livingEntity = craftLivingEntity.getHandle(); -+ double d1 = event.getIntensity(victim); -+ { -+ { -+ // CraftBukkit end - for (MobEffectInstance mobEffectInstance : effects) { - Holder effect = mobEffectInstance.getEffect(); - if (effect.value().isInstantenous()) { -@@ -151,7 +_,7 @@ - effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible() - ); - if (!mobEffectInstance1.endsWithin(20)) { -- livingEntity.addEffect(mobEffectInstance1, effectSource); -+ livingEntity.addEffect(mobEffectInstance1, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit - } - } - } -@@ -159,9 +_,10 @@ - } - } - } -+ return !event.isCancelled(); // Paper - Fix potions splash events - } - -- private void makeAreaOfEffectCloud(PotionContents potionContents) { -+ private boolean makeAreaOfEffectCloud(PotionContents potionContents, @Nullable HitResult result) { // CraftBukkit - Pass HitResult // Paper - More projectile API - AreaEffectCloud areaEffectCloud = new AreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ()); - if (this.getOwner() instanceof LivingEntity livingEntity) { - areaEffectCloud.setOwner(livingEntity); -@@ -172,7 +_,16 @@ - areaEffectCloud.setWaitTime(10); - areaEffectCloud.setRadiusPerTick(-areaEffectCloud.getRadius() / areaEffectCloud.getDuration()); - areaEffectCloud.setPotionContents(potionContents); -- this.level().addFreshEntity(areaEffectCloud); -+ boolean noEffects = potionContents.hasEffects(); // Paper - Fix potions splash events -+ // CraftBukkit start -+ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, result, areaEffectCloud); -+ if (!(event.isCancelled() || areaEffectCloud.isRemoved() || (!event.allowsEmptyCreation() && (noEffects && !areaEffectCloud.potionContents.hasEffects())))) { // Paper - don't spawn area effect cloud if the effects were empty and not changed during the event handling -+ this.level().addFreshEntity(areaEffectCloud); -+ } else { -+ areaEffectCloud.discard(null); // add Bukkit remove cause -+ } -+ // CraftBukkit end -+ return !event.isCancelled(); // Paper - Fix potions splash events - } - - public boolean isLingering() { -@@ -182,13 +_,19 @@ - private void dowseFire(BlockPos pos) { - BlockState blockState = this.level().getBlockState(pos); - if (blockState.is(BlockTags.FIRE)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state - this.level().destroyBlock(pos, false, this); -+ } // CraftBukkit - } else if (AbstractCandleBlock.isLit(blockState)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(AbstractCandleBlock.LIT, Boolean.valueOf(false)))) { // CraftBukkit - AbstractCandleBlock.extinguish(null, blockState, this.level(), pos); -+ } // CraftBukkit - } else if (CampfireBlock.isLitCampfire(blockState)) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)))) { // CraftBukkit - this.level().levelEvent(null, 1009, pos, 0); - CampfireBlock.dowse(this.getOwner(), this.level(), pos, blockState); - this.level().setBlockAndUpdate(pos, blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false))); -+ } // CraftBukkit - } - } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch new file mode 100644 index 000000000..a5890d24b --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownSplashPotion.java.patch @@ -0,0 +1,65 @@ +--- a/net/minecraft/world/entity/projectile/ThrownSplashPotion.java ++++ b/net/minecraft/world/entity/projectile/ThrownSplashPotion.java +@@ -36,12 +_,13 @@ + } + + @Override +- public void onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity) { ++ public boolean onHitAsPotion(ServerLevel level, ItemStack stack, @Nullable Entity entity, @Nullable net.minecraft.world.phys.HitResult hitResult) { // Paper - Add HitResult parameter // Paper - More projectile API + PotionContents potionContents = stack.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); + float orDefault = stack.getOrDefault(DataComponents.POTION_DURATION_SCALE, 1.0F); + Iterable allEffects = potionContents.getAllEffects(); + AABB aabb = this.getBoundingBox().inflate(4.0, 2.0, 4.0); + List entitiesOfClass = this.level().getEntitiesOfClass(LivingEntity.class, aabb); ++ java.util.Map affected = new java.util.HashMap<>(); // CraftBukkit + if (!entitiesOfClass.isEmpty()) { + Entity effectSource = this.getEffectSource(); + +@@ -50,12 +_,31 @@ + double d = this.distanceToSqr(livingEntity); + if (d < 16.0) { + double d1; ++ // Paper - diff on change, used when calling the splash event for water splash potions + if (livingEntity == entity) { + d1 = 1.0; + } else { + d1 = 1.0 - Math.sqrt(d) / 4.0; + } + ++ // CraftBukkit start ++ affected.put(livingEntity.getBukkitLivingEntity(), d1); ++ } ++ } ++ } ++ } ++ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, hitResult, affected); ++ if (!event.isCancelled() && !entitiesOfClass.isEmpty()) { // do not process effects if there are no effects to process ++ Entity effectSource = this.getEffectSource(); ++ for (org.bukkit.entity.LivingEntity victim : event.getAffectedEntities()) { ++ if (!(victim instanceof org.bukkit.craftbukkit.entity.CraftLivingEntity craftLivingEntity)) { ++ continue; ++ } ++ LivingEntity livingEntity = craftLivingEntity.getHandle(); ++ double d1 = event.getIntensity(victim); ++ { ++ { ++ // CraftBukkit end + for (MobEffectInstance mobEffectInstance : allEffects) { + Holder effect = mobEffectInstance.getEffect(); + if (effect.value().isInstantenous()) { +@@ -66,7 +_,7 @@ + effect, i, mobEffectInstance.getAmplifier(), mobEffectInstance.isAmbient(), mobEffectInstance.isVisible() + ); + if (!mobEffectInstance1.endsWithin(20)) { +- livingEntity.addEffect(mobEffectInstance1, effectSource); ++ livingEntity.addEffect(mobEffectInstance1, effectSource, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_SPLASH); // CraftBukkit + } + } + } +@@ -74,5 +_,6 @@ + } + } + } ++ return !event.isCancelled(); // Paper - Fix potions splash events + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch index dad0da0b9..6b8b6812e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownTrident.java +++ b/net/minecraft/world/entity/projectile/ThrownTrident.java -@@ -32,16 +_,19 @@ +@@ -33,16 +_,19 @@ public ThrownTrident(EntityType entityType, Level level) { super(entityType, level); @@ -20,7 +20,7 @@ this.entityData.set(ID_LOYALTY, this.getLoyaltyFromItem(pickupItemStack)); this.entityData.set(ID_FOIL, pickupItemStack.hasFoil()); } -@@ -67,10 +_,10 @@ +@@ -68,10 +_,10 @@ this.spawnAtLocation(serverLevel, this.getPickupItem(), 0.1F); } @@ -33,7 +33,7 @@ return; } -@@ -99,6 +_,20 @@ +@@ -100,6 +_,20 @@ return this.entityData.get(ID_FOIL); } @@ -54,12 +54,12 @@ @Nullable @Override protected EntityHitResult findHitEntity(Vec3 startVec, Vec3 endVec) { -@@ -108,7 +_,7 @@ +@@ -109,7 +_,7 @@ @Override protected void onHitEntity(EntityHitResult result) { Entity entity = result.getEntity(); - float f = 8.0F; -+ float f = (float) this.getBaseDamage(); // Paper - Allow trident custom damage ++ float f = (float) this.baseDamage; // Paper - Allow trident custom damage Entity owner = this.getOwner(); DamageSource damageSource = this.damageSources().trident(this, (Entity)(owner == null ? this : owner)); if (this.level() instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch index 2eef3589e..71e3572b0 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/WitherSkull.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/WitherSkull.java +++ b/net/minecraft/world/entity/projectile/WitherSkull.java -@@ -65,11 +_,11 @@ +@@ -66,11 +_,11 @@ if (var8.isAlive()) { EnchantmentHelper.doPostAttackEffects(serverLevel, var8, damageSource); } else { @@ -14,7 +14,7 @@ } if (flag && var8 instanceof LivingEntity livingEntityx) { -@@ -81,7 +_,7 @@ +@@ -82,7 +_,7 @@ } if (i > 0) { @@ -23,7 +23,7 @@ } } } -@@ -91,8 +_,15 @@ +@@ -92,8 +_,13 @@ protected void onHit(HitResult result) { super.onHit(result); if (!this.level().isClientSide) { @@ -31,9 +31,7 @@ - this.discard(); + // CraftBukkit start + org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false); -+ this.level().getCraftServer().getPluginManager().callEvent(event); -+ -+ if (!event.isCancelled()) { ++ if (event.callEvent()) { + this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.MOB); + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch index 52c955c67..752fef308 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raid.java.patch @@ -1,30 +1,51 @@ --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -104,6 +_,11 @@ - private Raid.RaidStatus status; - private int celebrationTicks; - private Optional waveSpawnPos = Optional.empty(); +@@ -59,6 +_,12 @@ + import net.minecraft.world.phys.Vec3; + + public class Raid { + // Paper start + private static final String PDC_NBT_KEY = "BukkitValues"; + private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry PDC_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); -+ public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY); ++ public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; ++ public int idOrNegativeOne = -1; + // Paper end + public static final SpawnPlacementType RAVAGER_SPAWN_PLACEMENT_TYPE = SpawnPlacements.getPlacementType(EntityType.RAVAGER); + public static final MapCodec MAP_CODEC = RecordCodecBuilder.mapCodec( + instance -> instance.group( +@@ -74,6 +_,7 @@ + Raid.RaidStatus.CODEC.fieldOf("status").forGetter(raid -> raid.status), + BlockPos.CODEC.fieldOf("center").forGetter(raid -> raid.center), + UUIDUtil.CODEC_SET.fieldOf("heroes_of_the_village").forGetter(raid -> raid.heroesOfTheVillage) ++ , org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer.createCodec(PDC_TYPE_REGISTRY).fieldOf(PDC_NBT_KEY).forGetter(raid -> raid.persistentDataContainer) + ) + .apply(instance, Raid::new) + ); +@@ -126,6 +_,7 @@ + this.center = center; + this.numGroups = this.getNumGroups(difficulty); + this.status = Raid.RaidStatus.ONGOING; ++ this.persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(PDC_TYPE_REGISTRY); // Paper - add persistent data container + } - public Raid(int id, ServerLevel level, BlockPos center) { - this.id = id; -@@ -136,6 +_,11 @@ - this.heroesOfTheVillage.add(NbtUtils.loadUUID(tag)); - } - } -+ // Paper start -+ if (compound.contains(PDC_NBT_KEY, net.minecraft.nbt.Tag.TAG_COMPOUND)) { -+ this.persistentDataContainer.putAll(compound.getCompound(PDC_NBT_KEY)); -+ } -+ // Paper end + private Raid( +@@ -141,6 +_,7 @@ + Raid.RaidStatus status, + BlockPos center, + Set heroesOfTheVillage ++ , final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer // Paper - add persistent data container + ) { + this.started = started; + this.active = active; +@@ -154,6 +_,7 @@ + this.numGroups = numGroups; + this.status = status; + this.heroesOfTheVillage.addAll(heroesOfTheVillage); ++ this.persistentDataContainer = persistentDataContainer; // Paper - add persistent data container } public boolean isOver() { -@@ -162,6 +_,12 @@ +@@ -180,6 +_,12 @@ return this.status == Raid.RaidStatus.LOSS; } @@ -37,107 +58,94 @@ public float getTotalHealth() { return this.totalHealth; } -@@ -252,6 +_,7 @@ +@@ -266,6 +_,7 @@ boolean flag = this.active; - this.active = this.level.hasChunkAt(this.center); - if (this.level.getDifficulty() == Difficulty.PEACEFUL) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit + this.active = level.hasChunkAt(this.center); + if (level.getDifficulty() == Difficulty.PEACEFUL) { ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.PEACE); // CraftBukkit this.stop(); return; } -@@ -271,13 +_,16 @@ - if (!this.level.isVillage(this.center)) { +@@ -285,13 +_,16 @@ + if (!level.isVillage(this.center)) { if (this.groupsSpawned > 0) { this.status = Raid.RaidStatus.LOSS; -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, new java.util.ArrayList<>()); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(level, this, new java.util.ArrayList<>()); // CraftBukkit } else { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.NOT_IN_VILLAGE); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.NOT_IN_VILLAGE); // CraftBukkit this.stop(); } } this.ticksActive++; if (this.ticksActive >= 48000L) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.TIMEOUT); // CraftBukkit this.stop(); return; } -@@ -346,6 +_,7 @@ +@@ -360,6 +_,7 @@ } if (i > 5) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit this.stop(); break; } -@@ -357,6 +_,7 @@ +@@ -371,6 +_,7 @@ } else { this.status = Raid.RaidStatus.VICTORY; + List winners = new java.util.ArrayList<>(); // CraftBukkit for (UUID uuid : this.heroesOfTheVillage) { - Entity entity = this.level.getEntity(uuid); - if (entity instanceof LivingEntity) { -@@ -368,10 +_,12 @@ - if (livingEntity instanceof ServerPlayer serverPlayer) { - serverPlayer.awardStat(Stats.RAID_WIN); - CriteriaTriggers.RAID_WIN.trigger(serverPlayer); -+ winners.add(serverPlayer.getBukkitEntity()); // CraftBukkit - } + Entity entity = level.getEntity(uuid); + if (entity instanceof LivingEntity livingEntity && !entity.isSpectator()) { +@@ -378,9 +_,11 @@ + if (livingEntity instanceof ServerPlayer serverPlayer) { + serverPlayer.awardStat(Stats.RAID_WIN); + CriteriaTriggers.RAID_WIN.trigger(serverPlayer); ++ winners.add(serverPlayer.getBukkitEntity()); // CraftBukkit } } } -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(this, winners); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidFinishEvent(level, this, winners); // CraftBukkit } } -@@ -379,6 +_,7 @@ +@@ -388,6 +_,7 @@ } else if (this.isOver()) { this.celebrationTicks++; if (this.celebrationTicks >= 600) { -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.FINISHED); // CraftBukkit this.stop(); return; } -@@ -486,7 +_,7 @@ +@@ -492,7 +_,7 @@ - private void spawnGroup(BlockPos pos) { + private void spawnGroup(ServerLevel level, BlockPos pos) { boolean flag = false; - int i = this.groupsSpawned + 1; + int i = this.groupsSpawned + 1; final int wave = i; // Paper - OBFHELPER this.totalHealth = 0.0F; - DifficultyInstance currentDifficultyAt = this.level.getCurrentDifficultyAt(pos); + DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(pos); boolean shouldSpawnBonusGroup = this.shouldSpawnBonusGroup(); -@@ -535,6 +_,7 @@ +@@ -541,6 +_,7 @@ this.groupsSpawned++; this.updateBossbar(); - this.setDirty(); -+ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(this, java.util.Objects.requireNonNull(this.getLeader(wave)), this.groupRaiderMap.get(wave)); // CraftBukkit + this.setDirty(level); ++ org.bukkit.craftbukkit.event.CraftEventFactory.callRaidSpawnWaveEvent(level, this, java.util.Objects.requireNonNull(this.getLeader(wave)), this.groupRaiderMap.get(wave)); // CraftBukkit } - public void joinRaid(int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) { -@@ -549,7 +_,7 @@ - raider.finalizeSpawn(this.level, this.level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); - raider.applyRaidBuffs(this.level, wave, false); + public void joinRaid(ServerLevel level, int wave, Raider raider, @Nullable BlockPos pos, boolean isRecruited) { +@@ -555,7 +_,7 @@ + raider.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.EVENT, null); + raider.applyRaidBuffs(level, wave, false); raider.setOnGround(true); -- this.level.addFreshEntityWithPassengers(raider); -+ this.level.addFreshEntityWithPassengers(raider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit +- level.addFreshEntityWithPassengers(raider); ++ level.addFreshEntityWithPassengers(raider, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.RAID); // CraftBukkit } } } -@@ -770,6 +_,11 @@ - } - - compound.put("HeroesOfTheVillage", listTag); -+ // Paper start -+ if (!this.persistentDataContainer.isEmpty()) { -+ compound.put(PDC_NBT_KEY, this.persistentDataContainer.toTagCompound()); -+ } -+ // Paper end - return compound; - } - -@@ -802,6 +_,12 @@ +@@ -774,6 +_,12 @@ public void addHeroOfTheVillage(Entity player) { this.heroesOfTheVillage.add(player.getUUID()); } @@ -148,5 +156,5 @@ + } + // CraftBukkit end - static enum RaidStatus { - ONGOING, + static enum RaidStatus implements StringRepresentable { + ONGOING("ongoing"), diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch index 59f462b6c..dac5a3ee4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raider.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java -@@ -212,17 +_,24 @@ +@@ -213,17 +_,24 @@ if (this.hasActiveRaid() && !flag && ItemStack.matches(item, Raid.getOminousBannerInstance(this.registryAccess().lookupOrThrow(Registries.BANNER_PATTERN)))) { @@ -11,7 +11,7 @@ + // Paper end - EntityPickupItemEvent fixes EquipmentSlot equipmentSlot = EquipmentSlot.HEAD; ItemStack itemBySlot = this.getItemBySlot(equipmentSlot); - double d = this.getEquipmentDropChance(equipmentSlot); + double d = this.getDropChances().byEquipment(equipmentSlot); if (!itemBySlot.isEmpty() && Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d) { + this.forceDrops = true; // Paper - Add missing forceDrop toggles this.spawnAtLocation(level, itemBySlot); @@ -26,25 +26,25 @@ this.getCurrentRaid().setLeader(this.getWave(), this); this.setPatrolLeader(true); } else { -@@ -296,7 +_,7 @@ +@@ -297,7 +_,7 @@ for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { - raider.setTarget(this.mob.getTarget()); -+ raider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit ++ raider.setTarget(this.mob.getTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER); // CraftBukkit } } -@@ -307,7 +_,7 @@ +@@ -308,7 +_,7 @@ if (target != null) { for (Raider raider : getServerLevel(this.mob) .getNearbyEntities(Raider.class, this.shoutTargeting, this.mob, this.mob.getBoundingBox().inflate(8.0, 8.0, 8.0))) { - raider.setTarget(target); -+ raider.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER, true); // CraftBukkit ++ raider.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FOLLOW_LEADER); // CraftBukkit raider.setAggressive(true); } -@@ -392,6 +_,7 @@ +@@ -393,6 +_,7 @@ } private boolean cannotPickUpBanner() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch index 89f05b3b2..a697f3cc9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/raid/Raids.java.patch @@ -1,28 +1,39 @@ --- a/net/minecraft/world/entity/raid/Raids.java +++ b/net/minecraft/world/entity/raid/Raids.java -@@ -112,11 +_,23 @@ - } +@@ -57,6 +_,7 @@ + private Raids(List raids, int nextId, int tick) { + for (Raids.RaidWithId raidWithId : raids) { + this.raidMap.put(raidWithId.id, raidWithId.raid); ++ raidWithId.raid.idOrNegativeOne = raidWithId.id; // Paper - expose id of raids while method is kept around as deprecated for removal + } - Raid raid = this.getOrCreateRaid(player.serverLevel(), blockPos); -+ /* CraftBukkit - moved down - if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) { - this.raidMap.put(raid.getId(), raid); - } + this.nextId = nextId; +@@ -141,11 +_,23 @@ + } + + Raid raid = this.getOrCreateRaid(serverLevel, blockPos); +- if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { +- this.raidMap.put(this.getUniqueId(), raid); +- } - -- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { -+ */ +- if (!raid.isStarted() || raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel()) { ++ // CraftBukkit - moved down ++ // if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ // this.raidMap.put(this.getUniqueId(), raid); ++ // } + -+ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(raid, player)) { -+ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); -+ return null; -+ } ++ if (!raid.isStarted() || (raid.isInProgress() && raid.getRaidOmenLevel() < raid.getMaxRaidOmenLevel())) { // CraftBukkit - fixed a bug with raid: players could add up Bad Omen level even when the raid had finished ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callRaidTriggerEvent(serverLevel, raid, player)) { ++ player.removeEffect(net.minecraft.world.effect.MobEffects.RAID_OMEN); ++ return null; ++ } + -+ if (!raid.isStarted() && !this.raidMap.containsKey(raid.getId())) { -+ this.raidMap.put(raid.getId(), raid); -+ } -+ // CraftBukkit end - raid.absorbRaidOmen(player); - } ++ if (!raid.isStarted() && !this.raidMap.containsValue(raid)) { ++ this.raidMap.put(this.getUniqueId(), raid); ++ raid.idOrNegativeOne = this.nextId; // Paper - expose id of raids while method is kept around as deprecated for removal ++ } ++ // CraftBukkit end + raid.absorbRaidOmen(player); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/variant/StructureCheck.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/variant/StructureCheck.java.patch new file mode 100644 index 000000000..fea326d41 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/variant/StructureCheck.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/entity/variant/StructureCheck.java ++++ b/net/minecraft/world/entity/variant/StructureCheck.java +@@ -15,7 +_,7 @@ + + @Override + public boolean test(SpawnContext context) { +- return context.level().getLevel().structureManager().getStructureWithPieceAt(context.pos(), this.requiredStructures).isValid(); ++ return context.level().getLevel().structureManager().getStructureWithPieceAt(context.pos(), this.requiredStructures, context.level()).isValid(); // Paper - Fix swamp hut cat generation deadlock + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch index 3d61d83b4..8d37dc117 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractBoat.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/AbstractBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -83,6 +_,15 @@ +@@ -79,6 +_,15 @@ private Leashable.LeashData leashData; private final Supplier dropItem; @@ -16,7 +16,7 @@ public AbstractBoat(EntityType entityType, Level level, Supplier dropItem) { super(entityType, level); this.dropItem = dropItem; -@@ -124,7 +_,7 @@ +@@ -120,7 +_,7 @@ } @Override @@ -25,7 +25,7 @@ return true; } -@@ -177,11 +_,30 @@ +@@ -175,11 +_,30 @@ @Override public void push(Entity entity) { @@ -56,7 +56,7 @@ super.push(entity); } } -@@ -283,6 +_,18 @@ +@@ -246,6 +_,18 @@ this.setDeltaMovement(Vec3.ZERO); } @@ -75,7 +75,7 @@ this.applyEffectsFromBlocks(); this.applyEffectsFromBlocks(); this.tickBubbleColumn(); -@@ -598,7 +_,7 @@ +@@ -548,7 +_,7 @@ this.waterLevel = this.getY(1.0); double d2 = this.getWaterLevelAbove() - this.getBbHeight() + 0.101; if (this.level().noCollision(this, this.getBoundingBox().move(0.0, d2 - this.getY(), 0.0))) { @@ -84,17 +84,12 @@ this.setDeltaMovement(this.getDeltaMovement().multiply(1.0, 0.0, 1.0)); this.lastYd = 0.0; } -@@ -762,11 +_,18 @@ +@@ -711,12 +_,12 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { -+ // CraftBukkit end +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide && reason.shouldDestroy() && this.isLeashed()) { this.dropLeash(); } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch index 9fd4787f9..80087e535 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractChestBoat.java.patch @@ -1,16 +1,11 @@ --- a/net/minecraft/world/entity/vehicle/AbstractChestBoat.java +++ b/net/minecraft/world/entity/vehicle/AbstractChestBoat.java -@@ -66,11 +_,18 @@ +@@ -65,12 +_,12 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { -+ // CraftBukkit end +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -78,7 +73,7 @@ + } + + @Override -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { + org.bukkit.entity.Entity entity = this.getBukkitEntity(); + return entity instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch index 35881f5e7..793116d49 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecart.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -74,6 +_,17 @@ - map.put(RailShape.NORTH_WEST, Pair.of(unitVec3i2, unitVec3i)); - map.put(RailShape.NORTH_EAST, Pair.of(unitVec3i2, unitVec3i1)); - }); +@@ -94,6 +_,17 @@ + } + ) + ); + // CraftBukkit start + public boolean slowWhenEmpty = true; + private double derailedX = 0.5; @@ -12,13 +12,13 @@ + private double flyingX = 0.95; + private double flyingY = 0.95; + private double flyingZ = 0.95; -+ public Double maxSpeed; ++ public @Nullable Double maxSpeed; + public net.kyori.adventure.util.TriState frictionState = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Friction API + // CraftBukkit end protected AbstractMinecart(EntityType entityType, Level level) { super(entityType, level); -@@ -134,11 +_,19 @@ +@@ -153,11 +_,19 @@ @Override public boolean canCollideWith(Entity entity) { @@ -29,7 +29,7 @@ + return false; + } + -+ org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) getBukkitEntity(), entity.getBukkitEntity()); ++ org.bukkit.event.vehicle.VehicleEntityCollisionEvent collisionEvent = new org.bukkit.event.vehicle.VehicleEntityCollisionEvent((org.bukkit.entity.Vehicle) this.getBukkitEntity(), entity.getBukkitEntity()); + return collisionEvent.callEvent(); + // Paper end - fix VehicleEntityCollisionEvent not called when colliding with player } @@ -40,7 +40,7 @@ return true; } -@@ -239,6 +_,14 @@ +@@ -258,6 +_,14 @@ @Override public void tick() { @@ -55,7 +55,7 @@ if (this.getHurtTime() > 0) { this.setHurtTime(this.getHurtTime() - 1); } -@@ -248,8 +_,20 @@ +@@ -267,8 +_,20 @@ } this.checkBelowWorld(); @@ -76,8 +76,8 @@ + // CraftBukkit end this.updateInWaterStateAndDoFluidPushing(); if (this.isInLava()) { - this.lavaHurt(); -@@ -360,12 +_,16 @@ + this.lavaIgnite(); +@@ -350,12 +_,16 @@ Vec3 deltaMovement = this.getDeltaMovement(); this.setDeltaMovement(Mth.clamp(deltaMovement.x, -maxSpeed, maxSpeed), deltaMovement.y, Mth.clamp(deltaMovement.z, -maxSpeed, maxSpeed)); if (this.onGround()) { @@ -96,24 +96,23 @@ } } -@@ -469,6 +_,16 @@ - - this.flipped = compound.getBoolean("FlippedRotation"); - this.firstTick = compound.getBoolean("HasTicked"); +@@ -457,6 +_,15 @@ + this.setDisplayOffset(compound.getIntOr("DisplayOffset", this.getDefaultDisplayOffset())); + this.flipped = compound.getBooleanOr("FlippedRotation", false); + this.firstTick = compound.getBooleanOr("HasTicked", false); + // Paper start - Friction API -+ if (compound.contains("Paper.FrictionState")) { -+ String fs = compound.getString("Paper.FrictionState"); ++ compound.getString("Paper.FrictionState").ifPresent(frictionState -> { + try { -+ frictionState = net.kyori.adventure.util.TriState.valueOf(fs); ++ this.frictionState = net.kyori.adventure.util.TriState.valueOf(frictionState); + } catch (Exception ignored) { -+ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state " + fs + " for " + this); ++ com.mojang.logging.LogUtils.getLogger().error("Unknown friction state {} for {}", frictionState, this); + } -+ } ++ }); + // Paper end - Friction API } @Override -@@ -481,13 +_,27 @@ +@@ -472,13 +_,27 @@ compound.putBoolean("FlippedRotation", this.flipped); compound.putBoolean("HasTicked", this.firstTick); @@ -141,7 +140,7 @@ double d = entity.getX() - this.getX(); double d1 = entity.getZ() - this.getZ(); double d2 = d * d + d1 * d1; -@@ -602,4 +_,28 @@ +@@ -587,4 +_,26 @@ public boolean isFurnace() { return false; } @@ -167,6 +166,4 @@ + this.derailedZ = derailed.getZ(); + } + // CraftBukkit end -+ -+ public net.minecraft.world.item.Item publicGetDropItem() { return getDropItem(); } // Paper - api to get boat and minecart material - expose public drop item } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch index 5289f0b57..9b1cbd423 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java.patch @@ -13,17 +13,12 @@ protected AbstractMinecartContainer(EntityType entityType, Level level) { super(entityType, level); -@@ -72,11 +_,18 @@ +@@ -71,12 +_,12 @@ + } @Override - public void remove(Entity.RemovalReason reason) { -+ // CraftBukkit start - add Bukkit remove cause -+ this.remove(reason, null); -+ } -+ -+ @Override -+ public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { -+ // CraftBukkit end - add Bukkit remove cause +- public void remove(Entity.RemovalReason reason) { ++ public void remove(Entity.RemovalReason reason, @Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause cause) { // CraftBukkit - add Bukkit remove cause if (!this.level().isClientSide && reason.shouldDestroy()) { Containers.dropContents(this.level(), this, this); } @@ -33,7 +28,7 @@ } @Override -@@ -164,4 +_,50 @@ +@@ -164,4 +_,56 @@ public void clearItemStacks() { this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); } @@ -49,23 +44,28 @@ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public java.util.List getContents() { + return this.itemStacks; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ @Override ++ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { + return this.getBukkitEntity() instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } + @@ -74,6 +74,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch index fea198069..72cec8ed4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/ContainerEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -62,22 +_,26 @@ +@@ -60,12 +_,12 @@ default void addChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) { if (this.getContainerLootTable() != null) { tag.putString("LootTable", this.getContainerLootTable().location().toString()); @@ -15,24 +15,21 @@ } default void readChestVehicleSaveData(CompoundTag tag, HolderLookup.Provider levelRegistry) { - this.clearItemStacks(); - if (tag.contains("LootTable", 8)) { -- this.setContainerLootTable(ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString("LootTable")))); -+ this.setContainerLootTable(net.minecraft.Optionull.map(ResourceLocation.tryParse(tag.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl))); // Paper - Validate ResourceLocation -+ // Paper start - LootTable API -+ if (this.getContainerLootTable() != null) { -+ this.lootableData().loadNbt(tag); -+ } -+ // Paper end - LootTable API - this.setContainerLootTableSeed(tag.getLong("LootTableSeed")); -- } else { -- ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry); +@@ -73,7 +_,12 @@ + ResourceKey resourceKey = tag.read("LootTable", LootTable.KEY_CODEC).orElse(null); + this.setContainerLootTable(resourceKey); + this.setContainerLootTableSeed(tag.getLongOr("LootTableSeed", 0L)); +- if (resourceKey == null) { ++ // Paper start - LootTable API ++ if (this.getContainerLootTable() != null) { ++ this.lootableData().loadNbt(tag); ++ } ++ // Paper end - LootTable API ++ if (true || resourceKey == null) { // Paper - always read the items, table may still remain + ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry); } -+ ContainerHelper.loadAllItems(tag, this.getItemStacks(), levelRegistry); // Paper - always read the items, table may still remain } - - default void chestVehicleDestroyed(DamageSource damageSource, ServerLevel level, Entity entity) { -@@ -91,19 +_,27 @@ +@@ -89,19 +_,27 @@ } default InteractionResult interactWithContainerVehicle(Player player) { @@ -63,7 +60,7 @@ LootParams.Builder builder = new LootParams.Builder((ServerLevel)this.level()).withParameter(LootContextParams.ORIGIN, this.position()); if (player != null) { builder.withLuck(player.getLuck()).withParameter(LootContextParams.THIS_ENTITY, player); -@@ -173,4 +_,14 @@ +@@ -171,4 +_,14 @@ default boolean isChestVehicleStillValid(Player player) { return !this.isRemoved() && player.canInteractWithEntity(this.getBoundingBox(), 4.0); } @@ -74,7 +71,7 @@ + } + + default com.destroystokyo.paper.loottable.PaperLootableInventory getLootableInventory() { -+ return ((com.destroystokyo.paper.loottable.PaperLootableInventory) ((net.minecraft.world.entity.Entity) this).getBukkitEntity()); ++ return ((com.destroystokyo.paper.loottable.PaperLootableInventory) ((Entity) this).getBukkitEntity()); + } + // Paper end - LootTable API } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch index 0f23c30d4..19c33d666 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/MinecartTNT.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/entity/vehicle/MinecartTNT.java +++ b/net/minecraft/world/entity/vehicle/MinecartTNT.java -@@ -33,6 +_,7 @@ +@@ -38,6 +_,7 @@ public int fuse = -1; public float explosionPowerBase = 4.0F; public float explosionSpeedFactor = 1.0F; -+ public boolean isIncendiary = false; // CraftBukkit - add field ++ public boolean isIncendiary = false; // CraftBukkit public MinecartTNT(EntityType entityType, Level level) { super(entityType, level); -@@ -47,6 +_,12 @@ +@@ -52,6 +_,12 @@ public void tick() { super.tick(); if (this.fuse > 0) { @@ -21,36 +21,39 @@ this.fuse--; this.level().addParticle(ParticleTypes.SMOKE, this.getX(), this.getY() + 0.5, this.getZ(), 0.0, 0.0, 0.0); } else if (this.fuse == 0) { -@@ -101,6 +_,17 @@ - protected void explode(@Nullable DamageSource damageSource, double radiusModifier) { +@@ -107,6 +_,17 @@ if (this.level() instanceof ServerLevel serverLevel) { - double min = Math.min(Math.sqrt(radiusModifier), 5.0); -+ // CraftBukkit start -+ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent( -+ this.getBukkitEntity(), -+ (float) (this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min), -+ this.isIncendiary -+ ); -+ if (!event.callEvent()) { -+ this.fuse = -1; -+ return; -+ } -+ // CraftBukkit end - serverLevel.explode( - this, - damageSource, -@@ -108,11 +_,11 @@ - this.getX(), - this.getY(), - this.getZ(), -- (float)(this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min), -- false, -+ event.getRadius(), // CraftBukkit - explosion prime event -+ event.getFire(), // CraftBukkit - explosion prime event - Level.ExplosionInteraction.TNT - ); -- this.discard(); -+ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + if (serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { + double min = Math.min(Math.sqrt(radiusModifier), 5.0); ++ // CraftBukkit start ++ org.bukkit.event.entity.ExplosionPrimeEvent event = new org.bukkit.event.entity.ExplosionPrimeEvent( ++ this.getBukkitEntity(), ++ (float) (this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min), ++ this.isIncendiary ++ ); ++ if (!event.callEvent()) { ++ this.fuse = -1; ++ return; ++ } ++ // CraftBukkit end + serverLevel.explode( + this, + damageSource, +@@ -114,13 +_,13 @@ + this.getX(), + this.getY(), + this.getZ(), +- (float)(this.explosionPowerBase + this.explosionSpeedFactor * this.random.nextDouble() * 1.5 * min), +- false, ++ event.getRadius(), // CraftBukkit - explosion prime event ++ event.getFire(), // CraftBukkit - explosion prime event + Level.ExplosionInteraction.TNT + ); +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause + } else if (this.isPrimed()) { +- this.discard(); ++ this.discard(null); // CraftBukkit + } } } - diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch index 31506e855..6e71e7a03 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/NewMinecartBehavior.java.patch @@ -7,7 +7,7 @@ + // CraftBukkit start + Double maxSpeed = this.minecart.maxSpeed; + if (maxSpeed != null) { -+ return (this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed); ++ return this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed; + } + // CraftBukkit end return level.getGameRules().getInt(GameRules.RULE_MINECART_MAX_SPEED) * (this.minecart.isInWater() ? 0.5 : 1.0) / 20.0; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch index cc3a0cf21..71c314ca3 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java +++ b/net/minecraft/world/entity/vehicle/OldMinecartBehavior.java -@@ -414,8 +_,22 @@ +@@ -378,8 +_,22 @@ && !(entity instanceof AbstractMinecart) && !this.minecart.isVehicle() && !entity.isPassenger()) { @@ -23,7 +23,7 @@ entity.push(this.minecart); } } -@@ -423,6 +_,12 @@ +@@ -387,6 +_,12 @@ } else { for (Entity entity1 : this.level().getEntities(this.minecart, aabb)) { if (!this.minecart.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof AbstractMinecart) { @@ -36,14 +36,14 @@ entity1.push(this.minecart); } } -@@ -443,11 +_,18 @@ +@@ -409,11 +_,18 @@ @Override public double getMaxSpeed(ServerLevel level) { + // CraftBukkit start + Double maxSpeed = this.minecart.maxSpeed; + if (maxSpeed != null) { -+ return (this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed); ++ return this.minecart.isInWater() ? maxSpeed / 2.0D : maxSpeed; + } + // CraftBukkit end return this.minecart.isInWater() ? 0.2 : 0.4; diff --git a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch index b18d67421..a13b83e49 100644 --- a/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/food/FoodData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/food/FoodData.java +++ b/net/minecraft/world/food/FoodData.java -@@ -12,6 +_,11 @@ +@@ -14,6 +_,11 @@ public float saturationLevel = 5.0F; public float exhaustionLevel; private int tickTimer; @@ -12,7 +12,7 @@ private void add(int foodLevel, float saturationLevel) { this.foodLevel = Mth.clamp(foodLevel + this.foodLevel, 0, 20); -@@ -26,6 +_,17 @@ +@@ -28,6 +_,17 @@ this.add(foodProperties.nutrition(), foodProperties.saturation()); } @@ -30,7 +30,7 @@ public void tick(ServerPlayer player) { ServerLevel serverLevel = player.serverLevel(); Difficulty difficulty = serverLevel.getDifficulty(); -@@ -34,29 +_,39 @@ +@@ -36,29 +_,39 @@ if (this.saturationLevel > 0.0F) { this.saturationLevel = Math.max(this.saturationLevel - 1.0F, 0.0F); } else if (difficulty != Difficulty.PEACEFUL) { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch index e9201236d..b705483ed 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractContainerMenu.java.patch @@ -1,21 +1,13 @@ --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -19,6 +_,8 @@ - import net.minecraft.ReportedException; - import net.minecraft.core.NonNullList; - import net.minecraft.core.registries.BuiltInRegistries; -+import net.minecraft.network.chat.Component; -+import net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.Mth; - import net.minecraft.world.Container; -@@ -63,6 +_,32 @@ +@@ -65,6 +_,36 @@ @Nullable private ContainerSynchronizer synchronizer; private boolean suppressRemoteUpdates; + // CraftBukkit start + public boolean checkReachable = true; + public abstract org.bukkit.inventory.InventoryView getBukkitView(); ++ + public void transferTo(AbstractContainerMenu other, org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + org.bukkit.inventory.InventoryView source = this.getBukkitView(), destination = other.getBukkitView(); + ((org.bukkit.craftbukkit.inventory.CraftInventory) source.getTopInventory()).getInventory().onClose(player); @@ -23,47 +15,51 @@ + ((org.bukkit.craftbukkit.inventory.CraftInventory) destination.getTopInventory()).getInventory().onOpen(player); + ((org.bukkit.craftbukkit.inventory.CraftInventory) destination.getBottomInventory()).getInventory().onOpen(player); + } -+ private Component title; -+ public final Component getTitle() { ++ ++ @Nullable ++ private net.minecraft.network.chat.Component title; ++ public final net.minecraft.network.chat.Component getTitle() { + // Paper start - return chat component with empty text instead of throwing error -+ // Preconditions.checkState(this.title != null, "Title not set"); -+ if (this.title == null){ -+ return Component.literal(""); ++ if (this.title == null) { ++ return net.minecraft.network.chat.Component.empty(); + } + // Paper end - return chat component with empty text instead of throwing error + return this.title; + } -+ public final void setTitle(Component title) { ++ ++ public final void setTitle(net.minecraft.network.chat.Component title) { + com.google.common.base.Preconditions.checkState(this.title == null, "Title already set"); + this.title = title; + } ++ + public void startOpen() {} + // CraftBukkit end protected AbstractContainerMenu(@Nullable MenuType menuType, int containerId) { this.menuType = menuType; -@@ -168,8 +_,18 @@ +@@ -176,8 +_,19 @@ if (this.synchronizer != null) { - this.synchronizer.sendInitialData(this, this.remoteSlots, this.remoteCarried, this.remoteDataSlots.toIntArray()); + this.synchronizer.sendInitialData(this, list, carried.copy(), this.remoteDataSlots.toIntArray()); - } - } + this.synchronizer.sendOffHandSlotChange(); // Paper - Sync offhand slot in menus; update player's offhand since the offhand slot is not added to the slots for menus but can be changed by swapping from a menu slot + } + } + -+ // CraftBukkit start ++ // CraftBukkit start - from synchronizeCarriedToRemote + public void broadcastCarriedItem() { -+ this.remoteCarried = this.getCarried().copy(); ++ ItemStack carried = this.getCarried(); ++ this.remoteCarried.force(carried); + if (this.synchronizer != null) { -+ this.synchronizer.sendCarriedChange(this, this.remoteCarried); ++ this.synchronizer.sendCarriedChange(this, carried.copy()); + } + } + // CraftBukkit end public void removeSlotListener(ContainerListener listener) { this.containerListeners.remove(listener); -@@ -235,7 +_,7 @@ +@@ -243,7 +_,7 @@ this.lastSlots.set(slotIndex, itemStack1); for (ContainerListener containerListener : this.containerListeners) { @@ -72,42 +68,7 @@ } } } -@@ -243,7 +_,7 @@ - private void synchronizeSlotToRemote(int slotIndex, ItemStack stack, Supplier supplier) { - if (!this.suppressRemoteUpdates) { - ItemStack itemStack = this.remoteSlots.get(slotIndex); -- if (!ItemStack.matches(itemStack, stack)) { -+ if (!this.matchesRemote(itemStack, stack)) { // Paper - add flag to simplify remote matching logic - ItemStack itemStack1 = supplier.get(); - this.remoteSlots.set(slotIndex, itemStack1); - if (this.synchronizer != null) { -@@ -267,7 +_,7 @@ - - private void synchronizeCarriedToRemote() { - if (!this.suppressRemoteUpdates) { -- if (!ItemStack.matches(this.getCarried(), this.remoteCarried)) { -+ if (!this.matchesRemote(this.getCarried(), this.remoteCarried)) { // Paper - add flag to simplify remote matching logic - this.remoteCarried = this.getCarried().copy(); - if (this.synchronizer != null) { - this.synchronizer.sendCarriedChange(this, this.remoteCarried); -@@ -276,6 +_,16 @@ - } - } - -+ // Paper start - add flag to simplify remote matching logic -+ private boolean matchesRemote(final ItemStack stack, final ItemStack other) { -+ if (this.synchronizer != null && this.synchronizer.player() != null && this.synchronizer.player().getBukkitEntity().simplifyContainerDesyncCheck()) { -+ // Only check the item type and count -+ return stack == other || (stack.getCount() == other.getCount() && ItemStack.isSameItem(stack, other)); -+ } -+ return ItemStack.matches(stack, other); -+ } -+ // Paper end - add flag to simplify remote matching logic -+ - public void setRemoteSlot(int slot, ItemStack stack) { - this.remoteSlots.set(slot, stack.copy()); - } -@@ -343,6 +_,7 @@ +@@ -351,6 +_,7 @@ this.resetQuickCraft(); } } else if (this.quickcraftStatus == 1) { @@ -115,7 +76,7 @@ Slot slot = this.slots.get(slotId); ItemStack carried = this.getCarried(); if (canItemQuickReplace(slot, carried, true) -@@ -367,6 +_,7 @@ +@@ -375,6 +_,7 @@ } int count = this.getCarried().getCount(); @@ -123,7 +84,7 @@ for (Slot slot1 : this.quickcraftSlots) { ItemStack carried1 = this.getCarried(); -@@ -379,12 +_,48 @@ +@@ -387,12 +_,48 @@ int min = Math.min(itemStack.getMaxStackSize(), slot1.getMaxStackSize(itemStack)); int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min); count -= min1 - i2; @@ -152,9 +113,9 @@ + this.setCarried(org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(newcursor)); + + org.bukkit.event.inventory.InventoryDragEvent event = new org.bukkit.event.inventory.InventoryDragEvent(view, (newcursor.getType() != org.bukkit.Material.AIR ? newcursor : null), org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(oldCursor), this.quickcraftType == 1, eventmap); -+ player.level().getCraftServer().getPluginManager().callEvent(event); ++ event.callEvent(); + -+ // Whether or not a change was made to the inventory that requires an update. ++ // Whether a change was made to the inventory that requires an update. + boolean needsUpdate = event.getResult() != org.bukkit.event.Event.Result.DEFAULT; + + if (event.getResult() != org.bukkit.event.Event.Result.DENY) { @@ -178,7 +139,7 @@ } this.resetQuickCraft(); -@@ -398,8 +_,11 @@ +@@ -406,8 +_,11 @@ if (slotId == -999) { if (!this.getCarried().isEmpty()) { if (clickAction == ClickAction.PRIMARY) { @@ -191,16 +152,16 @@ } else { player.drop(this.getCarried().split(1), true); } -@@ -461,8 +_,18 @@ +@@ -469,8 +_,18 @@ } slot.setChanged(); + // CraftBukkit start - Make sure the client has the right slot contents + if (player instanceof ServerPlayer serverPlayer && slot.getMaxStackSize() != 64) { -+ serverPlayer.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem())); ++ serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), slot.index, slot.getItem())); + // Updating a crafting inventory makes the client reset the result slot, have to send it again + if (this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.WORKBENCH || this.getBukkitView().getType() == org.bukkit.event.inventory.InventoryType.CRAFTING) { -+ serverPlayer.connection.send(new ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); ++ serverPlayer.connection.send(new net.minecraft.network.protocol.game.ClientboundContainerSetSlotPacket(this.containerId, this.incrementStateId(), 0, this.getSlot(0).getItem())); + } + } + // CraftBukkit end @@ -210,7 +171,7 @@ ItemStack item = inventory.getItem(button); Slot slot = this.slots.get(slotId); ItemStack carried = slot.getItem(); -@@ -582,8 +_,9 @@ +@@ -590,8 +_,9 @@ if (player instanceof ServerPlayer) { ItemStack carried = this.getCarried(); if (!carried.isEmpty()) { @@ -221,7 +182,7 @@ } } } -@@ -629,6 +_,14 @@ +@@ -637,6 +_,14 @@ public abstract boolean stillValid(Player player); protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { @@ -236,7 +197,7 @@ boolean flag = false; int i = startIndex; if (reverseDirection) { -@@ -639,18 +_,27 @@ +@@ -647,18 +_,27 @@ while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) { Slot slot = this.slots.get(i); ItemStack item = slot.getItem(); @@ -264,7 +225,7 @@ flag = true; } } -@@ -673,10 +_,21 @@ +@@ -681,10 +_,21 @@ while (reverseDirection ? i >= startIndex : i < endIndex) { Slot slotx = this.slots.get(i); ItemStack itemx = slotx.getItem(); @@ -286,7 +247,7 @@ flag = true; break; } -@@ -760,6 +_,11 @@ +@@ -768,6 +_,11 @@ } public ItemStack getCarried() { @@ -298,7 +259,7 @@ return this.carried; } -@@ -808,4 +_,15 @@ +@@ -820,4 +_,15 @@ this.stateId = this.stateId + 1 & 32767; return this.stateId; } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch index 0daa1431a..7fc235df8 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractCraftingMenu.java.patch @@ -15,8 +15,8 @@ this.height = height; - this.craftSlots = new TransientCraftingContainer(this, width, height); + // CraftBukkit start -+ this.craftSlots = new TransientCraftingContainer(this, width, height, playerInventory.player); // CraftBukkit - pass player -+ this.craftSlots.resultInventory = this.resultSlots; // CraftBukkit - let InventoryCrafting know about its result slot ++ this.craftSlots = new TransientCraftingContainer(this, width, height, playerInventory.player); ++ this.craftSlots.resultInventory = this.resultSlots; // let InventoryCrafting know about its result slot + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch index 4d7c9ff8f..cfc170467 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AbstractFurnaceMenu.java.patch @@ -5,18 +5,18 @@ private final RecipePropertySet acceptedInputs; private final RecipeBookType recipeBookType; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftFurnaceView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftFurnaceView view = null; ++ private final Inventory inventory; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftFurnaceView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryFurnace inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryFurnace((net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity) this.container); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftFurnaceView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftFurnaceView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end @@ -26,7 +26,7 @@ this.addSlot(new Slot(container, 0, 56, 17)); this.addSlot(new FurnaceFuelSlot(this, container, 1, 56, 53)); this.addSlot(new FurnaceResultSlot(inventory.player, container, 2, 116, 35)); -+ this.player = inventory; // CraftBukkit - save player ++ this.inventory = inventory; // CraftBukkit this.addStandardInventorySlots(inventory, 8, 84); this.addDataSlots(data); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch index a1143aed1..30f670375 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/AnvilMenu.java.patch @@ -46,7 +46,7 @@ if (blockState1 == null) { level.removeBlock(blockPos, false); level.levelEvent(1029, blockPos, 0); -@@ -128,8 +_,8 @@ +@@ -127,8 +_,8 @@ if (itemStack.isDamageableItem() && item.isValidRepairItem(item1)) { int min = Math.min(itemStack.getDamageValue(), itemStack.getMaxDamage() / 4); if (min <= 0) { @@ -57,7 +57,7 @@ return; } -@@ -144,8 +_,8 @@ +@@ -143,8 +_,8 @@ this.repairItemCountCost = i2; } else { if (!hasStoredEnchantments && (!itemStack.is(item1.getItem()) || !itemStack.isDamageableItem())) { @@ -68,7 +68,7 @@ return; } -@@ -191,7 +_,7 @@ +@@ -190,7 +_,7 @@ flag1 = true; } else { flag = true; @@ -77,7 +77,7 @@ intValue = enchantment.getMaxLevel(); } -@@ -209,8 +_,8 @@ +@@ -208,8 +_,8 @@ } if (flag1 && !flag) { @@ -88,7 +88,7 @@ return; } } -@@ -235,14 +_,16 @@ +@@ -234,14 +_,16 @@ } if (i1 == i && i1 > 0) { @@ -103,12 +103,12 @@ this.onlyRenaming = true; } -- if (this.cost.get() >= 40 && !this.player.getAbilities().instabuild) { -+ if (this.cost.get() >= this.maximumRepairCost && !this.player.getAbilities().instabuild) { // CraftBukkit +- if (this.cost.get() >= 40 && !this.player.hasInfiniteMaterials()) { ++ if (this.cost.get() >= this.maximumRepairCost && !this.player.hasInfiniteMaterials()) { // CraftBukkit itemStack = ItemStack.EMPTY; } -@@ -260,12 +_,13 @@ +@@ -259,12 +_,13 @@ EnchantmentHelper.setEnchantments(itemStack, mutable.toImmutable()); } @@ -125,7 +125,7 @@ } public static int calculateIncreasedRepairCost(int oldRepairCost) { -@@ -286,6 +_,7 @@ +@@ -285,6 +_,7 @@ } this.createResult(); @@ -133,7 +133,7 @@ return true; } else { return false; -@@ -301,4 +_,19 @@ +@@ -300,4 +_,19 @@ public int getCost() { return this.cost.get(); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch index e0549ad65..76af523d8 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BeaconMenu.java.patch @@ -21,17 +21,17 @@ private final ContainerLevelAccess access; private final ContainerData beaconData; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftBeaconView bukkitEntity = null; -+ private net.minecraft.world.entity.player.Inventory player; ++ private @Nullable org.bukkit.craftbukkit.inventory.view.CraftBeaconView view = null; ++ private final net.minecraft.world.entity.player.Inventory inventory; + // CraftBukkit end public BeaconMenu(int containerId, Container container) { this(containerId, container, new SimpleContainerData(3), ContainerLevelAccess.NULL); -@@ -43,6 +_,27 @@ +@@ -43,6 +_,25 @@ public BeaconMenu(int containerId, Container container, ContainerData beaconData, ContainerLevelAccess access) { super(MenuType.BEACON, containerId); -+ this.player = (net.minecraft.world.entity.player.Inventory) container; // CraftBukkit - TODO: check this ++ this.inventory = (net.minecraft.world.entity.player.Inventory) container; // CraftBukkit - TODO: check this + // Paper - Add missing InventoryHolders + this.beacon = new SimpleContainer(this.createBlockHolder(access), 1) { + @Override @@ -44,12 +44,10 @@ + return 1; + } + -+ // Paper start - Fix inventories returning null Locations + @Override + public org.bukkit.Location getLocation() { + return access.getLocation(); + } -+ // Paper end - Fix inventories returning null Locations + }; + // Paper end checkContainerDataCount(beaconData, 3); @@ -83,7 +81,7 @@ - this.beaconData.set(1, encodeEffect(primaryEffect.orElse(null))); - this.beaconData.set(2, encodeEffect(secondaryEffect.orElse(null))); + // Paper start - Add PlayerChangeBeaconEffectEvent -+ io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.player.player.getBukkitEntity(), convert(primaryEffect), convert(secondaryEffect), this.access.getLocation().getBlock()); ++ io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent event = new io.papermc.paper.event.player.PlayerChangeBeaconEffectEvent((org.bukkit.entity.Player) this.inventory.player.getBukkitEntity(), convert(primaryEffect), convert(secondaryEffect), this.access.getLocation().getBlock()); + if (event.callEvent()) { + // Paper end - Add PlayerChangeBeaconEffectEvent + this.beaconData.set(1, BeaconMenu.encodeEffect(event.getPrimary() == null ? null : org.bukkit.craftbukkit.potion.CraftPotionEffectType.bukkitToMinecraftHolder(event.getPrimary())));// CraftBukkit - decompile error @@ -104,13 +102,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.view.CraftBeaconView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryBeacon inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBeacon(this.beacon); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftBeaconView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftBeaconView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch index 1c0ac6136..fb6d90fa6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/BrewingStandMenu.java.patch @@ -5,8 +5,8 @@ public final ContainerData brewingStandData; private final Slot ingredientSlot; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView view = null; ++ private final Inventory inventory; + // CraftBukkit end public BrewingStandMenu(int containerId, Inventory playerInventory) { @@ -16,7 +16,7 @@ public BrewingStandMenu(int containerId, Inventory playerInventory, Container brewingStandContainer, ContainerData brewingStandData) { super(MenuType.BREWING_STAND, containerId); -+ this.player = playerInventory; // CraftBukkit ++ this.inventory = playerInventory; // CraftBukkit checkContainerSize(brewingStandContainer, 5); - checkContainerDataCount(brewingStandData, 2); + checkContainerDataCount(brewingStandData, 3); // Paper - Add recipeBrewTime @@ -62,7 +62,7 @@ return ItemStack.EMPTY; } - } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack)) { -+ } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack, this.player.player.level().potionBrewing())) { // Paper - custom potion mixes ++ } else if (BrewingStandMenu.PotionSlot.mayPlaceItem(itemStack, this.inventory.player.level().potionBrewing())) { // Paper - custom potion mixes if (!this.moveItemStackTo(item, 0, 3, false)) { return ItemStack.EMPTY; } @@ -102,13 +102,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryBrewer inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryBrewer(this.brewingStand); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftBrewingStandView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch index 2e2aa4a42..d927bf3e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CartographyTableMenu.java.patch @@ -5,18 +5,18 @@ public class CartographyTableMenu extends AbstractContainerMenu { + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ private org.bukkit.entity.Player player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; ++ private final org.bukkit.entity.Player player; + + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryCartography inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryCartography(this.container, this.resultContainer); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView<>(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end public static final int MAP_SLOT = 0; @@ -50,7 +50,7 @@ public CartographyTableMenu(int containerId, Inventory playerInventory, final ContainerLevelAccess access) { super(MenuType.CARTOGRAPHY_TABLE, containerId); + // Paper start - Add missing InventoryHolders - move down -+ this.container = new SimpleContainer(this.createBlockHolder(access), 2) { // Paper - Add missing InventoryHolders ++ this.container = new SimpleContainer(this.createBlockHolder(access), 2) { + @Override + public void setChanged() { + CartographyTableMenu.this.slotsChanged(this); @@ -63,7 +63,7 @@ + } + // CraftBukkit end + }; -+ this.resultContainer = new ResultContainer(this.createBlockHolder(access)) { // Paper - Add missing InventoryHolders ++ this.resultContainer = new ResultContainer(this.createBlockHolder(access)) { + @Override + public void setChanged() { + // CartographyTableMenu.this.slotsChanged(this); // Paper - Add CartographyItemEvent - do not recompute results if the result slot changes - allows to set the result slot via api diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ChestMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ChestMenu.java.patch index 1be2d1bc4..b65327296 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ChestMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ChestMenu.java.patch @@ -5,13 +5,13 @@ private final Container container; private final int containerRows; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; ++ private final Inventory inventory; + + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory; @@ -23,13 +23,13 @@ + inventory = new org.bukkit.craftbukkit.inventory.CraftInventory(this.container); + } + -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + + @Override + public void startOpen() { -+ this.container.startOpen(this.player.player); ++ this.container.startOpen(this.inventory.player); + } + // CraftBukkit end @@ -42,7 +42,7 @@ - container.startOpen(playerInventory.player); + // container.startOpen(playerInventory.player); // Paper - don't startOpen until menu actually opens + // CraftBukkit start - Save player -+ this.player = playerInventory; ++ this.inventory = playerInventory; + // CraftBukkit end int i = 18; this.addChestGrid(container, 8, 18); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerLevelAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerLevelAccess.java.patch index 273a80aee..d87be55c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerLevelAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerLevelAccess.java.patch @@ -51,7 +51,7 @@ + } + + default org.bukkit.Location getLocation() { -+ return new org.bukkit.Location(this.getWorld().getWorld(), this.getPosition().getX(), this.getPosition().getY(), this.getPosition().getZ()); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.getPosition(), this.getWorld()); + } + // CraftBukkit end + // Paper start - Add missing InventoryHolders diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch index e5eda2e88..b5e0c30bc 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ContainerSynchronizer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/inventory/ContainerSynchronizer.java +++ b/net/minecraft/world/inventory/ContainerSynchronizer.java -@@ -11,4 +_,12 @@ - void sendCarriedChange(AbstractContainerMenu containerMenu, ItemStack stack); - +@@ -13,4 +_,12 @@ void sendDataChange(AbstractContainerMenu container, int id, int value); + + RemoteSlot createSlot(); + + default void sendOffHandSlotChange() {} // Paper - Sync offhand slot in menus + diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CrafterMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CrafterMenu.java.patch index e5fb55841..02190277d 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CrafterMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CrafterMenu.java.patch @@ -5,17 +5,17 @@ private final Player player; private final CraftingContainer container; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftCrafterView bukkitEntity = null; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftCrafterView view = null; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftCrafterView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryCrafter inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryCrafter(this.container, this.resultContainer); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftCrafterView(this.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftCrafterView(this.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch index d04a6f281..50d426ca1 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/CraftingMenu.java.patch @@ -1,12 +1,10 @@ --- a/net/minecraft/world/inventory/CraftingMenu.java +++ b/net/minecraft/world/inventory/CraftingMenu.java -@@ -30,13 +_,16 @@ +@@ -30,13 +_,14 @@ public final ContainerLevelAccess access; private final Player player; private boolean placingRecipe; -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ // CraftBukkit end ++ private @Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; // CraftBukkit public CraftingMenu(int containerId, Inventory playerInventory) { this(containerId, playerInventory, ContainerLevelAccess.NULL); @@ -75,13 +73,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryCrafting(this.craftSlots, this.resultSlots); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch index de6614874..739a0a9d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/DispenserMenu.java.patch @@ -5,8 +5,8 @@ private static final int USE_ROW_SLOT_END = 45; public final Container dispenser; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; ++ private final Inventory inventory; + // CraftBukkit end public DispenserMenu(int containerId, Inventory playerInventory) { @@ -16,7 +16,7 @@ public DispenserMenu(int containerId, Inventory playerInventory, Container container) { super(MenuType.GENERIC_3x3, containerId); + // CraftBukkit start - Save player -+ this.player = playerInventory; ++ this.inventory = playerInventory; + // CraftBukkit end checkContainerSize(container, 9); this.dispenser = container; @@ -37,13 +37,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventory(this.dispenser); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch index dbdb35bbc..80fbd66e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/EnchantmentMenu.java.patch @@ -19,7 +19,7 @@ public final int[] enchantClue = new int[]{-1, -1, -1}; public final int[] levelClue = new int[]{-1, -1, -1}; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView bukkitEntity = null; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView view = null; + private final org.bukkit.entity.Player player; + // CraftBukkit end @@ -107,7 +107,7 @@ this.broadcastChanges(); }); } else { -@@ -145,19 +_,53 @@ +@@ -145,19 +_,52 @@ return false; } else { this.access.execute((level, blockPos) -> { @@ -121,7 +121,7 @@ + // player.onEnchantmentPerformed(item, i); // Moved down + java.util.Map enchants = new java.util.HashMap<>(); + for (EnchantmentInstance instance : enchantmentList) { -+ enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment), instance.level); ++ enchants.put(org.bukkit.craftbukkit.enchantments.CraftEnchantment.minecraftHolderToBukkit(instance.enchantment()), instance.level()); + } + org.bukkit.craftbukkit.inventory.CraftItemStack craftItemStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack); + Holder holder = registry.byId(this.enchantClue[id]); @@ -148,13 +148,12 @@ + + // CraftBukkit start + for (java.util.Map.Entry entry : event.getEnchantsToAdd().entrySet()) { -+ Holder nms = org.bukkit.craftbukkit.enchantments.CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); -+ if (nms == null) { ++ Holder enchant = org.bukkit.craftbukkit.enchantments.CraftEnchantment.bukkitToMinecraftHolder(entry.getKey()); ++ if (enchant == null) { + continue; + } + -+ EnchantmentInstance weightedrandomenchant = new EnchantmentInstance(nms, entry.getValue()); -+ itemStack.enchant(weightedrandomenchant.enchantment, weightedrandomenchant.level); ++ itemStack.enchant(enchant, entry.getValue()); + } player.onEnchantmentPerformed(item, i); - if (item.is(Items.BOOK)) { @@ -163,7 +162,7 @@ - } - - for (EnchantmentInstance enchantmentInstance : enchantmentList) { -- itemStack.enchant(enchantmentInstance.enchantment, enchantmentInstance.level); +- itemStack.enchant(enchantmentInstance.enchantment(), enchantmentInstance.level()); - } - + // CraftBukkit end @@ -172,6 +171,19 @@ item1.consume(i, player); if (item1.isEmpty()) { this.enchantSlots.setItem(1, ItemStack.EMPTY); +@@ -202,6 +_,12 @@ + return item.isEmpty() ? 0 : item.getCount(); + } + ++ // Paper start - add enchantment seed update API ++ public void setEnchantmentSeed(int seed) { ++ this.enchantmentSeed.set(seed); ++ } ++ // Paper end - add enchantment seed update API ++ + public int getEnchantmentSeed() { + return this.enchantmentSeed.get(); + } @@ -214,6 +_,7 @@ @Override @@ -180,7 +192,7 @@ return stillValid(this.access, player, Blocks.ENCHANTING_TABLE); } -@@ -261,4 +_,23 @@ +@@ -261,4 +_,17 @@ return itemStack; } @@ -188,19 +200,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryEnchanting(this.enchantSlots); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftEnchantmentView(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end -+ -+ // Paper start - add enchantment seed update API -+ public void setEnchantmentSeed(int seed) { -+ this.enchantmentSeed.set(seed); -+ } -+ // Paper end - add enchantment seed update API } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/FurnaceResultSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/FurnaceResultSlot.java.patch index 8cf409634..5f4858a6d 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/FurnaceResultSlot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/FurnaceResultSlot.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/inventory/FurnaceResultSlot.java @@ -45,7 +_,7 @@ protected void checkTakeAchievements(ItemStack stack) { - stack.onCraftedBy(this.player.level(), this.player, this.removeCount); + stack.onCraftedBy(this.player, this.removeCount); if (this.player instanceof ServerPlayer serverPlayer && this.container instanceof AbstractFurnaceBlockEntity abstractFurnaceBlockEntity) { - abstractFurnaceBlockEntity.awardUsedRecipesAndPopExperience(serverPlayer); + abstractFurnaceBlockEntity.awardUsedRecipesAndPopExperience(serverPlayer, stack, this.removeCount); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch index 3ef40a118..ec3ca3557 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/GrindstoneMenu.java.patch @@ -5,18 +5,18 @@ public class GrindstoneMenu extends AbstractContainerMenu { + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ private org.bukkit.entity.Player player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; ++ private final org.bukkit.entity.Player player; + + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryGrindstone(this.repairSlots, this.resultSlots); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end public static final int MAX_NAME_LENGTH = 35; diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/HopperMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/HopperMenu.java.patch index d6d2f6c1d..17d3a0332 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/HopperMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/HopperMenu.java.patch @@ -5,18 +5,18 @@ public static final int CONTAINER_SIZE = 5; private final Container hopper; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; ++ private final Inventory inventory; + + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventory inventory = new org.bukkit.craftbukkit.inventory.CraftInventory(this.hopper); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end @@ -26,7 +26,7 @@ public HopperMenu(int containerId, Inventory playerInventory, Container container) { super(MenuType.HOPPER, containerId); this.hopper = container; -+ this.player = playerInventory; // CraftBukkit - save player ++ this.inventory = playerInventory; // CraftBukkit checkContainerSize(container, 5); container.startOpen(playerInventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch index 5f7e1b774..1526896b9 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/HorseInventoryMenu.java.patch @@ -1,26 +1,26 @@ --- a/net/minecraft/world/inventory/HorseInventoryMenu.java +++ b/net/minecraft/world/inventory/HorseInventoryMenu.java @@ -19,9 +_,23 @@ - public final AbstractHorse horse; + public static final int SLOT_SADDLE = 0; public static final int SLOT_BODY_ARMOR = 1; - private static final int SLOT_HORSE_INVENTORY_START = 2; + public static final int SLOT_HORSE_INVENTORY_START = 2; + // CraftBukkit start -+ org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; -+ Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; ++ private final Inventory inventory; + + @Override + public org.bukkit.inventory.InventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + -+ return this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), this.horseContainer.getOwner().getInventory(), this); ++ return this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), this.horseContainer.getOwner().getInventory(), this); + } + // CraftBukkit end public HorseInventoryMenu(int containerId, Inventory inventory, Container horseContainer, final AbstractHorse horse, int columns) { super(null, containerId); -+ this.player = inventory; // CraftBukkit - save player ++ this.inventory = inventory; // CraftBukkit this.horseContainer = horseContainer; - this.armorContainer = horse.getBodyArmorAccess(); this.horse = horse; + horseContainer.startOpen(inventory.player); diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch index 678db7249..2aff25815 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/InventoryMenu.java.patch @@ -1,26 +1,16 @@ --- a/net/minecraft/world/inventory/InventoryMenu.java +++ b/net/minecraft/world/inventory/InventoryMenu.java -@@ -2,6 +_,7 @@ - - import java.util.List; - import java.util.Map; -+import net.minecraft.network.chat.Component; - import net.minecraft.resources.ResourceLocation; - import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.Container; -@@ -44,9 +_,15 @@ +@@ -44,9 +_,13 @@ private static final EquipmentSlot[] SLOT_IDS = new EquipmentSlot[]{EquipmentSlot.HEAD, EquipmentSlot.CHEST, EquipmentSlot.LEGS, EquipmentSlot.FEET}; public final boolean active; private final Player owner; -+ // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity = null; -+ // CraftBukkit end ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view = null; // CraftBukkit public InventoryMenu(Inventory playerInventory, boolean active, final Player owner) { - super(null, 0, 2, 2); + // CraftBukkit start -+ super((MenuType) null, 0, 2, 2, playerInventory); // CraftBukkit - save player -+ this.setTitle(Component.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory ++ super(null, 0, 2, 2, playerInventory); // CraftBukkit ++ this.setTitle(net.minecraft.network.chat.Component.translatable("container.crafting")); // SPIGOT-4722: Allocate title for player inventory + // CraftBukkit end this.active = active; this.owner = owner; @@ -33,13 +23,13 @@ + // CraftBukkit start + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryCrafting inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryCrafting(this.craftSlots, this.resultSlots); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.owner.getBukkitEntity(), inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.owner.getBukkitEntity(), inventory, this); ++ return this.view; + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch index 11190b889..2f73276c2 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LecternMenu.java.patch @@ -11,18 +11,18 @@ - - public LecternMenu(int containerId, Container lectern, ContainerData lecternData) { + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftLecternView bukkitEntity = null; -+ private org.bukkit.entity.Player player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftLecternView view = null; ++ private final org.bukkit.entity.Player player; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftLecternView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryLectern inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLectern(this.lectern); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftLecternView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftLecternView(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end + @@ -83,7 +83,7 @@ } + // CraftBukkit start - Event for taking the book -+ org.bukkit.event.player.PlayerTakeLecternBookEvent event = new org.bukkit.event.player.PlayerTakeLecternBookEvent(this.player, ((org.bukkit.craftbukkit.inventory.CraftInventoryLectern) this.getBukkitView().getTopInventory()).getHolder()); ++ org.bukkit.event.player.PlayerTakeLecternBookEvent event = new org.bukkit.event.player.PlayerTakeLecternBookEvent(this.player, this.getBukkitView().getTopInventory().getHolder()); + org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return false; diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch index 8182e17e7..66aebda55 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/LoomMenu.java.patch @@ -22,18 +22,18 @@ + private final Container inputContainer; // Paper - Add missing InventoryHolders - move down + private final Container outputContainer; // Paper - Add missing InventoryHolders - move down + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftLoomView bukkitEntity = null; -+ private org.bukkit.entity.Player player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftLoomView view = null; ++ private final org.bukkit.entity.Player player; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftLoomView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + + org.bukkit.craftbukkit.inventory.CraftInventoryLoom inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryLoom(this.inputContainer, this.outputContainer); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftLoomView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftLoomView(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end @@ -88,7 +88,7 @@ - this.setupResultSlot(this.selectablePatterns.get(id)); + // Paper start - Add PlayerLoomPatternSelectEvent + int selectablePatternIndex = id; -+ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((org.bukkit.entity.Player) player.getBukkitEntity(), ((org.bukkit.craftbukkit.inventory.CraftInventoryLoom) getBukkitView().getTopInventory()), org.bukkit.craftbukkit.block.banner.CraftPatternType.minecraftHolderToBukkit(this.selectablePatterns.get(selectablePatternIndex))); ++ io.papermc.paper.event.player.PlayerLoomPatternSelectEvent event = new io.papermc.paper.event.player.PlayerLoomPatternSelectEvent((org.bukkit.entity.Player) player.getBukkitEntity(), this.getBukkitView().getTopInventory(), org.bukkit.craftbukkit.block.banner.CraftPatternType.minecraftHolderToBukkit(this.selectablePatterns.get(selectablePatternIndex))); + if (!event.callEvent()) { + player.containerMenu.sendAllDataToRemote(); + return false; @@ -115,7 +115,7 @@ return true; } else { return false; -@@ -180,7 +_,8 @@ +@@ -181,7 +_,8 @@ this.resultSlot.set(ItemStack.EMPTY); } @@ -125,7 +125,7 @@ } else { this.resultSlot.set(ItemStack.EMPTY); this.selectablePatterns = List.of(); -@@ -269,7 +_,14 @@ +@@ -270,7 +_,14 @@ itemStack.update( DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY, diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch index 3168efc55..31a0a81d1 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -30,16 +30,16 @@ + return this.maxStack; + } + -+ public void setMaxStackSize(int i) { -+ this.maxStack = i; ++ public void setMaxStackSize(int size) { ++ this.maxStack = size; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ public @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner() { + return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? (org.bukkit.craftbukkit.entity.CraftAbstractVillager) abstractVillager.getBukkitEntity() : null; + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @javax.annotation.Nullable org.bukkit.Location getLocation() { + return (this.merchant instanceof net.minecraft.world.entity.npc.AbstractVillager abstractVillager) ? abstractVillager.getBukkitEntity().getLocation() : null; // Paper - Fix inventories returning null Locations + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantMenu.java.patch index f1c3c78a5..d71ca0403 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantMenu.java.patch @@ -5,15 +5,15 @@ private boolean showProgressBar; private boolean canRestock; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftMerchantView bukkitEntity = null; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftMerchantView view = null; ++ private final Inventory inventory; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftMerchantView getBukkitView() { -+ if (this.bukkitEntity == null) { -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftMerchantView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(this.trader, this.tradeContainer), this, this.trader); ++ if (this.view == null) { ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftMerchantView(this.inventory.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(this.trader, this.tradeContainer), this, this.trader); + } -+ return this.bukkitEntity; ++ return this.view; + } + // CraftBukkit end @@ -23,7 +23,7 @@ this.addSlot(new Slot(this.tradeContainer, 0, 136, 37)); this.addSlot(new Slot(this.tradeContainer, 1, 162, 37)); this.addSlot(new MerchantResultSlot(playerInventory.player, trader, this.tradeContainer, 2, 220, 37)); -+ this.player = playerInventory; // CraftBukkit - save player ++ this.inventory = playerInventory; // CraftBukkit this.addStandardInventorySlots(playerInventory, 108, 84); } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch index 66df3c79f..17cd510f9 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/MerchantResultSlot.java.patch @@ -18,8 +18,8 @@ + if (event != null) { + if (!event.callEvent()) { + stack.setCount(0); -+ event.getPlayer().updateInventory(); -+ int level = merchant instanceof net.minecraft.world.entity.npc.Villager villager ? villager.getVillagerData().getLevel() : 1; ++ player.containerMenu.sendAllDataToRemote(); ++ int level = merchant instanceof net.minecraft.world.entity.npc.Villager villager ? villager.getVillagerData().level() : 1; + serverPlayer.sendMerchantOffers(player.containerMenu.containerId, merchant.getOffers(), level, merchant.getVillagerXp(), merchant.showProgressBar(), merchant.canRestock()); + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch index 62ebcb22a..c30aff9c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/PlayerEnderChestContainer.java.patch @@ -14,7 +14,7 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + return this.activeChest != null ? org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.activeChest.getBlockPos(), this.activeChest.getLevel().getWorld()) : null; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/RemoteSlot.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/RemoteSlot.java.patch new file mode 100644 index 000000000..5002dfb42 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/inventory/RemoteSlot.java.patch @@ -0,0 +1,27 @@ +--- a/net/minecraft/world/inventory/RemoteSlot.java ++++ b/net/minecraft/world/inventory/RemoteSlot.java +@@ -29,12 +_,14 @@ + + public static class Synchronized implements RemoteSlot { + private final HashedPatchMap.HashGenerator hasher; ++ private final boolean simplifyMatching; // Paper - add flag to simplify remote matching logic + @Nullable + private ItemStack remoteStack = null; + @Nullable + private HashedStack remoteHash = null; + +- public Synchronized(HashedPatchMap.HashGenerator hasher) { ++ public Synchronized(HashedPatchMap.HashGenerator hasher, final boolean simplifyMatching) { // Paper - add flag to simplify remote matching logic ++ this.simplifyMatching = simplifyMatching; // Paper - add flag to simplify remote matching logic + this.hasher = hasher; + } + +@@ -54,7 +_,7 @@ + public boolean matches(ItemStack stack) { + if (this.remoteStack != null) { + return ItemStack.matches(this.remoteStack, stack); +- } else if (this.remoteHash != null && this.remoteHash.matches(stack, this.hasher)) { ++ } else if (this.remoteHash != null && this.remoteHash.matches(stack, this.hasher, this.simplifyMatching)) { // Paper - add flag to simplify remote matching logic + this.remoteStack = stack.copy(); + return true; + } else { diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch index a384ac95a..b3efe5e40 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ResultContainer.java.patch @@ -1,17 +1,19 @@ --- a/net/minecraft/world/inventory/ResultContainer.java +++ b/net/minecraft/world/inventory/ResultContainer.java -@@ -12,6 +_,53 @@ +@@ -12,6 +_,55 @@ private final NonNullList itemStacks = NonNullList.withSize(1, ItemStack.EMPTY); @Nullable private RecipeHolder recipeUsed; + // CraftBukkit start + private int maxStack = MAX_STACK; + ++ @Override + public java.util.List getContents() { + return this.itemStacks; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ @Override ++ public @Nullable org.bukkit.inventory.InventoryHolder getOwner() { + // Paper start - Add missing InventoryHolders + if (this.holder == null && this.holderCreator != null) { + this.holder = this.holderCreator.get(); @@ -37,7 +39,7 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + return null; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch index 590e2788d..d5208fa9c 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/ShulkerBoxMenu.java.patch @@ -5,22 +5,22 @@ private static final int CONTAINER_SIZE = 27; private final Container container; + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.CraftInventoryView bukkitEntity; -+ private Inventory player; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.CraftInventoryView view; ++ private final Inventory inventory; + + @Override + public org.bukkit.craftbukkit.inventory.CraftInventoryView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; + } + -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventory(this.container), this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.CraftInventoryView(this.inventory.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventory(this.container), this); ++ return this.view; + } + + @Override + public void startOpen() { -+ container.startOpen(player.player); ++ this.container.startOpen(this.inventory.player); + } + // CraftBukkit end @@ -31,7 +31,7 @@ checkContainerSize(container, 27); this.container = container; - container.startOpen(playerInventory.player); -+ this.player = playerInventory; // CraftBukkit - save player ++ this.inventory = playerInventory; // CraftBukkit + // container.startOpen(playerInventory.player); // Paper - don't startOpen until menu actually opens int i = 3; int i1 = 9; diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch index 5f9f27b0f..185263b89 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/StonecutterMenu.java.patch @@ -22,20 +22,20 @@ + public final Container container; // Paper - Add missing InventoryHolders - move down + final ResultContainer resultContainer; // Paper - Add missing InventoryHolders - move down + // CraftBukkit start -+ private org.bukkit.craftbukkit.inventory.view.CraftStonecutterView bukkitEntity = null; ++ private @javax.annotation.Nullable org.bukkit.craftbukkit.inventory.view.CraftStonecutterView view = null; + private final org.bukkit.entity.Player player; + + @Override + public org.bukkit.craftbukkit.inventory.view.CraftStonecutterView getBukkitView() { -+ if (this.bukkitEntity != null) { -+ return this.bukkitEntity; ++ if (this.view != null) { ++ return this.view; } - }; - final ResultContainer resultContainer = new ResultContainer(); + + org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter inventory = new org.bukkit.craftbukkit.inventory.CraftInventoryStonecutter(this.container, this.resultContainer); -+ this.bukkitEntity = new org.bukkit.craftbukkit.inventory.view.CraftStonecutterView(this.player, inventory, this); -+ return this.bukkitEntity; ++ this.view = new org.bukkit.craftbukkit.inventory.view.CraftStonecutterView(this.player, inventory, this); ++ return this.view; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/inventory/TransientCraftingContainer.java.patch b/paper-server/patches/sources/net/minecraft/world/inventory/TransientCraftingContainer.java.patch index 85f7ca863..cded5ee71 100644 --- a/paper-server/patches/sources/net/minecraft/world/inventory/TransientCraftingContainer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/inventory/TransientCraftingContainer.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/inventory/TransientCraftingContainer.java +++ b/net/minecraft/world/inventory/TransientCraftingContainer.java -@@ -13,6 +_,68 @@ +@@ -13,6 +_,70 @@ private final int height; private final AbstractContainerMenu menu; @@ -11,27 +11,28 @@ + private Player owner; + private int maxStack = MAX_STACK; + ++ @Override + public List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + -+ public org.bukkit.event.inventory.InventoryType getInvType() { -+ return this.items.size() == 4 ? org.bukkit.event.inventory.InventoryType.CRAFTING : org.bukkit.event.inventory.InventoryType.WORKBENCH; -+ } -+ ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public List getViewers() { + return this.transaction; + } + -+ public org.bukkit.inventory.InventoryHolder getOwner() { ++ @Override ++ public @javax.annotation.Nullable org.bukkit.inventory.InventoryHolder getOwner() { + return (this.owner == null) ? null : this.owner.getBukkitEntity(); + } + @@ -40,6 +41,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + this.resultInventory.setMaxStackSize(size); diff --git a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch index 34157daf7..fe9ce9ce0 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ArmorStandItem.java.patch @@ -3,7 +3,7 @@ @@ -45,6 +_,12 @@ float f = Mth.floor((Mth.wrapDegrees(context.getRotation() - 180.0F) + 22.5F) / 45.0F) * 45.0F; - armorStand.moveTo(armorStand.getX(), armorStand.getY(), armorStand.getZ(), f, 0.0F); + armorStand.snapTo(armorStand.getX(), armorStand.getY(), armorStand.getZ(), f, 0.0F); + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPlaceEvent(context, armorStand).isCancelled()) { + if (context.getPlayer() != null) context.getPlayer().containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync diff --git a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch index dddf4b93f..bbcf05ba0 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BlockItem.java.patch @@ -1,18 +1,6 @@ --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -30,6 +_,11 @@ - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.gameevent.GameEvent; - import net.minecraft.world.phys.shapes.CollisionContext; -+// CraftBukkit start -+import org.bukkit.craftbukkit.block.CraftBlock; -+import org.bukkit.craftbukkit.block.data.CraftBlockData; -+import org.bukkit.event.block.BlockCanBuildEvent; -+// CraftBukkit end - - public class BlockItem extends Item { - @Deprecated -@@ -59,6 +_,14 @@ +@@ -57,6 +_,14 @@ return InteractionResult.FAIL; } else { BlockState placementState = this.getPlacementState(blockPlaceContext); @@ -27,7 +15,7 @@ if (placementState == null) { return InteractionResult.FAIL; } else if (!this.placeBlock(blockPlaceContext, placementState)) { -@@ -71,15 +_,40 @@ +@@ -69,15 +_,40 @@ BlockState blockState = level.getBlockState(clickedPos); if (blockState.is(placementState.getBlock())) { blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); @@ -36,7 +24,7 @@ this.updateCustomBlockEntityTag(clickedPos, level, player, itemInHand, blockState); updateBlockEntityComponents(level, clickedPos, itemInHand); + } catch (Exception ex) { -+ oldBukkitState.update(true, false); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) oldBukkitState).revertPlace(); + if (player instanceof ServerPlayer serverPlayer) { + org.apache.logging.log4j.LogManager.getLogger().error("Player {} tried placing invalid block", player.getScoreboardName(), ex); + serverPlayer.getBukkitEntity().kickPlayer("Packet processing error"); @@ -48,9 +36,9 @@ blockState.getBlock().setPlacedBy(level, clickedPos, blockState, player, itemInHand); + // CraftBukkit start + if (bukkitState != null) { -+ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, blockPlaceContext.getHand(), bukkitState, clickedPos.getX(), clickedPos.getY(), clickedPos.getZ()); ++ org.bukkit.event.block.BlockPlaceEvent placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent((net.minecraft.server.level.ServerLevel) level, player, blockPlaceContext.getHand(), bukkitState, clickedPos); + if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { -+ bukkitState.update(true, false); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) bukkitState).revertPlace(); + + // Paper - if the event is called here, the inventory should be updated + player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 @@ -68,18 +56,21 @@ level.playSound( player, clickedPos, -@@ -140,8 +_,16 @@ +@@ -137,8 +_,19 @@ + protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); - CollisionContext collisionContext = player == null ? CollisionContext.empty() : CollisionContext.of(player); - return (!this.mustSurvive() || state.canSurvive(context.getLevel(), context.getClickedPos())) -- && context.getLevel().isUnobstructed(state, context.getClickedPos(), collisionContext); +- && context.getLevel().isUnobstructed(state, context.getClickedPos(), CollisionContext.placementContext(player)); + // CraftBukkit start + Level world = context.getLevel(); // Paper - Cancel hit for vanished players -+ boolean canBuild = (!this.mustSurvive() || state.canSurvive(world, context.getClickedPos())) && world.checkEntityCollision(state, player, collisionContext, context.getClickedPos(), true); // Paper - Cancel hit for vanished players ++ boolean canBuild = (!this.mustSurvive() || state.canSurvive(world, context.getClickedPos())) && world.checkEntityCollision(state, player, CollisionContext.placementContext(player), context.getClickedPos(), true); // Paper - Cancel hit for vanished players + org.bukkit.entity.Player bukkitPlayer = (context.getPlayer() instanceof ServerPlayer) ? (org.bukkit.entity.Player) context.getPlayer().getBukkitEntity() : null; + -+ BlockCanBuildEvent event = new BlockCanBuildEvent(CraftBlock.at(world, context.getClickedPos()), bukkitPlayer, CraftBlockData.fromData(state), canBuild, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand())); // Paper - Expose hand in BlockCanBuildEvent ++ org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent( ++ org.bukkit.craftbukkit.block.CraftBlock.at(world, context.getClickedPos()), bukkitPlayer, ++ org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(state), canBuild, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()) ++ ); + world.getCraftServer().getPluginManager().callEvent(event); + + return event.isBuildable(); @@ -87,7 +78,7 @@ } protected boolean mustSurvive() { -@@ -170,7 +_,7 @@ +@@ -167,7 +_,7 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch index 6a14409bf..fcf6b5772 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/BucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/BucketItem.java +++ b/net/minecraft/world/item/BucketItem.java -@@ -29,6 +_,7 @@ +@@ -30,6 +_,7 @@ import net.minecraft.world.phys.HitResult; public class BucketItem extends Item implements DispensibleContainerItem { @@ -8,18 +8,17 @@ public final Fluid content; public BucketItem(Fluid content, Item.Properties properties) { -@@ -55,12 +_,23 @@ +@@ -56,12 +_,22 @@ } else if (this.content == Fluids.EMPTY) { BlockState blockState = level.getBlockState(blockPos); if (blockState.getBlock() instanceof BucketPickup bucketPickup) { + // CraftBukkit start + ItemStack dummyFluid = bucketPickup.pickupBlock(player, org.bukkit.craftbukkit.util.DummyGeneratorAccess.INSTANCE, blockPos, blockState); + if (dummyFluid.isEmpty()) return InteractionResult.FAIL; // Don't fire event if the bucket won't be filled. -+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((net.minecraft.server.level.ServerLevel) level, player, blockPos, blockPos, playerPovHitResult.getDirection(), itemInHand, dummyFluid.getItem(), hand); ++ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(level, player, blockPos, blockPos, playerPovHitResult.getDirection(), itemInHand, dummyFluid.getItem(), hand); + + if (event.isCancelled()) { -+ // ((ServerPlayer) user).connection.send(new ClientboundBlockUpdatePacket(level, blockPos)); // SPIGOT-5163 (see PlayerInteractManager) // Paper - Don't resend blocks -+ ((ServerPlayer) player).getBukkitEntity().updateInventory(); // SPIGOT-4541 ++ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 + return InteractionResult.FAIL; + } + // CraftBukkit end @@ -33,7 +32,7 @@ if (!level.isClientSide) { CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, itemStack); } -@@ -73,7 +_,7 @@ +@@ -74,7 +_,7 @@ } else { BlockState blockState = level.getBlockState(blockPos); BlockPos blockPos2 = blockState.getBlock() instanceof LiquidBlockContainer && this.content == Fluids.WATER ? blockPos : blockPos1; @@ -42,7 +41,7 @@ this.checkExtraContent(player, level, itemInHand, blockPos2); if (player instanceof ServerPlayer) { CriteriaTriggers.PLACED_BLOCK.trigger((ServerPlayer)player, blockPos2, itemInHand); -@@ -90,6 +_,13 @@ +@@ -91,6 +_,13 @@ } public static ItemStack getEmptySuccessItem(ItemStack bucketStack, Player player) { @@ -56,37 +55,37 @@ return !player.hasInfiniteMaterials() ? new ItemStack(Items.BUCKET) : bucketStack; } -@@ -99,6 +_,12 @@ +@@ -100,6 +_,12 @@ @Override - public boolean emptyContents(@Nullable Player player, Level level, BlockPos pos, @Nullable BlockHitResult result) { + public boolean emptyContents(@Nullable LivingEntity entity, Level level, BlockPos pos, @Nullable BlockHitResult hitResult) { + // CraftBukkit start -+ return this.emptyContents(player, level, pos, result, null, null, null, InteractionHand.MAIN_HAND); ++ return this.emptyContents(entity, level, pos, hitResult, null, null, null, InteractionHand.MAIN_HAND); + } + -+ public boolean emptyContents(@Nullable Player player, Level level, BlockPos pos, @Nullable BlockHitResult result, Direction enumdirection, BlockPos clicked, ItemStack itemstack, InteractionHand enumhand) { ++ public boolean emptyContents(@Nullable LivingEntity entity, Level level, BlockPos pos, @Nullable BlockHitResult hitResult, Direction direction, BlockPos clicked, ItemStack itemstack, InteractionHand hand) { + // CraftBukkit end if (!(this.content instanceof FlowingFluid flowingFluid)) { return false; } else { -@@ -109,8 +_,19 @@ +@@ -110,8 +_,19 @@ || canBeReplaced || block instanceof LiquidBlockContainer liquidBlockContainer - && liquidBlockContainer.canPlaceLiquid(player, level, pos, blockState, this.content); + && liquidBlockContainer.canPlaceLiquid(entity, level, pos, blockState, this.content); ++ + // CraftBukkit start -+ if (flag && player != null) { -+ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent((net.minecraft.server.level.ServerLevel) level, player, pos, clicked, enumdirection, itemstack, enumhand); ++ if (flag && entity instanceof Player player) { ++ org.bukkit.event.player.PlayerBucketEmptyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketEmptyEvent(level, player, pos, clicked, direction, itemstack, hand); + if (event.isCancelled()) { -+ // ((ServerPlayer) player).connection.send(new ClientboundBlockUpdatePacket(level, pos)); // SPIGOT-4238: needed when looking through entity // Paper - Don't resend blocks -+ ((ServerPlayer) player).getBukkitEntity().updateInventory(); // SPIGOT-4541 ++ player.containerMenu.sendAllDataToRemote(); // SPIGOT-4541 + return false; + } + itemLeftInHandAfterPlayerBucketEmptyEvent = event.getItemStack() != null ? event.getItemStack().equals(org.bukkit.craftbukkit.inventory.CraftItemStack.asNewCraftStack(net.minecraft.world.item.Items.BUCKET)) ? null : org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(event.getItemStack()) : ItemStack.EMPTY; // Paper - Fix PlayerBucketEmptyEvent result itemstack + } + // CraftBukkit end if (!flag) { -- return result != null && this.emptyContents(player, level, result.getBlockPos().relative(result.getDirection()), null); -+ return result != null && this.emptyContents(player, level, result.getBlockPos().relative(result.getDirection()), null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit +- return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null); ++ return hitResult != null && this.emptyContents(entity, level, hitResult.getBlockPos().relative(hitResult.getDirection()), null, direction, clicked, itemstack, hand); // CraftBukkit } else if (level.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { int x = pos.getX(); int y = pos.getY(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch index 2f24e0047..ef4344e7f 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/CrossbowItem.java.patch @@ -1,38 +1,23 @@ --- a/net/minecraft/world/item/CrossbowItem.java +++ b/net/minecraft/world/item/CrossbowItem.java -@@ -90,7 +_,14 @@ - public boolean releaseUsing(ItemStack stack, Level level, LivingEntity entity, int timeLeft) { - int i = this.getUseDuration(stack, entity) - timeLeft; - float powerForTime = getPowerForTime(i, stack, entity); -- if (powerForTime >= 1.0F && !isCharged(stack) && tryLoadProjectiles(entity, stack)) { -+ // Paper start - Add EntityLoadCrossbowEvent -+ if (powerForTime >= 1.0F && !isCharged(stack)) { -+ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(entity.getBukkitLivingEntity(), stack.asBukkitMirror(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(entity.getUsedItemHand())); -+ if (!event.callEvent() || !tryLoadProjectiles(entity, stack, event.shouldConsumeItem()) || !event.shouldConsumeItem()) { -+ if (entity instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote(); -+ return false; -+ } -+ // Paper end - Add EntityLoadCrossbowEvent - CrossbowItem.ChargingSounds chargingSounds = this.getChargingSounds(stack); - chargingSounds.end() - .ifPresent( -@@ -111,8 +_,14 @@ - } +@@ -88,8 +_,15 @@ + return getPowerForTime(i, stack, entity) >= 1.0F && isCharged(stack); } -+ @io.papermc.paper.annotation.DoNotUse // Paper - Add EntityLoadCrossbowEvent ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add EntityLoadCrossbowEvent private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack crossbowStack) { - List list = draw(crossbowStack, shooter.getProjectile(crossbowStack), shooter); + // Paper start - Add EntityLoadCrossbowEvent -+ return CrossbowItem.tryLoadProjectiles(shooter, crossbowStack, true); ++ return tryLoadProjectiles(shooter, crossbowStack, true); + } ++ + private static boolean tryLoadProjectiles(LivingEntity shooter, ItemStack crossbowStack, boolean consume) { + List list = draw(crossbowStack, shooter.getProjectile(crossbowStack), shooter, consume); + // Paper end - Add EntityLoadCrossbowEvent if (!list.isEmpty()) { crossbowStack.set(DataComponents.CHARGED_PROJECTILES, ChargedProjectiles.of(list)); return true; -@@ -164,7 +_,11 @@ +@@ -141,7 +_,11 @@ @Override protected Projectile createProjectile(Level level, LivingEntity shooter, ItemStack weapon, ItemStack ammo, boolean isCrit) { if (ammo.is(Items.FIREWORK_ROCKET)) { @@ -45,3 +30,19 @@ } else { Projectile projectile = super.createProjectile(level, shooter, weapon, ammo, isCrit); if (projectile instanceof AbstractArrow abstractArrow) { +@@ -211,7 +_,14 @@ + ); + } + +- if (f >= 1.0F && !isCharged(stack) && tryLoadProjectiles(livingEntity, stack)) { ++ if (f >= 1.0F && !isCharged(stack)) { ++ // Paper start - Add EntityLoadCrossbowEvent ++ final io.papermc.paper.event.entity.EntityLoadCrossbowEvent event = new io.papermc.paper.event.entity.EntityLoadCrossbowEvent(livingEntity.getBukkitLivingEntity(), stack.asBukkitMirror(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(livingEntity.getUsedItemHand())); ++ if (!event.callEvent() || !tryLoadProjectiles(livingEntity, stack, event.shouldConsumeItem()) || !event.shouldConsumeItem()) { ++ if (livingEntity instanceof ServerPlayer player) player.containerMenu.sendAllDataToRemote(); ++ return; ++ } ++ // Paper end - Add EntityLoadCrossbowEvent + chargingSounds.end() + .ifPresent( + sound -> level.playSound( diff --git a/paper-server/patches/sources/net/minecraft/world/item/EggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EggItem.java.patch index c1b9e1c9d..2f1eca1b2 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EggItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/EggItem.java +++ b/net/minecraft/world/item/EggItem.java -@@ -23,22 +_,36 @@ +@@ -23,22 +_,35 @@ @Override public InteractionResult use(Level level, Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); @@ -14,19 +14,20 @@ - 0.5F, - 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) - ); - if (level instanceof ServerLevel serverLevel) { -- Projectile.spawnProjectileFromRotation(ThrownEgg::new, serverLevel, itemInHand, player, 0.0F, PROJECTILE_SHOOT_POWER, 1.0F); -+ // CraftBukkit start -+ // Paper start - PlayerLaunchProjectileEvent -+ final Projectile.Delayed thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, serverLevel, itemInHand, player, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F); -+ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownEgg.projectile().getBukkitEntity()); -+ if (event.callEvent() && thrownEgg.attemptSpawn()) { -+ if (event.shouldConsume()) { -+ itemInHand.consume(1, player); -+ } else { -+ player.containerMenu.sendAllDataToRemote(); -+ } -+ level.playSound( +- if (level instanceof ServerLevel serverLevel) { +- Projectile.spawnProjectileFromRotation(ThrownEgg::new, serverLevel, itemInHand, player, 0.0F, 1.5F, 1.0F); +- } ++ // Paper start ++ final Projectile.Delayed thrownEgg = Projectile.spawnProjectileFromRotationDelayed(ThrownEgg::new, (ServerLevel) level, itemInHand, player, 0.0F, EggItem.PROJECTILE_SHOOT_POWER, 1.0F); ++ com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownEgg.projectile().getBukkitEntity()); ++ if (event.callEvent() && thrownEgg.attemptSpawn()) { ++ if (event.shouldConsume()) { ++ itemInHand.consume(1, player); ++ } else { ++ player.containerMenu.sendAllDataToRemote(); ++ } ++ level.playSound( ++ // Paper end + null, + player.getX(), + player.getY(), @@ -35,19 +36,18 @@ + SoundSource.PLAYERS, + 0.5F, + 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) -+ ); -+ player.awardStat(Stats.ITEM_USED.get(this)); -+ } else { -+ // Paper end - PlayerLaunchProjectileEvent -+ player.containerMenu.sendAllDataToRemote(); -+ return InteractionResult.FAIL; -+ } -+ // CraftBukkit end - } -- ++ ); ++ // Paper - move up + - player.awardStat(Stats.ITEM_USED.get(this)); - itemInHand.consume(1, player); -+ // Paper - PlayerLaunchProjectileEvent - moved up ++ player.awardStat(Stats.ITEM_USED.get(this)); ++ // Paper start ++ } else { ++ player.containerMenu.sendAllDataToRemote(); ++ return InteractionResult.FAIL; ++ } ++ // CraftBukkit end return InteractionResult.SUCCESS; } diff --git a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch index f6474104d..a82c58ec7 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EndCrystalItem.java.patch @@ -5,7 +5,7 @@ return InteractionResult.FAIL; } else { - BlockPos blockPos = clickedPos.above(); -+ BlockPos blockPos = clickedPos.above(); final BlockPos aboveBlockPosition = blockPos; // Paper - OBFHELPER ++ BlockPos blockPos = clickedPos.above(); final BlockPos aboveBlockPos = blockPos; // Paper - OBFHELPER if (!level.isEmptyBlock(blockPos)) { return InteractionResult.FAIL; } else { @@ -24,7 +24,7 @@ EndDragonFight dragonFight = ((ServerLevel)level).getDragonFight(); if (dragonFight != null) { - dragonFight.tryRespawn(); -+ dragonFight.tryRespawn(aboveBlockPosition); // Paper - Perf: Do crystal-portal proximity check before entity lookup ++ dragonFight.tryRespawn(aboveBlockPos); // Paper - Perf: Do crystal-portal proximity check before entity lookup } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch index 1145ec35d..522f73571 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/EnderEyeItem.java.patch @@ -3,7 +3,7 @@ @@ -42,6 +_,11 @@ return InteractionResult.SUCCESS; } else { - BlockState blockState1 = blockState.setValue(EndPortalFrameBlock.HAS_EYE, Boolean.valueOf(true)); + BlockState blockState1 = blockState.setValue(EndPortalFrameBlock.HAS_EYE, true); + // Paper start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(context.getPlayer(), clickedPos, blockState1)) { + return InteractionResult.PASS; @@ -12,7 +12,7 @@ Block.pushEntitiesUp(blockState, blockState1, level, clickedPos); level.setBlock(clickedPos, blockState1, 2); level.updateNeighbourForOutputSignal(clickedPos, Blocks.END_PORTAL_FRAME); -@@ -57,7 +_,27 @@ +@@ -59,7 +_,27 @@ } } @@ -41,7 +41,7 @@ } return InteractionResult.SUCCESS; -@@ -87,7 +_,11 @@ +@@ -89,7 +_,11 @@ eyeOfEnder.setItem(itemInHand); eyeOfEnder.signalTo(blockPos); level.gameEvent(GameEvent.PROJECTILE_SHOOT, eyeOfEnder.position(), GameEvent.Context.of(player)); diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch index a182da8d7..7d07004ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireChargeItem.java.patch @@ -27,5 +27,5 @@ + } + // CraftBukkit end this.playSound(level, clickedPos); - level.setBlockAndUpdate(clickedPos, blockState.setValue(BlockStateProperties.LIT, Boolean.valueOf(true))); + level.setBlockAndUpdate(clickedPos, blockState.setValue(BlockStateProperties.LIT, true)); level.gameEvent(context.getPlayer(), GameEvent.BLOCK_CHANGE, clickedPos); diff --git a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch index 00153390e..82cda7233 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FireworkRocketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -33,7 +_,7 @@ +@@ -29,7 +_,7 @@ ItemStack itemInHand = context.getItemInHand(); Vec3 clickLocation = context.getClickLocation(); Direction clickedFace = context.getClickedFace(); @@ -9,7 +9,7 @@ new FireworkRocketEntity( level, context.getPlayer(), -@@ -43,9 +_,14 @@ +@@ -39,9 +_,14 @@ itemInHand ), serverLevel, @@ -26,7 +26,7 @@ } return InteractionResult.SUCCESS; -@@ -56,9 +_,21 @@ +@@ -52,9 +_,21 @@ if (player.isFallFlying()) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch index d3a5d6505..5bb1d50fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FishingRodItem.java.patch @@ -5,7 +5,7 @@ if (player.fishing != null) { if (!level.isClientSide) { - int i = player.fishing.retrieve(itemInHand); -+ int i = player.fishing.retrieve(hand, itemInHand); // Paper - Add hand parameter to PlayerFishEvent ++ int i = player.fishing.retrieve(itemInHand, hand); // Paper - Add hand parameter to PlayerFishEvent itemInHand.hurtAndBreak(i, player, LivingEntity.getSlotForHand(hand)); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch index 19ba3b4a2..c240cc3fc 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/FlintAndSteelItem.java.patch @@ -24,5 +24,5 @@ + } + // CraftBukkit end level.playSound(player, clickedPos, SoundEvents.FLINTANDSTEEL_USE, SoundSource.BLOCKS, 1.0F, level.getRandom().nextFloat() * 0.4F + 0.8F); - level.setBlock(clickedPos, blockState.setValue(BlockStateProperties.LIT, Boolean.valueOf(true)), 11); + level.setBlock(clickedPos, blockState.setValue(BlockStateProperties.LIT, true), 11); level.gameEvent(player, GameEvent.BLOCK_CHANGE, clickedPos); diff --git a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch index c1d7700dc..3fa7a981b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/HangingEntityItem.java.patch @@ -1,16 +1,16 @@ --- a/net/minecraft/world/item/HangingEntityItem.java +++ b/net/minecraft/world/item/HangingEntityItem.java -@@ -66,6 +_,20 @@ - +@@ -62,6 +_,20 @@ + EntityType.createDefaultStackConfig(level, itemInHand, player).accept(hangingEntity); if (hangingEntity.survives()) { if (!level.isClientSide) { + // CraftBukkit start - fire HangingPlaceEvent -+ org.bukkit.entity.Player who = player == null ? null : (org.bukkit.entity.Player) player.getBukkitEntity(); ++ org.bukkit.entity.Player bukkitPlayer = player == null ? null : (org.bukkit.entity.Player) player.getBukkitEntity(); + org.bukkit.block.Block blockClicked = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos); + org.bukkit.block.BlockFace blockFace = org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(clickedFace); + org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand()); + -+ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) hangingEntity.getBukkitEntity(), who, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemInHand)); ++ org.bukkit.event.hanging.HangingPlaceEvent event = new org.bukkit.event.hanging.HangingPlaceEvent((org.bukkit.entity.Hanging) hangingEntity.getBukkitEntity(), bukkitPlayer, blockClicked, blockFace, hand, org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemInHand)); + level.getCraftServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch index e0ed9f76a..6d3893213 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemStack.java.patch @@ -1,45 +1,29 @@ --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -136,18 +_,35 @@ - } else { - Holder holder = ITEM_STREAM_CODEC.decode(buffer); - DataComponentPatch dataComponentPatch = DataComponentPatch.STREAM_CODEC.decode(buffer); -- return new ItemStack(holder, varInt, dataComponentPatch); -+ // CraftBukkit start -+ ItemStack stack = new ItemStack(holder, varInt, dataComponentPatch); -+ if (false && !dataComponentPatch.isEmpty()) { // Paper - This is no longer needed with raw NBT being handled in metadata -+ org.bukkit.craftbukkit.inventory.CraftItemStack.setItemMeta(stack, org.bukkit.craftbukkit.inventory.CraftItemStack.getItemMeta(stack)); -+ } -+ return stack; -+ // CraftBukkit end - } - } +@@ -198,12 +_,20 @@ - @Override - public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { -- if (value.isEmpty()) { -+ if (value.isEmpty() || value.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() - buffer.writeVarInt(0); - } else { -- buffer.writeVarInt(value.getCount()); -+ buffer.writeVarInt(io.papermc.paper.util.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.ItemObfuscationSession.currentSession(), value, value.getCount())); // Paper - potentially sanitize count - ITEM_STREAM_CODEC.encode(buffer, value.getItemHolder()); -+ // Spigot start - filter -+ // value = value.copy(); -+ // CraftItemStack.setItemMeta(value, CraftItemStack.getItemMeta(value)); // Paper - This is no longer with raw NBT being handled in metadata -+ // Paper start - adventure; conditionally render translatable components -+ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get(); -+ try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.ItemObfuscationSession.withContext(c -> c.itemStack(value))) { // pass the itemstack as context to the obfuscation session -+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true); - DataComponentPatch.STREAM_CODEC.encode(buffer, value.components.asPatch()); -+ } finally { -+ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev); -+ } -+ // Paper end - adventure; conditionally render translatable components + @Override + public void encode(RegistryFriendlyByteBuf buffer, ItemStack value) { +- if (value.isEmpty()) { ++ if (value.isEmpty() || value.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() + buffer.writeVarInt(0); + } else { +- buffer.writeVarInt(value.getCount()); ++ buffer.writeVarInt(io.papermc.paper.util.sanitizer.ItemComponentSanitizer.sanitizeCount(io.papermc.paper.util.sanitizer.ItemObfuscationSession.currentSession(), value, value.getCount())); // Paper - potentially sanitize count + Item.STREAM_CODEC.encode(buffer, value.getItemHolder()); ++ // Paper start - adventure; conditionally render translatable components ++ boolean prev = net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.get(); ++ try (final io.papermc.paper.util.SafeAutoClosable ignored = io.papermc.paper.util.sanitizer.ItemObfuscationSession.withContext(c -> c.itemStack(value))) { // pass the itemstack as context to the obfuscation session ++ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(true); + codec.encode(buffer, value.components.asPatch()); ++ } finally { ++ net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev); ++ } ++ // Paper end - adventure; conditionally render translatable components + } } - } - }; -@@ -365,10 +_,171 @@ + }; +@@ -373,10 +_,167 @@ return InteractionResult.PASS; } else { Item item = this.getItem(); @@ -90,10 +74,10 @@ + this.restorePatch(newPatch); + this.setCount(newCount); + } -+ for (org.bukkit.craftbukkit.block.CraftBlockState blockstate : blocks) { ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : blocks) { + // SPIGOT-7572 - Move fix for SPIGOT-7248 to CapturedBlockState, to allow bees in bee nest -+ org.bukkit.craftbukkit.block.CapturedBlockState.setBlockState(blockstate); -+ serverLevel.checkCapturedTreeStateForObserverNotify(clickedPos, blockstate); // Paper - notify observers even if grow failed ++ snapshot.place(snapshot.getFlags()); ++ serverLevel.checkCapturedTreeStateForObserverNotify(clickedPos, snapshot); // Paper - notify observers even if grow failed + } + player.awardStat(Stats.ITEM_USED.get(item)); // SPIGOT-7236 - award stat + } @@ -109,24 +93,20 @@ + List blocks = new java.util.ArrayList<>(serverLevel.capturedBlockStates.values()); + serverLevel.capturedBlockStates.clear(); + if (blocks.size() > 1) { -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(serverLevel, player, hand, blocks, clickedPos.getX(), clickedPos.getY(), clickedPos.getZ()); ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(serverLevel, player, hand, blocks, clickedPos); + } else if (blocks.size() == 1 && item != Items.POWDER_SNOW_BUCKET) { // Paper - Fix cancelled powdered snow bucket placement -+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(serverLevel, player, hand, blocks.getFirst(), clickedPos.getX(), clickedPos.getY(), clickedPos.getZ()); ++ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(serverLevel, player, hand, blocks.getFirst(), clickedPos); + } + + if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild())) { + interactionResult = InteractionResult.FAIL; // cancel placement + // PAIL: Remove this when MC-99075 fixed -+ placeEvent.getPlayer().updateInventory(); ++ player.containerMenu.sendAllDataToRemote(); + serverLevel.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot + // revert back all captured blocks -+ serverLevel.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 -+ serverLevel.isBlockPlaceCancelled = true; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent + for (org.bukkit.block.BlockState blockstate : blocks) { -+ blockstate.update(true, false); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).revertPlace(); + } -+ serverLevel.isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent -+ serverLevel.preventPoiUpdated = false; + + SignItem.openSign = null; // SPIGOT-6758 - Reset on early return + } else { @@ -141,7 +121,7 @@ + } + + for (org.bukkit.block.BlockState blockstate : blocks) { -+ int updateFlag = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlag(); ++ int updateFlags = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getFlags(); + net.minecraft.world.level.block.state.BlockState oldBlock = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getHandle(); + BlockPos newPos = ((org.bukkit.craftbukkit.block.CraftBlockState) blockstate).getPosition(); + net.minecraft.world.level.block.state.BlockState block = serverLevel.getBlockState(newPos); @@ -150,7 +130,7 @@ + block.onPlace(serverLevel, newPos, oldBlock, true, context); + } + -+ serverLevel.notifyAndUpdatePhysics(newPos, null, oldBlock, block, serverLevel.getBlockState(newPos), updateFlag, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point ++ serverLevel.notifyAndUpdatePhysics(newPos, null, oldBlock, block, serverLevel.getBlockState(newPos), updateFlags, net.minecraft.world.level.block.Block.UPDATE_LIMIT); // send null chunk as chunk.k() returns false by this point + } + + if (this.item == Items.WITHER_SKELETON_SKULL) { // Special case skulls to allow wither spawns to be cancelled @@ -183,25 +163,25 @@ + } + } + -+ // SPIGOT-7315: Moved from BlockBed#setPlacedBy ++ // SPIGOT-7315: Moved from BedBlock#setPlacedBy + if (placeEvent != null && this.item instanceof BedItem) { -+ BlockPos position = ((org.bukkit.craftbukkit.block.CraftBlock) placeEvent.getBlock()).getPosition(); -+ net.minecraft.world.level.block.state.BlockState blockData = serverLevel.getBlockState(position); ++ BlockPos pos = ((org.bukkit.craftbukkit.block.CraftBlock) placeEvent.getBlock()).getPosition(); ++ net.minecraft.world.level.block.state.BlockState state = serverLevel.getBlockState(pos); + -+ if (blockData.getBlock() instanceof net.minecraft.world.level.block.BedBlock) { -+ serverLevel.blockUpdated(position, net.minecraft.world.level.block.Blocks.AIR); -+ blockData.updateNeighbourShapes(serverLevel, position, 3); ++ if (state.getBlock() instanceof net.minecraft.world.level.block.BedBlock) { ++ serverLevel.updateNeighborsAt(pos, net.minecraft.world.level.block.Blocks.AIR); ++ state.updateNeighbourShapes(serverLevel, pos, 3); + } + } + -+ // SPIGOT-1288 - play sound stripped from ItemBlock ++ // SPIGOT-1288 - play sound stripped from BlockItem + if (this.item instanceof BlockItem) { + // Paper start - Fix spigot sound playing for BlockItem ItemStacks -+ BlockPos position = new net.minecraft.world.item.context.BlockPlaceContext(context).getClickedPos(); -+ net.minecraft.world.level.block.state.BlockState blockData = serverLevel.getBlockState(position); -+ net.minecraft.world.level.block.SoundType soundeffecttype = blockData.getSoundType(); ++ BlockPos pos = new net.minecraft.world.item.context.BlockPlaceContext(context).getClickedPos(); ++ net.minecraft.world.level.block.state.BlockState state = serverLevel.getBlockState(pos); ++ net.minecraft.world.level.block.SoundType soundType = state.getSoundType(); + // Paper end - Fix spigot sound playing for BlockItem ItemStacks -+ serverLevel.playSound(player, clickedPos, soundeffecttype.getPlaceSound(), net.minecraft.sounds.SoundSource.BLOCKS, (soundeffecttype.getVolume() + 1.0F) / 2.0F, soundeffecttype.getPitch() * 0.8F); ++ serverLevel.playSound(player, clickedPos, soundType.getPlaceSound(), net.minecraft.sounds.SoundSource.BLOCKS, (soundType.getVolume() + 1.0F) / 2.0F, soundType.getPitch() * 0.8F); + } + + player.awardStat(Stats.ITEM_USED.get(item)); @@ -213,7 +193,7 @@ return interactionResult; } -@@ -469,31 +_,70 @@ +@@ -473,31 +_,71 @@ return this.isDamageableItem() && this.getDamageValue() >= this.getMaxDamage() - 1; } @@ -224,6 +204,7 @@ + // Paper start - add force boolean overload + this.hurtAndBreak(damage, level, player, onBreak, false); + } ++ + public void hurtAndBreak(int damage, ServerLevel level, @Nullable LivingEntity player, Consumer onBreak, boolean force) { // Paper - Add EntityDamageItemEvent + // Paper end + final int originalDamage = damage; // Paper - Expand PlayerItemDamageEvent @@ -234,7 +215,7 @@ + event.getPlayer().getServer().getPluginManager().callEvent(event); + + if (i != event.getDamage() || event.isCancelled()) { -+ event.getPlayer().updateInventory(); ++ serverPlayer.containerMenu.sendAllDataToRemote(); + } + if (event.isCancelled()) { + return; @@ -292,7 +273,7 @@ this.shrink(1); onBreak.accept(item); } -@@ -506,15 +_,39 @@ +@@ -510,15 +_,39 @@ return; } @@ -334,7 +315,7 @@ ); } } -@@ -715,6 +_,12 @@ +@@ -732,6 +_,12 @@ return this.getItem().useOnRelease(this); } @@ -345,35 +326,38 @@ + // CraftBukkit end + @Nullable - public T set(DataComponentType component, @Nullable T value) { + public T set(DataComponentType component, @Nullable T value) { return this.components.set(component, value); -@@ -748,6 +_,25 @@ - } +@@ -779,6 +_,28 @@ + this.getItem().verifyComponentsAfterLoad(this); } + // Paper start - (this is just a good no conflict location) + public org.bukkit.inventory.ItemStack asBukkitMirror() { + return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this); + } ++ + public org.bukkit.inventory.ItemStack asBukkitCopy() { + return org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.copy()); + } ++ + public static ItemStack fromBukkitCopy(org.bukkit.inventory.ItemStack itemstack) { + return org.bukkit.craftbukkit.inventory.CraftItemStack.asNMSCopy(itemstack); + } -+ private org.bukkit.craftbukkit.inventory.CraftItemStack bukkitStack; ++ ++ private @Nullable org.bukkit.craftbukkit.inventory.CraftItemStack bukkitStack; + public org.bukkit.inventory.ItemStack getBukkitStack() { -+ if (bukkitStack == null || bukkitStack.handle != this) { -+ bukkitStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this); ++ if (this.bukkitStack == null || this.bukkitStack.handle != this) { ++ this.bukkitStack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this); + } -+ return bukkitStack; ++ return this.bukkitStack; + } + // Paper end + - public void applyComponents(DataComponentPatch components) { - this.components.applyPatch(components); - this.getItem().verifyComponentsAfterLoad(this); -@@ -1016,6 +_,19 @@ + public Component getHoverName() { + Component customName = this.getCustomName(); + return customName != null ? customName : this.getItemName(); +@@ -1054,6 +_,19 @@ EnchantmentHelper.forEachModifier(this, equipmentSLot, action); } @@ -393,7 +377,7 @@ public Component getDisplayName() { MutableComponent mutableComponent = Component.empty().append(this.getHoverName()); if (this.has(DataComponents.CUSTOM_NAME)) { -@@ -1072,7 +_,7 @@ +@@ -1109,7 +_,7 @@ } public void consume(int amount, @Nullable LivingEntity entity) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/LingeringPotionItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/LingeringPotionItem.java.patch index 3c0c4271a..f4ab3c1e4 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/LingeringPotionItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/LingeringPotionItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/LingeringPotionItem.java +++ b/net/minecraft/world/item/LingeringPotionItem.java -@@ -24,6 +_,10 @@ +@@ -19,6 +_,10 @@ @Override public InteractionResult use(Level level, Player player, InteractionHand hand) { @@ -11,11 +11,12 @@ level.playSound( null, player.getX(), -@@ -34,6 +_,6 @@ +@@ -29,7 +_,7 @@ 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) ); - return super.use(level, player, hand); + return wrapper; // Paper - PlayerLaunchProjectileEvent } - } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch index 908812946..3eb3315bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MaceItem.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/MaceItem.java +++ b/net/minecraft/world/item/MaceItem.java -@@ -61,7 +_,13 @@ +@@ -52,7 +_,13 @@ @Override - public boolean hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { + public void hurtEnemy(ItemStack stack, LivingEntity target, LivingEntity attacker) { - if (canSmashAttack(attacker)) { + // Paper start - Add EntityAttemptSmashAttackEvent + final boolean canSmashAttack = canSmashAttack(attacker); @@ -15,7 +15,7 @@ ServerLevel serverLevel = (ServerLevel)attacker.level(); attacker.setDeltaMovement(attacker.getDeltaMovement().with(Direction.Axis.Y, 0.01F)); if (attacker instanceof ServerPlayer serverPlayer) { -@@ -139,7 +_,7 @@ +@@ -127,7 +_,7 @@ double knockbackPower = getKnockbackPower(attacker, livingEntity, vec3); Vec3 vec31 = vec3.normalize().scale(knockbackPower); if (knockbackPower > 0.0) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch index 8488078d8..182efad8a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MapItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MapItem.java +++ b/net/minecraft/world/item/MapItem.java -@@ -99,8 +_,8 @@ +@@ -97,8 +_,8 @@ int i9 = (i1 / i + i6 - 64) * i; int i10 = (i2 / i + i7 - 64) * i; Multiset multiset = LinkedHashMultiset.create(); @@ -11,7 +11,7 @@ int i11 = 0; double d1 = 0.0; if (level.dimensionType().hasCeiling()) { -@@ -207,7 +_,7 @@ +@@ -205,7 +_,7 @@ for (int i5 = 0; i5 < 128; i5++) { for (int i6 = 0; i6 < 128; i6++) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch index 668262765..cfbe0cbbf 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/MobBucketItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/MobBucketItem.java +++ b/net/minecraft/world/item/MobBucketItem.java -@@ -58,7 +_,7 @@ +@@ -50,7 +_,7 @@ } if (mob != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/NameTagItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/NameTagItem.java.patch index f3a064fec..206188be5 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/NameTagItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/NameTagItem.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/item/NameTagItem.java @@ -18,8 +_,14 @@ Component component = stack.get(DataComponents.CUSTOM_NAME); - if (component != null && target.getType().canSerialize() && target.canBeNameTagged()) { + if (component != null && target.getType().canSerialize()) { if (!player.level().isClientSide && target.isAlive()) { - target.setCustomName(component); - if (target instanceof Mob mob) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/PotionItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/PotionItem.java.patch index a25346910..f3c68675b 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/PotionItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/PotionItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/PotionItem.java +++ b/net/minecraft/world/item/PotionItem.java -@@ -42,6 +_,12 @@ +@@ -41,6 +_,12 @@ PotionContents potionContents = itemInHand.getOrDefault(DataComponents.POTION_CONTENTS, PotionContents.EMPTY); BlockState blockState = level.getBlockState(clickedPos); if (context.getClickedFace() != Direction.DOWN && blockState.is(BlockTags.CONVERTABLE_TO_MUD) && potionContents.is(Potions.WATER)) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch index bfc05c761..012015c26 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ProjectileWeaponItem.java.patch @@ -27,7 +27,7 @@ + itemStack + ).isRemoved()) { + if (shooter instanceof net.minecraft.server.level.ServerPlayer serverPlayer) { -+ serverPlayer.getBukkitEntity().updateInventory(); ++ serverPlayer.containerMenu.sendAllDataToRemote(); + } + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch index 142d69182..0c0627410 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ShovelItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/ShovelItem.java +++ b/net/minecraft/world/item/ShovelItem.java -@@ -46,20 +_,29 @@ +@@ -45,20 +_,29 @@ Player player = context.getPlayer(); BlockState blockState1 = FLATTENABLES.get(blockState.getBlock()); BlockState blockState2 = null; @@ -17,7 +17,7 @@ CampfireBlock.dowse(context.getPlayer(), level, clickedPos, blockState); + }; // Paper - blockState2 = blockState.setValue(CampfireBlock.LIT, Boolean.valueOf(false)); + blockState2 = blockState.setValue(CampfireBlock.LIT, false); } if (blockState2 != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch index 03672c4a1..0c0af5a22 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SpawnEggItem.java.patch @@ -8,12 +8,12 @@ EntityType type = this.getType(level.registryAccess(), itemInHand); spawner.setEntityId(type, level.getRandom()); level.sendBlockUpdated(clickedPos, blockState, blockState, 3); -@@ -169,7 +_,7 @@ - return Optional.empty(); +@@ -170,7 +_,7 @@ } else { - breedOffspring.moveTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); + breedOffspring.snapTo(pos.x(), pos.y(), pos.z(), 0.0F, 0.0F); + breedOffspring.applyComponentsFromItemStack(stack); - serverLevel.addFreshEntityWithPassengers(breedOffspring); + serverLevel.addFreshEntityWithPassengers(breedOffspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit - breedOffspring.setCustomName(stack.get(DataComponents.CUSTOM_NAME)); stack.consume(1, player); return Optional.of(breedOffspring); + } diff --git a/paper-server/patches/sources/net/minecraft/world/item/SplashPotionItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/SplashPotionItem.java.patch index 1744dbddc..06950791a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/SplashPotionItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/SplashPotionItem.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/SplashPotionItem.java +++ b/net/minecraft/world/item/SplashPotionItem.java -@@ -14,6 +_,10 @@ +@@ -19,6 +_,10 @@ @Override public InteractionResult use(Level level, Player player, InteractionHand hand) { @@ -11,11 +11,12 @@ level.playSound( null, player.getX(), -@@ -24,6 +_,6 @@ +@@ -29,7 +_,7 @@ 0.5F, 0.4F / (level.getRandom().nextFloat() * 0.4F + 0.8F) ); - return super.use(level, player, hand); + return wrapper; // Paper - PlayerLaunchProjectileEvent } - } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/item/ThrowablePotionItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ThrowablePotionItem.java.patch index 220fab6ac..d68ec052a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ThrowablePotionItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ThrowablePotionItem.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/item/ThrowablePotionItem.java +++ b/net/minecraft/world/item/ThrowablePotionItem.java -@@ -22,11 +_,25 @@ +@@ -23,11 +_,24 @@ public InteractionResult use(Level level, Player player, InteractionHand hand) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { -- Projectile.spawnProjectileFromRotation(ThrownPotion::new, serverLevel, itemInHand, player, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F); +- Projectile.spawnProjectileFromRotation(this::createPotion, serverLevel, itemInHand, player, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F); + // Paper start - PlayerLaunchProjectileEvent -+ final Projectile.Delayed thrownPotion = Projectile.spawnProjectileFromRotationDelayed(ThrownPotion::new, serverLevel, itemInHand, player, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F); ++ final Projectile.Delayed thrownPotion = Projectile.spawnProjectileFromRotationDelayed(this::createPotion, serverLevel, itemInHand, player, -20.0F, PROJECTILE_SHOOT_POWER, 1.0F); + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Projectile) thrownPotion.projectile().getBukkitEntity()); + if (event.callEvent() && thrownPotion.attemptSpawn()) { + if (event.shouldConsume()) { @@ -14,8 +14,6 @@ + } else { + player.containerMenu.sendAllDataToRemote(); + } -+ -+ player.awardStat(Stats.ITEM_USED.get(this)); + } else { + player.containerMenu.sendAllDataToRemote(); + return InteractionResult.FAIL; @@ -23,7 +21,7 @@ + // Paper end - PlayerLaunchProjectileEvent } -- player.awardStat(Stats.ITEM_USED.get(this)); + player.awardStat(Stats.ITEM_USED.get(this)); - itemInHand.consume(1, player); + // Paper - PlayerLaunchProjectileEvent - move up return InteractionResult.SUCCESS; diff --git a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch index 1e9f3060b..56b659eb6 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/TridentItem.java.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java -@@ -87,19 +_,35 @@ +@@ -79,18 +_,39 @@ .orElse(SoundEvents.TRIDENT_THROW); player.awardStat(Stats.ITEM_USED.get(this)); if (level instanceof ServerLevel serverLevel) { - stack.hurtWithoutBreaking(1, player); + // stack.hurtWithoutBreaking(1, player); // CraftBukkit - moved down if (tridentSpinAttackStrength == 0.0F) { +- ItemStack itemStack = stack.consumeAndReturn(1, player); - ThrownTrident thrownTrident = Projectile.spawnProjectileFromRotation( -+ Projectile.Delayed tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent - ThrownTrident::new, serverLevel, stack, player, 0.0F, 2.5F, 1.0F ++ ItemStack itemStack = stack.copyWithCount(1); // Paper ++ Projectile.Delayed tridentDelayed = Projectile.spawnProjectileFromRotationDelayed( // Paper - PlayerLaunchProjectileEvent( + ThrownTrident::new, serverLevel, itemStack, player, 0.0F, 2.5F, 1.0F ); + // Paper start - PlayerLaunchProjectileEvent + com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent event = new com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(stack), (org.bukkit.entity.Projectile) tridentDelayed.projectile().getBukkitEntity()); @@ -20,14 +22,16 @@ + return false; + } + ThrownTrident thrownTrident = tridentDelayed.projectile(); // Paper - PlayerLaunchProjectileEvent -+ if (event.shouldConsume()) stack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent ++ if (event.shouldConsume()) { ++ stack.hurtWithoutBreaking(1, player); // Paper - PlayerLaunchProjectileEvent ++ } + thrownTrident.pickupItemStack = stack.copy(); // SPIGOT-4511 update since damage call moved ++ if (event.shouldConsume()) { ++ stack.consume(1, player); ++ } + // CraftBukkit end if (player.hasInfiniteMaterials()) { thrownTrident.pickup = AbstractArrow.Pickup.CREATIVE_ONLY; -- } else { -+ } else if (event.shouldConsume()) { // Paper - PlayerLaunchProjectileEvent - player.getInventory().removeItem(stack); } level.playSound(null, thrownTrident, holder.value(), SoundSource.PLAYERS, 1.0F, 1.0F); @@ -39,7 +43,7 @@ } } -@@ -113,6 +_,7 @@ +@@ -104,6 +_,7 @@ f *= tridentSpinAttackStrength / squareRoot; f1 *= tridentSpinAttackStrength / squareRoot; f2 *= tridentSpinAttackStrength / squareRoot; diff --git a/paper-server/patches/sources/net/minecraft/world/item/WrittenBookItem.java.patch b/paper-server/patches/sources/net/minecraft/world/item/WrittenBookItem.java.patch deleted file mode 100644 index a8a03bfee..000000000 --- a/paper-server/patches/sources/net/minecraft/world/item/WrittenBookItem.java.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/net/minecraft/world/item/WrittenBookItem.java -+++ b/net/minecraft/world/item/WrittenBookItem.java -@@ -41,7 +_,7 @@ - - public static boolean resolveBookComponents(ItemStack bookStack, CommandSourceStack resolvingSource, @Nullable Player resolvingPlayer) { - WrittenBookContent writtenBookContent = bookStack.get(DataComponents.WRITTEN_BOOK_CONTENT); -- if (writtenBookContent != null && !writtenBookContent.resolved()) { -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && writtenBookContent != null && !writtenBookContent.resolved()) { // Paper - Disable component selector resolving in books by default - WrittenBookContent writtenBookContent1 = writtenBookContent.resolve(resolvingSource, resolvingPlayer); - if (writtenBookContent1 != null) { - bookStack.set(DataComponents.WRITTEN_BOOK_CONTENT, writtenBookContent1); diff --git a/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch index f499dec2e..95e0c047a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/alchemy/PotionContents.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/item/alchemy/PotionContents.java +++ b/net/minecraft/world/item/alchemy/PotionContents.java @@ -158,7 +_,7 @@ - if (mobEffectInstance.getEffect().value().isInstantenous()) { - mobEffectInstance.getEffect().value().applyInstantenousEffect(serverLevel, player1, player1, entity, mobEffectInstance.getAmplifier(), 1.0); + if (effect.getEffect().value().isInstantenous()) { + effect.getEffect().value().applyInstantenousEffect(serverLevel, player1, player1, entity, effect.getAmplifier(), 1.0); } else { -- entity.addEffect(mobEffectInstance); -+ entity.addEffect(mobEffectInstance, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit +- entity.addEffect(effect); ++ entity.addEffect(effect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.POTION_DRINK); // CraftBukkit } - }); + }, durationScale); } diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/BlocksAttacks.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/BlocksAttacks.java.patch new file mode 100644 index 000000000..789abff77 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/component/BlocksAttacks.java.patch @@ -0,0 +1,18 @@ +--- a/net/minecraft/world/item/component/BlocksAttacks.java ++++ b/net/minecraft/world/item/component/BlocksAttacks.java +@@ -86,10 +_,14 @@ + ); + } + +- public void disable(ServerLevel level, LivingEntity entity, float duration, ItemStack stack) { ++ public void disable(ServerLevel level, LivingEntity entity, float duration, ItemStack stack, LivingEntity attacker) { // Paper + int i = this.disableBlockingForTicks(duration); + if (i > 0) { + if (entity instanceof Player player) { ++ // Paper start ++ final io.papermc.paper.event.player.PlayerShieldDisableEvent shieldDisableEvent = new io.papermc.paper.event.player.PlayerShieldDisableEvent((org.bukkit.entity.Player) player.getBukkitEntity(), attacker.getBukkitEntity(), i); ++ if (!shieldDisableEvent.callEvent()) return; ++ // Paper end + player.getCooldowns().addCooldown(stack, i); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch index 37b441949..e8043215a 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/ChargedProjectiles.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/ChargedProjectiles.java +++ b/net/minecraft/world/item/component/ChargedProjectiles.java -@@ -16,6 +_,7 @@ +@@ -22,6 +_,7 @@ .xmap(ChargedProjectiles::new, chargedProjectiles -> chargedProjectiles.items); public static final StreamCodec STREAM_CODEC = ItemStack.STREAM_CODEC .apply(ByteBufCodecs.list()) diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/CustomData.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/CustomData.java.patch index 33b96fd4d..825f0b35c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/CustomData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/CustomData.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/item/component/CustomData.java +++ b/net/minecraft/world/item/component/CustomData.java -@@ -34,7 +_,17 @@ +@@ -33,7 +_,17 @@ private static final Logger LOGGER = LogUtils.getLogger(); public static final CustomData EMPTY = new CustomData(new CompoundTag()); private static final String TYPE_TAG = "id"; -- public static final Codec CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.AS_CODEC) +- public static final Codec CODEC = Codec.withAlternative(CompoundTag.CODEC, TagParser.FLATTENED_CODEC) + // Paper start - Item serialization as json + public static ThreadLocal SERIALIZE_CUSTOM_AS_SNBT = ThreadLocal.withInitial(() -> false); -+ public static final Codec CODEC = Codec.either(CompoundTag.CODEC, TagParser.AS_CODEC) ++ public static final Codec CODEC = Codec.either(CompoundTag.CODEC, TagParser.FLATTENED_CODEC) + .xmap(com.mojang.datafixers.util.Either::unwrap, data -> { // Both will be used for deserialization, but we decide which one to use for serialization + if (!SERIALIZE_CUSTOM_AS_SNBT.get()) { + return com.mojang.datafixers.util.Either.left(data); // First codec @@ -15,7 +15,7 @@ + return com.mojang.datafixers.util.Either.right(data); // Second codec + } + }) -+ // Paper end - Item serialization as json ++ // Paper end - Item serialization as json .xmap(CustomData::new, customData -> customData.tag); public static final Codec CODEC_WITH_ID = CODEC.validate( - data -> data.getUnsafe().contains("id", 8) ? DataResult.success(data) : DataResult.error(() -> "Missing id for entity in: " + data) + data -> data.getUnsafe().getString("id").isPresent() ? DataResult.success(data) : DataResult.error(() -> "Missing id for entity in: " + data) diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/ItemContainerContents.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/ItemContainerContents.java.patch index 825d0f014..03cce7d7e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/ItemContainerContents.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/ItemContainerContents.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/ItemContainerContents.java +++ b/net/minecraft/world/item/component/ItemContainerContents.java -@@ -22,6 +_,7 @@ +@@ -28,6 +_,7 @@ .xmap(ItemContainerContents::fromSlots, ItemContainerContents::asSlots); public static final StreamCodec STREAM_CODEC = ItemStack.OPTIONAL_STREAM_CODEC .apply(ByteBufCodecs.list(256)) diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/OminousBottleAmplifier.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/OminousBottleAmplifier.java.patch index 6a00c3c6f..3bad9d410 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/OminousBottleAmplifier.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/OminousBottleAmplifier.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/OminousBottleAmplifier.java +++ b/net/minecraft/world/item/component/OminousBottleAmplifier.java -@@ -28,8 +_,15 @@ +@@ -29,8 +_,15 @@ @Override public void onConsume(Level level, LivingEntity entity, ItemStack stack, Consumable consumable) { @@ -17,4 +17,4 @@ + // Paper end - properly resend entities - collect packets for bundle @Override - public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag tooltipFlag) { + public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/SuspiciousStewEffects.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/SuspiciousStewEffects.java.patch index d84c096c8..c6c3fb788 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/component/SuspiciousStewEffects.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/component/SuspiciousStewEffects.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/component/SuspiciousStewEffects.java +++ b/net/minecraft/world/item/component/SuspiciousStewEffects.java -@@ -41,6 +_,15 @@ +@@ -42,6 +_,15 @@ } } @@ -14,5 +14,5 @@ + // CraftBukkit end + @Override - public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag tooltipFlag) { - if (tooltipFlag.isCreative()) { + public void addToTooltip(Item.TooltipContext context, Consumer tooltipAdder, TooltipFlag flag, DataComponentGetter componentGetter) { + if (flag.isCreative()) { diff --git a/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch new file mode 100644 index 000000000..5b0109624 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/component/WrittenBookContent.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/item/component/WrittenBookContent.java ++++ b/net/minecraft/world/item/component/WrittenBookContent.java +@@ -94,7 +_,7 @@ + + public static boolean resolveForItem(ItemStack stack, CommandSourceStack source, @Nullable Player player) { + WrittenBookContent writtenBookContent = stack.get(DataComponents.WRITTEN_BOOK_CONTENT); +- if (writtenBookContent != null && !writtenBookContent.resolved()) { ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && writtenBookContent != null && !writtenBookContent.resolved()) { // Paper - Disable component selector resolving in books by default + WrittenBookContent writtenBookContent1 = writtenBookContent.resolve(source, player); + if (writtenBookContent1 != null) { + stack.set(DataComponents.WRITTEN_BOOK_CONTENT, writtenBookContent1); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch index 4d54b2d58..9bad69b28 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/Recipe.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/item/crafting/Recipe.java +++ b/net/minecraft/world/item/crafting/Recipe.java -@@ -44,4 +_,6 @@ +@@ -46,4 +_,6 @@ } RecipeBookCategory recipeBookCategory(); diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch index 5e4907953..699390e1e 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTransformRecipe.java.patch @@ -1,32 +1,31 @@ --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java @@ -21,8 +_,15 @@ - final ItemStack result; + final TransmuteResult result; @Nullable private PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy - public SmithingTransformRecipe(Optional template, Optional base, Optional addition, ItemStack result) { -+ // Paper start - Option to prevent data components copy + public SmithingTransformRecipe(Optional template, Ingredient base, Optional addition, TransmuteResult result) { ++ // Paper start - Option to prevent data components copy + this(template, base, addition, result, true); + } -+ public SmithingTransformRecipe(Optional template, Optional base, Optional addition, ItemStack result, boolean copyDataComponents) { ++ public SmithingTransformRecipe(Optional template, Ingredient base, Optional addition, TransmuteResult result, boolean copyDataComponents) { + this.copyDataComponents = copyDataComponents; -+ // Paper end - Option to prevent data components copy ++ // Paper end - Option to prevent data components copy this.template = template; this.base = base; this.addition = addition; -@@ -32,7 +_,9 @@ +@@ -31,7 +_,7 @@ + @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { - ItemStack itemStack = input.base().transmuteCopy(this.result.getItem(), this.result.getCount()); -+ if (this.copyDataComponents) { // Paper - Option to prevent data components copy - itemStack.applyComponents(this.result.getComponentsPatch()); -+ } // Paper - Option to prevent data components copy - return itemStack; +- return this.result.apply(input.base()); ++ return this.result.apply(input.base(), this.copyDataComponents); // Paper - Option to prevent data components copy } -@@ -77,6 +_,17 @@ + @Override +@@ -75,6 +_,17 @@ ) ); } @@ -34,7 +33,7 @@ + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { -+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result); ++ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(new ItemStack(this.result.item(), this.result.count(), this.result.components())); + + org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy + diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch index 09cb0b71f..7b1e17dca 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -1,48 +1,48 @@ --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -27,8 +_,15 @@ - final Optional addition; +@@ -28,8 +_,15 @@ + final Holder pattern; @Nullable private PlacementInfo placementInfo; + final boolean copyDataComponents; // Paper - Option to prevent data components copy - public SmithingTrimRecipe(Optional template, Optional base, Optional addition) { + public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, Holder pattern) { + // Paper start - Option to prevent data components copy -+ this(template, base, addition, true); ++ this(template, base, addition, pattern, true); + } -+ public SmithingTrimRecipe(Optional template, Optional base, Optional addition, boolean copyDataComponents) { ++ public SmithingTrimRecipe(Ingredient template, Ingredient base, Ingredient addition, Holder pattern, final boolean copyDataComponents) { + this.copyDataComponents = copyDataComponents; + // Paper end - Option to prevent data components copy this.template = template; this.base = base; this.addition = addition; -@@ -36,10 +_,15 @@ +@@ -38,10 +_,15 @@ @Override public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) { -- return applyTrim(registries, input.base(), input.addition(), input.template()); -+ return applyTrim(registries, input.base(), input.addition(), input.template(), this.copyDataComponents); // Paper - Option to prevent data components copy +- return applyTrim(registries, input.base(), input.addition(), this.pattern); ++ return applyTrim(registries, input.base(), input.addition(), this.pattern, this.copyDataComponents); // Paper start - Option to prevent data components copy } - public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template) { -+ // Paper start - Option to prevent data components copy -+ return applyTrim(registries, base, addition, template, true); + public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, Holder pattern) { ++ // Paper start - Option to prevent data components copy ++ return applyTrim(registries, base, addition, pattern, true); + } -+ public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template, boolean copyDataComponents) { -+ // Paper end - Option to prevent data components copy - Optional> fromIngredient = TrimMaterials.getFromIngredient(registries, addition); - Optional> fromTemplate = TrimPatterns.getFromTemplate(registries, template); - if (fromIngredient.isPresent() && fromTemplate.isPresent()) { -@@ -47,7 +_,7 @@ - if (armorTrim != null && armorTrim.hasPatternAndMaterial(fromTemplate.get(), fromIngredient.get())) { ++ public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, Holder pattern, final boolean copyDataComponents) { ++ // Paper end - Option to prevent data components copy + Optional> fromIngredient = TrimMaterials.getFromIngredient(registries, addition); + if (fromIngredient.isPresent()) { + ArmorTrim armorTrim = base.get(DataComponents.TRIM); +@@ -49,7 +_,7 @@ + if (Objects.equals(armorTrim, armorTrim1)) { return ItemStack.EMPTY; } else { - ItemStack itemStack = base.copyWithCount(1); + ItemStack itemStack = copyDataComponents ? base.copyWithCount(1) : new ItemStack(base.getItem(), 1); // Paper - Option to prevent data components copy - itemStack.set(DataComponents.TRIM, new ArmorTrim(fromIngredient.get(), fromTemplate.get())); + itemStack.set(DataComponents.TRIM, armorTrim1); return itemStack; } -@@ -100,6 +_,13 @@ +@@ -102,6 +_,13 @@ ) ); } @@ -50,7 +50,7 @@ + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { -+ return new org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe(id, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy ++ return new org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe(id, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern.minecraftHolderToBukkit(this.pattern), this.copyDataComponents); // Paper - Option to prevent data components copy + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch index bdfba17d6..53a594391 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteRecipe.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/item/crafting/TransmuteRecipe.java +++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java -@@ -88,6 +_,13 @@ +@@ -85,6 +_,13 @@ ); } + // CraftBukkit start + @Override + public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { -+ return new org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe(id, org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(this.result.value()), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.material)); ++ return new org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe(id, org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(this.result.item().value()), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.material)); + } + // CraftBukkit end + diff --git a/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteResult.java.patch b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteResult.java.patch new file mode 100644 index 000000000..e26185120 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/item/crafting/TransmuteResult.java.patch @@ -0,0 +1,17 @@ +--- a/net/minecraft/world/item/crafting/TransmuteResult.java ++++ b/net/minecraft/world/item/crafting/TransmuteResult.java +@@ -45,8 +_,13 @@ + } + + public ItemStack apply(ItemStack stack) { ++ // Paper start - Option to prevent data components copy ++ return apply(stack, true); ++ } ++ public ItemStack apply(ItemStack stack, boolean applyComponents) { ++ // Paper end - Option to prevent data components copy + ItemStack itemStack = stack.transmuteCopy(this.item.value(), this.count); +- itemStack.applyComponents(this.components); ++ if (applyComponents) itemStack.applyComponents(this.components); // Paper - Option to prevent data components copy + return itemStack; + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch index d49d59d33..d0e55ad13 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/ItemEnchantments.java.patch @@ -1,54 +1,41 @@ --- a/net/minecraft/world/item/enchantment/ItemEnchantments.java +++ b/net/minecraft/world/item/enchantment/ItemEnchantments.java -@@ -28,10 +_,19 @@ +@@ -28,21 +_,24 @@ import net.minecraft.world.item.component.TooltipProvider; public class ItemEnchantments implements TooltipProvider { -- public static final ItemEnchantments EMPTY = new ItemEnchantments(new Object2IntOpenHashMap<>(), true); -+ // Paper start -+ private static final java.util.Comparator> ENCHANTMENT_ORDER = java.util.Comparator.comparing(Holder::getRegisteredName); -+ public static final ItemEnchantments EMPTY = new ItemEnchantments(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), true); -+ // Paper end - private static final Codec LEVEL_CODEC = Codec.intRange(1, 255); -- private static final Codec>> LEVELS_CODEC = Codec.unboundedMap(Enchantment.CODEC, LEVEL_CODEC) -- .xmap(Object2IntOpenHashMap::new, Function.identity()); +- public static final ItemEnchantments EMPTY = new ItemEnchantments(new Object2IntOpenHashMap<>()); + // Paper start - sort enchantments -+ private static final Codec>> LEVELS_CODEC = Codec.unboundedMap(Enchantment.CODEC, LEVEL_CODEC) -+ .xmap(m -> { -+ final it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap> map = new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER); -+ map.putAll(m); -+ return map; -+ }, Function.identity()); ++ private static final java.util.Comparator> ENCHANTMENT_ORDER = java.util.Comparator.comparing(Holder::getRegisteredName); ++ public static final ItemEnchantments EMPTY = new ItemEnchantments(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER)); + // Paper end - sort enchantments - private static final Codec FULL_CODEC = RecordCodecBuilder.create( - instance -> instance.group( - LEVELS_CODEC.fieldOf("levels").forGetter(itemEnchantments -> itemEnchantments.enchantments), -@@ -41,16 +_,16 @@ - ); - public static final Codec CODEC = Codec.withAlternative(FULL_CODEC, LEVELS_CODEC, map -> new ItemEnchantments(map, true)); + private static final Codec LEVEL_CODEC = Codec.intRange(1, 255); + public static final Codec CODEC = Codec.unboundedMap(Enchantment.CODEC, LEVEL_CODEC) + .xmap( +- map -> new ItemEnchantments(new Object2IntOpenHashMap<>((Map, ? extends Integer>)map)), ++ map -> new net.minecraft.world.item.enchantment.ItemEnchantments(net.minecraft.Util.make(new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), m -> m.putAll(map))), // Paper - sort enchantments + itemEnchantments -> itemEnchantments.enchantments + ); public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ByteBufCodecs.map(Object2IntOpenHashMap::new, Enchantment.STREAM_CODEC, ByteBufCodecs.VAR_INT), + ByteBufCodecs.map((v) -> new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER), Enchantment.STREAM_CODEC, ByteBufCodecs.VAR_INT), // Paper itemEnchantments -> itemEnchantments.enchantments, - ByteBufCodecs.BOOL, - itemEnchantments -> itemEnchantments.showInTooltip, ItemEnchantments::new ); - final Object2IntOpenHashMap> enchantments; + final it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap> enchantments; // Paper - public final boolean showInTooltip; -- ItemEnchantments(Object2IntOpenHashMap> enchantments, boolean showInTooltip) { -+ ItemEnchantments(it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap> enchantments, boolean showInTooltip) { // Paper +- ItemEnchantments(Object2IntOpenHashMap> enchantments) { ++ ItemEnchantments(it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap> enchantments) { // Paper this.enchantments = enchantments; - this.showInTooltip = showInTooltip; -@@ -139,7 +_,7 @@ + for (Entry> entry : enchantments.object2IntEntrySet()) { +@@ -120,7 +_,7 @@ } public static class Mutable { - private final Object2IntOpenHashMap> enchantments = new Object2IntOpenHashMap<>(); + private final it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap> enchantments = new it.unimi.dsi.fastutil.objects.Object2IntAVLTreeMap<>(ENCHANTMENT_ORDER); // Paper - public boolean showInTooltip; public Mutable(ItemEnchantments enchantments) { + this.enchantments.putAll(enchantments.enchantments); diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java.patch index 4e789c8e9..b4bb653da 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceBlock.java.patch @@ -5,7 +5,7 @@ BlockPos blockPos = BlockPos.containing(origin).offset(this.offset); if (this.predicate.map(blockPredicate -> blockPredicate.test(level, blockPos)).orElse(true) - && level.setBlockAndUpdate(blockPos, this.blockState.getState(entity.getRandom(), blockPos))) { -+ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos, this.blockState.getState(entity.getRandom(), blockPos), entity)) { // CraftBukkit - Call EntityBlockFormEvent ++ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos, this.blockState.getState(entity.getRandom(), blockPos), 3, entity, true)) { // CraftBukkit - Call EntityBlockFormEvent this.triggerGameEvent.ifPresent(holder -> level.gameEvent(entity, (Holder)holder, blockPos)); } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch index 08b184622..ec0c0a741 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/enchantment/effects/ReplaceDisk.java.patch @@ -5,7 +5,7 @@ if (blockPos1.distToCenterSqr(origin.x(), blockPos1.getY() + 0.5, origin.z()) < Mth.square(i) && this.predicate.map(predicate -> predicate.test(level, blockPos1)).orElse(true) - && level.setBlockAndUpdate(blockPos1, this.blockState.getState(random, blockPos1))) { -+ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos1, this.blockState.getState(random, blockPos1), entity)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker ++ && org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, blockPos1, this.blockState.getState(random, blockPos1), 3, entity, true)) { // CraftBukkit - Call EntityBlockFormEvent for Frost Walker this.triggerGameEvent.ifPresent(event -> level.gameEvent(entity, (Holder)event, blockPos1)); } } diff --git a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch index 36c879841..9a3b747be 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/trading/Merchant.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/item/trading/Merchant.java +++ b/net/minecraft/world/item/trading/Merchant.java -@@ -19,6 +_,7 @@ +@@ -19,6 +_,8 @@ void overrideOffers(MerchantOffers offers); -+ default void processTrade(MerchantOffer merchantRecipe, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { this.notifyTrade(merchantRecipe); } // Paper ++ default void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { this.notifyTrade(offer); } // Paper ++ void notifyTrade(MerchantOffer offer); void notifyTradeUpdated(ItemStack stack); diff --git a/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch b/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch index 05eb5597d..a6c1d0753 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/item/trading/MerchantOffer.java +++ b/net/minecraft/world/item/trading/MerchantOffer.java @@ -21,6 +_,7 @@ - Codec.INT.lenientOptionalFieldOf("demand", Integer.valueOf(0)).forGetter(merchantOffer -> merchantOffer.demand), - Codec.FLOAT.lenientOptionalFieldOf("priceMultiplier", Float.valueOf(0.0F)).forGetter(merchantOffer -> merchantOffer.priceMultiplier), - Codec.INT.lenientOptionalFieldOf("xp", Integer.valueOf(1)).forGetter(merchantOffer -> merchantOffer.xp) + Codec.INT.lenientOptionalFieldOf("demand", 0).forGetter(merchantOffer -> merchantOffer.demand), + Codec.FLOAT.lenientOptionalFieldOf("priceMultiplier", 0.0F).forGetter(merchantOffer -> merchantOffer.priceMultiplier), + Codec.INT.lenientOptionalFieldOf("xp", 1).forGetter(merchantOffer -> merchantOffer.xp) + , Codec.BOOL.lenientOptionalFieldOf("Paper.IgnoreDiscounts", false).forGetter(merchantOffer -> merchantOffer.ignoreDiscounts) // Paper ) .apply(instance, MerchantOffer::new) diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch index a00c43b74..0c982e858 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseCommandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseCommandBlock.java +++ b/net/minecraft/world/level/BaseCommandBlock.java -@@ -32,6 +_,11 @@ +@@ -37,6 +_,11 @@ private String command = ""; @Nullable private Component customName; @@ -12,7 +12,7 @@ public int getSuccessCount() { return this.successCount; -@@ -126,7 +_,7 @@ +@@ -114,7 +_,7 @@ this.successCount++; } }); @@ -21,7 +21,7 @@ } catch (Throwable var6) { CrashReport crashReport = CrashReport.forThrowable(var6, "Executing command block"); CrashReportCategory crashReportCategory = crashReport.addCategory("Command to be executed"); -@@ -162,6 +_,7 @@ +@@ -150,6 +_,7 @@ @Override public void sendSystemMessage(Component component) { if (this.trackOutput) { @@ -29,7 +29,7 @@ this.lastOutput = Component.literal("[" + TIME_FORMAT.format(new Date()) + "] ").append(component); this.onUpdated(); } -@@ -184,7 +_,7 @@ +@@ -172,7 +_,7 @@ } public InteractionResult usedBy(Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch index a27f9ad41..3d0ff5e49 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BaseSpawner.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/BaseSpawner.java +++ b/net/minecraft/world/level/BaseSpawner.java -@@ -44,13 +_,15 @@ +@@ -46,13 +_,15 @@ public int maxNearbyEntities = 6; public int requiredPlayerRange = 16; public int spawnRange = 4; @@ -8,7 +8,7 @@ public void setEntityId(EntityType type, @Nullable Level level, RandomSource random, BlockPos pos) { this.getOrCreateNextSpawnData(level, random, pos).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(type).toString()); -+ this.spawnPotentials = SimpleWeightedRandomList.empty(); // CraftBukkit - SPIGOT-3496, MC-92282 ++ this.spawnPotentials = WeightedList.of(); // CraftBukkit - SPIGOT-3496, MC-92282 } public boolean isNearPlayer(Level level, BlockPos pos) { @@ -17,7 +17,7 @@ } public void clientTick(Level level, BlockPos pos) { -@@ -73,13 +_,19 @@ +@@ -75,13 +_,19 @@ } public void serverTick(ServerLevel serverLevel, BlockPos pos) { @@ -39,15 +39,15 @@ } else { boolean flag = false; RandomSource random = serverLevel.getRandom(); -@@ -113,6 +_,21 @@ +@@ -118,6 +_,21 @@ continue; } + // Paper start - PreCreatureSpawnEvent + com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent event = new com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(serverLevel, d, d1, d2), ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(vec3, serverLevel.getWorld()), + org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(optional.get()), -+ io.papermc.paper.util.MCUtil.toLocation(serverLevel, pos) ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, serverLevel) + ); + if (!event.callEvent()) { + flag = true; @@ -59,17 +59,17 @@ + // Paper end - PreCreatureSpawnEvent + Entity entity = EntityType.loadEntityRecursive(entityToSpawn, serverLevel, EntitySpawnReason.SPAWNER, entity1 -> { - entity1.moveTo(d, d1, d2, entity1.getYRot(), entity1.getXRot()); + entity1.snapTo(vec3.x, vec3.y, vec3.z, entity1.getYRot(), entity1.getXRot()); return entity1; -@@ -133,6 +_,7 @@ +@@ -138,6 +_,7 @@ return; } + entity.preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; preserve entity motion from tag - entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), random.nextFloat() * 360.0F, 0.0F); + entity.snapTo(entity.getX(), entity.getY(), entity.getZ(), random.nextFloat() * 360.0F, 0.0F); if (entity instanceof Mob mob) { if (nextSpawnData.getCustomSpawnRules().isEmpty() && !mob.checkSpawnRules(serverLevel, EntitySpawnReason.SPAWNER) -@@ -147,9 +_,22 @@ +@@ -152,9 +_,22 @@ } nextSpawnData.getEquipment().ifPresent(mob::equip); @@ -93,7 +93,7 @@ this.delay(serverLevel, pos); return; } -@@ -160,7 +_,7 @@ +@@ -165,7 +_,7 @@ ((Mob)entity).spawnAnim(); } @@ -102,39 +102,26 @@ } } -@@ -184,7 +_,13 @@ +@@ -189,12 +_,14 @@ } public void load(@Nullable Level level, BlockPos pos, CompoundTag tag) { -+ // Paper start - use larger int if set -+ if (tag.contains("Paper.Delay")) { -+ this.spawnDelay = tag.getInt("Paper.Delay"); -+ } else { - this.spawnDelay = tag.getShort("Delay"); -+ } -+ // Paper end - boolean flag = tag.contains("SpawnData", 10); - if (flag) { - SpawnData spawnData = SpawnData.CODEC -@@ -205,9 +_,15 @@ - this.spawnPotentials = SimpleWeightedRandomList.single(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData()); - } - -+ // Paper start - use ints if set -+ if (tag.contains("Paper.MinSpawnDelay", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ this.minSpawnDelay = tag.getInt("Paper.MinSpawnDelay"); -+ this.maxSpawnDelay = tag.getInt("Paper.MaxSpawnDelay"); -+ this.spawnCount = tag.getShort("SpawnCount"); -+ } else // Paper end - if (tag.contains("MinSpawnDelay", 99)) { -- this.minSpawnDelay = tag.getShort("MinSpawnDelay"); -- this.maxSpawnDelay = tag.getShort("MaxSpawnDelay"); -+ this.minSpawnDelay = tag.getInt("MinSpawnDelay"); // Paper - short -> int -+ this.maxSpawnDelay = tag.getInt("MaxSpawnDelay"); // Paper - short -> int - this.spawnCount = tag.getShort("SpawnCount"); - } - -@@ -224,9 +_,20 @@ +- this.spawnDelay = tag.getShortOr("Delay", (short)20); ++ this.spawnDelay = tag.getIntOr("Paper.Delay", tag.getShortOr("Delay", (short) 20)); // Paper - use int if set + tag.read("SpawnData", SpawnData.CODEC).ifPresent(spawnData -> this.setNextSpawnData(level, pos, spawnData)); + this.spawnPotentials = tag.read("SpawnPotentials", SpawnData.LIST_CODEC) +- .orElseGet(() -> WeightedList.of(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData())); +- this.minSpawnDelay = tag.getIntOr("MinSpawnDelay", 200); +- this.maxSpawnDelay = tag.getIntOr("MaxSpawnDelay", 800); ++ .orElseGet(() -> WeightedList.of(this.nextSpawnData != null ? this.nextSpawnData : new SpawnData())); ++ // Paper start - use int if set ++ this.minSpawnDelay = tag.getIntOr("Paper.MinSpawnDelay", tag.getIntOr("MinSpawnDelay", 200)); ++ this.maxSpawnDelay = tag.getIntOr("Paper.MaxSpawnDelay", tag.getIntOr("MaxSpawnDelay", 800)); ++ // Paper end - use int if set + this.spawnCount = tag.getIntOr("SpawnCount", 4); + this.maxNearbyEntities = tag.getIntOr("MaxNearbyEntities", 6); + this.requiredPlayerRange = tag.getIntOr("RequiredPlayerRange", 16); +@@ -203,9 +_,19 @@ } public CompoundTag save(CompoundTag tag) { @@ -142,16 +129,15 @@ - tag.putShort("MinSpawnDelay", (short)this.minSpawnDelay); - tag.putShort("MaxSpawnDelay", (short)this.maxSpawnDelay); + // Paper start -+ if (spawnDelay > Short.MAX_VALUE) { ++ if (this.spawnDelay > Short.MAX_VALUE) { + tag.putInt("Paper.Delay", this.spawnDelay); + } + tag.putShort("Delay", (short) Math.min(Short.MAX_VALUE, this.spawnDelay)); + -+ if (minSpawnDelay > Short.MAX_VALUE || maxSpawnDelay > Short.MAX_VALUE) { ++ if (this.minSpawnDelay > Short.MAX_VALUE || this.maxSpawnDelay > Short.MAX_VALUE) { + tag.putInt("Paper.MinSpawnDelay", this.minSpawnDelay); + tag.putInt("Paper.MaxSpawnDelay", this.maxSpawnDelay); + } -+ + tag.putShort("MinSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.minSpawnDelay)); + tag.putShort("MaxSpawnDelay", (short) Math.min(Short.MAX_VALUE, this.maxSpawnDelay)); + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch index 41d701302..c81558755 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/BlockGetter.java.patch @@ -1,25 +1,18 @@ --- a/net/minecraft/world/level/BlockGetter.java +++ b/net/minecraft/world/level/BlockGetter.java -@@ -11,6 +_,7 @@ - import net.minecraft.core.BlockPos; - import net.minecraft.core.Direction; - import net.minecraft.util.Mth; -+import net.minecraft.world.level.block.Block; - import net.minecraft.world.level.block.entity.BlockEntity; - import net.minecraft.world.level.block.entity.BlockEntityType; - import net.minecraft.world.level.block.state.BlockState; -@@ -33,6 +_,16 @@ +@@ -33,6 +_,17 @@ BlockState getBlockState(BlockPos pos); + // Paper start - if loaded util -+ @Nullable BlockState getBlockStateIfLoaded(BlockPos blockposition); ++ @Nullable BlockState getBlockStateIfLoaded(BlockPos pos); + -+ default @Nullable Block getBlockIfLoaded(BlockPos blockposition) { -+ BlockState type = this.getBlockStateIfLoaded(blockposition); ++ default @Nullable net.minecraft.world.level.block.Block getBlockIfLoaded(BlockPos pos) { ++ BlockState type = this.getBlockStateIfLoaded(pos); + return type == null ? null : type.getBlock(); + } -+ @Nullable FluidState getFluidIfLoaded(BlockPos blockposition); ++ ++ @Nullable FluidState getFluidIfLoaded(BlockPos pos); + // Paper end + FluidState getFluidState(BlockPos pos); @@ -39,7 +32,7 @@ + return clip(traverseContext, traversePos, null); + } + -+ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext traverseContext, BlockPos traversePos, @Nullable java.util.function.Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + // Paper start - Prevent raytrace from loading chunks + BlockState blockState = this.getBlockStateIfLoaded(traversePos); @@ -67,7 +60,7 @@ + return clip(context, (java.util.function.Predicate) null); + } + -+ default BlockHitResult clip(ClipContext context, java.util.function.Predicate canCollide) { ++ default BlockHitResult clip(ClipContext context, @Nullable java.util.function.Predicate canCollide) { + // Paper end - Add predicate for blocks when raytracing + return (BlockHitResult) BlockGetter.traverseBlocks(context.getFrom(), context.getTo(), context, (raytrace1, blockposition) -> { + return this.clip(raytrace1, blockposition, canCollide); // CraftBukkit - moved into separate method // Paper - Add predicate for blocks when raytracing diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch index 6ca1c8d13..f4f7f574b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockAndTintGetter.java.patch @@ -6,12 +6,12 @@ + // Paper start + @Override -+ public @org.jetbrains.annotations.Nullable BlockState getBlockStateIfLoaded(final BlockPos blockposition) { ++ public @Nullable BlockState getBlockStateIfLoaded(final BlockPos pos) { + return null; + } + + @Override -+ public @org.jetbrains.annotations.Nullable FluidState getFluidIfLoaded(final BlockPos blockposition) { ++ public @Nullable FluidState getFluidIfLoaded(final BlockPos pos) { + return null; + } + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch index dfb2f644a..d98e9785d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/EmptyBlockGetter.java.patch @@ -6,12 +6,12 @@ + // Paper start - If loaded util + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { ++ public final FluidState getFluidIfLoaded(BlockPos pos) { + return Fluids.EMPTY.defaultFluidState(); + } + + @Override -+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { ++ public final BlockState getBlockStateIfLoaded(BlockPos pos) { + return Blocks.AIR.defaultBlockState(); + } + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch index e4e113986..b644ae815 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/GameRules.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/GameRules.java +++ b/net/minecraft/world/level/GameRules.java -@@ -32,6 +_,14 @@ +@@ -34,6 +_,14 @@ import org.slf4j.Logger; public class GameRules { @@ -15,7 +15,7 @@ public static final int DEFAULT_RANDOM_TICK_SPEED = 3; static final Logger LOGGER = LogUtils.getLogger(); private static final Map, GameRules.Type> GAME_RULE_TYPES = Maps.newTreeMap(Comparator.comparing(entry -> entry.id)); -@@ -81,10 +_,10 @@ +@@ -86,10 +_,10 @@ "sendCommandFeedback", GameRules.Category.CHAT, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_REDUCEDDEBUGINFO = register( @@ -28,7 +28,7 @@ serverPlayer.connection.send(new ClientboundEntityEventPacket(serverPlayer, b)); } }) -@@ -108,8 +_,8 @@ +@@ -113,8 +_,8 @@ "doWeatherCycle", GameRules.Category.UPDATES, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_LIMITED_CRAFTING = register( @@ -39,7 +39,7 @@ serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.LIMITED_CRAFTING, value.get() ? 1.0F : 0.0F)); } }) -@@ -133,8 +_,8 @@ +@@ -138,8 +_,8 @@ "doInsomnia", GameRules.Category.SPAWNING, GameRules.BooleanValue.create(true) ); public static final GameRules.Key RULE_DO_IMMEDIATE_RESPAWN = register( @@ -50,7 +50,7 @@ serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.IMMEDIATE_RESPAWN, value.get() ? 1.0F : 0.0F)); } }) -@@ -205,16 +_,17 @@ +@@ -210,11 +_,11 @@ public static final GameRules.Key RULE_MINECART_MAX_SPEED = register( "minecartMaxSpeed", GameRules.Category.MISC, @@ -65,13 +65,15 @@ serverLevel.setDefaultSpawnPos(serverLevel.getSharedSpawnPos(), serverLevel.getSharedSpawnAngle()); }) ); +@@ -223,6 +_,7 @@ + ); private final Map, GameRules.Value> rules; private final FeatureFlagSet enabledFeatures; + private final GameRules.Value[] gameruleArray; // Paper - Perf: Use array for gamerule storage - private static > GameRules.Key register(String name, GameRules.Category category, GameRules.Type type) { - GameRules.Key key = new GameRules.Key<>(name, category); -@@ -242,10 +_,21 @@ + public static > GameRules.Type getType(GameRules.Key key) { + return (GameRules.Type)GAME_RULE_TYPES.get(key); +@@ -270,10 +_,21 @@ private GameRules(Map, GameRules.Value> rules, FeatureFlagSet enabledFeatures) { this.rules = rules; this.enabledFeatures = enabledFeatures; @@ -94,7 +96,7 @@ if (value == null) { throw new IllegalArgumentException("Tried to access invalid game rule"); } else { -@@ -286,13 +_,13 @@ +@@ -314,13 +_,13 @@ } } @@ -112,7 +114,7 @@ } public boolean getBoolean(GameRules.Key key) { -@@ -306,7 +_,7 @@ +@@ -334,7 +_,7 @@ public static class BooleanValue extends GameRules.Value { private boolean value; @@ -121,7 +123,7 @@ return new GameRules.Type<>( BoolArgumentType::bool, type -> new GameRules.BooleanValue(type, defaultValue), -@@ -326,17 +_,21 @@ +@@ -355,17 +_,21 @@ } @Override @@ -129,7 +131,7 @@ - this.value = BoolArgumentType.getBool(context, paramName); + // Paper start - Add WorldGameRuleChangeEvent + protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName))); ++ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(BoolArgumentType.getBool(context, paramName))); + if (!event.callEvent()) return; + this.value = Boolean.parseBoolean(event.getValue()); + // Paper end - Add WorldGameRuleChangeEvent @@ -147,16 +149,7 @@ } @Override -@@ -345,7 +_,7 @@ - } - - @Override -- protected void deserialize(String value) { -+ public void deserialize(String value) { // PAIL - protected->public - this.value = Boolean.parseBoolean(value); - } - -@@ -365,9 +_,9 @@ +@@ -394,9 +_,9 @@ } @Override @@ -168,7 +161,7 @@ } } -@@ -405,7 +_,7 @@ +@@ -434,7 +_,7 @@ public static class IntegerValue extends GameRules.Value { private int value; @@ -177,7 +170,7 @@ return new GameRules.Type<>( IntegerArgumentType::integer, type -> new GameRules.IntegerValue(type, defaultValue), -@@ -416,7 +_,7 @@ +@@ -446,7 +_,7 @@ } static GameRules.Type create( @@ -186,7 +179,7 @@ ) { return new GameRules.Type<>( () -> IntegerArgumentType.integer(min, max), -@@ -437,17 +_,21 @@ +@@ -468,17 +_,21 @@ } @Override @@ -194,7 +187,7 @@ - this.value = IntegerArgumentType.getInteger(context, paramName); + // Paper start - Add WorldGameRuleChangeEvent + protected void updateFromArgument(CommandContext context, String paramName, GameRules.Key gameRuleKey) { -+ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), (org.bukkit.GameRule) org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName))); ++ io.papermc.paper.event.world.WorldGameRuleChangeEvent event = new io.papermc.paper.event.world.WorldGameRuleChangeEvent(context.getSource().getBukkitWorld(), context.getSource().getBukkitSender(), org.bukkit.GameRule.getByName(gameRuleKey.toString()), String.valueOf(IntegerArgumentType.getInteger(context, paramName))); + if (!event.callEvent()) return; + this.value = Integer.parseInt(event.getValue()); + // Paper end - Add WorldGameRuleChangeEvent @@ -212,16 +205,7 @@ } @Override -@@ -456,7 +_,7 @@ - } - - @Override -- protected void deserialize(String value) { -+ public void deserialize(String value) { // PAIL - protected->public - this.value = safeParse(value); - } - -@@ -498,13 +_,17 @@ +@@ -529,13 +_,17 @@ } @Override @@ -241,24 +225,25 @@ final String id; private final GameRules.Category category; -@@ -544,14 +_,14 @@ +@@ -575,7 +_,7 @@ public static class Type> { final Supplier> argument; private final Function, T> constructor; - final BiConsumer callback; + final BiConsumer callback; // CraftBukkit - per-world private final GameRules.VisitorCaller visitorCaller; + final Class valueClass; final FeatureFlagSet requiredFeatures; - +@@ -583,7 +_,7 @@ Type( Supplier> argument, Function, T> constructor, - BiConsumer callback, + BiConsumer callback, // CraftBukkit - per-world GameRules.VisitorCaller visitorCaller, - FeatureFlagSet requiredFeature - ) { -@@ -586,20 +_,20 @@ + Class valueClass, + FeatureFlagSet requiredFeatures +@@ -620,16 +_,16 @@ this.type = type; } @@ -282,12 +267,7 @@ } } -- protected abstract void deserialize(String value); -+ public abstract void deserialize(String value); // PAIL - private->public - - public abstract String serialize(); - -@@ -614,7 +_,7 @@ +@@ -648,7 +_,7 @@ protected abstract T copy(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch index 9958bd72b..e037c3af1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/Level.java.patch @@ -1,68 +1,36 @@ --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -24,8 +_,10 @@ - import net.minecraft.network.protocol.Packet; - import net.minecraft.resources.ResourceKey; - import net.minecraft.resources.ResourceLocation; -+import io.papermc.paper.util.MCUtil; - import net.minecraft.server.MinecraftServer; - import net.minecraft.server.level.FullChunkStatus; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; -@@ -79,6 +_,27 @@ +@@ -83,6 +_,16 @@ import net.minecraft.world.phys.Vec3; import net.minecraft.world.scores.Scoreboard; +// CraftBukkit start -+import java.util.HashMap; +import java.util.Map; -+import net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket; -+import net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket; -+import net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket; -+import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket; -+import net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket; -+import net.minecraft.world.level.border.BorderChangeListener; -+import net.minecraft.world.level.dimension.LevelStem; -+import org.bukkit.Bukkit; ++import net.minecraft.server.level.ServerLevel; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.CraftWorld; -+import org.bukkit.craftbukkit.block.CapturedBlockState; +import org.bukkit.craftbukkit.block.CraftBlockState; +import org.bukkit.craftbukkit.block.data.CraftBlockData; -+import org.bukkit.craftbukkit.util.CraftSpawnCategory; +import org.bukkit.entity.SpawnCategory; -+import org.bukkit.event.block.BlockPhysicsEvent; +// CraftBukkit end + - public abstract class Level implements LevelAccessor, AutoCloseable { + public abstract class Level implements LevelAccessor, UUIDLookup, AutoCloseable { public static final Codec> RESOURCE_KEY_CODEC = ResourceKey.codec(Registries.DIMENSION); public static final ResourceKey OVERWORLD = ResourceKey.create(Registries.DIMENSION, ResourceLocation.withDefaultNamespace("overworld")); -@@ -91,7 +_,7 @@ - public static final int TICKS_PER_DAY = 24000; - public static final int MAX_ENTITY_SPAWN_Y = 20000000; - public static final int MIN_ENTITY_SPAWN_Y = -20000000; -- protected final List blockEntityTickers = Lists.newArrayList(); -+ public final List blockEntityTickers = Lists.newArrayList(); // Paper - public - protected final NeighborUpdater neighborUpdater; - private final List pendingBlockEntityTickers = Lists.newArrayList(); - private boolean tickingBlockEntities; -@@ -117,6 +_,61 @@ +@@ -121,6 +_,57 @@ private final DamageSources damageSources; private long subTickCount; -+ // CraftBukkit start Added the following ++ // CraftBukkit start + private final CraftWorld world; + public boolean pvpMode; + public org.bukkit.generator.ChunkGenerator generator; + -+ public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; -+ public boolean isBlockPlaceCancelled = false; // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent + public Map capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper + public Map capturedTileEntities = new java.util.LinkedHashMap<>(); // Paper - Retain block place order when capturing blockstates ++ @Nullable + public List captureDrops; + public final it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap ticksPerSpawnCategory = new it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap<>(); + public boolean populating; @@ -74,11 +42,9 @@ + } + // Paper end - add paper world config + -+ public static BlockPos lastPhysicsProblem; // Spigot -+ private org.spigotmc.TickLimiter entityLimiter; -+ private org.spigotmc.TickLimiter tileLimiter; ++ public static @Nullable BlockPos lastPhysicsProblem; // Spigot + private int tileTickPosition; -+ public final Map explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions ++ public final Map explosionDensityCache = new java.util.HashMap<>(); // Paper - Optimize explosions + public java.util.ArrayDeque redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here + + public CraftWorld getWorld() { @@ -86,7 +52,7 @@ + } + + public CraftServer getCraftServer() { -+ return (CraftServer) Bukkit.getServer(); ++ return (CraftServer) org.bukkit.Bukkit.getServer(); + } + // Paper start - Use getChunkIfLoadedImmediately + @Override @@ -96,7 +62,7 @@ + // Paper end - Use getChunkIfLoadedImmediately + // Paper start - per world ticks per spawn + private int getTicksPerSpawn(SpawnCategory spawnCategory) { -+ final int perWorld = this.paperConfig().entities.spawning.ticksPerSpawn.getInt(CraftSpawnCategory.toNMS(spawnCategory)); ++ final int perWorld = this.paperConfig().entities.spawning.ticksPerSpawn.getInt(org.bukkit.craftbukkit.util.CraftSpawnCategory.toNMS(spawnCategory)); + if (perWorld >= 0) { + return perWorld; + } @@ -104,13 +70,12 @@ + } + // Paper end + -+ -+ public abstract ResourceKey getTypeKey(); ++ public abstract ResourceKey getTypeKey(); + protected Level( WritableLevelData levelData, ResourceKey dimension, -@@ -125,8 +_,26 @@ +@@ -129,8 +_,24 @@ boolean isClientSide, boolean isDebug, long biomeZoomSeed, @@ -127,18 +92,16 @@ + this.generator = gen; + this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); + -+ // CraftBukkit Ticks things + for (SpawnCategory spawnCategory : SpawnCategory.values()) { -+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { -+ this.ticksPerSpawnCategory.put(spawnCategory, this.getTicksPerSpawn(spawnCategory)); // Paper ++ if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { ++ this.ticksPerSpawnCategory.put(spawnCategory, this.getTicksPerSpawn(spawnCategory)); + } + } -+ + // CraftBukkit end this.levelData = levelData; this.dimensionTypeRegistration = dimensionTypeRegistration; final DimensionType dimensionType = dimensionTypeRegistration.value(); -@@ -136,12 +_,12 @@ +@@ -140,12 +_,12 @@ this.worldBorder = new WorldBorder() { @Override public double getCenterX() { @@ -153,7 +116,7 @@ } }; } else { -@@ -154,7 +_,86 @@ +@@ -158,7 +_,84 @@ this.neighborUpdater = new CollectingNeighborUpdater(this, maxChainedNeighborUpdates); this.registryAccess = registryAccess; this.damageSources = new DamageSources(registryAccess); @@ -162,30 +125,30 @@ + // CraftBukkit start + this.getWorldBorder().world = (ServerLevel) this; + // From PlayerList.setPlayerFileData -+ this.getWorldBorder().addListener(new BorderChangeListener() { ++ this.getWorldBorder().addListener(new net.minecraft.world.level.border.BorderChangeListener() { + @Override + public void onBorderSizeSet(WorldBorder border, double size) { -+ Level.this.getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderSizePacket(border), border.world); ++ Level.this.getCraftServer().getHandle().broadcastAll(new net.minecraft.network.protocol.game.ClientboundSetBorderSizePacket(border), border.world); + } + + @Override + public void onBorderSizeLerping(WorldBorder border, double fromSize, double toSize, long time) { -+ Level.this.getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderLerpSizePacket(border), border.world); ++ Level.this.getCraftServer().getHandle().broadcastAll(new net.minecraft.network.protocol.game.ClientboundSetBorderLerpSizePacket(border), border.world); + } + + @Override + public void onBorderCenterSet(WorldBorder border, double centerX, double centerZ) { -+ Level.this.getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderCenterPacket(border), border.world); ++ Level.this.getCraftServer().getHandle().broadcastAll(new net.minecraft.network.protocol.game.ClientboundSetBorderCenterPacket(border), border.world); + } + + @Override + public void onBorderSetWarningTime(WorldBorder border, int warningTime) { -+ Level.this.getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderWarningDelayPacket(border), border.world); ++ Level.this.getCraftServer().getHandle().broadcastAll(new net.minecraft.network.protocol.game.ClientboundSetBorderWarningDelayPacket(border), border.world); + } + + @Override + public void onBorderSetWarningBlocks(WorldBorder border, int warningBlockDistance) { -+ Level.this.getCraftServer().getHandle().broadcastAll(new ClientboundSetBorderWarningDistancePacket(border), border.world); ++ Level.this.getCraftServer().getHandle().broadcastAll(new net.minecraft.network.protocol.game.ClientboundSetBorderWarningDistancePacket(border), border.world); + } + + @Override @@ -195,26 +158,24 @@ + public void onBorderSetDamageSafeZOne(WorldBorder border, double safeZoneRadius) {} + }); + // CraftBukkit end -+ this.entityLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.entityMaxTickTime); -+ this.tileLimiter = new org.spigotmc.TickLimiter(this.spigotConfig.tileMaxTickTime); + } + + // Paper start - Cancel hit for vanished players + // ret true if no collision -+ public final boolean checkEntityCollision(BlockState data, Entity source, net.minecraft.world.phys.shapes.CollisionContext voxelshapedcollision, ++ public final boolean checkEntityCollision(BlockState state, Entity source, net.minecraft.world.phys.shapes.CollisionContext collisionContext, + BlockPos position, boolean checkCanSee) { -+ // Copied from IWorldReader#a(IBlockData, BlockPosition, VoxelShapeCollision) & EntityAccess#a(Entity, VoxelShape) -+ net.minecraft.world.phys.shapes.VoxelShape voxelshape = data.getCollisionShape(this, position, voxelshapedcollision); -+ if (voxelshape.isEmpty()) { ++ // Copied from CollisionGetter#isUnobstructed(BlockState, BlockPos, CollisionContext) & EntityGetter#isUnobstructed(Entity, VoxelShape) ++ net.minecraft.world.phys.shapes.VoxelShape collisionShape = state.getCollisionShape(this, position, collisionContext); ++ if (collisionShape.isEmpty()) { + return true; + } + -+ voxelshape = voxelshape.move((double) position.getX(), (double) position.getY(), (double) position.getZ()); -+ if (voxelshape.isEmpty()) { ++ collisionShape = collisionShape.move((double) position.getX(), (double) position.getY(), (double) position.getZ()); ++ if (collisionShape.isEmpty()) { + return true; + } + -+ List entities = this.getEntities(null, voxelshape.bounds()); ++ List entities = this.getEntities(null, collisionShape.bounds()); + for (int i = 0, len = entities.size(); i < len; ++i) { + Entity entity = entities.get(i); + @@ -223,14 +184,14 @@ + continue; + } + -+ // !entity1.dead && entity1.i && (entity == null || !entity1.x(entity)); ++ // !entity1.isRemoved() && entity1.blocksBuilding && (entity == null || !entity1.isPassengerOfSameVehicle(entity)) + // elide the last check since vanilla calls with entity = null + // only we care about the source for the canSee check + if (entity.isRemoved() || !entity.blocksBuilding) { + continue; + } + -+ if (net.minecraft.world.phys.shapes.Shapes.joinIsNotEmpty(voxelshape, net.minecraft.world.phys.shapes.Shapes.create(entity.getBoundingBox()), net.minecraft.world.phys.shapes.BooleanOp.AND)) { ++ if (net.minecraft.world.phys.shapes.Shapes.joinIsNotEmpty(collisionShape, net.minecraft.world.phys.shapes.Shapes.create(entity.getBoundingBox()), net.minecraft.world.phys.shapes.BooleanOp.AND)) { + return false; + } + } @@ -241,7 +202,7 @@ @Override public boolean isClientSide() { -@@ -167,8 +_,15 @@ +@@ -171,8 +_,15 @@ return null; } @@ -258,7 +219,7 @@ } public static boolean isInSpawnableBounds(BlockPos pos) { -@@ -176,21 +_,84 @@ +@@ -180,21 +_,86 @@ } private static boolean isInWorldBoundsHorizontal(BlockPos pos) { @@ -318,10 +279,11 @@ + } + + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { -+ ChunkAccess chunk = this.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); ++ @Nullable ++ public final FluidState getFluidIfLoaded(BlockPos pos) { ++ ChunkAccess chunk = this.getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); + -+ return chunk == null ? null : chunk.getFluidState(blockposition); ++ return chunk == null ? null : chunk.getFluidState(pos); + } + + @Override @@ -329,26 +291,27 @@ + return getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4) != null; // Paper - Perf: Optimize Level.hasChunkAt(BlockPosition)Z + } + -+ public final boolean isLoadedAndInBounds(BlockPos blockposition) { // Paper - final for inline -+ return getWorldBorder().isWithinBounds(blockposition) && getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) != null; ++ public final boolean isLoadedAndInBounds(BlockPos pos) { // Paper - final for inline ++ return getWorldBorder().isWithinBounds(pos) && getChunkIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4) != null; + } + -+ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in WorldServer for ABI compat which has final ++ public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { // Overridden in ServerLevel for ABI compat which has final + return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(x, z); + } -+ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos blockposition) { -+ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4); ++ ++ public final @Nullable LevelChunk getChunkIfLoaded(BlockPos pos) { ++ return ((ServerLevel) this).getChunkSource().getChunkAtIfLoadedImmediately(pos.getX() >> 4, pos.getZ() >> 4); + } + + // reduces need to do isLoaded before getType -+ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos blockposition) { -+ return getWorldBorder().isWithinBounds(blockposition) ? getBlockStateIfLoaded(blockposition) : null; ++ public final @Nullable BlockState getBlockStateIfLoadedAndInBounds(BlockPos pos) { ++ return getWorldBorder().isWithinBounds(pos) ? getBlockStateIfLoaded(pos) : null; + } + // Paper end @Nullable @Override -@@ -210,6 +_,22 @@ +@@ -214,6 +_,22 @@ @Override public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { @@ -360,34 +323,36 @@ + // Paper end - Protect Bedrock and End Portal/Frames from being destroyed + CraftBlockState blockstate = this.capturedBlockStates.get(pos); + if (blockstate == null) { -+ blockstate = CapturedBlockState.getTreeBlockState(this, pos, flags); ++ blockstate = org.bukkit.craftbukkit.block.CapturedBlockState.getTreeBlockState(this, pos, flags); + this.capturedBlockStates.put(pos.immutable(), blockstate); + } + blockstate.setData(state); -+ blockstate.setFlag(flags); ++ blockstate.setFlags(flags); + return true; + } + // CraftBukkit end if (this.isOutsideBuildHeight(pos)) { return false; } else if (!this.isClientSide && this.isDebug()) { -@@ -217,11 +_,28 @@ +@@ -221,11 +_,31 @@ } else { LevelChunk chunkAt = this.getChunkAt(pos); Block block = state.getBlock(); -- BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0); + // CraftBukkit start - capture blockstates + boolean captured = false; -+ if (this.captureBlockStates && !this.capturedBlockStates.containsKey(pos)) { -+ CraftBlockState blockstate = (CraftBlockState) world.getBlockAt(pos.getX(), pos.getY(), pos.getZ()).getState(); // Paper - use CB getState to get a suitable snapshot -+ blockstate.setFlag(flags); // Paper - set flag -+ this.capturedBlockStates.put(pos.immutable(), blockstate); -+ captured = true; ++ if (this.captureBlockStates) { ++ final CraftBlockState snapshot; ++ if (!this.capturedBlockStates.containsKey(pos)) { ++ snapshot = (CraftBlockState) org.bukkit.craftbukkit.block.CraftBlock.at(this, pos).getState(); // Paper - use CB getState to get a suitable snapshot ++ this.capturedBlockStates.put(pos.immutable(), snapshot); ++ captured = true; ++ } else { ++ snapshot = this.capturedBlockStates.get(pos); ++ } ++ snapshot.setFlags(flags); // Paper - always set the flag of the most recent call to mitigate issues with multiple update at the same pos with different flags + } + BlockState blockState = chunkAt.setBlockState(pos, state, flags); + // CraftBukkit end -+ -+ BlockState blockState = chunkAt.setBlockState(pos, state, (flags & 64) != 0, (flags & 1024) == 0); // CraftBukkit custom NO_PLACE flag -+ if (blockState == null) { + // CraftBukkit start - remove blockstate if failed (or the same) + if (this.captureBlockStates && captured) { @@ -401,9 +366,9 @@ if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -249,12 +_,76 @@ +@@ -253,12 +_,68 @@ - this.onBlockStateChange(pos, blockState, blockState1); + this.updatePOIOnBlockStateChange(pos, blockState, blockState1); } + */ + @@ -414,7 +379,7 @@ + try { + this.notifyAndUpdatePhysics(pos, chunkAt, blockState, state, blockState1, flags, recursionLeft); + } catch (StackOverflowError ex) { -+ Level.lastPhysicsProblem = new BlockPos(pos); ++ Level.lastPhysicsProblem = pos.immutable(); + } + // Spigot end + } @@ -426,65 +391,57 @@ } + // CraftBukkit start - Split off from above in order to directly send client and physic updates -+ public void notifyAndUpdatePhysics(BlockPos blockposition, LevelChunk chunk, BlockState oldBlock, BlockState newBlock, BlockState actualBlock, int i, int j) { -+ BlockState iblockdata = newBlock; -+ BlockState iblockdata1 = oldBlock; -+ BlockState iblockdata2 = actualBlock; -+ if (iblockdata2 == iblockdata) { -+ if (iblockdata1 != iblockdata2) { -+ this.setBlocksDirty(blockposition, iblockdata1, iblockdata2); ++ public void notifyAndUpdatePhysics(BlockPos pos, LevelChunk chunkAt, BlockState oldState, BlockState newState, BlockState currentState, int flags, int recursionLeft) { ++ BlockState state = newState; ++ BlockState blockState = oldState; ++ BlockState blockState1 = currentState; ++ if (blockState1 == state) { ++ if (blockState != blockState1) { ++ this.setBlocksDirty(pos, blockState, blockState1); + } + -+ if ((i & 2) != 0 && (!this.isClientSide || (i & 4) == 0) && (this.isClientSide || chunk == null || (chunk.getFullStatus() != null && chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement -+ this.sendBlockUpdated(blockposition, iblockdata1, iblockdata, i); ++ if ((flags & 2) != 0 && (!this.isClientSide || (flags & 4) == 0) && (this.isClientSide || chunkAt == null || (chunkAt.getFullStatus() != null && chunkAt.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING)))) { // allow chunk to be null here as chunk.isReady() is false when we send our notification during block placement ++ this.sendBlockUpdated(pos, blockState, state, flags); + } + -+ if ((i & 1) != 0) { -+ this.blockUpdated(blockposition, iblockdata1.getBlock()); -+ if (!this.isClientSide && iblockdata.hasAnalogOutputSignal()) { -+ this.updateNeighbourForOutputSignal(blockposition, newBlock.getBlock()); ++ if ((flags & 1) != 0) { ++ this.updateNeighborsAt(pos, blockState.getBlock()); ++ if (!this.isClientSide && state.hasAnalogOutputSignal()) { ++ this.updateNeighbourForOutputSignal(pos, newState.getBlock()); + } + } + -+ if ((i & 16) == 0 && j > 0) { -+ int k = i & -34; ++ if ((flags & 16) == 0 && recursionLeft > 0) { ++ int i = flags & -34; + + // CraftBukkit start -+ iblockdata1.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); // Don't call an event for the old block to limit event spam -+ CraftWorld world = ((ServerLevel) this).getWorld(); ++ blockState.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); // Don't call an event for the old block to limit event spam + boolean cancelledUpdates = false; // Paper - Fix block place logic -+ if (world != null && ((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent -+ BlockPhysicsEvent event = new BlockPhysicsEvent(world.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), CraftBlockData.fromData(iblockdata)); -+ this.getCraftServer().getPluginManager().callEvent(event); -+ -+ cancelledUpdates = event.isCancelled(); // Paper - Fix block place logic ++ if (((ServerLevel)this).hasPhysicsEvent) { // Paper - BlockPhysicsEvent ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(this, pos), CraftBlockData.fromData(state)); ++ cancelledUpdates = !event.callEvent(); // Paper - Fix block place logic + } + // CraftBukkit end + if (!cancelledUpdates) { // Paper - Fix block place logic -+ iblockdata.updateNeighbourShapes(this, blockposition, k, j - 1); -+ iblockdata.updateIndirectNeighbourShapes(this, blockposition, k, j - 1); ++ state.updateNeighbourShapes(this, pos, i, recursionLeft - 1); ++ state.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); + } // Paper - Fix block place logic + } + -+ // CraftBukkit start - SPIGOT-5710 -+ if (!this.preventPoiUpdated) { -+ this.onBlockStateChange(blockposition, iblockdata1, iblockdata2); -+ } -+ // CraftBukkit end ++ this.updatePOIOnBlockStateChange(pos, blockState, blockState1); + } + } + // CraftBukkit end -+ - public void onBlockStateChange(BlockPos pos, BlockState blockState, BlockState newState) { + public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { } -@@ -271,13 +_,31 @@ +@@ -275,13 +_,31 @@ return false; } else { FluidState fluidState = this.getFluidState(pos); - if (!(blockState.getBlock() instanceof BaseFireBlock)) { - this.levelEvent(2001, pos, Block.getId(blockState)); -+ // Paper start - BlockDestroyEvent; while the above setAir method is named same and looks very similar ++ // Paper start - BlockDestroyEvent; while the above removeBlock method looks very similar + // they are NOT used with same intent and the above should not fire this event. The above method is more of a BlockSetToAirEvent, + // it doesn't imply destruction of a block that plays a sound effect / drops an item. + boolean playEffect = true; @@ -513,7 +470,7 @@ } boolean flag = this.setBlock(pos, fluidState.createLegacyBlock(), 3, recursionLeft); -@@ -344,10 +_,18 @@ +@@ -345,10 +_,18 @@ @Override public BlockState getBlockState(BlockPos pos) { @@ -533,7 +490,7 @@ return chunk.getBlockState(pos); } } -@@ -454,32 +_,49 @@ +@@ -463,32 +_,48 @@ this.pendingBlockEntityTickers.clear(); } @@ -545,8 +502,7 @@ - TickingBlockEntity tickingBlockEntity = iterator.next(); + var toRemove = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet(); // Paper - Fix MC-117075; use removeAll + toRemove.add(null); // Paper - Fix MC-117075 -+ for (tileTickPosition = 0; tileTickPosition < this.blockEntityTickers.size(); tileTickPosition++) { // Paper - Disable tick limiters -+ this.tileTickPosition = (this.tileTickPosition < this.blockEntityTickers.size()) ? this.tileTickPosition : 0; ++ for (this.tileTickPosition = 0; this.tileTickPosition < this.blockEntityTickers.size(); this.tileTickPosition++) { // Paper - Disable tick limiters + TickingBlockEntity tickingBlockEntity = this.blockEntityTickers.get(this.tileTickPosition); + // Spigot end if (tickingBlockEntity.isRemoved()) { @@ -591,7 +547,7 @@ public boolean shouldTickDeath(Entity entity) { return true; -@@ -599,6 +_,19 @@ +@@ -608,6 +_,19 @@ @Nullable @Override public BlockEntity getBlockEntity(BlockPos pos) { @@ -611,7 +567,7 @@ if (this.isOutsideBuildHeight(pos)) { return null; } else { -@@ -611,6 +_,12 @@ +@@ -620,6 +_,12 @@ public void setBlockEntity(BlockEntity blockEntity) { BlockPos blockPos = blockEntity.getBlockPos(); if (!this.isOutsideBuildHeight(blockPos)) { @@ -624,7 +580,7 @@ this.getChunkAt(blockPos).addAndRegisterBlockEntity(blockEntity); } } -@@ -987,7 +_,8 @@ +@@ -1009,7 +_,8 @@ BLOCK("block"), MOB("mob"), TNT("tnt"), diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch index d80e4a75b..1540db17e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelAccessor.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -101,4 +_,6 @@ +@@ -100,4 +_,6 @@ default void gameEvent(ResourceKey gameEvent, BlockPos pos, GameEvent.Context context) { this.gameEvent(this.registryAccess().lookupOrThrow(Registries.GAME_EVENT).getOrThrow(gameEvent), pos, context); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch index a092d0dad..d752f6baf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/LevelWriter.java.patch @@ -6,7 +6,7 @@ } + + // CraftBukkit start -+ default boolean addFreshEntity(Entity entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { ++ default boolean addFreshEntity(Entity entity, @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason reason) { + return false; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch index 89849d7d7..0bd4fefcb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/NaturalSpawner.java.patch @@ -1,20 +1,6 @@ --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -49,6 +_,13 @@ - import net.minecraft.world.phys.Vec3; - import org.slf4j.Logger; - -+// CraftBukkit start -+import net.minecraft.world.level.storage.LevelData; -+import org.bukkit.craftbukkit.util.CraftSpawnCategory; -+import org.bukkit.entity.SpawnCategory; -+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; -+// CraftBukkit end -+ - public final class NaturalSpawner { - private static final Logger LOGGER = LogUtils.getLogger(); - private static final int MIN_SPAWN_DISTANCE = 24; -@@ -72,6 +_,13 @@ +@@ -73,6 +_,13 @@ if (!(entity instanceof Mob mob && (mob.isPersistenceRequired() || mob.requiresCustomPersistence()))) { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { @@ -28,7 +14,7 @@ BlockPos blockPos = entity.blockPosition(); chunkGetter.query(ChunkPos.asLong(blockPos), chunk -> { MobSpawnSettings.MobSpawnCost mobSpawnCost = getRoughBiome(blockPos, chunk).getMobSettings().getMobSpawnCost(entity.getType()); -@@ -96,17 +_,34 @@ +@@ -97,17 +_,34 @@ return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } @@ -37,7 +23,7 @@ - NaturalSpawner.SpawnState spawnState, boolean spawnFriendlies, boolean spawnEnemies, boolean spawnPassives + NaturalSpawner.SpawnState spawnState, boolean spawnFriendlies, boolean spawnEnemies, boolean spawnPassives, ServerLevel level ) { -+ LevelData worlddata = level.getLevelData(); // CraftBukkit - Other mob type spawn tick rate ++ net.minecraft.world.level.storage.LevelData worlddata = level.getLevelData(); // CraftBukkit - Other mob type spawn tick rate + // CraftBukkit end List list = new ArrayList<>(SPAWNING_CATEGORIES.length); @@ -45,8 +31,8 @@ + // CraftBukkit start - Use per-world spawn limits + boolean spawnThisTick = true; + int limit = mobCategory.getMaxInstancesPerChunk(); -+ SpawnCategory spawnCategory = CraftSpawnCategory.toBukkit(mobCategory); -+ if (CraftSpawnCategory.isValidForLimits(spawnCategory)) { ++ org.bukkit.entity.SpawnCategory spawnCategory = org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(mobCategory); ++ if (org.bukkit.craftbukkit.util.CraftSpawnCategory.isValidForLimits(spawnCategory)) { + spawnThisTick = level.ticksPerSpawnCategory.getLong(spawnCategory) != 0 && worlddata.getGameTime() % level.ticksPerSpawnCategory.getLong(spawnCategory) == 0; + limit = level.getWorld().getSpawnLimit(spawnCategory); + } @@ -65,13 +51,13 @@ } } -@@ -126,6 +_,16 @@ +@@ -127,6 +_,16 @@ profilerFiller.pop(); } + // Paper start - Add mobcaps commands + public static int globalLimitForCategory(final ServerLevel level, final MobCategory category, final int spawnableChunkCount) { -+ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(CraftSpawnCategory.toBukkit(category)); ++ final int categoryLimit = level.getWorld().getSpawnLimitUnsafe(org.bukkit.craftbukkit.util.CraftSpawnCategory.toBukkit(category)); + if (categoryLimit < 1) { + return categoryLimit; + } @@ -82,7 +68,7 @@ public static void spawnCategoryForChunk( MobCategory category, ServerLevel level, LevelChunk chunk, NaturalSpawner.SpawnPredicate filter, NaturalSpawner.AfterSpawnCallback callback ) { -@@ -151,8 +_,8 @@ +@@ -152,8 +_,8 @@ StructureManager structureManager = level.structureManager(); ChunkGenerator generator = level.getChunkSource().getGenerator(); int y = pos.getY(); @@ -93,7 +79,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); int i = 0; -@@ -174,7 +_,7 @@ +@@ -175,7 +_,7 @@ Player nearestPlayer = level.getNearestPlayer(d, y, d1, -1.0, false); if (nearestPlayer != null) { double d2 = nearestPlayer.distanceToSqr(d, y, d1); @@ -102,23 +88,22 @@ if (spawnerData == null) { Optional randomSpawnMobAt = getRandomSpawnMobAt( level, structureManager, generator, category, level.random, mutableBlockPos -@@ -187,8 +_,13 @@ - ceil = spawnerData.minCount + level.random.nextInt(1 + spawnerData.maxCount - spawnerData.minCount); +@@ -188,7 +_,13 @@ + ceil = spawnerData.minCount() + level.random.nextInt(1 + spawnerData.maxCount() - spawnerData.minCount()); } - if (isValidSpawnPostitionForType(level, category, structureManager, generator, spawnerData, mutableBlockPos, d2) -- && filter.test(spawnerData.type, mutableBlockPos, chunk)) { + // Paper start - PreCreatureSpawnEvent + PreSpawnStatus doSpawning = isValidSpawnPostitionForType(level, category, structureManager, generator, spawnerData, mutableBlockPos, d2); + if (doSpawning == PreSpawnStatus.ABORT) { + return; + } -+ if (doSpawning == PreSpawnStatus.SUCCESS && filter.test(spawnerData.type, mutableBlockPos, chunk)) { -+ // Paper end - PreCreatureSpawnEvent - Mob mobForSpawn = getMobForSpawn(level, spawnerData.type); ++ if (doSpawning == PreSpawnStatus.SUCCESS ++ // Paper end - PreCreatureSpawnEvent + && filter.test(spawnerData.type(), mutableBlockPos, chunk)) { + Mob mobForSpawn = getMobForSpawn(level, spawnerData.type()); if (mobForSpawn == null) { - return; -@@ -199,10 +_,15 @@ +@@ -200,10 +_,15 @@ spawnGroupData = mobForSpawn.finalizeSpawn( level, level.getCurrentDifficultyAt(mobForSpawn.blockPosition()), EntitySpawnReason.NATURAL, spawnGroupData ); @@ -128,7 +113,7 @@ - callback.run(mobForSpawn, chunk); + // CraftBukkit start + // SPIGOT-7045: Give ocelot babies back their special spawn reason. Note: This is the only modification required as ocelots count as monsters which means they only spawn during normal chunk ticking and do not spawn during chunk generation as starter mobs. -+ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? SpawnReason.OCELOT_BABY : SpawnReason.NATURAL); ++ level.addFreshEntityWithPassengers(mobForSpawn, (mobForSpawn instanceof net.minecraft.world.entity.animal.Ocelot && !((org.bukkit.entity.Ageable) mobForSpawn.getBukkitEntity()).isAdult()) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.OCELOT_BABY : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); + if (!mobForSpawn.isRemoved()) { + ++i; + ++i3; @@ -138,8 +123,8 @@ if (i >= mobForSpawn.getMaxSpawnClusterSize()) { return; } -@@ -225,7 +_,15 @@ - && (Objects.equals(new ChunkPos(pos), chunk.getPos()) || level.isNaturalSpawningAllowed(pos)); +@@ -231,7 +_,15 @@ + } } - private static boolean isValidSpawnPostitionForType( @@ -155,16 +140,15 @@ ServerLevel level, MobCategory category, StructureManager structureManager, -@@ -235,7 +_,20 @@ +@@ -241,7 +_,19 @@ double distance ) { - EntityType entityType = data.type; + EntityType entityType = data.type(); - return entityType.getCategory() != MobCategory.MISC -+ + // Paper start - PreCreatureSpawnEvent + com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent event = new com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent( -+ io.papermc.paper.util.MCUtil.toLocation(level, pos), -+ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entityType), SpawnReason.NATURAL ++ org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), ++ org.bukkit.craftbukkit.entity.CraftEntityType.minecraftToBukkit(entityType), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL + ); + if (!event.callEvent()) { + if (event.shouldAbortSpawn()) { @@ -173,11 +157,11 @@ + return PreSpawnStatus.CANCELLED; + } + final boolean success = entityType.getCategory() != MobCategory.MISC -+ // Paper end - PreCreatureSpawnEvent ++ // Paper end - PreCreatureSpawnEvent && ( entityType.canSpawnFarFromPlayer() || !(distance > entityType.getCategory().getDespawnDistance() * entityType.getCategory().getDespawnDistance()) -@@ -245,6 +_,7 @@ +@@ -251,6 +_,7 @@ && SpawnPlacements.isSpawnPositionOk(entityType, level, pos) && SpawnPlacements.checkSpawnRules(entityType, level, EntitySpawnReason.NATURAL, pos, level.random) && level.noCollision(entityType.getSpawnAABB(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5)); @@ -185,7 +169,7 @@ } @Nullable -@@ -258,6 +_,7 @@ +@@ -263,6 +_,7 @@ LOGGER.warn("Can't spawn entity of type: {}", BuiltInRegistries.ENTITY_TYPE.getKey(entityType)); } catch (Exception var4) { LOGGER.warn("Failed to create mob", (Throwable)var4); @@ -193,24 +177,24 @@ } return null; -@@ -364,6 +_,7 @@ - entity = spawnerData.type.create(levelAccessor.getLevel(), EntitySpawnReason.NATURAL); +@@ -369,6 +_,7 @@ + entity = spawnerData.type().create(levelAccessor.getLevel(), EntitySpawnReason.NATURAL); } catch (Exception var27) { LOGGER.warn("Failed to create mob", (Throwable)var27); + com.destroystokyo.paper.exception.ServerInternalException.reportInternalException(var27); // Paper - ServerExceptionEvent continue; } -@@ -381,7 +_,7 @@ +@@ -386,7 +_,7 @@ EntitySpawnReason.CHUNK_GENERATION, spawnGroupData ); - levelAccessor.addFreshEntityWithPassengers(mob); -+ levelAccessor.addFreshEntityWithPassengers(mob, SpawnReason.CHUNK_GEN); // CraftBukkit ++ levelAccessor.addFreshEntityWithPassengers(mob, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit flag = true; } } -@@ -501,8 +_,10 @@ +@@ -506,8 +_,10 @@ return this.unmodifiableMobCategoryCounts; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch index 2305a1f77..8d1de8e39 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/PathNavigationRegion.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/level/PathNavigationRegion.java +++ b/net/minecraft/world/level/PathNavigationRegion.java -@@ -8,6 +_,7 @@ - import net.minecraft.core.Holder; - import net.minecraft.core.SectionPos; - import net.minecraft.core.registries.Registries; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.level.biome.Biome; - import net.minecraft.world.level.biome.Biomes; -@@ -66,13 +_,37 @@ +@@ -66,13 +_,41 @@ private ChunkAccess getChunk(int x, int z) { int i = x - this.centerX; int i1 = z - this.centerZ; @@ -22,7 +14,8 @@ } + + // Paper start - if loaded util -+ private @Nullable ChunkAccess getChunkIfLoaded(int x, int z) { ++ @Nullable ++ private ChunkAccess getChunkIfLoaded(int x, int z) { + // Based on getChunk(int, int) + int xx = x - this.centerX; + int zz = z - this.centerZ; @@ -32,16 +25,19 @@ + } + return null; + } ++ ++ @Nullable + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { -+ ChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); -+ return chunk == null ? null : chunk.getFluidState(blockposition); ++ public final FluidState getFluidIfLoaded(BlockPos pos) { ++ ChunkAccess chunk = getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4); ++ return chunk == null ? null : chunk.getFluidState(pos); + } + ++ @Nullable + @Override -+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { -+ ChunkAccess chunk = getChunkIfLoaded(blockposition.getX() >> 4, blockposition.getZ() >> 4); -+ return chunk == null ? null : chunk.getBlockState(blockposition); ++ public final BlockState getBlockStateIfLoaded(BlockPos pos) { ++ ChunkAccess chunk = getChunkIfLoaded(pos.getX() >> 4, pos.getZ() >> 4); ++ return chunk == null ? null : chunk.getBlockState(pos); + } + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch index a7b3faa86..5d4fa1818 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/ServerExplosion.java.patch @@ -1,18 +1,15 @@ --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -33,6 +_,17 @@ +@@ -33,6 +_,14 @@ import net.minecraft.world.phys.HitResult; import net.minecraft.world.phys.Vec3; +// CraftBukkit start +import net.minecraft.world.entity.boss.EnderDragonPart; +import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -+import net.minecraft.world.level.block.Blocks; +import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.util.CraftLocation; -+import org.bukkit.event.entity.EntityExplodeEvent; +import org.bukkit.Location; -+import org.bukkit.event.block.BlockExplodeEvent; +// CraftBukkit end + public class ServerExplosion implements Explosion { @@ -60,7 +57,7 @@ if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockPos, blockState, f)) { set.add(blockPos); + // Paper start - prevent headless pistons from forming -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(Blocks.MOVING_PISTON)) { ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockState.is(net.minecraft.world.level.block.Blocks.MOVING_PISTON)) { + net.minecraft.world.level.block.entity.BlockEntity extension = this.level.getBlockEntity(blockPos); + if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { + net.minecraft.core.Direction direction = blockState.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); @@ -77,7 +74,7 @@ int floor5 = Mth.floor(this.center.z + f + 1.0); - - for (Entity entity : this.level.getEntities(this.source, new AABB(floor, floor2, floor4, floor1, floor3, floor5))) { -+ List list = this.level.getEntities(excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source ++ List list = this.level.getEntities(this.excludeSourceFromDamage ? this.source : null, new AABB(floor, floor2, floor4, floor1, floor3, floor5), entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities, Allow explosions to damage source + for (Entity entity : list) { // Paper - used in loop if (!entity.ignoreExplosion(this)) { double d = Math.sqrt(entity.distanceToSqr(this.center)) / f; @@ -96,8 +93,8 @@ + // Thinks to note: + // - Setting a velocity to a EnderDragonPart is ignored (and therefore not needed) + // - Damaging EnderDragonPart while forward the damage to EnderDragon -+ // - Damaging EntityEnderDragon does nothing -+ // - EnderDragon hitbock always covers the other parts and is therefore always present ++ // - Damaging EnderDragon does nothing ++ // - EnderDragon hitbox always covers the other parts and is therefore always present + if (entity instanceof EnderDragonPart) { + continue; + } @@ -108,7 +105,7 @@ + for (EnderDragonPart dragonPart : ((EnderDragon) entity).getSubEntities()) { + // Calculate damage separately for each EntityComplexPart + if (list.contains(dragonPart)) { -+ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, f1)); ++ dragonPart.hurtServer(this.level, this.damageSource, this.damageCalculator.getEntityDamageAmount(this, dragonPart, f1)); + } + } + } else { @@ -129,7 +126,7 @@ } else { d5 = d4; } -@@ -206,10 +_,18 @@ +@@ -206,8 +_,16 @@ d2 *= d5; d3 *= d5; Vec3 vec3 = new Vec3(d1, d2, d3); @@ -137,30 +134,25 @@ + if (entity instanceof LivingEntity) { + // Paper start - knockback events + io.papermc.paper.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, this.damageSource.getEntity() != null ? this.damageSource.getEntity() : this.source, io.papermc.paper.event.entity.EntityKnockbackEvent.Cause.EXPLOSION, d5, vec3); -+ vec3 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toNMS(event.getKnockback()); ++ vec3 = event.isCancelled() ? Vec3.ZERO : org.bukkit.craftbukkit.util.CraftVector.toVec3(event.getKnockback()); + // Paper end - knockback events + } + // CraftBukkit end entity.push(vec3); - if (entity instanceof Player) { - Player player = (Player)entity; -- if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { -+ if (!player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback - this.hitPlayers.put(player, vec3); - } +- if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying)) { ++ if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback + this.hitPlayers.put(player, vec3); } -@@ -225,7 +_,61 @@ + +@@ -222,7 +_,56 @@ List list = new ArrayList<>(); Util.shuffle(blocks, this.level.random); + // CraftBukkit start -+ org.bukkit.World bworld = this.level.getWorld(); -+ Location location = CraftLocation.toBukkit(this.center, bworld); -+ ++ Location location = CraftLocation.toBukkit(this.center, this.level.getWorld()); + List blockList = new ObjectArrayList<>(); + for (int i1 = blocks.size() - 1; i1 >= 0; i1--) { -+ BlockPos cpos = blocks.get(i1); -+ org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ()); ++ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, blocks.get(i1)); + if (!bblock.getType().isAir()) { + blockList.add(bblock); + } @@ -169,24 +161,22 @@ + List bukkitBlocks; + + if (this.source != null) { -+ EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, this.getBlockInteraction()); ++ org.bukkit.event.entity.EntityExplodeEvent event = CraftEventFactory.callEntityExplodeEvent(this.source, blockList, this.yield, this.getBlockInteraction()); + this.wasCanceled = event.isCancelled(); + bukkitBlocks = event.blockList(); + this.yield = event.getYield(); + } else { + org.bukkit.block.Block block = location.getBlock(); + org.bukkit.block.BlockState blockState = (this.damageSource.causingBlockSnapshot() != null) ? this.damageSource.causingBlockSnapshot() : block.getState(); -+ BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, this.getBlockInteraction()); ++ org.bukkit.event.block.BlockExplodeEvent event = CraftEventFactory.callBlockExplodeEvent(block, blockState, blockList, this.yield, this.getBlockInteraction()); + this.wasCanceled = event.isCancelled(); + bukkitBlocks = event.blockList(); + this.yield = event.getYield(); + } + + blocks.clear(); -+ + for (org.bukkit.block.Block bblock : bukkitBlocks) { -+ BlockPos coords = new BlockPos(bblock.getX(), bblock.getY(), bblock.getZ()); -+ blocks.add(coords); ++ blocks.add(((org.bukkit.craftbukkit.block.CraftBlock) bblock).getPosition()); + } + + if (this.wasCanceled) { @@ -196,13 +186,13 @@ + for (BlockPos blockPos : blocks) { + // CraftBukkit start - TNTPrimeEvent -+ BlockState iblockdata = this.level.getBlockState(blockPos); -+ Block block = iblockdata.getBlock(); -+ if (block instanceof net.minecraft.world.level.block.TntBlock) { ++ BlockState state = this.level.getBlockState(blockPos); ++ Block block = state.getBlock(); ++ if (level.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && block instanceof net.minecraft.world.level.block.TntBlock) { + Entity sourceEntity = this.source == null ? null : this.source; + BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.center) : null; + if (!CraftEventFactory.callTNTPrimeEvent(this.level, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.EXPLOSION, sourceEntity, sourceBlock)) { -+ this.level.sendBlockUpdated(blockPos, Blocks.AIR.defaultBlockState(), iblockdata, 3); // Update the block on the client ++ this.level.sendBlockUpdated(blockPos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), state, 3); // Update the block on the client + continue; + } + } @@ -211,7 +201,7 @@ this.level .getBlockState(blockPos) .onExplosionHit(this.level, blockPos, this, (itemStack, blockPos1) -> addOrAppendStack(list, itemStack, blockPos1)); -@@ -239,12 +_,21 @@ +@@ -236,12 +_,21 @@ private void createFire(List blocks) { for (BlockPos blockPos : blocks) { if (this.level.random.nextInt(3) == 0 && this.level.getBlockState(blockPos).isAir() && this.level.getBlockState(blockPos.below()).isSolidRender()) { @@ -234,15 +224,7 @@ this.level.gameEvent(this.source, GameEvent.EXPLODE, this.center); List list = this.calculateExplodedPositions(); this.hurtEntities(); -@@ -261,6 +_,7 @@ - } - - private static void addOrAppendStack(List stackCollectors, ItemStack stack, BlockPos pos) { -+ if (stack.isEmpty()) return; // CraftBukkit - SPIGOT-5425 - for (ServerExplosion.StackCollector stackCollector : stackCollectors) { - stackCollector.tryMerge(stack); - if (stack.isEmpty()) { -@@ -342,4 +_,86 @@ +@@ -339,4 +_,86 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch index 2286bb70a..a62cc1788 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/StructureManager.java.patch @@ -15,7 +15,17 @@ Builder builder = ImmutableList.builder(); for (Entry entry : allReferences.entrySet()) { -@@ -118,10 +_,20 @@ +@@ -114,14 +_,29 @@ + } + + public StructureStart getStructureWithPieceAt(BlockPos pos, HolderSet structures) { +- return this.getStructureWithPieceAt(pos, structures::contains); ++ // Paper start - Fix swamp hut cat generation deadlock ++ return this.getStructureWithPieceAt(pos, structures, null); ++ } ++ public StructureStart getStructureWithPieceAt(BlockPos pos, HolderSet structures, final @Nullable ServerLevelAccessor levelAccessor) { ++ return this.getStructureWithPieceAt(pos, structures::contains, levelAccessor); ++ // Paper end - Fix swamp hut cat generation deadlock } public StructureStart getStructureWithPieceAt(BlockPos pos, Predicate> predicate) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch new file mode 100644 index 000000000..ff5aabed7 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/TicketStorage.java.patch @@ -0,0 +1,40 @@ +--- a/net/minecraft/world/level/TicketStorage.java ++++ b/net/minecraft/world/level/TicketStorage.java +@@ -161,7 +_,7 @@ + } + + private static boolean isTicketSameTypeAndLevel(Ticket first, Ticket second) { +- return second.getType() == first.getType() && second.getTicketLevel() == first.getTicketLevel(); ++ return second.getType() == first.getType() && second.getTicketLevel() == first.getTicketLevel() && java.util.Objects.equals(second.getIdentifier(), first.getIdentifier()); // Paper - add identifier + } + + public int getTicketLevelAt(long chunkPos, boolean requireSimulation) { +@@ -264,7 +_,7 @@ + } + + public void deactivateTicketsOnClosing() { +- this.removeTicketIf(ticket -> ticket.getType() != TicketType.UNKNOWN, this.deactivatedTickets); ++ this.removeTicketIf(ticket -> ticket.getType() != TicketType.UNKNOWN && ticket.getType() != TicketType.CHUNK_LOAD && ticket.getType() != TicketType.FUTURE_AWAIT, this.deactivatedTickets); + } + + public void removeTicketIf(Predicate predicate, @Nullable Long2ObjectOpenHashMap> tickets) { +@@ -369,4 +_,19 @@ + public interface ChunkUpdated { + void update(long chunkPos, int i, boolean ticketLevel); + } ++ // Paper start ++ public boolean addPluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { ++ // Keep inline with force loading ++ return addTicket(pos.toLong(), new Ticket(TicketType.PLUGIN_TICKET, ChunkMap.FORCED_TICKET_LEVEL, value)); ++ } ++ ++ public boolean removePluginRegionTicket(final ChunkPos pos, final org.bukkit.plugin.Plugin value) { ++ // Keep inline with force loading ++ return removeTicket(pos.toLong(), new Ticket(TicketType.PLUGIN_TICKET, ChunkMap.FORCED_TICKET_LEVEL, value)); ++ } ++ ++ public void removeAllPluginRegionTickets(TicketType ticketType, int ticketLevel, org.bukkit.plugin.Plugin ticketIdentifier) { ++ removeTicketIf(ticket -> ticket.getType() == ticketType && ticket.getTicketLevel() == ticketLevel && ticket.getIdentifier() == ticketIdentifier, null); ++ } ++ // Paper end + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/biome/Biome.java.patch b/paper-server/patches/sources/net/minecraft/world/level/biome/Biome.java.patch index df0ac9026..eb3fb2f32 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/biome/Biome.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/biome/Biome.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/biome/Biome.java +++ b/net/minecraft/world/level/biome/Biome.java -@@ -176,7 +_,7 @@ +@@ -177,7 +_,7 @@ } public boolean shouldSnow(LevelReader level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch index 103372431..8f76166ac 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/biome/MobSpawnSettings.java.patch @@ -1,43 +1,36 @@ --- a/net/minecraft/world/level/biome/MobSpawnSettings.java +++ b/net/minecraft/world/level/biome/MobSpawnSettings.java -@@ -75,8 +_,40 @@ +@@ -70,9 +_,33 @@ } public static class Builder { + // Paper start - Perf: keep track of data in a pair set to give O(1) contains calls - we have to hook removals incase plugins mess with it -+ public static class MobList extends java.util.ArrayList { -+ java.util.Set biomes = new java.util.HashSet<>(); -+ ++ public static class MobListBuilder extends WeightedList.Builder { + @Override -+ public boolean contains(Object o) { -+ return biomes.contains(o); -+ } -+ -+ @Override -+ public boolean add(MobSpawnSettings.SpawnerData BiomeSettingsMobs) { -+ biomes.add(BiomeSettingsMobs); -+ return super.add(BiomeSettingsMobs); -+ } -+ -+ @Override -+ public MobSpawnSettings.SpawnerData remove(int index) { -+ MobSpawnSettings.SpawnerData removed = super.remove(index); -+ if (removed != null) { -+ biomes.remove(removed); -+ } -+ return removed; -+ } -+ -+ @Override -+ public void clear() { -+ biomes.clear(); -+ super.clear(); ++ public WeightedList build() { ++ return new WeightedSpawnerDataList<>(this.result.build()); + } + } -+ // use toImmutableEnumMap collector - private final Map> spawners = Stream.of(MobCategory.values()) -- .collect(ImmutableMap.toImmutableMap(key -> (MobCategory)key, value -> Lists.newArrayList())); -+ .collect(Maps.toImmutableEnumMap(mobCategory -> (MobCategory)mobCategory, mobCategory -> new MobList())); // Use MobList instead of ArrayList ++ ++ public static class WeightedSpawnerDataList extends WeightedList { ++ private final java.util.Set spawnerDataSet = new java.util.HashSet<>(); ++ ++ public WeightedSpawnerDataList(final java.util.List> items) { ++ super(items); ++ for (final net.minecraft.util.random.Weighted item : items) { ++ this.spawnerDataSet.add(item.value()); ++ } ++ } ++ ++ @Override ++ public boolean contains(final E element) { ++ return this.spawnerDataSet.contains(element); ++ } ++ } + private final Map> spawners = Util.makeEnumMap( +- MobCategory.class, mobCategory -> WeightedList.builder() ++ MobCategory.class, mobCategory -> new MobListBuilder<>() + ); + // Paper end - Perf: keep track of data in a pair set to give O(1) contains calls private final Map, MobSpawnSettings.MobSpawnCost> mobSpawnCosts = Maps.newLinkedHashMap(); private float creatureGenerationProbability = 0.1F; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/AbstractCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/AbstractCauldronBlock.java.patch index 506f6551e..a63dec69e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/AbstractCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/AbstractCauldronBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AbstractCauldronBlock.java +++ b/net/minecraft/world/level/block/AbstractCauldronBlock.java -@@ -58,7 +_,7 @@ +@@ -62,7 +_,7 @@ ItemStack stack, BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hitResult ) { CauldronInteraction cauldronInteraction = this.interactions.map().get(stack.getItem()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/AnvilBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/AnvilBlock.java.patch index 8701c8ba8..9ada1b0ac 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/AnvilBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/AnvilBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/AnvilBlock.java +++ b/net/minecraft/world/level/block/AnvilBlock.java -@@ -62,8 +_,9 @@ +@@ -57,8 +_,9 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (!level.isClientSide) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch index df4b06991..82f3adbba 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooSaplingBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/BambooSaplingBlock.java +++ b/net/minecraft/world/level/block/BambooSaplingBlock.java -@@ -43,7 +_,7 @@ +@@ -38,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (random.nextInt(3) == 0 && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { -+ if (random.nextFloat() < (level.spigotConfig.bambooModifier / (100.0f * 3)) && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < (level.spigotConfig.bambooModifier / (100.0F * 3)) && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution this.growBamboo(level, pos); } } -@@ -99,6 +_,6 @@ +@@ -89,6 +_,6 @@ } protected void growBamboo(Level level, BlockPos state) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch index c5c9ef2c7..e34999376 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BambooStalkBlock.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -130,9 +_,9 @@ +@@ -120,9 +_,9 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(STAGE) == 0) { - if (random.nextInt(3) == 0 && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { -+ if (random.nextFloat() < (level.spigotConfig.bambooModifier / (100.0f * 3)) && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < (level.spigotConfig.bambooModifier / (100.0F * 3)) && level.isEmptyBlock(pos.above()) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution int i = this.getHeightBelowUpToMax(level, pos) + 1; - if (i < 16) { + if (i < level.paperConfig().maxGrowthHeight.bamboo.max) { // Paper - Configurable cactus/bamboo/reed growth height this.growBamboo(state, level, pos, random, i); } } -@@ -168,7 +_,7 @@ +@@ -158,7 +_,7 @@ public boolean isValidBonemealTarget(LevelReader level, BlockPos pos, BlockState state) { int heightAboveUpToMax = this.getHeightAboveUpToMax(level, pos); int heightBelowUpToMax = this.getHeightBelowUpToMax(level, pos); @@ -21,7 +21,7 @@ } @Override -@@ -186,7 +_,7 @@ +@@ -176,7 +_,7 @@ for (int i2 = 0; i2 < i1; i2++) { BlockPos blockPos = pos.above(heightAboveUpToMax); BlockState blockState = level.getBlockState(blockPos); @@ -30,7 +30,7 @@ return; } -@@ -206,29 +_,38 @@ +@@ -191,27 +_,38 @@ BlockPos blockPos = pos.below(2); BlockState blockState1 = level.getBlockState(blockPos); BambooLeaves bambooLeaves = BambooLeaves.NONE; @@ -54,12 +54,10 @@ int i = state.getValue(AGE) != 1 && !blockState1.is(Blocks.BAMBOO) ? 0 : 1; - int i1 = (age < 11 || !(random.nextFloat() < 0.25F)) && age != 15 ? 0 : 1; -- level.setBlock( -- pos.above(), this.defaultBlockState().setValue(AGE, Integer.valueOf(i)).setValue(LEAVES, bambooLeaves).setValue(STAGE, Integer.valueOf(i1)), 3 -- ); +- level.setBlock(pos.above(), this.defaultBlockState().setValue(AGE, i).setValue(LEAVES, bambooLeaves).setValue(STAGE, i1), 3); + int i1 = (age < level.paperConfig().maxGrowthHeight.bamboo.min || random.nextFloat() >= 0.25F) && age != (level.paperConfig().maxGrowthHeight.bamboo.max - 1) ? 0 : 1; // Paper - Configurable cactus/bamboo/reed growth height + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.above(), this.defaultBlockState().setValue(net.minecraft.world.level.block.BambooStalkBlock.AGE, i).setValue(BambooStalkBlock.LEAVES, bambooLeaves).setValue(net.minecraft.world.level.block.BambooStalkBlock.STAGE, i1), 3)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.above(), this.defaultBlockState().setValue(AGE, i).setValue(LEAVES, bambooLeaves).setValue(STAGE, i1), 3)) { + if (shouldUpdateOthers) { + level.setBlock(pos.below(), blockState.setValue(BambooStalkBlock.LEAVES, BambooLeaves.SMALL), 3); + level.setBlock(blockPos, blockState1.setValue(BambooStalkBlock.LEAVES, BambooLeaves.NONE), 3); @@ -76,7 +74,7 @@ i++; } -@@ -238,7 +_,7 @@ +@@ -221,7 +_,7 @@ protected int getHeightBelowUpToMax(BlockGetter level, BlockPos pos) { int i = 0; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch index a9273622c..2f9733b56 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BaseFireBlock.java.patch @@ -1,29 +1,27 @@ --- a/net/minecraft/world/level/block/BaseFireBlock.java +++ b/net/minecraft/world/level/block/BaseFireBlock.java -@@ -12,6 +_,7 @@ - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.player.Player; - import net.minecraft.world.item.context.BlockPlaceContext; -+import net.minecraft.world.item.context.UseOnContext; - import net.minecraft.world.level.BlockGetter; - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.state.BlockBehaviour; -@@ -128,6 +_,7 @@ +@@ -129,11 +_,12 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent + effectApplier.apply(InsideBlockEffectType.FIRE_IGNITE); + effectApplier.runAfter(InsideBlockEffectType.FIRE_IGNITE, entity1 -> entity1.hurt(entity1.level().damageSources().inFire(), this.fireDamage)); + } + +- public static void fireIgnite(Entity entity) { ++ public static void fireIgnite(Entity entity, BlockPos pos) { // Paper - track position inside effect was triggered on if (!entity.fireImmune()) { if (entity.getRemainingFireTicks() < 0) { entity.setRemainingFireTicks(entity.getRemainingFireTicks() + 1); -@@ -137,7 +_,18 @@ +@@ -143,30 +_,41 @@ } if (entity.getRemainingFireTicks() >= 0) { - entity.igniteForSeconds(8.0F); + // CraftBukkit start -+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), entity.getBukkitEntity(), 8.0F); -+ level.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(entity.level(), pos), entity.getBukkitEntity(), 8.0F); ++ entity.level().getCraftServer().getPluginManager().callEvent(event); + + if (!event.isCancelled()) { + entity.igniteForSeconds(event.getDuration(), false); @@ -35,13 +33,11 @@ + // CraftBukkit end } } - -@@ -146,24 +_,24 @@ } @Override - protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { -+ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving, UseOnContext context) { // CraftBukkit - context ++ protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving, net.minecraft.world.item.context.UseOnContext context) { // CraftBukkit - context if (!oldState.is(state.getBlock())) { if (inPortalDimension(level)) { Optional optional = PortalShape.findEmptyPortalShape(level, pos, Direction.Axis.X); @@ -65,7 +61,7 @@ } @Override -@@ -208,4 +_,12 @@ +@@ -211,4 +_,12 @@ } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch index 2cada56fb..f1ba44786 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BasePressurePlateBlock.java.patch @@ -1,25 +1,22 @@ --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java -@@ -81,6 +_,7 @@ +@@ -82,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide) { int signalForState = this.getSignalForState(state); if (signalForState == 0) { -@@ -93,6 +_,19 @@ +@@ -94,6 +_,16 @@ int signalStrength = this.getSignalStrength(level, pos); boolean flag = currentSignal > 0; boolean flag1 = signalStrength > 0; -+ -+ // CraftBukkit start - Interact Pressure Plate -+ org.bukkit.World bworld = level.getWorld(); -+ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); + ++ // CraftBukkit start - Interact Pressure Plate + if (flag != flag1) { -+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), currentSignal, signalStrength); -+ manager.callEvent(eventRedstone); ++ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), currentSignal, signalStrength); ++ eventRedstone.callEvent(); + + flag1 = eventRedstone.getNewCurrent() > 0; + signalStrength = eventRedstone.getNewCurrent(); @@ -28,7 +25,7 @@ if (currentSignal != signalStrength) { BlockState blockState = this.setSignalForState(state, signalStrength); level.setBlock(pos, blockState, 2); -@@ -145,7 +_,13 @@ +@@ -142,7 +_,13 @@ } protected static int getEntityCount(Level level, AABB box, Class entityClass) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch index 1b12bd9f7..4e4bc1fa0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BedBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BedBlock.java +++ b/net/minecraft/world/level/block/BedBlock.java -@@ -92,7 +_,7 @@ +@@ -90,7 +_,7 @@ } } @@ -9,7 +9,7 @@ level.removeBlock(pos, false); BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); if (level.getBlockState(blockPos).is(this)) { -@@ -103,22 +_,56 @@ +@@ -101,22 +_,56 @@ level.explode(null, level.damageSources().badRespawnPointExplosion(center), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); return InteractionResult.SUCCESS_SERVER; } else if (state.getValue(OCCUPIED)) { @@ -67,7 +67,7 @@ public static boolean canSetSpawn(Level level) { return level.dimensionType().bedWorks(); } -@@ -311,6 +_,11 @@ +@@ -299,6 +_,11 @@ if (!level.isClientSide) { BlockPos blockPos = pos.relative(state.getValue(FACING)); level.setBlock(blockPos, state.setValue(PART, BedPart.HEAD), 3); @@ -76,6 +76,6 @@ + return; + } + // CraftBukkit end - level.blockUpdated(pos, Blocks.AIR); + level.updateNeighborsAt(pos, Blocks.AIR); state.updateNeighbourShapes(level, pos, 3); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch index 221e36c66..00c14e713 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BeehiveBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BeehiveBlock.java +++ b/net/minecraft/world/level/block/BeehiveBlock.java -@@ -91,8 +_,8 @@ +@@ -88,8 +_,8 @@ } @Override @@ -11,7 +11,7 @@ if (!level.isClientSide && te instanceof BeehiveBlockEntity beehiveBlockEntity) { if (!EnchantmentHelper.hasTag(stack, EnchantmentTags.PREVENTS_BEE_SPAWNS_WHEN_MINING)) { beehiveBlockEntity.emptyAllLivingFromHive(player, state, BeehiveBlockEntity.BeeReleaseStatus.EMERGENCY); -@@ -100,7 +_,7 @@ +@@ -97,7 +_,7 @@ this.angerNearbyBees(level, pos); } @@ -20,12 +20,12 @@ } } -@@ -122,14 +_,14 @@ +@@ -119,14 +_,14 @@ for (Bee bee : entitiesOfClass) { if (bee.getTarget() == null) { Player player = Util.getRandom(entitiesOfClass1, level.random); - bee.setTarget(player); -+ bee.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit ++ bee.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit } } } @@ -37,7 +37,7 @@ } @Override -@@ -141,8 +_,19 @@ +@@ -138,8 +_,19 @@ if (honeyLevelValue >= 5) { Item item = stack.getItem(); if (stack.is(Items.SHEARS)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch index 67deb9015..2a870fa79 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BellBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BellBlock.java +++ b/net/minecraft/world/level/block/BellBlock.java -@@ -142,6 +_,11 @@ +@@ -137,6 +_,11 @@ direction = level.getBlockState(pos).getValue(FACING); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch index f3f15caba..05cd12c5a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BigDripleafBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BigDripleafBlock.java +++ b/net/minecraft/world/level/block/BigDripleafBlock.java -@@ -136,7 +_,7 @@ +@@ -129,7 +_,7 @@ @Override protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { @@ -9,10 +9,10 @@ } @Override -@@ -199,9 +_,23 @@ +@@ -192,9 +_,23 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide) { if (state.getValue(TILT) == Tilt.NONE && canEntityTilt(pos, entity) && !level.hasNeighborSignal(pos)) { @@ -22,7 +22,7 @@ + if (entity instanceof net.minecraft.world.entity.player.Player player) { + cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + @@ -34,7 +34,7 @@ } } } -@@ -213,9 +_,9 @@ +@@ -206,9 +_,9 @@ } else { Tilt tilt = state.getValue(TILT); if (tilt == Tilt.UNSTABLE) { @@ -46,7 +46,7 @@ } else if (tilt == Tilt.FULL) { resetTilt(state, level, pos); } -@@ -238,8 +_,11 @@ +@@ -231,8 +_,11 @@ return entity.onGround() && entity.position().y > pos.getY() + 0.6875F; } @@ -60,7 +60,7 @@ if (sound != null) { playTiltSound(level, pos, sound); } -@@ -251,18 +_,26 @@ +@@ -244,18 +_,26 @@ } private static void resetTilt(BlockState state, Level level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch index 1fe47eae6..557a1c5cf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/Block.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -90,6 +_,21 @@ +@@ -99,6 +_,21 @@ public static final int UPDATE_LIMIT = 512; protected final StateDefinition stateDefinition; private BlockState defaultBlockState; @@ -22,7 +22,7 @@ @Nullable private Item item; private static final int CACHE_SIZE = 256; -@@ -272,6 +_,27 @@ +@@ -318,6 +_,27 @@ return state.getDrops(builder); } @@ -49,8 +49,8 @@ + public static void dropResources(BlockState state, Level level, BlockPos pos) { if (level instanceof ServerLevel) { - getDrops(state, (ServerLevel)level, pos, null).forEach(itemStack -> popResource(level, pos, itemStack)); -@@ -287,9 +_,14 @@ + getDrops(state, (ServerLevel)level, pos, null).forEach(stack -> popResource(level, pos, stack)); +@@ -333,9 +_,14 @@ } public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool) { @@ -60,13 +60,13 @@ + public static void dropResources(BlockState state, Level level, BlockPos pos, @Nullable BlockEntity blockEntity, @Nullable Entity entity, ItemStack tool, boolean dropExperience) { + // Paper end - Properly handle xp dropping if (level instanceof ServerLevel) { - getDrops(state, (ServerLevel)level, pos, blockEntity, entity, tool).forEach(itemStack -> popResource(level, pos, itemStack)); + getDrops(state, (ServerLevel)level, pos, blockEntity, entity, tool).forEach(stack -> popResource(level, pos, stack)); - state.spawnAfterBreak((ServerLevel)level, pos, tool, true); -+ state.spawnAfterBreak((ServerLevel) level, pos, tool, dropExperience); // Paper - Properly handle xp dropping ++ state.spawnAfterBreak((ServerLevel)level, pos, tool, dropExperience); // Paper - Properly handle xp dropping } } -@@ -320,13 +_,24 @@ +@@ -366,13 +_,25 @@ if (level instanceof ServerLevel serverLevel && !stack.isEmpty() && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { ItemEntity itemEntity = itemEntitySupplier.get(); itemEntity.setDefaultPickUpDelay(); @@ -85,7 +85,8 @@ + // Paper start - add entity parameter + popExperience(level, pos, amount, null); + } -+ public void popExperience(ServerLevel level, BlockPos pos, int amount, net.minecraft.world.entity.Entity entity) { ++ ++ public void popExperience(ServerLevel level, BlockPos pos, int amount, @Nullable net.minecraft.world.entity.Entity entity) { + // Paper end - add entity parameter if (level.getGameRules().getBoolean(GameRules.RULE_DOBLOCKDROPS)) { - ExperienceOrb.award(level, Vec3.atCenterOf(pos), amount); @@ -93,17 +94,18 @@ } } -@@ -345,10 +_,18 @@ +@@ -391,10 +_,19 @@ return this.defaultBlockState(); } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - fix drops not preventing stats/food exhaustion ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - fix drops not preventing stats/food exhaustion public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool) { -+ // Paper start - fix drops not preventing stats/food exhaustion ++ // Paper start - fix drops not preventing stats/food exhaustion + this.playerDestroy(level, player, pos, state, blockEntity, tool, true, true); + } ++ + public void playerDestroy(Level level, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack tool, boolean includeDrops, boolean dropExp) { -+ // Paper end - fix drops not preventing stats/food exhaustion ++ // Paper end - fix drops not preventing stats/food exhaustion player.awardStat(Stats.BLOCK_MINED.get(this)); - player.causeFoodExhaustion(0.005F); - dropResources(state, level, pos, blockEntity, player, tool); @@ -114,7 +116,7 @@ } public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { -@@ -469,12 +_,33 @@ +@@ -533,12 +_,20 @@ return this.builtInRegistryHolder; } @@ -123,32 +125,18 @@ int i = EnchantmentHelper.processBlockExperience(level, heldItem, amount.sample(level.getRandom())); if (i > 0) { - this.popExperience(level, pos, i); -- } -- } + // CraftBukkit start + //this.popExperience(level, pos, i); + return i; -+ // CraftBukkit end -+ } -+ return 0; // CraftBukkit + } +- } ++ return 0; + } -+ // CraftBukkit start ++ + public int getExpDrop(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { + return 0; + } + // CraftBukkit end -+ -+ // Spigot start -+ public static float range(float min, float value, float max) { -+ if (value < min) { -+ return min; -+ } -+ if (value > max) { -+ return max; -+ } -+ return value; -+ } -+ // Spigot end record ShapePairKey(VoxelShape first, VoxelShape second) { @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch index e2bbf7575..40b2683bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BrewingStandBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/net/minecraft/world/level/block/BrewingStandBlock.java -@@ -68,8 +_,7 @@ +@@ -63,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BubbleColumnBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BubbleColumnBlock.java.patch index 1ca54afa4..7e1b6a743 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BubbleColumnBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BubbleColumnBlock.java.patch @@ -1,10 +1,10 @@ --- a/net/minecraft/world/level/block/BubbleColumnBlock.java +++ b/net/minecraft/world/level/block/BubbleColumnBlock.java -@@ -48,6 +_,7 @@ +@@ -49,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent BlockState blockState = level.getBlockState(pos.above()); - if (blockState.isAir()) { - entity.onAboveBubbleCol(state.getValue(DRAG_DOWN)); + boolean flag = blockState.getCollisionShape(level, pos).isEmpty() && blockState.getFluidState().isEmpty(); + if (flag) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch index 81ceb891c..be41e780e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/BuddingAmethystBlock.java.patch @@ -3,13 +3,13 @@ @@ -44,7 +_,13 @@ BlockState blockState1 = block.defaultBlockState() .setValue(AmethystClusterBlock.FACING, direction) - .setValue(AmethystClusterBlock.WATERLOGGED, Boolean.valueOf(blockState.getFluidState().getType() == Fluids.WATER)); + .setValue(AmethystClusterBlock.WATERLOGGED, blockState.getFluidState().getType() == Fluids.WATER); - level.setBlockAndUpdate(blockPos, blockState1); + // Paper start - Have Amethyst throw both spread and grow events + if (block == Blocks.SMALL_AMETHYST_BUD) { + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState1, 3); // CraftBukkit + } else { -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, blockState1); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, blockState1, 3); + } + // Paper end - Have Amethyst throw both spread and grow events } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/BushBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/BushBlock.java.patch deleted file mode 100644 index 377f1220e..000000000 --- a/paper-server/patches/sources/net/minecraft/world/level/block/BushBlock.java.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/net/minecraft/world/level/block/BushBlock.java -+++ b/net/minecraft/world/level/block/BushBlock.java -@@ -35,9 +_,15 @@ - BlockState neighborState, - RandomSource random - ) { -- return !state.canSurvive(level, pos) -- ? Blocks.AIR.defaultBlockState() -- : super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); -+ // CraftBukkit start -+ if (!state.canSurvive(level, pos)) { -+ // Suppress during worldgen -+ if (!(level instanceof net.minecraft.server.level.ServerLevel serverLevel && serverLevel.hasPhysicsEvent) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(serverLevel, pos).isCancelled()) { // Paper -+ return Blocks.AIR.defaultBlockState(); -+ } -+ } -+ return super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); -+ // CraftBukkit end - } - - @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch index 956c25b45..965cd3cbc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ButtonBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/ButtonBlock.java +++ b/net/minecraft/world/level/block/ButtonBlock.java -@@ -114,6 +_,19 @@ +@@ -89,6 +_,19 @@ if (state.getValue(POWERED)) { return InteractionResult.CONSUME; } else { + // CraftBukkit start + boolean powered = state.getValue(ButtonBlock.POWERED); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -20,21 +20,21 @@ this.press(state, level, pos, player); return InteractionResult.SUCCESS; } -@@ -179,6 +_,7 @@ +@@ -150,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide && this.type.canButtonBeActivatedByArrows() && !state.getValue(POWERED)) { this.checkPressed(state, level, pos); } -@@ -190,7 +_,31 @@ +@@ -161,7 +_,31 @@ : null; boolean flag = abstractArrow != null; boolean poweredValue = state.getValue(POWERED); + // CraftBukkit start - Call interact event when arrows turn on wooden buttons + if (poweredValue != flag && flag) { -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(abstractArrow.getBukkitEntity(), block); + level.getCraftServer().getPluginManager().callEvent(event); + @@ -46,7 +46,7 @@ if (flag != poweredValue) { + // CraftBukkit start + boolean powered = poweredValue; -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + @@ -57,6 +57,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(flag)), 3); + level.setBlock(pos, state.setValue(POWERED, flag), 3); this.updateNeighbours(state, level, pos); this.playSound(null, level, pos, flag); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch index 3690ad3d1..4ea4f1ba5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CactusBlock.java.patch @@ -1,30 +1,46 @@ --- a/net/minecraft/world/level/block/CactusBlock.java +++ b/net/minecraft/world/level/block/CactusBlock.java -@@ -56,14 +_,16 @@ - i++; - } +@@ -58,25 +_,29 @@ + int ageValue = state.getValue(AGE); -- if (i < 3) { -+ if (i < level.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height - int ageValue = state.getValue(AGE); -- if (ageValue == 15) { -- level.setBlockAndUpdate(blockPos, this.defaultBlockState()); -+ -+ int modifier = level.spigotConfig.cactusModifier; // Spigot - SPIGOT-7159: Better modifier resolution -+ if (ageValue >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, this.defaultBlockState()); // CraftBukkit - BlockState blockState = state.setValue(AGE, Integer.valueOf(0)); - level.setBlock(pos, blockState, 4); - level.neighborChanged(blockState, blockPos, this, null, false); -- } else { -+ } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution - level.setBlock(pos, state.setValue(AGE, Integer.valueOf(ageValue + 1)), 4); + while (level.getBlockState(pos.below(i)).is(this)) { +- if (++i == 3 && ageValue == 15) { ++ if (++i == level.paperConfig().maxGrowthHeight.cactus && ageValue == 15) { // Paper - Configurable cactus/bamboo/reed growth height + return; } } -@@ -113,7 +_,8 @@ + + if (ageValue == 8 && this.canSurvive(this.defaultBlockState(), level, pos.above())) { +- double d = i >= 3 ? 0.25 : 0.1; ++ double d = i >= level.paperConfig().maxGrowthHeight.cactus ? 0.25 : 0.1; // Paper - Configurable cactus/bamboo/reed growth height + if (random.nextDouble() <= d) { +- level.setBlockAndUpdate(blockPos, Blocks.CACTUS_FLOWER.defaultBlockState()); +- } +- } else if (ageValue == 15 && i < 3) { +- level.setBlockAndUpdate(blockPos, this.defaultBlockState()); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, Blocks.CACTUS_FLOWER.defaultBlockState(), 3); ++ } ++ } else if (ageValue == 15 && i < level.paperConfig().maxGrowthHeight.cactus) { // Paper - Configurable cactus/bamboo/reed growth height ++ // Paper start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, this.defaultBlockState(), 3)) { ++ return; ++ } ++ // Paper end + BlockState blockState = state.setValue(AGE, 0); + level.setBlock(pos, blockState, 260); + level.neighborChanged(blockState, blockPos, this, null, false); + } + + if (ageValue < 15) { +- level.setBlock(pos, state.setValue(AGE, ageValue + 1), 260); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(AGE, ageValue + 1), 260); // Paper + } + } + } +@@ -124,7 +_,8 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { - entity.hurt(level.damageSources().cactus(), 1.0F); + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent + entity.hurt(level.damageSources().cactus().eventBlockDamager(level, pos), 1.0F); // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch index f3add7001..f59bfeee8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CakeBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CakeBlock.java +++ b/net/minecraft/world/level/block/CakeBlock.java -@@ -67,6 +_,12 @@ +@@ -57,6 +_,12 @@ ) { Item item = stack.getItem(); if (stack.is(ItemTags.CANDLES) && state.getValue(BITES) == 0 && Block.byItem(item) instanceof CandleBlock candleBlock) { @@ -13,7 +13,7 @@ stack.consume(1, player); level.playSound(null, pos, SoundEvents.CAKE_ADD_CANDLE, SoundSource.BLOCKS, 1.0F, 1.0F); level.setBlockAndUpdate(pos, CandleCakeBlock.byCandle(candleBlock)); -@@ -97,9 +_,28 @@ +@@ -87,9 +_,28 @@ if (!player.canEat(false)) { return InteractionResult.PASS; } else { @@ -43,4 +43,4 @@ + // Paper - move up level.gameEvent(player, GameEvent.EAT, pos); if (bitesValue < 6) { - level.setBlock(pos, state.setValue(BITES, Integer.valueOf(bitesValue + 1)), 3); + level.setBlock(pos, state.setValue(BITES, bitesValue + 1), 3); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch index df0ab0b58..84c287b0d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CampfireBlock.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java -@@ -112,8 +_,9 @@ +@@ -107,8 +_,9 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (state.getValue(LIT) && entity instanceof LivingEntity) { - entity.hurt(level.damageSources().campfire(), this.fireDamage); + entity.hurt(level.damageSources().campfire().eventBlockDamager(level, pos), (float) this.fireDamage); // CraftBukkit } - super.entityInside(state, level, pos, entity); -@@ -242,6 +_,11 @@ + super.entityInside(state, level, pos, entity, effectApplier); +@@ -220,6 +_,11 @@ && projectile.mayInteract(serverLevel, blockPos) && !state.getValue(LIT) && !state.getValue(WATERLOGGED)) { @@ -20,6 +20,6 @@ + return; + } + // CraftBukkit end - level.setBlock(blockPos, state.setValue(BlockStateProperties.LIT, Boolean.valueOf(true)), 11); + level.setBlock(blockPos, state.setValue(BlockStateProperties.LIT, true), 11); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch index 4343b42a3..1e424bfd3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CarvedPumpkinBlock.java.patch @@ -1,18 +1,19 @@ --- a/net/minecraft/world/level/block/CarvedPumpkinBlock.java +++ b/net/minecraft/world/level/block/CarvedPumpkinBlock.java -@@ -79,9 +_,13 @@ +@@ -79,9 +_,14 @@ } private static void spawnGolemInWorld(Level level, BlockPattern.BlockPatternMatch patternMatch, Entity golem, BlockPos pos) { - clearPatternBlocks(level, patternMatch); -+ // clearPatternBlocks(level, patternMatch); // CraftBukkit - moved down - golem.moveTo(pos.getX() + 0.5, pos.getY() + 0.05, pos.getZ() + 0.5, 0.0F, 0.0F); ++ // clearPatternBlocks(level, patternMatch); // Paper - moved down + golem.snapTo(pos.getX() + 0.5, pos.getY() + 0.05, pos.getZ() + 0.5, 0.0F, 0.0F); - level.addFreshEntity(golem); ++ // Paper start + if (!level.addFreshEntity(golem, (golem.getType() == EntityType.SNOW_GOLEM) ? org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_SNOWMAN : org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BUILD_IRONGOLEM)) { + return; + } -+ clearPatternBlocks(level, patternMatch); // CraftBukkit - from above -+ // CraftBukkit end ++ // Paper end ++ clearPatternBlocks(level, patternMatch); // Paper - from above for (ServerPlayer serverPlayer : level.getEntitiesOfClass(ServerPlayer.class, golem.getBoundingBox().inflate(5.0))) { CriteriaTriggers.SUMMONED_ENTITY.trigger(serverPlayer, golem); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CaveVines.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CaveVines.java.patch index f24e49e93..9a7464130 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CaveVines.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CaveVines.java.patch @@ -24,4 +24,4 @@ + // CraftBukkit end float f = Mth.randomBetween(level.random, 0.8F, 1.2F); level.playSound(null, pos, SoundEvents.CAVE_VINES_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, f); - BlockState blockState = state.setValue(BERRIES, Boolean.valueOf(false)); + BlockState blockState = state.setValue(BERRIES, false); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CaveVinesBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CaveVinesBlock.java.patch index c0eb21e51..332ca7363 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CaveVinesBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CaveVinesBlock.java.patch @@ -4,9 +4,9 @@ @Override protected BlockState getGrowIntoState(BlockState state, RandomSource random) { -- return super.getGrowIntoState(state, random).setValue(BERRIES, Boolean.valueOf(random.nextFloat() < 0.11F)); +- return super.getGrowIntoState(state, random).setValue(BERRIES, random.nextFloat() < 0.11F); - } -+ // Paper start - Fix Spigot growth modifiers ++ // Paper start - Fix Spigot growth modifiers + return this.getGrowIntoState(state, random, null); + } + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch index f965aa92d..3a77d4216 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CeilingHangingSignBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CeilingHangingSignBlock.java +++ b/net/minecraft/world/level/block/CeilingHangingSignBlock.java -@@ -184,6 +_,6 @@ +@@ -166,6 +_,6 @@ @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch index 6601a243a..8ed6706e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChangeOverTimeBlock.java.patch @@ -5,7 +5,7 @@ float f = 0.05688889F; if (random.nextFloat() < 0.05688889F) { - this.getNextState(state, level, pos, random).ifPresent(blockState -> level.setBlockAndUpdate(pos, blockState)); -+ this.getNextState(state, level, pos, random).ifPresent(blockState -> org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, blockState)); // CraftBukkit ++ this.getNextState(state, level, pos, random).ifPresent(blockState -> org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, blockState, 3)); // CraftBukkit } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch index 7b27fcf64..63d081faf 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChestBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -85,7 +_,7 @@ +@@ -82,7 +_,7 @@ @Override public Optional acceptDouble(final ChestBlockEntity first, final ChestBlockEntity second) { final Container container = new CompoundContainer(first, second); @@ -9,7 +9,7 @@ @Nullable @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { -@@ -103,10 +_,10 @@ +@@ -100,10 +_,10 @@ if (first.hasCustomName()) { return first.getDisplayName(); } else { @@ -22,7 +22,7 @@ } @Override -@@ -120,6 +_,34 @@ +@@ -117,6 +_,34 @@ } }; @@ -57,7 +57,7 @@ @Override public MapCodec codec() { return CODEC; -@@ -245,8 +_,7 @@ +@@ -225,8 +_,7 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel) { MenuProvider menuProvider = this.getMenuProvider(state, level, pos); @@ -67,7 +67,7 @@ player.awardStat(this.getOpenChestStat()); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -285,7 +_,14 @@ +@@ -265,7 +_,14 @@ @Nullable @Override public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { @@ -83,7 +83,7 @@ } public static DoubleBlockCombiner.Combiner opennessCombiner(final LidBlockEntity lid) { -@@ -328,6 +_,11 @@ +@@ -308,6 +_,11 @@ } private static boolean isCatSittingOnChest(LevelAccessor level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch index 907be0333..cca451923 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ChorusFlowerBlock.java.patch @@ -4,18 +4,18 @@ } if (flag && allNeighborsEmpty(level, blockPos, null) && level.isEmptyBlock(pos.above(2))) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, ageValue), 2)) { // CraftBukkit - add event ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, this.defaultBlockState().setValue(AGE, ageValue), 2)) { // CraftBukkit - add event level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), 2); this.placeGrownFlower(level, blockPos, ageValue); + } // CraftBukkit } else if (ageValue < 4) { int i = random.nextInt(4); if (flag1) { -@@ -112,18 +_,28 @@ +@@ -112,30 +_,40 @@ if (level.isEmptyBlock(blockPos1) && level.isEmptyBlock(blockPos1.below()) && allNeighborsEmpty(level, blockPos1, randomDirection.getOpposite())) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos1, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, ageValue + 1), 2)) { // CraftBukkit - add event ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos1, this.defaultBlockState().setValue(AGE, ageValue + 1), 2)) { // CraftBukkit - add event this.placeGrownFlower(level, blockPos1, ageValue + 1); flag2 = true; + } // CraftBukkit @@ -26,20 +26,34 @@ level.setBlock(pos, ChorusPlantBlock.getStateWithConnections(level, pos, this.plant.defaultBlockState()), 2); } else { + // CraftBukkit start - add event -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, Integer.valueOf(5)), 2)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(AGE, 5), 2)) { this.placeDeadFlower(level, pos); + } + // CraftBukkit end } } else { + // CraftBukkit start - add event -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(ChorusFlowerBlock.AGE, Integer.valueOf(5)), 2)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.defaultBlockState().setValue(AGE, 5), 2)) { this.placeDeadFlower(level, pos); + } + // CraftBukkit end } } } + } + + private void placeGrownFlower(Level level, BlockPos pos, int age) { +- level.setBlock(pos, this.defaultBlockState().setValue(AGE, age), 2); ++ // level.setBlock(pos, this.defaultBlockState().setValue(AGE, age), 2); // Paper - already done above in the event call + level.levelEvent(1033, pos, 0); + } + + private void placeDeadFlower(Level level, BlockPos pos) { +- level.setBlock(pos, this.defaultBlockState().setValue(AGE, 5), 2); ++ // level.setBlock(pos, this.defaultBlockState().setValue(AGE, 5), 2); // Paper - already done above in the event call + level.levelEvent(1034, pos, 0); + } + @@ -261,6 +_,11 @@ protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { BlockPos blockPos = hit.getBlockPos(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch index 1ba2e5608..963613a8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CocoaBlock.java.patch @@ -1,24 +1,24 @@ --- a/net/minecraft/world/level/block/CocoaBlock.java +++ b/net/minecraft/world/level/block/CocoaBlock.java -@@ -64,10 +_,10 @@ +@@ -50,10 +_,10 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (level.random.nextInt(5) == 0) { -+ if (level.random.nextFloat() < (level.spigotConfig.cocoaModifier / (100.0f * 5))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (level.random.nextFloat() < (level.spigotConfig.cocoaModifier / (100.0F * 5))) { // Spigot - SPIGOT-7159: Better modifier resolution int ageValue = state.getValue(AGE); if (ageValue < 2) { -- level.setBlock(pos, state.setValue(AGE, Integer.valueOf(ageValue + 1)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(CocoaBlock.AGE, ageValue + 1), 2); // CraftBukkit +- level.setBlock(pos, state.setValue(AGE, ageValue + 1), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(AGE, ageValue + 1), 2); // CraftBukkit } } } -@@ -141,7 +_,7 @@ +@@ -116,7 +_,7 @@ @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { -- level.setBlock(pos, state.setValue(AGE, Integer.valueOf(state.getValue(AGE) + 1)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(CocoaBlock.AGE, state.getValue(CocoaBlock.AGE) + 1), 2); // CraftBukkit +- level.setBlock(pos, state.setValue(AGE, state.getValue(AGE) + 1), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(AGE, state.getValue(AGE) + 1), 2); // CraftBukkit } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch index a1cc0188d..ee56dfd5e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CommandBlock.java.patch @@ -5,7 +5,7 @@ private void setPoweredAndUpdate(Level level, BlockPos pos, CommandBlockEntity blockEntity, boolean powered) { boolean isPowered = blockEntity.isPowered(); + // CraftBukkit start -+ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + int old = isPowered ? 15 : 0; + int current = powered ? 15 : 0; + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch index 713361e2b..af8a2f18f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComparatorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java -@@ -170,8 +_,18 @@ +@@ -168,8 +_,18 @@ boolean shouldTurnOn = this.shouldTurnOn(level, pos, state); boolean poweredValue = state.getValue(POWERED); if (poweredValue && !shouldTurnOn) { @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(false)), 2); + level.setBlock(pos, state.setValue(POWERED, false), 2); } else if (!poweredValue && shouldTurnOn) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 2); + level.setBlock(pos, state.setValue(POWERED, true), 2); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch index 5a21c3937..ed812e30b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ComposterBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java -@@ -243,6 +_,11 @@ +@@ -252,6 +_,11 @@ if (levelValue < 8 && COMPOSTABLES.containsKey(stack.getItem())) { if (levelValue < 7 && !level.isClientSide) { BlockState blockState = addItem(player, state, level, pos, stack); @@ -12,7 +12,7 @@ level.levelEvent(1500, pos, state != blockState ? 1 : 0); player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(1, player); -@@ -268,7 +_,19 @@ +@@ -277,7 +_,19 @@ public static BlockState insertItem(Entity entity, BlockState state, ServerLevel level, ItemStack stack, BlockPos pos) { int levelValue = state.getValue(LEVEL); if (levelValue < 7 && COMPOSTABLES.containsKey(stack.getItem())) { @@ -33,7 +33,7 @@ stack.shrink(1); return blockState; } else { -@@ -277,6 +_,14 @@ +@@ -286,6 +_,14 @@ } public static BlockState extractProduce(Entity entity, BlockState state, Level level, BlockPos pos) { @@ -48,7 +48,7 @@ if (!level.isClientSide) { Vec3 vec3 = Vec3.atLowerCornerWithOffset(pos, 0.5, 1.01, 0.5).offsetRandom(level.random, 0.7F); ItemEntity itemEntity = new ItemEntity(level, vec3.x(), vec3.y(), vec3.z(), new ItemStack(Items.BONE_MEAL)); -@@ -296,14 +_,39 @@ +@@ -305,14 +_,39 @@ return blockState; } @@ -80,7 +80,7 @@ return state; } else { int i = levelValue + 1; - BlockState blockState = state.setValue(LEVEL, Integer.valueOf(i)); + BlockState blockState = state.setValue(LEVEL, i); + // Paper start - move the EntityChangeBlockEvent here to avoid conflict later for the compost events + if (entity != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, blockState)) { + return null; @@ -89,7 +89,7 @@ level.setBlock(pos, blockState, 3); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(entity, blockState)); if (i == 7) { -@@ -348,13 +_,14 @@ +@@ -357,13 +_,14 @@ if (levelValue == 8) { return new ComposterBlock.OutputContainer(state, level, pos, new ItemStack(Items.BONE_MEAL)); } else { @@ -106,7 +106,7 @@ } @Override -@@ -381,6 +_,7 @@ +@@ -390,6 +_,7 @@ public InputContainer(BlockState state, LevelAccessor level, BlockPos pos) { super(1); @@ -114,7 +114,7 @@ this.state = state; this.level = level; this.pos = pos; -@@ -412,6 +_,11 @@ +@@ -421,6 +_,11 @@ if (!item.isEmpty()) { this.changed = true; BlockState blockState = ComposterBlock.addItem(null, this.state, this.level, this.pos, item); @@ -126,7 +126,7 @@ this.level.levelEvent(1500, this.pos, blockState != this.state ? 1 : 0); this.removeItemNoUpdate(0); } -@@ -426,6 +_,7 @@ +@@ -435,6 +_,7 @@ public OutputContainer(BlockState state, LevelAccessor level, BlockPos pos, ItemStack stack) { super(stack); @@ -134,7 +134,7 @@ this.state = state; this.level = level; this.pos = pos; -@@ -453,8 +_,15 @@ +@@ -462,8 +_,15 @@ @Override public void setChanged() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch index ff375bb06..99203da0a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralFanBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), 2); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch index c768b4c63..92526024d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralPlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CoralPlantBlock.java +++ b/net/minecraft/world/level/block/CoralPlantBlock.java -@@ -43,6 +_,11 @@ +@@ -42,6 +_,11 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!scanForWater(state, level, pos)) { @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false), 2); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch index 7ac0a5182..896584437 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CoralWallFanBlock.java.patch @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, Boolean.valueOf(false)).setValue(FACING, state.getValue(FACING)), 2); + level.setBlock(pos, this.deadBlock.defaultBlockState().setValue(WATERLOGGED, false).setValue(FACING, state.getValue(FACING)), 2); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch index fb9ecec88..dbd5408e2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CrafterBlock.java.patch @@ -1,19 +1,11 @@ --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -11,6 +_,7 @@ - import net.minecraft.server.level.ServerLevel; - import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.RandomSource; -+import net.minecraft.world.CompoundContainer; - import net.minecraft.world.Container; - import net.minecraft.world.Containers; - import net.minecraft.world.InteractionResult; -@@ -159,6 +_,13 @@ +@@ -152,6 +_,13 @@ } else { RecipeHolder recipeHolder = potentialResults.get(); ItemStack itemStack = recipeHolder.value().assemble(var11, level.registryAccess()); + // CraftBukkit start -+ org.bukkit.event.block.CrafterCraftEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callCrafterCraftEvent(pos, level, crafterBlockEntity, itemStack, recipeHolder); ++ org.bukkit.event.block.CrafterCraftEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callCrafterCraftEvent(pos, level, itemStack, recipeHolder); + if (event.isCancelled()) { + return; + } @@ -22,7 +14,7 @@ if (itemStack.isEmpty()) { level.levelEvent(1050, pos, 0); } else { -@@ -193,7 +_,25 @@ +@@ -186,7 +_,25 @@ Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); ItemStack itemStack = stack.copy(); if (containerAt != null && (containerAt instanceof CrafterBlockEntity || stack.getCount() > containerAt.getMaxStackSize(stack))) { @@ -31,7 +23,7 @@ + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly -+ if (containerAt instanceof CompoundContainer compoundContainer) { ++ if (containerAt instanceof net.minecraft.world.CompoundContainer compoundContainer) { + destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); + } else { + destinationInventory = containerAt.getOwner().getInventory(); @@ -48,7 +40,7 @@ ItemStack itemStack1 = itemStack.copyWithCount(1); ItemStack itemStack2 = HopperBlockEntity.addItem(crafter, containerAt, itemStack1, direction.getOpposite()); if (!itemStack2.isEmpty()) { -@@ -203,7 +_,25 @@ +@@ -196,7 +_,25 @@ itemStack.shrink(1); } } else if (containerAt != null) { @@ -57,7 +49,7 @@ + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly -+ if (containerAt instanceof CompoundContainer compoundContainer) { ++ if (containerAt instanceof net.minecraft.world.CompoundContainer compoundContainer) { + destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); + } else { + destinationInventory = containerAt.getOwner().getInventory(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch index 0897bcc22..077d7ff4b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/CropBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/CropBlock.java +++ b/net/minecraft/world/level/block/CropBlock.java -@@ -88,8 +_,25 @@ +@@ -80,8 +_,25 @@ int age = this.getAge(state); if (age < this.getMaxAge()) { float growthSpeed = getGrowthSpeed(this, level, pos); @@ -22,25 +22,25 @@ + modifier = level.spigotConfig.wheatModifier; + } + -+ if (random.nextFloat() < (modifier / (100.0f * (Math.floor((25.0F / growthSpeed) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < (modifier / (100.0F * (Math.floor((25.0F / growthSpeed) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution + // Spigot end + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(age + 1), 2); // CraftBukkit } } } -@@ -102,7 +_,7 @@ - i = maxAge; - } +@@ -89,7 +_,7 @@ -- level.setBlock(pos, this.getStateForAge(i), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(i), 2); // CraftBukkit + public void growCrops(Level level, BlockPos pos, BlockState state) { + int min = Math.min(this.getMaxAge(), this.getAge(state) + this.getBonemealAgeIncrease(level)); +- level.setBlock(pos, this.getStateForAge(min), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, this.getStateForAge(min), 2); // CraftBukkit } protected int getBonemealAgeIncrease(Level level) { -@@ -164,7 +_,8 @@ +@@ -151,7 +_,8 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { - if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent + if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch index eee537faa..1857abf85 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DaylightDetectorBlock.java.patch @@ -5,6 +5,6 @@ i = Mth.clamp(i, 0, 15); if (state.getValue(POWER) != i) { + i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, state.getValue(DaylightDetectorBlock.POWER), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent - level.setBlock(pos, state.setValue(POWER, Integer.valueOf(i)), 3); + level.setBlock(pos, state.setValue(POWER, i), 3); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch index 492d3d7e7..491493f97 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DecoratedPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -237,6 +_,11 @@ +@@ -210,6 +_,11 @@ protected void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) { BlockPos blockPos = hit.getBlockPos(); if (level instanceof ServerLevel serverLevel && projectile.mayInteract(serverLevel, blockPos) && projectile.mayBreak(serverLevel)) { @@ -9,6 +9,6 @@ + return; + } + // CraftBukkit end - level.setBlock(blockPos, state.setValue(CRACKED, Boolean.valueOf(true)), 4); + level.setBlock(blockPos, state.setValue(CRACKED, true), 260); level.destroyBlock(blockPos, true, projectile); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch index d65731b15..812e525a3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DetectorRailBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/DetectorRailBlock.java +++ b/net/minecraft/world/level/block/DetectorRailBlock.java -@@ -54,6 +_,7 @@ +@@ -49,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide) { if (!state.getValue(POWERED)) { this.checkPressed(level, pos, state); -@@ -84,6 +_,7 @@ +@@ -79,6 +_,7 @@ private void checkPressed(Level level, BlockPos pos, BlockState state) { if (this.canSurvive(state, level, pos)) { @@ -16,13 +16,13 @@ boolean poweredValue = state.getValue(POWERED); boolean flag = false; List interactingMinecartOfType = this.getInteractingMinecartOfType(level, pos, AbstractMinecart.class, entity -> true); -@@ -91,6 +_,16 @@ +@@ -86,6 +_,16 @@ flag = true; } + // CraftBukkit start + if (poweredValue != flag) { -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + + org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(block, flag ? 15 : 0, flag ? 15 : 0); + level.getCraftServer().getPluginManager().callEvent(eventRedstone); @@ -31,5 +31,5 @@ + } + // CraftBukkit end if (flag && !poweredValue) { - BlockState blockState = state.setValue(POWERED, Boolean.valueOf(true)); + BlockState blockState = state.setValue(POWERED, true); level.setBlock(pos, blockState, 3); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch index bde27499c..94ed51c9c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DiodeBlock.java.patch @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(false)), 2); + level.setBlock(pos, state.setValue(POWERED, false), 2); } else if (!poweredValue) { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 2); + level.setBlock(pos, state.setValue(POWERED, true), 2); if (!shouldTurnOn) { level.scheduleTick(pos, this, this.getDelay(state), TickPriority.VERY_HIGH); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch index 2bce500d4..f90298e89 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DispenserBlock.java.patch @@ -1,13 +1,5 @@ --- a/net/minecraft/world/level/block/DispenserBlock.java +++ b/net/minecraft/world/level/block/DispenserBlock.java -@@ -50,6 +_,7 @@ - private static final DefaultDispenseItemBehavior DEFAULT_BEHAVIOR = new DefaultDispenseItemBehavior(); - public static final Map DISPENSER_REGISTRY = new IdentityHashMap<>(); - private static final int TRIGGER_DURATION = 4; -+ public static boolean eventFired = false; // CraftBukkit - - @Override - public MapCodec codec() { @@ -71,8 +_,7 @@ @Override @@ -18,7 +10,7 @@ player.awardStat(dispenserBlockEntity instanceof DropperBlockEntity ? Stats.INSPECT_DROPPER : Stats.INSPECT_DISPENSER); } -@@ -87,18 +_,27 @@ +@@ -87,17 +_,26 @@ BlockSource blockSource = new BlockSource(level, pos, state, dispenserBlockEntity); int randomSlot = dispenserBlockEntity.getRandomSlot(level.random); if (randomSlot < 0) { @@ -31,18 +23,17 @@ DispenseItemBehavior dispenseMethod = this.getDispenseMethod(level, item); if (dispenseMethod != DispenseItemBehavior.NOOP) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockPreDispenseEvent(level, pos, item, randomSlot)) return; // Paper - Add BlockPreDispenseEvent -+ DispenserBlock.eventFired = false; // CraftBukkit - reset event status dispenserBlockEntity.setItem(randomSlot, dispenseMethod.dispense(blockSource, item)); } } } } - ++ + // Paper start - Fix NPE with equippable and items without behavior + public static DispenseItemBehavior getDispenseBehavior(BlockSource pointer, ItemStack stack) { + return ((DispenserBlock) pointer.state().getBlock()).getDispenseMethod(pointer.level(), stack); + } + // Paper end - Fix NPE with equippable and items without behavior + protected DispenseItemBehavior getDispenseMethod(Level level, ItemStack item) { if (!item.isItemEnabled(level.enabledFeatures())) { - return DEFAULT_BEHAVIOR; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch index 03420b637..18fcad808 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoorBlock.java +++ b/net/minecraft/world/level/block/DoorBlock.java -@@ -229,9 +_,22 @@ +@@ -222,9 +_,22 @@ @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch index f57b086e6..f033661f9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DoublePlantBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/DoublePlantBlock.java +++ b/net/minecraft/world/level/block/DoublePlantBlock.java -@@ -112,11 +_,16 @@ +@@ -110,11 +_,16 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch index bcab2da23..e1fc914b4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/DropperBlock.java.patch @@ -1,22 +1,5 @@ --- a/net/minecraft/world/level/block/DropperBlock.java +++ b/net/minecraft/world/level/block/DropperBlock.java -@@ -8,6 +_,7 @@ - import net.minecraft.core.dispenser.DefaultDispenseItemBehavior; - import net.minecraft.core.dispenser.DispenseItemBehavior; - import net.minecraft.server.level.ServerLevel; -+import net.minecraft.world.CompoundContainer; - import net.minecraft.world.Container; - import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; -@@ -23,7 +_,7 @@ - public class DropperBlock extends DispenserBlock { - private static final Logger LOGGER = LogUtils.getLogger(); - public static final MapCodec CODEC = simpleCodec(DropperBlock::new); -- private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(); -+ private static final DispenseItemBehavior DISPENSE_BEHAVIOUR = new DefaultDispenseItemBehavior(true); // CraftBukkit - - @Override - public MapCodec codec() { @@ -53,6 +_,7 @@ BlockSource blockSource = new BlockSource(level, pos, state, dispenserBlockEntity); int randomSlot = dispenserBlockEntity.getRandomSlot(level.random); @@ -39,7 +22,7 @@ + + org.bukkit.inventory.Inventory destinationInventory; + // Have to special case large chests as they work oddly -+ if (containerAt instanceof CompoundContainer compoundContainer) { ++ if (containerAt instanceof net.minecraft.world.CompoundContainer compoundContainer) { + destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest(compoundContainer); + } else { + destinationInventory = containerAt.getOwner().getInventory(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch index 2b564a8c3..d86e5dea4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndGatewayBlock.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/block/EndGatewayBlock.java +++ b/net/minecraft/world/level/block/EndGatewayBlock.java -@@ -89,10 +_,15 @@ +@@ -90,10 +_,15 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (entity.canUsePortal(false) && !level.isClientSide && level.getBlockEntity(pos) instanceof TheEndGatewayBlockEntity theEndGatewayBlockEntity && !theEndGatewayBlockEntity.isCoolingDown()) { + // Paper start - call EntityPortalEnterEvent -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(level.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.END_GATEWAY); // Paper - add portal type ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), org.bukkit.PortalType.END_GATEWAY); // Paper - add portal type + if (!event.callEvent()) return; + // Paper end - call EntityPortalEnterEvent entity.setAsInsidePortal(this, pos); TheEndGatewayBlockEntity.triggerCooldown(level, pos, state, theEndGatewayBlockEntity); } -@@ -107,9 +_,9 @@ +@@ -108,9 +_,9 @@ return null; } else { return entity instanceof ThrownEnderpearl diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch index a63044ae4..bb6b957fb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EndPortalBlock.java.patch @@ -1,13 +1,13 @@ --- a/net/minecraft/world/level/block/EndPortalBlock.java +++ b/net/minecraft/world/level/block/EndPortalBlock.java -@@ -56,8 +_,15 @@ +@@ -57,8 +_,15 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(level.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.ENDER); // Paper - add portal type ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), org.bukkit.PortalType.ENDER); // Paper - add portal type + level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) return; // Paper - make cancellable + // CraftBukkit end @@ -16,7 +16,7 @@ serverPlayer.showEndCredits(); } else { entity.setAsInsidePortal(this, pos); -@@ -67,7 +_,7 @@ +@@ -68,7 +_,7 @@ @Override public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { @@ -25,7 +25,7 @@ ServerLevel level1 = level.getServer().getLevel(resourceKey); if (level1 == null) { return null; -@@ -78,7 +_,7 @@ +@@ -79,7 +_,7 @@ float f; Set set; if (flag) { @@ -34,7 +34,7 @@ f = Direction.WEST.toYRot(); set = Relative.union(Relative.DELTA, Set.of(Relative.X_ROT)); if (entity instanceof ServerPlayer) { -@@ -88,15 +_,23 @@ +@@ -89,15 +_,23 @@ f = 0.0F; set = Relative.union(Relative.DELTA, Relative.ROTATION); if (entity instanceof ServerPlayer serverPlayer) { @@ -57,7 +57,7 @@ + } + org.bukkit.Location to = event.getTo(); + -+ return new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3D(to), Vec3.ZERO, to.getYaw(), to.getPitch(), set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL); ++ return new TeleportTransition(((org.bukkit.craftbukkit.CraftWorld) to.getWorld()).getHandle(), org.bukkit.craftbukkit.util.CraftLocation.toVec3(to), Vec3.ZERO, to.getYaw(), to.getPitch(), set, TeleportTransition.PLAY_PORTAL_SOUND.then(TeleportTransition.PLACE_PORTAL_TICKET), org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.END_PORTAL); + // CraftBukkit end } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/EyeblossomBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/EyeblossomBlock.java.patch index a7765e31c..057565bf5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/EyeblossomBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/EyeblossomBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/EyeblossomBlock.java +++ b/net/minecraft/world/level/block/EyeblossomBlock.java -@@ -99,6 +_,7 @@ +@@ -100,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide() && level.getDifficulty() != Difficulty.PEACEFUL diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch index 7b5e8dcbc..acdb36a41 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FarmBlock.java.patch @@ -8,22 +8,22 @@ + if (moistureValue == 0 && level.paperConfig().tickRates.dryFarmland != 1 && (level.paperConfig().tickRates.dryFarmland < 1 || (net.minecraft.server.MinecraftServer.currentTick + pos.hashCode()) % level.paperConfig().tickRates.dryFarmland != 0)) { return; } // Paper - Configurable random tick rates for blocks if (!isNearWater(level, pos) && !level.isRainingAt(pos.above())) { if (moistureValue > 0) { -- level.setBlock(pos, state.setValue(MOISTURE, Integer.valueOf(moistureValue - 1)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(FarmBlock.MOISTURE, moistureValue - 1), 2); // CraftBukkit +- level.setBlock(pos, state.setValue(MOISTURE, moistureValue - 1), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(MOISTURE, moistureValue - 1), 2); // CraftBukkit } else if (!shouldMaintainFarmland(level, pos)) { turnToDirt(null, state, level, pos); } } else if (moistureValue < 7) { -- level.setBlock(pos, state.setValue(MOISTURE, Integer.valueOf(7)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(FarmBlock.MOISTURE, 7), 2); // CraftBukkit +- level.setBlock(pos, state.setValue(MOISTURE, 7), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(level, pos, state.setValue(MOISTURE, 7), 2); // CraftBukkit } } @Override - public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) { + public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) { + super.fallOn(level, state, pos, entity, fallDistance); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage. if (level instanceof ServerLevel serverLevel - && level.random.nextFloat() < fallDistance - 0.5F + && level.random.nextFloat() < fallDistance - 0.5 && entity instanceof LivingEntity && (entity instanceof Player || serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) && entity.getBbWidth() * entity.getBbWidth() * entity.getBbHeight() > 0.512F) { @@ -32,7 +32,7 @@ + if (entity instanceof Player) { + cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch index 718a99aac..08e353d32 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FenceGateBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FenceGateBlock.java +++ b/net/minecraft/world/level/block/FenceGateBlock.java -@@ -213,6 +_,17 @@ +@@ -199,6 +_,17 @@ protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { if (!level.isClientSide) { boolean hasNeighborSignal = level.hasNeighborSignal(pos); @@ -16,5 +16,5 @@ + } + // CraftBukkit end if (state.getValue(POWERED) != hasNeighborSignal) { - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(hasNeighborSignal)).setValue(OPEN, Boolean.valueOf(hasNeighborSignal)), 2); + level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal).setValue(OPEN, hasNeighborSignal), 2); if (state.getValue(OPEN) != hasNeighborSignal) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch index 3d286f8b4..ed71c0640 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -122,7 +_,25 @@ +@@ -101,7 +_,25 @@ BlockState neighborState, RandomSource random ) { @@ -27,95 +27,94 @@ } @Override -@@ -162,10 +_,10 @@ +@@ -141,11 +_,11 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - level.scheduleTick(pos, this, getFireTickDelay(level.random)); + level.scheduleTick(pos, this, getFireTickDelay(level)); // Paper - Add fire-tick-delay option if (level.getGameRules().getBoolean(GameRules.RULE_DOFIRETICK)) { - if (!state.canSurvive(level, pos)) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location - } - - BlockState blockState = level.getBlockState(pos.below()); -@@ -184,26 +_,28 @@ - if (!this.isValidFireLocation(level, pos)) { - BlockPos blockPos = pos.below(); - if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain - } - - return; - } - - if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { -- level.removeBlock(pos, false); -+ this.fireExtinguished(level, pos); // CraftBukkit - return; - } + if (level.getGameRules().getBoolean(GameRules.RULE_ALLOWFIRETICKAWAYFROMPLAYERS) || level.anyPlayerCloseEnoughForSpawning(pos)) { + if (!state.canSurvive(level, pos)) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - invalid place location } - boolean isIncreasedFireBurnout = level.getBiome(pos).is(BiomeTags.INCREASED_FIRE_BURNOUT); - int i = isIncreasedFireBurnout ? -50 : 0; -- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); -- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); -- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); -+ // CraftBukkit start - add source blockposition to burn calls -+ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); -+ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); -+ // CraftBukkit end - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + BlockState blockState = level.getBlockState(pos.below()); +@@ -164,26 +_,28 @@ + if (!this.isValidFireLocation(level, pos)) { + BlockPos blockPos = pos.below(); + if (!level.getBlockState(blockPos).isFaceSturdy(level, blockPos, Direction.UP) || ageValue > 3) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit - extinguished by rain + } - for (int i1 = -1; i1 <= 1; i1++) { -@@ -225,7 +_,15 @@ + return; + } - if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { - int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); -- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); -+ // CraftBukkit start - Call to stop spread of fire -+ if (level.getBlockState(mutableBlockPos).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { -+ continue; -+ } + if (ageValue == 15 && random.nextInt(4) == 0 && !this.canBurn(level.getBlockState(pos.below()))) { +- level.removeBlock(pos, false); ++ this.fireExtinguished(level, pos); // CraftBukkit + return; + } + } + + boolean isIncreasedFireBurnout = level.getBiome(pos).is(BiomeTags.INCREASED_FIRE_BURNOUT); + int i = isIncreasedFireBurnout ? -50 : 0; +- this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue); +- this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue); +- this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue); ++ // CraftBukkit start - add source blockPos to burn calls ++ this.checkBurnOut(level, pos.east(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.west(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.below(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.above(), 250 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.north(), 300 + i, random, ageValue, pos); ++ this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); ++ // CraftBukkit end + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + + for (int i1 = -1; i1 <= 1; i1++) { +@@ -205,7 +_,15 @@ + + if (i5 > 0 && random.nextInt(i4) <= i5 && (!level.isRaining() || !this.isNearRain(level, mutableBlockPos))) { + int min1 = Math.min(15, ageValue + random.nextInt(5) / 4); +- level.setBlock(mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); ++ // CraftBukkit start - Call to stop spread of fire ++ if (!level.getBlockState(mutableBlockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, mutableBlockPos, pos).isCancelled()) { ++ continue; ++ } + -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); // CraftBukkit -+ } -+ // CraftBukkit end ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, mutableBlockPos, this.getStateWithAge(level, mutableBlockPos, min1), 3); // CraftBukkit ++ } ++ // CraftBukkit end + } } } - } -@@ -256,19 +_,42 @@ +@@ -237,19 +_,40 @@ : this.igniteOdds.getInt(state.getBlock()); } - private void checkBurnOut(Level level, BlockPos pos, int chance, RandomSource random, int age) { -+ private void checkBurnOut(Level level, BlockPos pos, int chance, RandomSource random, int age, BlockPos sourceposition) { // CraftBukkit add sourceposition ++ private void checkBurnOut(Level level, BlockPos pos, int chance, RandomSource random, int age, BlockPos sourcePos) { // CraftBukkit add sourcePos int burnOdds = this.getBurnOdds(level.getBlockState(pos)); if (random.nextInt(chance) < burnOdds) { BlockState blockState = level.getBlockState(pos); + + // CraftBukkit start -+ org.bukkit.block.Block theBlock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); -+ org.bukkit.block.Block sourceBlock = level.getWorld().getBlockAt(sourceposition.getX(), sourceposition.getY(), sourceposition.getZ()); ++ org.bukkit.block.Block burnBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ org.bukkit.block.Block sourceBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, sourcePos); + -+ org.bukkit.event.block.BlockBurnEvent event = new org.bukkit.event.block.BlockBurnEvent(theBlock, sourceBlock); -+ level.getCraftServer().getPluginManager().callEvent(event); -+ -+ if (event.isCancelled()) { ++ org.bukkit.event.block.BlockBurnEvent event = new org.bukkit.event.block.BlockBurnEvent(burnBlock, sourceBlock); ++ if (!event.callEvent()) { + return; + } + -+ if (blockState.getBlock() instanceof TntBlock && !org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.FIRE, null, sourceposition)) { ++ if (blockState.getBlock() instanceof TntBlock && !org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.FIRE, null, sourcePos)) { + return; + } + // CraftBukkit end @@ -136,10 +135,10 @@ + } + level.removeBlock(pos, false); + // Paper end - TNTPrimeEvent - TntBlock.explode(level, pos); + TntBlock.prime(level, pos); } } -@@ -310,13 +_,14 @@ +@@ -291,13 +_,14 @@ } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch index 26f504f93..b5078a5bc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FlowerPotBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/FlowerPotBlock.java +++ b/net/minecraft/world/level/block/FlowerPotBlock.java -@@ -67,6 +_,18 @@ +@@ -66,6 +_,18 @@ } else if (!this.isEmpty()) { return InteractionResult.CONSUME; } else { @@ -19,7 +19,7 @@ level.setBlock(pos, blockState, 3); level.gameEvent(player, GameEvent.BLOCK_CHANGE, pos); player.awardStat(Stats.POT_FLOWER); -@@ -81,6 +_,18 @@ +@@ -80,6 +_,18 @@ return InteractionResult.CONSUME; } else { ItemStack itemStack = new ItemStack(this.potted); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch index 961a62ea3..d2799f0da 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/FrogspawnBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/FrogspawnBlock.java +++ b/net/minecraft/world/level/block/FrogspawnBlock.java -@@ -89,6 +_,7 @@ +@@ -90,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (entity.getType().equals(EntityType.FALLING_BLOCK)) { this.destroyBlock(level, pos); } -@@ -101,6 +_,11 @@ +@@ -102,6 +_,11 @@ } private void hatchFrogspawn(ServerLevel level, BlockPos pos, RandomSource random) { @@ -20,9 +20,9 @@ this.destroyBlock(level, pos); level.playSound(null, pos, SoundEvents.FROGSPAWN_HATCH, SoundSource.BLOCKS, 1.0F, 1.0F); this.spawnTadpoles(level, pos, random); -@@ -121,7 +_,7 @@ +@@ -122,7 +_,7 @@ int randomInt1 = random.nextInt(1, 361); - tadpole.moveTo(d, pos.getY() - 0.5, d1, randomInt1, 0.0F); + tadpole.snapTo(d, pos.getY() - 0.5, d1, randomInt1, 0.0F); tadpole.setPersistenceRequired(); - level.addFreshEntity(tadpole); + level.addFreshEntity(tadpole, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper - use correct spawn reason diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/GrindstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/GrindstoneBlock.java.patch index f242c126d..d1608589c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/GrindstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/GrindstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/GrindstoneBlock.java +++ b/net/minecraft/world/level/block/GrindstoneBlock.java -@@ -151,8 +_,7 @@ +@@ -72,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch index 997e408b2..49bad6cad 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/GrowingPlantHeadBlock.java.patch @@ -21,7 +21,7 @@ BlockPos blockPos = pos.relative(this.growthDirection); if (this.canGrowInto(level.getBlockState(blockPos))) { - level.setBlockAndUpdate(blockPos, this.getGrowIntoState(state, level.random)); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, this.getGrowIntoState(state, level.random, level)); // CraftBukkit // Paper - Fix Spigot growth modifiers ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, this.getGrowIntoState(state, level.random, level), 3); // CraftBukkit // Paper - Fix Spigot growth modifiers } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch index 36a0794c0..08a76f074 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HoneyBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/HoneyBlock.java +++ b/net/minecraft/world/level/block/HoneyBlock.java -@@ -60,6 +_,7 @@ +@@ -61,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (this.isSlidingDown(pos, entity)) { this.maybeDoSlideAchievement(entity, pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch index b33d6bde7..4c4b365bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HopperBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -125,8 +_,7 @@ +@@ -106,8 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { @@ -10,10 +10,10 @@ player.awardStat(Stats.INSPECT_HOPPER); } -@@ -178,6 +_,7 @@ +@@ -158,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent BlockEntity blockEntity = level.getBlockEntity(pos); if (blockEntity instanceof HopperBlockEntity) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/HugeMushroomBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/HugeMushroomBlock.java.patch index 9a4c3e64c..7a241a1e9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/HugeMushroomBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/HugeMushroomBlock.java.patch @@ -14,7 +14,7 @@ ) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableMushroomBlockUpdates) return state; // Paper - add option to disable block updates return neighborState.is(this) - ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), Boolean.valueOf(false)) + ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), false) : super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); @@ -74,6 +_,7 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch index 23815e6bf..54834bd83 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/InfestedBlock.java.patch @@ -3,7 +3,7 @@ @@ -52,7 +_,7 @@ Silverfish silverfish = EntityType.SILVERFISH.create(level, EntitySpawnReason.TRIGGERED); if (silverfish != null) { - silverfish.moveTo(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0.0F, 0.0F); + silverfish.snapTo(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0.0F, 0.0F); - level.addFreshEntity(silverfish); + level.addFreshEntity(silverfish, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason silverfish.spawnAnim(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LavaCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LavaCauldronBlock.java.patch index 4c96395fd..4b532f0d3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LavaCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LavaCauldronBlock.java.patch @@ -1,10 +1,15 @@ --- a/net/minecraft/world/level/block/LavaCauldronBlock.java +++ b/net/minecraft/world/level/block/LavaCauldronBlock.java -@@ -32,6 +_,7 @@ +@@ -33,9 +_,10 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (this.isEntityInsideContent(state, pos, entity)) { - entity.lavaHurt(); +- entity.lavaIgnite(); +- entity.lavaHurt(); ++ entity.lavaIgnite(pos); // Paper - track lava contact ++ entity.lavaHurt(pos); // Paper - track lava contact } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch index 6d49c999f..c0a3c2eb1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LayeredCauldronBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/LayeredCauldronBlock.java +++ b/net/minecraft/world/level/block/LayeredCauldronBlock.java -@@ -61,35 +_,68 @@ +@@ -62,35 +_,67 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (level instanceof ServerLevel serverLevel && entity.isOnFire() && this.isEntityInsideContent(state, pos, entity)) { - entity.clearFire(); @@ -22,32 +22,29 @@ - private void handleEntityOnFireInside(BlockState state, Level level, BlockPos pos) { + // CraftBukkit start -+ private boolean handleEntityOnFireInside(BlockState state, Level level, BlockPos pos, Entity entity) { ++ private boolean handleEntityOnFireInside(BlockState state, Level level, BlockPos pos, @javax.annotation.Nullable Entity entity) { if (this.precipitationType == Biome.Precipitation.SNOW) { - lowerFillLevel(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LEVEL, state.getValue(LEVEL)), level, pos); -+ return LayeredCauldronBlock.lowerFillLevel((BlockState) Blocks.WATER_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, (Integer) state.getValue(LayeredCauldronBlock.LEVEL)), level, pos, entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); // CraftBukkit ++ return lowerFillLevel(Blocks.WATER_CAULDRON.defaultBlockState().setValue(LEVEL, state.getValue(LEVEL)), level, pos, entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); // CraftBukkit } else { - lowerFillLevel(state, level, pos); -+ return LayeredCauldronBlock.lowerFillLevel(state, level, pos, entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); // CraftBukkit ++ return lowerFillLevel(state, level, pos, entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.EXTINGUISH); // CraftBukkit } } public static void lowerFillLevel(BlockState state, Level level, BlockPos pos) { -- int i = state.getValue(LEVEL) - 1; -- BlockState blockState = i == 0 ? Blocks.CAULDRON.defaultBlockState() : state.setValue(LEVEL, Integer.valueOf(i)); ++ // Paper start ++ lowerFillLevel(state, level, pos, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.UNKNOWN); ++ } ++ public static boolean lowerFillLevel(BlockState state, Level level, BlockPos pos, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { ++ // Paper end + int i = state.getValue(LEVEL) - 1; + BlockState blockState = i == 0 ? Blocks.CAULDRON.defaultBlockState() : state.setValue(LEVEL, i); - level.setBlockAndUpdate(pos, blockState); - level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); - } -+ // CraftBukkit start -+ LayeredCauldronBlock.lowerFillLevel(state, level, pos, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.UNKNOWN); ++ return changeLevel(level, pos, blockState, entity, reason); // Paper + } -+ public static boolean lowerFillLevel(BlockState state, Level level, BlockPos pos, Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { -+ int i = (Integer) state.getValue(LayeredCauldronBlock.LEVEL) - 1; -+ BlockState iblockdata1 = i == 0 ? Blocks.CAULDRON.defaultBlockState() : (BlockState) state.setValue(LayeredCauldronBlock.LEVEL, i); -+ -+ return LayeredCauldronBlock.changeLevel(level, pos, iblockdata1, entity, reason); -+ } -+ + // CraftBukkit start + // Paper start - Call CauldronLevelChangeEvent + public static boolean changeLevel(Level level, BlockPos pos, BlockState newBlock, @javax.annotation.Nullable Entity entity, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason reason) { // Paper - entity is nullable @@ -66,7 +63,7 @@ + if (!event.callEvent()) { + return false; + } -+ newState.update(true); ++ newState.place(3); + if (sendGameEvent) level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(newBlock)); // Paper - Call CauldronLevelChangeEvent + return true; + } @@ -78,18 +75,18 @@ BlockState blockState = state.cycle(LEVEL); - level.setBlockAndUpdate(pos, blockState); - level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); -+ LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit ++ changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL); // CraftBukkit } } -@@ -107,8 +_,11 @@ +@@ -108,8 +_,11 @@ protected void receiveStalactiteDrip(BlockState state, Level level, BlockPos pos, Fluid fluid) { if (!this.isFull(state)) { - BlockState blockState = state.setValue(LEVEL, Integer.valueOf(state.getValue(LEVEL) + 1)); + BlockState blockState = state.setValue(LEVEL, state.getValue(LEVEL) + 1); - level.setBlockAndUpdate(pos, blockState); - level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); + // CraftBukkit start -+ if (!LayeredCauldronBlock.changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { ++ if (!changeLevel(level, pos, blockState, null, org.bukkit.event.block.CauldronLevelChangeEvent.ChangeReason.NATURAL_FILL)) { + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch index b186e8813..24d95a362 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeavesBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/LeavesBlock.java +++ b/net/minecraft/world/level/block/LeavesBlock.java -@@ -63,6 +_,14 @@ +@@ -56,6 +_,14 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (this.decaying(state)) { + // CraftBukkit start -+ org.bukkit.event.block.LeavesDecayEvent event = new org.bukkit.event.block.LeavesDecayEvent(level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ org.bukkit.event.block.LeavesDecayEvent event = new org.bukkit.event.block.LeavesDecayEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled() || level.getBlockState(pos).getBlock() != this) { ++ if (event.isCancelled() || !level.getBlockState(pos).is(this)) { + return; + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch index fffc21a6f..7d195bf64 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LecternBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LecternBlock.java +++ b/net/minecraft/world/level/block/LecternBlock.java -@@ -169,7 +_,24 @@ +@@ -136,7 +_,24 @@ private static void placeBook(@Nullable LivingEntity entity, Level level, BlockPos pos, BlockState state, ItemStack stack) { if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity) { @@ -26,7 +26,7 @@ resetBookState(entity, level, pos, state, true); level.playSound(null, pos, SoundEvents.BOOK_PUT, SoundSource.BLOCKS, 1.0F, 1.0F); } -@@ -189,6 +_,16 @@ +@@ -156,6 +_,16 @@ } private static void changePowered(Level level, BlockPos pos, BlockState state, boolean powered) { @@ -40,22 +40,10 @@ + } + } + // Paper end - Call BlockRedstoneEvent properly - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(powered)), 3); + level.setBlock(pos, state.setValue(POWERED, powered), 3); updateBelow(level, pos, state); } -@@ -218,9 +_,10 @@ - } - - private void popBook(BlockState state, Level level, BlockPos pos) { -- if (level.getBlockEntity(pos) instanceof LecternBlockEntity lecternBlockEntity) { -+ if (level.getBlockEntity(pos, false) instanceof LecternBlockEntity lecternBlockEntity) { // CraftBukkit - don't validate, type may be changed already - Direction direction = state.getValue(FACING); - ItemStack itemStack = lecternBlockEntity.getBook().copy(); -+ if (itemStack.isEmpty()) return; // CraftBukkit - SPIGOT-5500 - float f = 0.25F * direction.getStepX(); - float f1 = 0.25F * direction.getStepZ(); - ItemEntity itemEntity = new ItemEntity(level, pos.getX() + 0.5 + f, pos.getY() + 1, pos.getZ() + 0.5 + f1, itemStack); -@@ -296,8 +_,7 @@ +@@ -243,8 +_,7 @@ private void openScreen(Level level, BlockPos pos, Player player) { BlockEntity blockEntity = level.getBlockEntity(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch index 98f131c9d..89c9166ec 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LeverBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/LeverBlock.java +++ b/net/minecraft/world/level/block/LeverBlock.java -@@ -100,6 +_,19 @@ +@@ -68,6 +_,19 @@ makeParticle(blockState, level, pos, 1.0F); } } else { + // CraftBukkit start - Interact Lever + boolean powered = state.getValue(LeverBlock.POWERED); // Old powered state -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + int old = (powered) ? 15 : 0; + int current = (!powered) ? 15 : 0; + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch index 7480d6343..b61914b8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LightningRodBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/LightningRodBlock.java +++ b/net/minecraft/world/level/block/LightningRodBlock.java -@@ -84,6 +_,18 @@ +@@ -82,6 +_,18 @@ } public void onLightningStrike(BlockState state, Level level, BlockPos pos) { @@ -16,6 +16,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 3); + level.setBlock(pos, state.setValue(POWERED, true), 3); this.updateNeighbours(state, level, pos); level.scheduleTick(pos, this, 8); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch index 4450068d1..8a5dcc088 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/LiquidBlock.java.patch @@ -48,7 +48,7 @@ - level.setBlockAndUpdate(pos, block.defaultBlockState()); - this.fizz(level, pos); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState())) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) { + this.fizz(level, pos); + } + // CraftBukkit end @@ -59,7 +59,7 @@ - level.setBlockAndUpdate(pos, Blocks.BASALT.defaultBlockState()); - this.fizz(level, pos); + // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, Blocks.BASALT.defaultBlockState())) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, Blocks.BASALT.defaultBlockState(), 3)) { + this.fizz(level, pos); + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch index 0ebbe0b61..5bb146741 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MangrovePropaguleBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/MangrovePropaguleBlock.java +++ b/net/minecraft/world/level/block/MangrovePropaguleBlock.java -@@ -123,7 +_,7 @@ +@@ -103,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!isHanging(state)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch index 20085ae07..804fee522 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MultifaceSpreader.java.patch @@ -5,7 +5,7 @@ } - return level.setBlock(pos.pos(), stateForPlacement, 2); -+ return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos.source(), pos.pos(), stateForPlacement, 2); // CraftBukkit ++ return org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos.source(), pos.pos(), stateForPlacement, 2, true); // CraftBukkit } else { return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch index 188da77ae..70703637a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/MushroomBlock.java.patch @@ -1,15 +1,15 @@ --- a/net/minecraft/world/level/block/MushroomBlock.java +++ b/net/minecraft/world/level/block/MushroomBlock.java -@@ -47,7 +_,7 @@ +@@ -46,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (random.nextInt(25) == 0) { -+ if (random.nextFloat() < (level.spigotConfig.mushroomModifier / (100.0f * 25))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < (level.spigotConfig.mushroomModifier / (100.0F * 25))) { // Spigot - SPIGOT-7159: Better modifier resolution int i = 5; int i1 = 4; -@@ -60,6 +_,7 @@ +@@ -59,6 +_,7 @@ } BlockPos blockPos1 = pos.offset(random.nextInt(3) - 1, random.nextInt(2) - random.nextInt(2), random.nextInt(3) - 1); @@ -17,7 +17,7 @@ for (int i2 = 0; i2 < 4; i2++) { if (level.isEmptyBlock(blockPos1) && state.canSurvive(level, blockPos1)) { -@@ -70,7 +_,7 @@ +@@ -69,7 +_,7 @@ } if (level.isEmptyBlock(blockPos1) && state.canSurvive(level, blockPos1)) { @@ -26,7 +26,7 @@ } } } -@@ -93,6 +_,7 @@ +@@ -92,6 +_,7 @@ return false; } else { level.removeBlock(pos, false); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch index fa161299c..34ec03d1f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherPortalBlock.java.patch @@ -7,9 +7,9 @@ - if (level.dimensionType().natural() + if (level.spigotConfig.enableZombiePigmenPortalSpawns && level.dimensionType().natural() // Spigot && level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) - && random.nextInt(2000) < level.getDifficulty().getId()) { - while (level.getBlockState(pos).is(this)) { -@@ -78,9 +_,13 @@ + && random.nextInt(2000) < level.getDifficulty().getId() + && level.anyPlayerCloseEnoughForSpawning(pos)) { +@@ -79,9 +_,13 @@ } if (level.getBlockState(pos).isValidSpawn(level, pos, EntityType.ZOMBIFIED_PIGLIN)) { @@ -24,21 +24,21 @@ Entity vehicle = entity.getVehicle(); if (vehicle != null) { vehicle.setPortalCooldown(); -@@ -111,7 +_,13 @@ +@@ -112,7 +_,13 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (entity.canUsePortal(false)) { + // CraftBukkit start - Entity in portal -+ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(level.getWorld(), pos.getX(), pos.getY(), pos.getZ()), org.bukkit.PortalType.NETHER); // Paper - add portal type ++ org.bukkit.event.entity.EntityPortalEnterEvent event = new org.bukkit.event.entity.EntityPortalEnterEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level), org.bukkit.PortalType.NETHER); // Paper - add portal type + level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) return; // Paper - make cancellable + // CraftBukkit end entity.setAsInsidePortal(this, pos); } } -@@ -134,22 +_,46 @@ +@@ -135,22 +_,46 @@ @Nullable @Override public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { @@ -90,7 +90,7 @@ BlockUtil.FoundRectangle largestRectangleAround; TeleportTransition.PostTeleportTransition postTeleportTransition; if (optional.isPresent()) { -@@ -164,17 +_,22 @@ +@@ -165,17 +_,22 @@ blockPos1 -> level.getBlockState(blockPos1) == blockState ); postTeleportTransition = TeleportTransition.PLAY_PORTAL_SOUND.then(entity1 -> entity1.placePortalTicket(blockPos)); @@ -116,7 +116,7 @@ return getDimensionTransitionFromExit(entity, pos, largestRectangleAround, level, postTeleportTransition); } -@@ -220,7 +_,7 @@ +@@ -221,7 +_,7 @@ boolean flag = axis1 == Direction.Axis.X; Vec3 vec3 = new Vec3(blockPos.getX() + (flag ? d2 : d4), blockPos.getY() + d3, blockPos.getZ() + (flag ? d4 : d2)); Vec3 vec31 = PortalShape.findCollisionFreePosition(vec3, level, entity, dimensions); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch index d55e5647c..4432a6956 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NetherWartBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/NetherWartBlock.java +++ b/net/minecraft/world/level/block/NetherWartBlock.java -@@ -55,9 +_,9 @@ +@@ -50,9 +_,9 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { int ageValue = state.getValue(AGE); - if (ageValue < 3 && random.nextInt(10) == 0) { -+ if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.wartModifier / (100.0f * 10))) { // Spigot - SPIGOT-7159: Better modifier resolution - state = state.setValue(AGE, Integer.valueOf(ageValue + 1)); ++ if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.wartModifier / (100.0F * 10))) { // Spigot - SPIGOT-7159: Better modifier resolution + state = state.setValue(AGE, ageValue + 1); - level.setBlock(pos, state, 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch index 76965a2ac..823e5dba3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/NoteBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/NoteBlock.java +++ b/net/minecraft/world/level/block/NoteBlock.java -@@ -70,6 +_,7 @@ +@@ -64,6 +_,7 @@ @Override public BlockState getStateForPlacement(BlockPlaceContext context) { @@ -8,7 +8,7 @@ return this.setInstrument(context.getLevel(), context.getClickedPos(), this.defaultBlockState()); } -@@ -84,6 +_,7 @@ +@@ -78,6 +_,7 @@ BlockState neighborState, RandomSource random ) { @@ -16,7 +16,7 @@ boolean flag = direction.getAxis() == Direction.Axis.Y; return flag ? this.setInstrument(level, pos, state) -@@ -92,10 +_,12 @@ +@@ -86,10 +_,12 @@ @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { @@ -28,8 +28,8 @@ + state = level.getBlockState(pos); // CraftBukkit - SPIGOT-5617: update in case changed in event } - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(hasNeighborSignal)), 3); -@@ -121,7 +_,7 @@ + level.setBlock(pos, state.setValue(POWERED, hasNeighborSignal), 3); +@@ -115,7 +_,7 @@ @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (!level.isClientSide) { @@ -38,7 +38,7 @@ level.setBlock(pos, state, 3); this.playNote(player, state, level, pos); player.awardStat(Stats.TUNE_NOTEBLOCK); -@@ -145,9 +_,13 @@ +@@ -139,9 +_,13 @@ @Override protected boolean triggerEvent(BlockState state, Level level, BlockPos pos, int id, int param) { NoteBlockInstrument noteBlockInstrument = state.getValue(INSTRUMENT); @@ -53,7 +53,7 @@ pitchFromNote = getPitchFromNote(noteValue); level.addParticle(ParticleTypes.NOTE, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, noteValue / 24.0, 0.0, 0.0); } else { -@@ -163,7 +_,7 @@ +@@ -157,7 +_,7 @@ holder = Holder.direct(SoundEvent.createVariableRangeEvent(customSoundId)); } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch index 12eb55330..9def2f110 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ObserverBlock.java.patch @@ -9,13 +9,13 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(false)), 2); + level.setBlock(pos, state.setValue(POWERED, false), 2); } else { + // CraftBukkit start + if (org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(level, pos, 0, 15).getNewCurrent() != 15) { + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(true)), 2); + level.setBlock(pos, state.setValue(POWERED, true), 2); level.scheduleTick(pos, this, 2); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch index 7015f932e..7f2cfba98 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PitcherCropBlock.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/PitcherCropBlock.java +++ b/net/minecraft/world/level/block/PitcherCropBlock.java -@@ -107,6 +_,7 @@ +@@ -118,6 +_,7 @@ @Override - public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (level instanceof ServerLevel serverLevel && entity instanceof Ravager && serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { serverLevel.destroyBlock(pos, true, entity); } -@@ -131,7 +_,7 @@ +@@ -140,7 +_,7 @@ @Override public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { float growthSpeed = CropBlock.getGrowthSpeed(this, level, pos); @@ -17,10 +17,10 @@ if (flag) { this.grow(level, state, pos, 1); } -@@ -141,7 +_,7 @@ +@@ -150,7 +_,7 @@ int min = Math.min(state.getValue(AGE) + ageIncrement, 4); if (this.canGrow(level, pos, state, min)) { - BlockState blockState = state.setValue(AGE, Integer.valueOf(min)); + BlockState blockState = state.setValue(AGE, min); - level.setBlock(pos, blockState, 2); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2)) return; // Paper if (isDouble(min)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch index 13c6c6845..bb7905752 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PointedDripstoneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java -@@ -147,6 +_,11 @@ +@@ -143,6 +_,11 @@ && projectile.mayBreak(serverLevel) && projectile instanceof ThrownTrident && projectile.getDeltaMovement().length() > 0.6) { @@ -12,21 +12,21 @@ level.destroyBlock(blockPos, true); } } -@@ -155,7 +_,7 @@ +@@ -151,7 +_,7 @@ @Override - public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, float fallDistance) { + public void fallOn(Level level, BlockState state, BlockPos pos, Entity entity, double fallDistance) { if (state.getValue(TIP_DIRECTION) == Direction.UP && state.getValue(THICKNESS) == DripstoneThickness.TIP) { -- entity.causeFallDamage(fallDistance + 2.0F, 2.0F, level.damageSources().stalagmite()); -+ entity.causeFallDamage(fallDistance + 2.0F, 2.0F, level.damageSources().stalagmite().eventBlockDamager(level, pos)); // CraftBukkit +- entity.causeFallDamage(fallDistance + 2.5, 2.0F, level.damageSources().stalagmite()); ++ entity.causeFallDamage(fallDistance + 2.5, 2.0F, level.damageSources().stalagmite().eventBlockDamager(level, pos)); // CraftBukkit } else { super.fallOn(level, state, pos, entity, fallDistance); } -@@ -213,10 +_,11 @@ +@@ -209,10 +_,11 @@ if (blockPos != null) { if (fluidAboveStalactite.get().sourceState.is(Blocks.MUD) && fluid == Fluids.WATER) { BlockState blockState = Blocks.CLAY.defaultBlockState(); - level.setBlockAndUpdate(fluidAboveStalactite.get().pos, blockState); -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, fluidAboveStalactite.get().pos, blockState)) { // Paper - Call BlockFormEvent ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, fluidAboveStalactite.get().pos, blockState, 3)) { // Paper - Call BlockFormEvent Block.pushEntitiesUp(fluidAboveStalactite.get().sourceState, blockState, level, fluidAboveStalactite.get().pos); level.gameEvent(GameEvent.BLOCK_CHANGE, fluidAboveStalactite.get().pos, GameEvent.Context.of(blockState)); level.levelEvent(1504, blockPos, 0); @@ -34,7 +34,7 @@ } else { BlockPos blockPos1 = findFillableCauldronBelowStalactiteTip(level, blockPos, fluid); if (blockPos1 != null) { -@@ -380,17 +_,17 @@ +@@ -364,17 +_,17 @@ if (isUnmergedTipWithDirection(blockState, direction.getOpposite())) { createMergedTips(blockState, server, blockPos); } else if (blockState.isAir() || blockState.is(Blocks.WATER)) { @@ -49,13 +49,13 @@ .defaultBlockState() .setValue(TIP_DIRECTION, direction) .setValue(THICKNESS, thickness) - .setValue(WATERLOGGED, Boolean.valueOf(level.getFluidState(pos).getType() == Fluids.WATER)); + .setValue(WATERLOGGED, level.getFluidState(pos).getType() == Fluids.WATER); - level.setBlock(pos, blockState, 3); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, pos, blockState, 3); // CraftBukkit } private static void createMergedTips(BlockState state, LevelAccessor level, BlockPos pos) { -@@ -404,8 +_,8 @@ +@@ -388,8 +_,8 @@ blockPos = pos.below(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch index 1254939fc..2fd9fda10 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/world/level/block/PowderSnowBlock.java +++ b/net/minecraft/world/level/block/PowderSnowBlock.java -@@ -58,6 +_,7 @@ +@@ -60,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!(entity instanceof LivingEntity) || entity.getInBlockState().is(this)) { entity.makeStuckInBlock(state, new Vec3(0.9F, 1.5, 0.9F)); if (level.isClientSide) { -@@ -80,8 +_,13 @@ - entity.setIsInPowderSnow(true); - if (level instanceof ServerLevel serverLevel) { - if (entity.isOnFire() -- && (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof Player) -+ // CraftBukkit - move down - && entity.mayInteract(serverLevel, pos)) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity instanceof Player))) { -+ return; -+ } -+ // CraftBukkit end - level.destroyBlock(pos, false); +@@ -85,8 +_,13 @@ + entity1 -> { + if (level instanceof ServerLevel serverLevel + && entity1.isOnFire() +- && (serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player) ++ // CraftBukkit - move down + && entity1.mayInteract(serverLevel, blockPos)) { ++ // CraftBukkit start ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity1, pos, Blocks.AIR.defaultBlockState(), !(serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || entity1 instanceof Player))) { ++ return; ++ } ++ // CraftBukkit end + level.destroyBlock(blockPos, false); + } } - diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch index 04777f56a..6662416ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PoweredRailBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/PoweredRailBlock.java +++ b/net/minecraft/world/level/block/PoweredRailBlock.java -@@ -133,6 +_,13 @@ +@@ -127,6 +_,13 @@ || this.findPoweredRailSignal(level, pos, state, true, 0) || this.findPoweredRailSignal(level, pos, state, false, 0); if (flag != poweredValue) { @@ -11,6 +11,6 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(POWERED, Boolean.valueOf(flag)), 3); + level.setBlock(pos, state.setValue(POWERED, flag), 3); level.updateNeighborsAt(pos.below(), this); if (state.getValue(SHAPE).isSlope()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/PressurePlateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/PressurePlateBlock.java.patch index a28da6fbd..d813220d2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/PressurePlateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/PressurePlateBlock.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/level/block/PressurePlateBlock.java +++ b/net/minecraft/world/level/block/PressurePlateBlock.java -@@ -5,6 +_,7 @@ - import net.minecraft.core.BlockPos; - import net.minecraft.world.entity.Entity; - import net.minecraft.world.entity.LivingEntity; -+import net.minecraft.world.entity.player.Player; - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.state.BlockBehaviour; - import net.minecraft.world.level.block.state.BlockState; -@@ -46,7 +_,31 @@ +@@ -46,7 +_,29 @@ case EVERYTHING -> Entity.class; case MOBS -> LivingEntity.class; }; @@ -16,15 +8,13 @@ + // CraftBukkit start - Call interact event when turning on a pressure plate + for (Entity entity : getEntities(level, PressurePlateBlock.TOUCH_AABB.move(pos), clazz)) { + if (this.getSignalForState(level.getBlockState(pos)) == 0) { -+ org.bukkit.World bworld = level.getWorld(); -+ org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); + org.bukkit.event.Cancellable cancellable; + -+ if (entity instanceof Player player) { ++ if (entity instanceof net.minecraft.world.entity.player.Player player) { + cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ())); -+ manager.callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); ++ level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + + // We only want to block turning the plate on if all events are cancelled diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch index c2c101fbf..91091f38c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedStoneOreBlock.java.patch @@ -20,7 +20,7 @@ + RedStoneOreBlock.interact(level.getBlockState(pos), level, pos, entity); // add entity + } + } else { -+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent(event); + if (!event.isCancelled()) { + RedStoneOreBlock.interact(level.getBlockState(pos), level, pos, entity); // add entity @@ -52,7 +52,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(true)), 3); + level.setBlock(pos, state.setValue(LIT, true), 3); } } @@ -80,6 +_,11 @@ @@ -64,7 +64,7 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(false)), 3); + level.setBlock(pos, state.setValue(LIT, false), 3); } } @@ -87,9 +_,17 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch index d8efa215b..d8b010cc3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RedstoneTorchBlock.java.patch @@ -30,8 +30,8 @@ + + // CraftBukkit start + org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); -+ org.bukkit.block.Block block = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); -+ int oldCurrent = ((Boolean) state.getValue(RedstoneTorchBlock.LIT)).booleanValue() ? 15 : 0; ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); ++ int oldCurrent = state.getValue(LIT) ? 15 : 0; + + org.bukkit.event.block.BlockRedstoneEvent event = new org.bukkit.event.block.BlockRedstoneEvent(block, oldCurrent, oldCurrent); + // CraftBukkit end @@ -46,7 +46,7 @@ + } + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(false)), 3); + level.setBlock(pos, state.setValue(LIT, false), 3); if (isToggledTooFrequently(level, pos, true)) { level.levelEvent(1502, pos, 0); @@ -87,6 +_,15 @@ @@ -62,7 +62,7 @@ + } + } + // CraftBukkit end - level.setBlock(pos, state.setValue(LIT, Boolean.valueOf(true)), 3); + level.setBlock(pos, state.setValue(LIT, true), 3); } } @@ -124,7 +_,12 @@ diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch index c66c883b7..e0d17a86d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RespawnAnchorBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/RespawnAnchorBlock.java +++ b/net/minecraft/world/level/block/RespawnAnchorBlock.java -@@ -102,11 +_,16 @@ - if (!level.isClientSide) { - ServerPlayer serverPlayer = (ServerPlayer)player; - if (serverPlayer.getRespawnDimension() != level.dimension() || !pos.equals(serverPlayer.getRespawnPosition())) { -- serverPlayer.setRespawnPosition(level.dimension(), pos, 0.0F, false, true); -+ if (serverPlayer.setRespawnPosition(level.dimension(), pos, 0.0F, false, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent +@@ -103,11 +_,16 @@ + ServerPlayer.RespawnConfig respawnConfig = serverPlayer.getRespawnConfig(); + ServerPlayer.RespawnConfig respawnConfig1 = new ServerPlayer.RespawnConfig(level.dimension(), pos, 0.0F, false); + if (respawnConfig == null || !respawnConfig.isSamePosition(respawnConfig1)) { +- serverPlayer.setRespawnPosition(respawnConfig1, true); ++ if (serverPlayer.setRespawnPosition(respawnConfig1, true, com.destroystokyo.paper.event.player.PlayerSetSpawnEvent.Cause.RESPAWN_ANCHOR)) { // Paper - Add PlayerSetSpawnEvent level.playSound( null, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, SoundEvents.RESPAWN_ANCHOR_SET_SPAWN, SoundSource.BLOCKS, 1.0F, 1.0F ); @@ -18,7 +18,7 @@ } } -@@ -140,6 +_,7 @@ +@@ -141,6 +_,7 @@ } private void explode(BlockState state, Level level, final BlockPos pos2) { @@ -26,7 +26,7 @@ level.removeBlock(pos2, false); boolean flag = Direction.Plane.HORIZONTAL.stream().map(pos2::relative).anyMatch(pos -> isWaterThatWouldFlow(pos, level)); final boolean flag1 = flag || level.getFluidState(pos2.above()).is(FluidTags.WATER); -@@ -153,7 +_,7 @@ +@@ -154,7 +_,7 @@ }; Vec3 center = pos2.getCenter(); level.explode( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/RootedDirtBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/RootedDirtBlock.java.patch index 6a3b2066a..7c7701108 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/RootedDirtBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/RootedDirtBlock.java.patch @@ -5,7 +5,7 @@ @Override public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { - level.setBlockAndUpdate(pos.below(), Blocks.HANGING_ROOTS.defaultBlockState()); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.below(), Blocks.HANGING_ROOTS.defaultBlockState()); // CraftBukkit ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, pos.below(), Blocks.HANGING_ROOTS.defaultBlockState(), 3); // CraftBukkit } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch index e165ace2f..be4f74802 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SaplingBlock.java.patch @@ -1,25 +1,25 @@ --- a/net/minecraft/world/level/block/SaplingBlock.java +++ b/net/minecraft/world/level/block/SaplingBlock.java -@@ -26,6 +_,7 @@ - protected static final float AABB_OFFSET = 6.0F; - protected static final VoxelShape SHAPE = Block.box(2.0, 0.0, 2.0, 14.0, 12.0, 14.0); +@@ -25,6 +_,7 @@ + public static final IntegerProperty STAGE = BlockStateProperties.STAGE; + private static final VoxelShape SHAPE = Block.column(12.0, 0.0, 12.0); protected final TreeGrower treeGrower; -+ public static org.bukkit.TreeType treeType; // CraftBukkit ++ public static @javax.annotation.Nullable org.bukkit.TreeType treeType; // CraftBukkit @Override public MapCodec codec() { -@@ -45,7 +_,7 @@ +@@ -44,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { - if (level.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextInt(7) == 0) { -+ if (level.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextFloat() < (level.spigotConfig.saplingModifier / (100.0f * 7))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (level.getMaxLocalRawBrightness(pos.above()) >= 9 && random.nextFloat() < (level.spigotConfig.saplingModifier / (100.0F * 7))) { // Spigot - SPIGOT-7159: Better modifier resolution this.advanceTree(level, pos, state, random); } } -@@ -54,7 +_,33 @@ +@@ -53,7 +_,34 @@ if (state.getValue(STAGE) == 0) { - level.setBlock(pos, state.cycle(STAGE), 4); + level.setBlock(pos, state.cycle(STAGE), 260); } else { - this.treeGrower.growTree(level, level.getChunkSource().getGenerator(), pos, state, random); + // CraftBukkit start @@ -42,8 +42,9 @@ + } + if (event == null || !event.isCancelled()) { + for (org.bukkit.block.BlockState blockstate : blocks) { -+ org.bukkit.craftbukkit.block.CapturedBlockState.setBlockState(blockstate); -+ level.checkCapturedTreeStateForObserverNotify(pos, (org.bukkit.craftbukkit.block.CraftBlockState) blockstate); // Paper - notify observers even if grow failed ++ org.bukkit.craftbukkit.block.CraftBlockState craftBlockState = (org.bukkit.craftbukkit.block.CraftBlockState) blockstate; ++ craftBlockState.place(craftBlockState.getFlags()); ++ level.checkCapturedTreeStateForObserverNotify(pos, craftBlockState); // Paper - notify observers even if grow failed + } + } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ScaffoldingBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ScaffoldingBlock.java.patch index fceeff2d2..ab3df7b7e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ScaffoldingBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ScaffoldingBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/ScaffoldingBlock.java +++ b/net/minecraft/world/level/block/ScaffoldingBlock.java -@@ -119,7 +_,7 @@ +@@ -117,7 +_,7 @@ protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { int distance = getDistance(level, pos); - BlockState blockState = state.setValue(DISTANCE, Integer.valueOf(distance)).setValue(BOTTOM, Boolean.valueOf(this.isBottom(level, pos, distance))); + BlockState blockState = state.setValue(DISTANCE, distance).setValue(BOTTOM, this.isBottom(level, pos, distance)); - if (blockState.getValue(DISTANCE) == 7) { + if (blockState.getValue(DISTANCE) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, blockState.getFluidState().createLegacyBlock()).isCancelled()) { // CraftBukkit - BlockFadeEvent // Paper - fix wrong block state if (state.getValue(DISTANCE) == 7) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch index 900eb7905..f251ca822 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSensorBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -108,6 +_,18 @@ +@@ -102,6 +_,18 @@ && level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensorBlockEntity && level instanceof ServerLevel serverLevel && sculkSensorBlockEntity.getVibrationUser().canReceiveVibration(serverLevel, pos, GameEvent.STEP, GameEvent.Context.of(state))) { @@ -9,7 +9,7 @@ + if (entity instanceof net.minecraft.world.entity.player.Player player) { + cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + if (cancellable.isCancelled()) { @@ -19,7 +19,7 @@ sculkSensorBlockEntity.getListener().forceScheduleVibration(serverLevel, GameEvent.STEP, GameEvent.Context.of(entity), entity.position()); } -@@ -200,10 +_,19 @@ +@@ -191,10 +_,19 @@ } public static boolean canActivate(BlockState state) { @@ -37,10 +37,10 @@ + return; + } + // CraftBukkit end - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, Integer.valueOf(0)), 3); + level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.COOLDOWN).setValue(POWER, 0), 3); level.scheduleTick(pos, state.getBlock(), 10); updateNeighbours(level, pos, state); -@@ -215,6 +_,15 @@ +@@ -206,6 +_,15 @@ } public void activate(@Nullable Entity entity, Level level, BlockPos pos, BlockState state, int power, int frequency) { @@ -53,10 +53,10 @@ + } + power = eventRedstone.getNewCurrent(); + // CraftBukkit end - level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, Integer.valueOf(power)), 3); + level.setBlock(pos, state.setValue(PHASE, SculkSensorPhase.ACTIVE).setValue(POWER, power), 3); level.scheduleTick(pos, state.getBlock(), this.getActiveTicks()); updateNeighbours(level, pos, state); -@@ -292,8 +_,16 @@ +@@ -283,8 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); @@ -69,9 +69,8 @@ - this.tryDropExperience(level, pos, stack, ConstantInt.of(5)); + return this.tryDropExperience(level, pos, stack, ConstantInt.of(5)); } -- } + + return 0; + // CraftBukkit end -+ } + } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch index ff23c12be..1c5547e45 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkShriekerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java -@@ -66,6 +_,7 @@ +@@ -60,6 +_,7 @@ if (level instanceof ServerLevel serverLevel) { ServerPlayer serverPlayer = SculkShriekerBlockEntity.tryGetPlayer(entity); if (serverPlayer != null) { @@ -8,7 +8,7 @@ serverLevel.getBlockEntity(pos, BlockEntityType.SCULK_SHRIEKER).ifPresent(sculkShrieker -> sculkShrieker.tryShriek(serverLevel, serverPlayer)); } } -@@ -144,9 +_,16 @@ +@@ -128,9 +_,16 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch index 1d958f6ac..06a57c671 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SculkSpreader.java.patch @@ -1,23 +1,23 @@ --- a/net/minecraft/world/level/block/SculkSpreader.java +++ b/net/minecraft/world/level/block/SculkSpreader.java -@@ -50,6 +_,7 @@ +@@ -45,6 +_,7 @@ + private final int chargeDecayRate; private final int additionalDecayRate; private List cursors = new ArrayList<>(); - private static final Logger LOGGER = LogUtils.getLogger(); + public net.minecraft.world.level.Level level; // CraftBukkit public SculkSpreader( boolean isWorldGeneration, TagKey replaceableBlocks, int growthSpawnCoat, int noGrowthRadius, int chargeDecayRate, int additionalDecayRate -@@ -114,7 +_,7 @@ - int min = Math.min(list.size(), 32); +@@ -100,7 +_,7 @@ - for (int i = 0; i < min; i++) { -- this.addCursor(list.get(i)); -+ this.addCursor(list.get(i), false); // Paper - don't fire event for block entity loading - } - } + public void load(CompoundTag tag) { + this.cursors.clear(); +- tag.read("cursors", SculkSpreader.ChargeCursor.CODEC.sizeLimitedListOf(32)).orElse(List.of()).forEach(this::addCursor); ++ tag.read("cursors", SculkSpreader.ChargeCursor.CODEC.sizeLimitedListOf(32)).orElse(List.of()).forEach((cursor) -> this.addCursor(cursor, false)); // Paper - don't fire event for block entity loading } -@@ -130,13 +_,24 @@ + + public void save(CompoundTag tag) { +@@ -110,13 +_,24 @@ public void addCursors(BlockPos pos, int charge) { while (charge > 0) { int min = Math.min(charge, 1000); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch index 148aaa4fd..15ba87e87 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/ShulkerBoxBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -100,8 +_,8 @@ +@@ -78,8 +_,8 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (level instanceof ServerLevel serverLevel && level.getBlockEntity(pos) instanceof ShulkerBoxBlockEntity shulkerBoxBlockEntity @@ -11,7 +11,7 @@ player.awardStat(Stats.OPEN_SHULKER_BOX); PiglinAi.angerNearbyPiglins(serverLevel, player, true); } -@@ -139,7 +_,7 @@ +@@ -117,7 +_,7 @@ itemEntity.setDefaultPickUpDelay(); level.addFreshEntity(itemEntity); } else { @@ -20,7 +20,7 @@ } } -@@ -149,7 +_,15 @@ +@@ -127,7 +_,15 @@ @Override protected List getDrops(BlockState state, LootParams.Builder params) { BlockEntity blockEntity = params.getOptionalParameter(LootContextParams.BLOCK_ENTITY); @@ -36,7 +36,7 @@ params = params.withDynamicDrop(CONTENTS, output -> { for (int i = 0; i < shulkerBoxBlockEntity.getContainerSize(); i++) { output.accept(shulkerBoxBlockEntity.getItem(i)); -@@ -157,7 +_,13 @@ +@@ -135,7 +_,13 @@ }); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch index 8029d51d2..0e34b8cc0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SignBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SignBlock.java +++ b/net/minecraft/world/level/block/SignBlock.java -@@ -134,7 +_,7 @@ +@@ -133,7 +_,7 @@ } else if (!this.otherPlayerIsEditingSign(player, signBlockEntity) && player.mayBuild() && this.hasEditableText(player, signBlockEntity, isFacingFrontText)) { @@ -9,15 +9,16 @@ return InteractionResult.SUCCESS_SERVER; } else { return InteractionResult.PASS; -@@ -176,7 +_,33 @@ +@@ -175,7 +_,34 @@ return woodType; } -+ @io.papermc.paper.annotation.DoNotUse @Deprecated // Paper - Add PlayerOpenSignEvent ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - Add PlayerOpenSignEvent public void openTextEdit(Player player, SignBlockEntity signEntity, boolean isFrontText) { + // Paper start - Add PlayerOpenSignEvent + this.openTextEdit(player, signEntity, isFrontText, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause.UNKNOWN); + } ++ + public void openTextEdit(Player player, SignBlockEntity signEntity, boolean isFrontText, io.papermc.paper.event.player.PlayerOpenSignEvent.Cause cause) { + org.bukkit.entity.Player bukkitPlayer = (org.bukkit.entity.Player) player.getBukkitEntity(); + org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(signEntity.getLevel(), signEntity.getBlockPos()); @@ -43,7 +44,7 @@ signEntity.setAllowedPlayerEditor(player.getUUID()); player.openTextEdit(signEntity, isFrontText); } -@@ -189,6 +_,6 @@ +@@ -188,6 +_,6 @@ @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch index dc26f22de..eb378047b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SnifferEggBlock.java.patch @@ -16,13 +16,13 @@ public void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!this.isReadyToHatch(state)) { + // Paper start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(HATCH, this.getHatchLevel(state) + 1), 2)) { + this.rescheduleTick(level, pos); + return; + } + // Paper end level.playSound(null, pos, SoundEvents.SNIFFER_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- level.setBlock(pos, state.setValue(HATCH, Integer.valueOf(this.getHatchLevel(state) + 1)), 2); +- level.setBlock(pos, state.setValue(HATCH, this.getHatchLevel(state) + 1), 2); } else { + // Paper start - Call BlockFadeEvent + if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(level, pos, state.getFluidState().createLegacyBlock()).isCancelled()) { @@ -36,7 +36,7 @@ @@ -74,7 +_,7 @@ Vec3 center = pos.getCenter(); sniffer.setBaby(true); - sniffer.moveTo(center.x(), center.y(), center.z(), Mth.wrapDegrees(level.random.nextFloat() * 360.0F), 0.0F); + sniffer.snapTo(center.x(), center.y(), center.z(), Mth.wrapDegrees(level.random.nextFloat() * 360.0F), 0.0F); - level.addFreshEntity(sniffer); + level.addFreshEntity(sniffer, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // Paper - use correct spawn reason } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SnowLayerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SnowLayerBlock.java.patch index 37be3cda9..c6cb4340d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SnowLayerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SnowLayerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SnowLayerBlock.java +++ b/net/minecraft/world/level/block/SnowLayerBlock.java -@@ -123,6 +_,11 @@ +@@ -103,6 +_,11 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (level.getBrightness(LightLayer.BLOCK, pos) > 11) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch index eebbd991a..d2ce10af2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpawnerBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SpawnerBlock.java +++ b/net/minecraft/world/level/block/SpawnerBlock.java -@@ -46,11 +_,19 @@ +@@ -41,9 +_,17 @@ @Override protected void spawnAfterBreak(BlockState state, ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { super.spawnAfterBreak(state, level, pos, stack, dropExperience); @@ -19,6 +19,4 @@ + return 0; + // CraftBukkit end + } - - @Override - public void appendHoverText(ItemStack stack, Item.TooltipContext context, List tooltipComponents, TooltipFlag tooltipFlag) { + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch index cba02b771..ade9ebb7b 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpongeBlock.java.patch @@ -56,17 +56,17 @@ - > 1; + ); + // CraftBukkit start -+ java.util.List blocks = blockList.getList(); // Is a clone -+ if (!blocks.isEmpty()) { ++ java.util.List snapshots = blockList.getSnapshotBlocks(); // Is a clone ++ if (!snapshots.isEmpty()) { + final org.bukkit.block.Block sponge = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + -+ org.bukkit.event.block.SpongeAbsorbEvent event = new org.bukkit.event.block.SpongeAbsorbEvent(sponge, (java.util.List) (java.util.List) blocks); ++ org.bukkit.event.block.SpongeAbsorbEvent event = new org.bukkit.event.block.SpongeAbsorbEvent(sponge, (java.util.List) (java.util.List) snapshots); + if (!event.callEvent()) { + return false; + } + -+ for (org.bukkit.craftbukkit.block.CraftBlockState block : blocks) { -+ BlockPos blockPos = block.getPosition(); ++ for (org.bukkit.craftbukkit.block.CraftBlockState snapshot : snapshots) { ++ BlockPos blockPos = snapshot.getPosition(); + BlockState state = level.getBlockState(blockPos); + FluidState fluid = level.getFluidState(blockPos); + @@ -79,13 +79,13 @@ + BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(blockPos) : null; + + // Paper start - Fix SpongeAbsortEvent handling -+ if (block.getHandle().isAir()) { ++ if (snapshot.getHandle().isAir()) { + dropResources(state, level, blockPos, blockEntity); + } + // Paper end - Fix SpongeAbsortEvent handling + } + } -+ level.setBlock(blockPos, block.getHandle(), block.getFlag()); ++ snapshot.place(snapshot.getFlags()); + } + + return true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch index 0e8433bda..7df3c13fc 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SpreadingSnowyDirtBlock.java.patch @@ -18,8 +18,8 @@ for (int i = 0; i < 4; i++) { BlockPos blockPos = pos.offset(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1); if (level.getBlockState(blockPos).is(Blocks.DIRT) && canPropagate(blockState, level, blockPos)) { -- level.setBlockAndUpdate(blockPos, blockState.setValue(SNOWY, Boolean.valueOf(isSnowySetting(level.getBlockState(blockPos.above()))))); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState.setValue(SNOWY, Boolean.valueOf(isSnowySetting(level.getBlockState(blockPos.above()))))); // CraftBukkit +- level.setBlockAndUpdate(blockPos, blockState.setValue(SNOWY, isSnowySetting(level.getBlockState(blockPos.above())))); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, pos, blockPos, blockState.setValue(SNOWY, isSnowySetting(level.getBlockState(blockPos.above()))), 3); // CraftBukkit } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch index 3e1e7cca5..aa85bf463 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/StemBlock.java.patch @@ -1,36 +1,36 @@ --- a/net/minecraft/world/level/block/StemBlock.java +++ b/net/minecraft/world/level/block/StemBlock.java -@@ -80,11 +_,11 @@ +@@ -70,11 +_,11 @@ protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (level.getRawBrightness(pos, 0) >= 9) { float growthSpeed = CropBlock.getGrowthSpeed(this, level, pos); - if (random.nextInt((int)(25.0F / growthSpeed) + 1) == 0) { -+ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? level.spigotConfig.pumpkinModifier : level.spigotConfig.melonModifier) / (100.0f * (Math.floor((25.0F / growthSpeed) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < ((this == Blocks.PUMPKIN_STEM ? level.spigotConfig.pumpkinModifier : level.spigotConfig.melonModifier) / (100.0F * (Math.floor((25.0F / growthSpeed) + 1))))) { // Spigot - SPIGOT-7159: Better modifier resolution int ageValue = state.getValue(AGE); if (ageValue < 7) { - state = state.setValue(AGE, Integer.valueOf(ageValue + 1)); + state = state.setValue(AGE, ageValue + 1); - level.setBlock(pos, state, 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state, 2); // CraftBukkit } else { Direction randomDirection = Direction.Plane.HORIZONTAL.getRandomDirection(random); BlockPos blockPos = pos.relative(randomDirection); -@@ -94,7 +_,11 @@ +@@ -84,7 +_,11 @@ Optional optional = registry.getOptional(this.fruit); Optional optional1 = registry.getOptional(this.attachedStem); if (optional.isPresent() && optional1.isPresent()) { - level.setBlockAndUpdate(blockPos, optional.get().defaultBlockState()); + // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, optional.get().defaultBlockState())) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, blockPos, optional.get().defaultBlockState(), 3)) { + return; + } + // CraftBukkit end level.setBlockAndUpdate(pos, optional1.get().defaultBlockState().setValue(HorizontalDirectionalBlock.FACING, randomDirection)); } } -@@ -122,7 +_,7 @@ +@@ -112,7 +_,7 @@ public void performBonemeal(ServerLevel level, RandomSource random, BlockPos pos, BlockState state) { int min = Math.min(7, state.getValue(AGE) + Mth.nextInt(level.random, 2, 5)); - BlockState blockState = state.setValue(AGE, Integer.valueOf(min)); + BlockState blockState = state.setValue(AGE, min); - level.setBlock(pos, blockState, 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2); // CraftBukkit if (min == 7) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch index 009e5542f..c9e65a7d7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SugarCaneBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/net/minecraft/world/level/block/SugarCaneBlock.java -@@ -56,12 +_,13 @@ +@@ -55,12 +_,13 @@ i++; } @@ -10,11 +10,11 @@ - if (ageValue == 15) { - level.setBlockAndUpdate(pos.above(), this.defaultBlockState()); + int modifier = level.spigotConfig.caneModifier; // Spigot - SPIGOT-7159: Better modifier resolution -+ if (ageValue >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos.above(), this.defaultBlockState()); // CraftBukkit - level.setBlock(pos, state.setValue(AGE, Integer.valueOf(0)), 4); ++ if (ageValue >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0F * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos.above(), this.defaultBlockState(), 3); // CraftBukkit + level.setBlock(pos, state.setValue(AGE, 0), 260); - } else { -+ } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution - level.setBlock(pos, state.setValue(AGE, Integer.valueOf(ageValue + 1)), 4); ++ } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0F * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution + level.setBlock(pos, state.setValue(AGE, ageValue + 1), 260); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch index ea6d6c6cc..d0aadf788 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/SweetBerryBushBlock.java.patch @@ -1,12 +1,12 @@ --- a/net/minecraft/world/level/block/SweetBerryBushBlock.java +++ b/net/minecraft/world/level/block/SweetBerryBushBlock.java -@@ -68,15 +_,16 @@ +@@ -70,15 +_,16 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { int ageValue = state.getValue(AGE); - if (ageValue < 3 && random.nextInt(5) == 0 && level.getRawBrightness(pos.above(), 0) >= 9) { -+ if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.sweetBerryModifier / (100.0f * 5)) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution - BlockState blockState = state.setValue(AGE, Integer.valueOf(ageValue + 1)); ++ if (ageValue < 3 && random.nextFloat() < (level.spigotConfig.sweetBerryModifier / (100.0F * 5)) && level.getRawBrightness(pos.above(), 0) >= 9) { // Spigot - SPIGOT-7159: Better modifier resolution + BlockState blockState = state.setValue(AGE, ageValue + 1); - level.setBlock(pos, blockState, 2); + if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, blockState, 2)) return; // CraftBukkit level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(blockState)); @@ -14,12 +14,12 @@ } @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (entity instanceof LivingEntity && entity.getType() != EntityType.FOX && entity.getType() != EntityType.BEE) { entity.makeStuckInBlock(state, new Vec3(0.8F, 0.75, 0.8F)); if (level instanceof ServerLevel serverLevel && state.getValue(AGE) != 0) { -@@ -85,7 +_,7 @@ +@@ -87,7 +_,7 @@ double abs = Math.abs(vec3.x()); double abs1 = Math.abs(vec3.z()); if (abs >= 0.003F || abs1 >= 0.003F) { @@ -28,7 +28,7 @@ } } } -@@ -109,7 +_,15 @@ +@@ -111,7 +_,15 @@ boolean flag = ageValue == 3; if (ageValue > 1) { int i = 1 + level.random.nextInt(2); @@ -43,5 +43,5 @@ + } + // CraftBukkit end level.playSound(null, pos, SoundEvents.SWEET_BERRY_BUSH_PICK_BERRIES, SoundSource.BLOCKS, 1.0F, 0.8F + level.random.nextFloat() * 0.4F); - BlockState blockState = state.setValue(AGE, Integer.valueOf(1)); + BlockState blockState = state.setValue(AGE, 1); level.setBlock(pos, blockState, 2); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch index b03b95ae3..fa7cf0c27 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TntBlock.java.patch @@ -1,91 +1,67 @@ --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java -@@ -45,7 +_,13 @@ +@@ -47,7 +_,7 @@ @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { if (!oldState.is(state.getBlock())) { -- if (level.hasNeighborSignal(pos)) { -+ if (level.hasNeighborSignal(pos) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { -+ return; -+ } -+ // Paper end - TNTPrimeEvent - explode(level, pos); +- if (level.hasNeighborSignal(pos) && prime(level, pos)) { ++ if (level.hasNeighborSignal(pos) && prime(level, pos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.REDSTONE, null, null))) { // CraftBukkit - TNTPrimeEvent level.removeBlock(pos, false); } -@@ -54,7 +_,13 @@ + } +@@ -55,7 +_,7 @@ @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { -- if (level.hasNeighborSignal(pos)) { -+ if (level.hasNeighborSignal(pos) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.REDSTONE, null, null)) { // CraftBukkit - TNTPrimeEvent -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.REDSTONE, null).callEvent()) { -+ return; -+ } -+ // Paper end - TNTPrimeEvent - explode(level, pos); +- if (level.hasNeighborSignal(pos) && prime(level, pos)) { ++ if (level.hasNeighborSignal(pos) && prime(level, pos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.REDSTONE, null, null))) { // CraftBukkit - TNTPrimeEvent level.removeBlock(pos, false); } -@@ -62,7 +_,7 @@ - + } +@@ -63,7 +_,7 @@ @Override public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) { -- if (!level.isClientSide() && !player.isCreative() && state.getValue(UNSTABLE)) { -+ if (!level.isClientSide() && !player.isCreative() && state.getValue(UNSTABLE) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.BLOCK_BREAK, player, null)) { // CraftBukkit - TNTPrimeEvent - explode(level, pos); + if (!level.isClientSide() && !player.getAbilities().instabuild && state.getValue(UNSTABLE)) { +- prime(level, pos); ++ prime(level, pos, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.BLOCK_BREAK, player, null)); // CraftBukkit - TNTPrimeEvent } -@@ -71,6 +_,13 @@ + return super.playerWillDestroy(level, pos, state, player); +@@ -80,11 +_,16 @@ + } - @Override - public void wasExploded(ServerLevel level, BlockPos pos, Explosion explosion) { -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ org.bukkit.entity.Entity source = explosion.getDirectSourceEntity() != null ? explosion.getDirectSourceEntity().getBukkitEntity() : null; -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.EXPLOSION, source).callEvent()) { -+ return; -+ } -+ // Paper end - TNTPrimeEvent - PrimedTnt primedTnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, explosion.getIndirectSourceEntity()); - int fuse = primedTnt.getFuse(); - primedTnt.setFuse((short)(level.random.nextInt(fuse / 4) + fuse / 8)); -@@ -97,6 +_,17 @@ + public static boolean prime(Level level, BlockPos pos) { +- return prime(level, pos, null); ++ // Paper start ++ return prime(level, pos, null, () -> true); ++ } ++ public static boolean prime(Level level, BlockPos pos, java.util.function.BooleanSupplier event) { ++ return prime(level, pos, null, event); ++ // Paper end + } + +- private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity) { +- if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES)) { ++ private static boolean prime(Level level, BlockPos pos, @Nullable LivingEntity entity, java.util.function.BooleanSupplier event) { // Paper ++ if (level instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_TNT_EXPLODES) && event.getAsBoolean()) { // Paper + PrimedTnt primedTnt = new PrimedTnt(level, pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, entity); + level.addFreshEntity(primedTnt); + level.playSound(null, primedTnt.getX(), primedTnt.getY(), primedTnt.getZ(), SoundEvents.TNT_PRIMED, SoundSource.BLOCKS, 1.0F, 1.0F); +@@ -102,7 +_,7 @@ if (!stack.is(Items.FLINT_AND_STEEL) && !stack.is(Items.FIRE_CHARGE)) { return super.useItemOn(stack, state, level, pos, player, hand, hitResult); } else { -+ // CraftBukkit start - TNTPrimeEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PLAYER, player, null)) { -+ return InteractionResult.CONSUME; -+ } -+ // CraftBukkit end -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.ITEM, player.getBukkitEntity()).callEvent()) { -+ return InteractionResult.FAIL; -+ } -+ // Paper end - TNTPrimeEvent - explode(level, pos, player); - level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11); - Item item = stack.getItem(); -@@ -117,6 +_,17 @@ - BlockPos blockPos = hit.getBlockPos(); +- if (prime(level, pos, player)) { ++ if (prime(level, pos, player, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, pos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PLAYER, player, null))) { // Paper + level.setBlock(pos, Blocks.AIR.defaultBlockState(), 11); + Item item = stack.getItem(); + if (stack.is(Items.FLINT_AND_STEEL)) { +@@ -128,7 +_,7 @@ Entity owner = projectile.getOwner(); - if (projectile.isOnFire() && projectile.mayInteract(serverLevel, blockPos)) { -+ // CraftBukkit start -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockPos, state.getFluidState().createLegacyBlock()) || !org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PROJECTILE, projectile, null)) { // Paper - fix wrong block state -+ return; -+ } -+ // CraftBukkit end -+ // Paper start - TNTPrimeEvent -+ org.bukkit.block.Block tntBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPos); -+ if (!new com.destroystokyo.paper.event.block.TNTPrimeEvent(tntBlock, com.destroystokyo.paper.event.block.TNTPrimeEvent.PrimeReason.PROJECTILE, projectile.getBukkitEntity()).callEvent()) { -+ return; -+ } -+ // Paper end - TNTPrimeEvent - explode(level, blockPos, owner instanceof LivingEntity ? (LivingEntity)owner : null); + if (projectile.isOnFire() + && projectile.mayInteract(serverLevel, blockPos) +- && prime(level, blockPos, owner instanceof LivingEntity ? (LivingEntity)owner : null)) { ++ && prime(level, blockPos, owner instanceof LivingEntity ? (LivingEntity)owner : null, () -> org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(projectile, blockPos, state.getFluidState().createLegacyBlock()) && org.bukkit.craftbukkit.event.CraftEventFactory.callTNTPrimeEvent(level, blockPos, org.bukkit.event.block.TNTPrimeEvent.PrimeCause.PROJECTILE, projectile, null))) { // Paper level.removeBlock(blockPos, false); } + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch index dac679ac7..b194e5b0f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TrapDoorBlock.java.patch @@ -1,15 +1,12 @@ --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -146,7 +_,40 @@ +@@ -128,7 +_,37 @@ if (!level.isClientSide) { boolean hasNeighborSignal = level.hasNeighborSignal(pos); if (hasNeighborSignal != state.getValue(POWERED)) { - if (state.getValue(OPEN) != hasNeighborSignal) { -+ // if (state.getValue(OPEN) != hasNeighborSignal) { + // CraftBukkit start -+ org.bukkit.World bworld = level.getWorld(); -+ org.bukkit.block.Block bblock = bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()); -+ ++ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + int power = bblock.getBlockPower(); + int oldPower = state.getValue(TrapDoorBlock.OPEN) ? 15 : 0; + @@ -21,7 +18,7 @@ + // CraftBukkit end + // Paper start - break redstone on trapdoors early + boolean open = state.getValue(TrapDoorBlock.OPEN) != hasNeighborSignal; -+ // note: this must run before any state for this block/its neighborus are written to the world ++ // note: this must run before any state for this block/its neighbours are written to the world + // we allow the redstone event to fire so that plugins can block + if (hasNeighborSignal && open) { // if we are now powered and it caused the trap door to open + // in this case, first check for the redstone on top first @@ -38,7 +35,7 @@ + } + } + if (open) { -+ // Paper end - break redstone on trapdoors early - state = state.setValue(OPEN, Boolean.valueOf(hasNeighborSignal)); ++ // Paper end - break redstone on trapdoors early + state = state.setValue(OPEN, hasNeighborSignal); this.playSound(null, level, pos, hasNeighborSignal); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch index 72fa2da03..747d8522e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java -@@ -72,6 +_,7 @@ +@@ -73,6 +_,7 @@ @Override public BlockState getStateForPlacement(BlockPlaceContext context) { @@ -8,15 +8,15 @@ BlockGetter level = context.getLevel(); BlockPos clickedPos = context.getClickedPos(); return this.defaultBlockState() -@@ -92,6 +_,7 @@ +@@ -93,6 +_,7 @@ BlockState neighborState, RandomSource random ) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // Paper - prevent tripwire from updating return direction.getAxis().isHorizontal() - ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), Boolean.valueOf(this.shouldConnectTo(neighborState, direction))) + ? state.setValue(PROPERTY_BY_DIRECTION.get(direction), this.shouldConnectTo(neighborState, direction)) : super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); -@@ -99,6 +_,7 @@ +@@ -100,6 +_,7 @@ @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean isMoving) { @@ -24,23 +24,23 @@ if (!oldState.is(state.getBlock())) { this.updateSource(level, pos, state); } -@@ -106,6 +_,7 @@ +@@ -107,6 +_,7 @@ @Override - protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) { + protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating - if (!isMoving && !state.is(newState.getBlock())) { - this.updateSource(level, pos, state.setValue(POWERED, Boolean.valueOf(true))); + if (!movedByPiston) { + this.updateSource(level, pos, state.setValue(POWERED, true)); } -@@ -113,6 +_,7 @@ +@@ -114,6 +_,7 @@ @Override public BlockState playerWillDestroy(Level level, BlockPos pos, BlockState state, Player player) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return state; // Paper - prevent disarming tripwires if (!level.isClientSide && !player.getMainHandItem().isEmpty() && player.getMainHandItem().is(Items.SHEARS)) { - level.setBlock(pos, state.setValue(DISARMED, Boolean.valueOf(true)), 4); + level.setBlock(pos, state.setValue(DISARMED, true), 260); level.gameEvent(player, GameEvent.SHEAR, pos); -@@ -122,6 +_,7 @@ +@@ -123,6 +_,7 @@ } private void updateSource(Level level, BlockPos pos, BlockState state) { @@ -48,16 +48,16 @@ for (Direction direction : new Direction[]{Direction.SOUTH, Direction.WEST}) { for (int i = 1; i < 42; i++) { BlockPos blockPos = pos.relative(direction, i); -@@ -147,6 +_,8 @@ +@@ -148,6 +_,8 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent tripwires from detecting collision + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (!level.isClientSide) { if (!state.getValue(POWERED)) { this.checkPressed(level, pos, List.of(entity)); -@@ -156,6 +_,7 @@ +@@ -157,6 +_,7 @@ @Override protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { @@ -65,16 +65,15 @@ if (level.getBlockState(pos).getValue(POWERED)) { this.checkPressed(level, pos); } -@@ -179,6 +_,40 @@ +@@ -180,6 +_,39 @@ } } } + + // CraftBukkit start - Call interact even when triggering connected tripwire + if (poweredValue != flag && flag && blockState.getValue(TripWireBlock.ATTACHED)) { -+ org.bukkit.World bworld = level.getWorld(); + org.bukkit.plugin.PluginManager manager = level.getCraftServer().getPluginManager(); -+ org.bukkit.block.Block block = bworld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + boolean allowed = false; + + // If all the events are cancelled block the tripwire trigger, else allow @@ -105,4 +104,4 @@ + // CraftBukkit end if (flag != poweredValue) { - blockState = blockState.setValue(POWERED, Boolean.valueOf(flag)); + blockState = blockState.setValue(POWERED, flag); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch index 909de7ef6..89c2581d9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TripWireHookBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -127,10 +_,10 @@ +@@ -113,10 +_,10 @@ if (optionalValue.isPresent()) { Direction direction = optionalValue.get(); boolean flag = hookState.getOptionalValue(ATTACHED).orElse(false); @@ -13,10 +13,10 @@ int i = 0; BlockState[] blockStates = new BlockState[42]; -@@ -166,21 +_,48 @@ +@@ -152,21 +_,48 @@ flag2 &= i > 1; flag3 &= flag2; - BlockState blockState1 = block.defaultBlockState().trySetValue(ATTACHED, Boolean.valueOf(flag2)).trySetValue(POWERED, Boolean.valueOf(flag3)); + BlockState blockState1 = block.defaultBlockState().trySetValue(ATTACHED, flag2).trySetValue(POWERED, flag3); + boolean cancelledEmitterHook = false, cancelledReceiverHook = false; // Paper - Call BlockRedstoneEvent + boolean wasPowered = flag1, willBePowered = flag3; // Paper - OBFHELPER if (i > 0) { @@ -63,12 +63,12 @@ if (flag != flag2) { for (int i2 = 1; i2 < i; i2++) { -@@ -189,7 +_,7 @@ +@@ -175,7 +_,7 @@ if (blockState2 != null) { BlockState blockState3 = level.getBlockState(blockPos1); if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { -- level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, Boolean.valueOf(flag2)), 3); // Paper - prevent tripwire from updating +- level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); // Paper - prevent tripwire from updating } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch index e7880ebb4..45b15ae3c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/TurtleEggBlock.java.patch @@ -20,18 +20,17 @@ this.decreaseEggs(serverLevel, pos, state); } } -@@ -95,10 +_,20 @@ +@@ -95,10 +_,19 @@ if (this.shouldUpdateHatchLevel(level) && onSand(level, pos)) { int hatchValue = state.getValue(HATCH); if (hatchValue < 2) { + // CraftBukkit start - Call BlockGrowEvent -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(TurtleEggBlock.HATCH, hatchValue + 1), 2)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(HATCH, hatchValue + 1), 2)) { + return; + } + // CraftBukkit end level.playSound(null, pos, SoundEvents.TURTLE_EGG_CRACK, SoundSource.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F); -- level.setBlock(pos, state.setValue(HATCH, Integer.valueOf(hatchValue + 1)), 2); -+ // level.setBlock(pos, state.setValue(HATCH, Integer.valueOf(hatchValue + 1)), 2); // CraftBukkit - handled above +- level.setBlock(pos, state.setValue(HATCH, hatchValue + 1), 2); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); } else { + // CraftBukkit start - Call BlockFadeEvent @@ -45,7 +44,7 @@ @@ -110,7 +_,7 @@ turtle.setAge(-24000); turtle.setHomePos(pos); - turtle.moveTo(pos.getX() + 0.3 + i * 0.2, pos.getY(), pos.getZ() + 0.3, 0.0F, 0.0F); + turtle.snapTo(pos.getX() + 0.3 + i * 0.2, pos.getY(), pos.getZ() + 0.3, 0.0F, 0.0F); - level.addFreshEntity(turtle); + level.addFreshEntity(turtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VegetationBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VegetationBlock.java.patch new file mode 100644 index 000000000..cc5f85a5a --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VegetationBlock.java.patch @@ -0,0 +1,21 @@ +--- a/net/minecraft/world/level/block/VegetationBlock.java ++++ b/net/minecraft/world/level/block/VegetationBlock.java +@@ -35,9 +_,15 @@ + BlockState neighborState, + RandomSource random + ) { +- return !state.canSurvive(level, pos) +- ? Blocks.AIR.defaultBlockState() +- : super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); ++ // CraftBukkit start ++ if (!state.canSurvive(level, pos)) { ++ // Suppress during worldgen ++ if (!(level instanceof net.minecraft.server.level.ServerLevel serverLevel && serverLevel.hasPhysicsEvent) || !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(serverLevel, pos).isCancelled()) { // Paper ++ return Blocks.AIR.defaultBlockState(); ++ } ++ } ++ return super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); ++ // CraftBukkit end + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch index f5fb87410..28c32d2c0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/VineBlock.java.patch @@ -1,54 +1,54 @@ --- a/net/minecraft/world/level/block/VineBlock.java +++ b/net/minecraft/world/level/block/VineBlock.java -@@ -191,7 +_,7 @@ +@@ -166,7 +_,7 @@ @Override protected void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (level.getGameRules().getBoolean(GameRules.RULE_DO_VINES_SPREAD)) { - if (random.nextInt(4) == 0) { -+ if (random.nextFloat() < (level.spigotConfig.vineModifier / (100.0f * 4))) { // Spigot - SPIGOT-7159: Better modifier resolution ++ if (random.nextFloat() < (level.spigotConfig.vineModifier / (100.0F * 4))) { // Spigot - SPIGOT-7159: Better modifier resolution Direction random1 = Direction.getRandom(random); BlockPos blockPos = pos.above(); if (random1.getAxis().isHorizontal() && !state.getValue(getPropertyForFace(random1))) { -@@ -205,28 +_,31 @@ +@@ -180,28 +_,31 @@ boolean value1 = state.getValue(getPropertyForFace(counterClockWise)); BlockPos blockPos2 = blockPos1.relative(clockWise); BlockPos blockPos3 = blockPos1.relative(counterClockWise); + // CraftBukkit start - Call BlockSpreadEvent + BlockPos source = pos; if (value && isAcceptableNeighbour(level, blockPos2, clockWise)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), Boolean.valueOf(true)), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(clockWise), true), 2); } else if (value1 && isAcceptableNeighbour(level, blockPos3, counterClockWise)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), Boolean.valueOf(true)), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(getPropertyForFace(counterClockWise), true), 2); } else { Direction opposite = random1.getOpposite(); if (value && level.isEmptyBlock(blockPos2) && isAcceptableNeighbour(level, pos.relative(clockWise), opposite)) { -- level.setBlock(blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), Boolean.valueOf(true)), 2); +- level.setBlock(blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos2, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); } else if (value1 && level.isEmptyBlock(blockPos3) && isAcceptableNeighbour(level, pos.relative(counterClockWise), opposite)) { -- level.setBlock(blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), Boolean.valueOf(true)), 2); +- level.setBlock(blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos3, this.defaultBlockState().setValue(getPropertyForFace(opposite), true), 2); } else if (random.nextFloat() < 0.05 && isAcceptableNeighbour(level, blockPos1.above(), Direction.UP)) { -- level.setBlock(blockPos1, this.defaultBlockState().setValue(UP, Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(UP, Boolean.valueOf(true)), 2); +- level.setBlock(blockPos1, this.defaultBlockState().setValue(UP, true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(level, source, blockPos1, this.defaultBlockState().setValue(UP, true), 2); } + // CraftBukkit end } } else if (isAcceptableNeighbour(level, blockPos1, random1)) { -- level.setBlock(pos, state.setValue(getPropertyForFace(random1), Boolean.valueOf(true)), 2); +- level.setBlock(pos, state.setValue(getPropertyForFace(random1), true), 2); + org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, (BlockState) state.setValue(VineBlock.getPropertyForFace(random1), true), 2); // CraftBukkit } } } else { if (random1 == Direction.UP && pos.getY() < level.getMaxY()) { if (this.canSupportAtFace(level, pos, random1)) { -- level.setBlock(pos, state.setValue(UP, Boolean.valueOf(true)), 2); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(UP, Boolean.valueOf(true)), 2); // CraftBukkit +- level.setBlock(pos, state.setValue(UP, true), 2); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(level, pos, state.setValue(UP, true), 2); // CraftBukkit return; } -@@ -244,7 +_,7 @@ +@@ -219,7 +_,7 @@ } if (this.hasHorizontalConnection(blockState1)) { @@ -57,7 +57,7 @@ } return; -@@ -258,7 +_,7 @@ +@@ -233,7 +_,7 @@ BlockState blockState2 = blockState.isAir() ? this.defaultBlockState() : blockState; BlockState blockState3 = this.copyRandomFaces(state, blockState2, random); if (blockState2 != blockState3 && this.hasHorizontalConnection(blockState3)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch index ad86e1ce3..e00affc15 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WallHangingSignBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/WallHangingSignBlock.java +++ b/net/minecraft/world/level/block/WallHangingSignBlock.java -@@ -187,6 +_,6 @@ +@@ -176,6 +_,6 @@ @Nullable @Override public BlockEntityTicker getTicker(Level level, BlockState state, BlockEntityType blockEntityType) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch index 717671584..76efdbc80 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WaterlilyBlock.java.patch @@ -1,11 +1,11 @@ --- a/net/minecraft/world/level/block/WaterlilyBlock.java +++ b/net/minecraft/world/level/block/WaterlilyBlock.java -@@ -29,8 +_,14 @@ +@@ -30,8 +_,14 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent - super.entityInside(state, level, pos, entity); + super.entityInside(state, level, pos, entity, effectApplier); if (level instanceof ServerLevel && entity instanceof AbstractBoat) { + // CraftBukkit start + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, state.getFluidState().createLegacyBlock())) { // Paper - fix wrong block state diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WebBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WebBlock.java.patch index e774bcdbb..017240eb4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WebBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WebBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/WebBlock.java +++ b/net/minecraft/world/level/block/WebBlock.java -@@ -24,6 +_,7 @@ +@@ -25,6 +_,7 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent Vec3 vec3 = new Vec3(0.25, 0.05F, 0.25); if (entity instanceof LivingEntity livingEntity && livingEntity.hasEffect(MobEffects.WEAVING)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch index 26787da95..07cf136cb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WeightedPressurePlateBlock.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +++ b/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -@@ -6,6 +_,7 @@ - import net.minecraft.core.BlockPos; - import net.minecraft.util.Mth; - import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.player.Player; - import net.minecraft.world.level.Level; - import net.minecraft.world.level.block.state.BlockBehaviour; - import net.minecraft.world.level.block.state.BlockState; -@@ -39,7 +_,27 @@ +@@ -39,7 +_,25 @@ @Override protected int getSignalStrength(Level level, BlockPos pos) { @@ -16,13 +8,13 @@ + // CraftBukkit start + // int min = Math.min(getEntityCount(level, TOUCH_AABB.move(pos), Entity.class), this.maxWeight); + int min = 0; -+ for (Entity entity : getEntities(level, WeightedPressurePlateBlock.TOUCH_AABB.move(pos), Entity.class)) { ++ for (Entity entity : getEntities(level, TOUCH_AABB.move(pos), Entity.class)) { + org.bukkit.event.Cancellable cancellable; + -+ if (entity instanceof Player) { -+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((Player) entity, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); ++ if (entity instanceof net.minecraft.world.entity.player.Player player) { ++ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent(player, org.bukkit.event.block.Action.PHYSICAL, pos, null, null, null); + } else { -+ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ())); ++ cancellable = new org.bukkit.event.entity.EntityInteractEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)); + level.getCraftServer().getPluginManager().callEvent((org.bukkit.event.entity.EntityInteractEvent) cancellable); + } + @@ -31,8 +23,6 @@ + min++; + } + } -+ -+ min = Math.min(min, this.maxWeight); + // CraftBukkit end if (min > 0) { float f = (float)Math.min(this.maxWeight, min) / this.maxWeight; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WitherRoseBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WitherRoseBlock.java.patch index 6a3cdd4e5..93d4ec3ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WitherRoseBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WitherRoseBlock.java.patch @@ -1,9 +1,9 @@ --- a/net/minecraft/world/level/block/WitherRoseBlock.java +++ b/net/minecraft/world/level/block/WitherRoseBlock.java -@@ -63,11 +_,12 @@ +@@ -64,11 +_,12 @@ @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent if (level instanceof ServerLevel serverLevel && level.getDifficulty() != Difficulty.PEACEFUL diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch index 63d29d1d8..b3d01b0f3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/WitherSkullBlock.java.patch @@ -15,7 +15,7 @@ - CarvedPumpkinBlock.clearPatternBlocks(level, blockPatternMatch); + // CarvedPumpkinBlock.clearPatternBlocks(level, blockPatternMatch); // CraftBukkit - move down BlockPos pos1 = blockPatternMatch.getBlock(1, 2, 0).getPos(); - witherBoss.moveTo( + witherBoss.snapTo( pos1.getX() + 0.5, @@ -70,12 +_,18 @@ ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch index f8c59e895..2cef802e6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -99,11 +_,44 @@ +@@ -104,11 +_,49 @@ }; public final Reference2IntOpenHashMap>> recipesUsed = new Reference2IntOpenHashMap<>(); private final RecipeManager.CachedCheck quickCheck; @@ -18,18 +18,22 @@ + private int maxStack = MAX_STACK; + public List transaction = new java.util.ArrayList<>(); + ++ @Override + public List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public List getViewers() { + return this.transaction; + } @@ -39,6 +43,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } @@ -46,36 +51,22 @@ private boolean isLit() { return this.litTimeRemaining > 0; -@@ -121,8 +_,19 @@ - CompoundTag compound = tag.getCompound("RecipesUsed"); - - for (String string : compound.getAllKeys()) { -- this.recipesUsed.put(ResourceKey.create(Registries.RECIPE, ResourceLocation.parse(string)), compound.getInt(string)); -- } -+ // Paper start - Validate ResourceLocation -+ final ResourceLocation resourceLocation = ResourceLocation.tryParse(string); -+ if (resourceLocation != null) { -+ this.recipesUsed.put(ResourceKey.create(Registries.RECIPE, resourceLocation), compound.getInt(string)); -+ } -+ // Paper end - Validate ResourceLocation -+ } -+ -+ // Paper start - cook speed multiplier API -+ if (tag.contains("Paper.CookSpeedMultiplier")) { -+ this.cookSpeedMultiplier = tag.getDouble("Paper.CookSpeedMultiplier"); -+ } -+ // Paper end - cook speed multiplier API +@@ -125,6 +_,7 @@ + this.litTotalTime = tag.getShortOr("lit_total_time", (short)0); + this.recipesUsed.clear(); + this.recipesUsed.putAll(tag.read("RecipesUsed", RECIPES_USED_CODEC).orElse(Map.of())); ++ this.cookSpeedMultiplier = tag.getDoubleOr("Paper.CookSpeedMultiplier", 1); // Paper - cook speed multiplier API } @Override -@@ -132,6 +_,7 @@ +@@ -134,6 +_,7 @@ tag.putShort("cooking_total_time", (short)this.cookingTotalTime); tag.putShort("lit_time_remaining", (short)this.litTimeRemaining); tag.putShort("lit_total_time", (short)this.litTotalTime); + tag.putDouble("Paper.CookSpeedMultiplier", this.cookSpeedMultiplier); // Paper - cook speed multiplier API ContainerHelper.saveAllItems(tag, this.items, registries); - CompoundTag compoundTag = new CompoundTag(); - this.recipesUsed.forEach((recipe, count) -> compoundTag.putInt(recipe.location().toString(), count)); + tag.store("RecipesUsed", RECIPES_USED_CODEC, this.recipesUsed); + } @@ -160,11 +_,22 @@ int maxStackSize = furnace.getMaxStackSize(); @@ -193,13 +184,13 @@ - public static int getTotalCookTime(ServerLevel level, AbstractFurnaceBlockEntity furnace) { + public static int getTotalCookTime(@Nullable ServerLevel level, AbstractFurnaceBlockEntity furnace, RecipeType recipeType, double cookSpeedMultiplier) { // Paper - cook speed multiplier API SingleRecipeInput singleRecipeInput = new SingleRecipeInput(furnace.getItem(0)); -- return furnace.quickCheck.getRecipeFor(singleRecipeInput, level).map(recipe -> recipe.value().cookingTime()).orElse(200); +- return furnace.quickCheck.getRecipeFor(singleRecipeInput, level).map(recipeHolder -> recipeHolder.value().cookingTime()).orElse(200); + // Paper start - cook speed multiplier API + /* Scale the recipe's cooking time to the current cookSpeedMultiplier */ + int cookTime = level != null -+ ? furnace.quickCheck.getRecipeFor(singleRecipeInput, level).map(holder -> holder.value().cookingTime()).orElse(200) ++ ? furnace.quickCheck.getRecipeFor(singleRecipeInput, level).map(recipeHolder -> recipeHolder.value().cookingTime()).orElse(200) + /* passing a null level here is safe. world is only used for map extending recipes which won't happen here */ -+ : (net.minecraft.server.MinecraftServer.getServer().getRecipeManager().getRecipeFor(recipeType, singleRecipeInput, level).map(holder -> holder.value().cookingTime()).orElse(200)); ++ : (net.minecraft.server.MinecraftServer.getServer().getRecipeManager().getRecipeFor(recipeType, singleRecipeInput, level).map(recipeHolder -> recipeHolder.value().cookingTime()).orElse(200)); + return (int) Math.ceil (cookTime / cookSpeedMultiplier); + // Paper end - cook speed multiplier API } @@ -237,11 +228,11 @@ List> list = Lists.newArrayList(); for (Entry>> entry : this.recipesUsed.reference2IntEntrySet()) { - level.recipeAccess().byKey(entry.getKey()).ifPresent(recipe -> { -+ if (!(recipe.value() instanceof AbstractCookingRecipe)) return; // Paper - don't process non-cooking recipes - list.add((RecipeHolder)recipe); -- createExperience(level, popVec, entry.getIntValue(), ((AbstractCookingRecipe)recipe.value()).experience()); -+ createExperience(level, popVec, entry.getIntValue(), ((AbstractCookingRecipe)recipe.value()).experience(), blockPos, serverPlayer, itemStack, amount); + level.recipeAccess().byKey(entry.getKey()).ifPresent(recipeHolder -> { ++ if (!(recipeHolder.value() instanceof AbstractCookingRecipe)) return; // Paper - don't process non-cooking recipes + list.add((RecipeHolder)recipeHolder); +- createExperience(level, popVec, entry.getIntValue(), ((AbstractCookingRecipe)recipeHolder.value()).experience()); ++ createExperience(level, popVec, entry.getIntValue(), ((AbstractCookingRecipe)recipeHolder.value()).experience(), blockPos, serverPlayer, itemStack, amount); // Paper - don't process non-cooking recipes }); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch index a398e2a01..a3aef845c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BannerBlockEntity.java.patch @@ -1,33 +1,24 @@ --- a/net/minecraft/world/level/block/entity/BannerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BannerBlockEntity.java -@@ -23,7 +_,7 @@ - public static final int MAX_PATTERNS = 6; - private static final String TAG_PATTERNS = "patterns"; - @Nullable -- private Component name; -+ public Component name; // Paper - AT public - public DyeColor baseColor; - private BannerPatternLayers patterns = BannerPatternLayers.EMPTY; - -@@ -50,7 +_,7 @@ - @Override +@@ -52,7 +_,7 @@ protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { super.saveAdditional(tag, registries); + RegistryOps registryOps = registries.createSerializationContext(NbtOps.INSTANCE); - if (!this.patterns.equals(BannerPatternLayers.EMPTY)) { + if (!this.patterns.equals(BannerPatternLayers.EMPTY) || serialisingForNetwork.get()) { // Paper - always send patterns to client - tag.put("patterns", BannerPatternLayers.CODEC.encodeStart(registries.createSerializationContext(NbtOps.INSTANCE), this.patterns).getOrThrow()); + tag.store("patterns", BannerPatternLayers.CODEC, registryOps, this.patterns); } -@@ -70,7 +_,7 @@ - BannerPatternLayers.CODEC - .parse(registries.createSerializationContext(NbtOps.INSTANCE), tag.get("patterns")) - .resultOrPartial(string -> LOGGER.error("Failed to parse banner patterns: '{}'", string)) -- .ifPresent(bannerPatternLayers -> this.patterns = bannerPatternLayers); -+ .ifPresent(bannerPatternLayers -> this.setPatterns(bannerPatternLayers)); // CraftBukkit - apply limits - } +@@ -64,7 +_,7 @@ + super.loadAdditional(tag, registries); + this.name = parseCustomNameSafe(tag.get("CustomName"), registries); + RegistryOps registryOps = registries.createSerializationContext(NbtOps.INSTANCE); +- this.patterns = tag.read("patterns", BannerPatternLayers.CODEC, registryOps).orElse(BannerPatternLayers.EMPTY); ++ this.setPatterns(tag.read("patterns", BannerPatternLayers.CODEC, registryOps).orElse(BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits } -@@ -79,9 +_,18 @@ + @Override +@@ -72,9 +_,18 @@ return ClientboundBlockEntityDataPacket.create(this); } @@ -46,16 +37,16 @@ } public BannerPatternLayers getPatterns() { -@@ -101,7 +_,7 @@ +@@ -94,7 +_,7 @@ @Override - protected void applyImplicitComponents(BlockEntity.DataComponentInput componentInput) { - super.applyImplicitComponents(componentInput); -- this.patterns = componentInput.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); -+ this.setPatterns(componentInput.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits - this.name = componentInput.get(DataComponents.CUSTOM_NAME); + protected void applyImplicitComponents(DataComponentGetter componentGetter) { + super.applyImplicitComponents(componentGetter); +- this.patterns = componentGetter.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY); ++ this.setPatterns(componentGetter.getOrDefault(DataComponents.BANNER_PATTERNS, BannerPatternLayers.EMPTY)); // CraftBukkit - apply limits + this.name = componentGetter.get(DataComponents.CUSTOM_NAME); } -@@ -117,4 +_,13 @@ +@@ -110,4 +_,13 @@ tag.remove("patterns"); tag.remove("CustomName"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch index a7e3cbcde..eaf144169 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BarrelBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -21,6 +_,40 @@ +@@ -21,6 +_,41 @@ import net.minecraft.world.level.block.state.BlockState; public class BarrelBlockEntity extends RandomizableContainerBlockEntity { @@ -34,10 +34,11 @@ + } + + @Override -+ public void setMaxStackSize(int i) { -+ this.maxStack = i; ++ public void setMaxStackSize(int size) { ++ this.maxStack = size; + } + // CraftBukkit end ++ private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { @Override diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch index 09da60cff..fe1960136 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -68,17 +_,44 @@ +@@ -69,17 +_,45 @@ protected abstract Component getDefaultName(); public boolean canOpen(Player player) { @@ -13,6 +13,7 @@ + // Paper start - Add BlockLockCheckEvent + return canUnlock(player, code, displayName, null); + } ++ + public static boolean canUnlock(Player player, LockCode code, Component displayName, @Nullable BlockEntity blockEntity) { + if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer && blockEntity != null && blockEntity.getLevel() != null && blockEntity.getLevel().getBlockEntity(blockEntity.getBlockPos()) == blockEntity) { + final org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(blockEntity.getLevel(), blockEntity.getBlockPos()); @@ -47,16 +48,16 @@ } protected abstract NonNullList getItems(); -@@ -166,4 +_,12 @@ +@@ -167,4 +_,12 @@ tag.remove("lock"); tag.remove("Items"); } + + // CraftBukkit start + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + if (this.level == null) return null; -+ return new org.bukkit.Location(this.level.getWorld(), this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } + // CraftBukkit end } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch index 55e57b57f..b55f64efa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeaconBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeaconBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeaconBlockEntity.java -@@ -106,6 +_,53 @@ +@@ -109,6 +_,53 @@ return 3; } }; @@ -54,7 +54,7 @@ @Nullable static Holder filterEffect(@Nullable Holder effect) { -@@ -163,17 +_,26 @@ +@@ -166,17 +_,26 @@ blockEntity.lastCheckY++; } @@ -83,7 +83,7 @@ if (blockEntity.lastCheckY >= height) { blockEntity.lastCheckY = level.getMinY() - 1; -@@ -224,35 +_,99 @@ +@@ -227,35 +_,100 @@ @Override public void setRemoved() { @@ -99,17 +99,18 @@ super.setRemoved(); } -+ @io.papermc.paper.annotation.DoNotUse // Paper - pass beacon block entity ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - pass beacon block entity private static void applyEffects( Level level, BlockPos pos, int beaconLevel, @Nullable Holder primaryEffect, @Nullable Holder secondaryEffect ) { -+ // Paper start - pass beacon block entity ++ // Paper start - pass beacon block entity + applyEffects(level, pos, beaconLevel, primaryEffect, secondaryEffect, null); + } ++ + private static void applyEffects( + Level level, BlockPos pos, int beaconLevel, @Nullable Holder primaryEffect, @Nullable Holder secondaryEffect, @Nullable BeaconBlockEntity blockEntity + ) { -+ // Paper emd - pass beacon block entity ++ // Paper end - pass beacon block entity if (!level.isClientSide && primaryEffect != null) { - double d = beaconLevel * 10 + 10; - int i = 0; @@ -201,38 +202,35 @@ public static void playSound(Level level, BlockPos pos, SoundEvent sound) { level.playSound(null, pos, sound, SoundSource.BLOCKS, 1.0F, 1.0F); -@@ -282,7 +_,7 @@ - private static Holder loadEffect(CompoundTag tag, String key) { - if (tag.contains(key, 8)) { - ResourceLocation resourceLocation = ResourceLocation.tryParse(tag.getString(key)); -- return resourceLocation == null ? null : BuiltInRegistries.MOB_EFFECT.get(resourceLocation).map(BeaconBlockEntity::filterEffect).orElse(null); -+ return resourceLocation == null ? null : BuiltInRegistries.MOB_EFFECT.get(resourceLocation).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) - } else { - return null; - } -@@ -293,11 +_,13 @@ - super.loadAdditional(tag, registries); - this.primaryPower = loadEffect(tag, "primary_effect"); - this.secondaryPower = loadEffect(tag, "secondary_effect"); -+ this.levels = tag.getInt("Levels"); // CraftBukkit - SPIGOT-5053, use where available - if (tag.contains("CustomName", 8)) { - this.name = parseCustomNameSafe(tag.getString("CustomName"), registries); - } +@@ -284,7 +_,7 @@ - this.lockKey = LockCode.fromTag(tag, registries); -+ this.effectRange = tag.contains(PAPER_RANGE_TAG, 6) ? tag.getDouble(PAPER_RANGE_TAG) : -1; // Paper - Custom beacon ranges + @Nullable + private static Holder loadEffect(CompoundTag tag, String key) { +- return tag.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).filter(VALID_EFFECTS::contains).orElse(null); ++ return tag.read(key, BuiltInRegistries.MOB_EFFECT.holderByNameCodec()).orElse(null); // CraftBukkit - persist manually set non-default beacon effects (SPIGOT-3598) } @Override -@@ -311,6 +_,7 @@ - } +@@ -292,8 +_,10 @@ + super.loadAdditional(tag, registries); + this.primaryPower = loadEffect(tag, "primary_effect"); + this.secondaryPower = loadEffect(tag, "secondary_effect"); ++ this.levels = tag.getIntOr("Levels", 0); // CraftBukkit - SPIGOT-5053, use where available + this.name = parseCustomNameSafe(tag.get("CustomName"), registries); + this.lockKey = LockCode.fromTag(tag, registries); ++ this.effectRange = tag.getDoubleOr(PAPER_RANGE_TAG, -1); // Paper - Custom beacon ranges + } + @Override +@@ -304,6 +_,7 @@ + tag.putInt("Levels", this.levels); + tag.storeNullable("CustomName", ComponentSerialization.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.name); this.lockKey.addToTag(tag, registries); + tag.putDouble(PAPER_RANGE_TAG, this.effectRange); // Paper - Custom beacon ranges } public void setCustomName(@Nullable Component name) { -@@ -326,7 +_,7 @@ +@@ -319,7 +_,7 @@ @Nullable @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch index 79355e0ee..a05c77e85 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -83,6 +_,7 @@ +@@ -79,6 +_,7 @@ private List stored = Lists.newArrayList(); @Nullable public BlockPos savedFlowerPos; @@ -8,7 +8,7 @@ public BeehiveBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.BEEHIVE, pos, blockState); -@@ -116,7 +_,7 @@ +@@ -112,7 +_,7 @@ } public boolean isFull() { @@ -17,16 +17,16 @@ } public void emptyAllLivingFromHive(@Nullable Player player, BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { -@@ -127,7 +_,7 @@ - Bee bee = (Bee)entity; - if (player.position().distanceToSqr(entity.position()) <= 16.0) { - if (!this.isSedated()) { -- bee.setTarget(player); -+ bee.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - } else { - bee.setStayOutOfHiveCountdown(400); - } -@@ -138,8 +_,14 @@ +@@ -121,7 +_,7 @@ + for (Entity entity : list) { + if (entity instanceof Bee bee && player.position().distanceToSqr(entity.position()) <= 16.0) { + if (!this.isSedated()) { +- bee.setTarget(player); ++ bee.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER); // CraftBukkit + } else { + bee.setStayOutOfHiveCountdown(400); + } +@@ -131,8 +_,14 @@ } private List releaseAllOccupants(BlockState state, BeehiveBlockEntity.BeeReleaseStatus releaseStatus) { @@ -42,7 +42,7 @@ if (!list.isEmpty()) { super.setChanged(); } -@@ -152,6 +_,11 @@ +@@ -145,6 +_,11 @@ return this.stored.size(); } @@ -54,7 +54,7 @@ public static int getHoneyLevel(BlockState state) { return state.getValue(BeehiveBlock.HONEY_LEVEL); } -@@ -162,7 +_,16 @@ +@@ -155,7 +_,16 @@ } public void addOccupant(Bee bee) { @@ -72,7 +72,7 @@ bee.stopRiding(); bee.ejectPassengers(); bee.dropLeash(); -@@ -187,7 +_,7 @@ +@@ -180,7 +_,7 @@ this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -81,7 +81,7 @@ super.setChanged(); } } -@@ -205,7 +_,21 @@ +@@ -198,7 +_,21 @@ BeehiveBlockEntity.BeeReleaseStatus releaseStatus, @Nullable BlockPos storedFlowerPos ) { @@ -104,7 +104,7 @@ return false; } else { Direction direction = state.getValue(BeehiveBlock.FACING); -@@ -216,6 +_,17 @@ +@@ -209,6 +_,17 @@ } else { Entity entity = occupant.createEntity(level, pos); if (entity != null) { @@ -115,20 +115,20 @@ + double d1 = pos.getX() + 0.5 + d * direction.getStepX(); + double d2 = pos.getY() + 0.5 - entity.getBbHeight() / 2.0F; + double d3 = pos.getZ() + 0.5 + d * direction.getStepZ(); -+ entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); ++ entity.snapTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + } + if (!level.addFreshEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below + // CraftBukkit end if (entity instanceof Bee bee) { if (storedFlowerPos != null && !bee.hasSavedFlowerPos() && level.random.nextFloat() < 0.9F) { bee.setSavedFlowerPos(storedFlowerPos); -@@ -231,7 +_,13 @@ +@@ -224,7 +_,13 @@ i--; } -- level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, Integer.valueOf(honeyLevel + i))); +- level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + i)); + // Paper start - Fire EntityChangeBlockEvent in more places -+ BlockState newBlockState = state.setValue(BeehiveBlock.HONEY_LEVEL, Integer.valueOf(honeyLevel + i)); ++ BlockState newBlockState = state.setValue(BeehiveBlock.HONEY_LEVEL, honeyLevel + i); + + if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, pos, newBlockState)) { + level.setBlockAndUpdate(pos, newBlockState); @@ -137,7 +137,7 @@ } } } -@@ -240,17 +_,19 @@ +@@ -233,17 +_,19 @@ storedInHives.add(bee); } @@ -147,7 +147,7 @@ double d1 = pos.getX() + 0.5 + d * direction.getStepX(); double d2 = pos.getY() + 0.5 - entity.getBbHeight() / 2.0F; double d3 = pos.getZ() + 0.5 + d * direction.getStepZ(); - entity.moveTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + entity.snapTo(d1, d2, d3, entity.getYRot(), entity.getXRot()); + */ // CraftBukkit end } @@ -158,7 +158,7 @@ } else { return false; } -@@ -276,6 +_,11 @@ +@@ -269,6 +_,11 @@ flag = true; iterator.remove(); } @@ -170,43 +170,34 @@ } } -@@ -299,7 +_,7 @@ +@@ -292,9 +_,10 @@ @Override protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { super.loadAdditional(tag, registries); - this.stored.clear(); + this.stored = Lists.newArrayList(); // CraftBukkit - SPIGOT-7790: create new copy (may be modified in physics event triggered by honey change) - if (tag.contains("bees")) { - BeehiveBlockEntity.Occupant.LIST_CODEC - .parse(NbtOps.INSTANCE, tag.get("bees")) -@@ -308,6 +_,11 @@ - } - - this.savedFlowerPos = NbtUtils.readBlockPos(tag, "flower_pos").orElse(null); -+ // CraftBukkit start -+ if (tag.contains("Bukkit.MaxEntities")) { -+ this.maxBees = tag.getInt("Bukkit.MaxEntities"); -+ } -+ // CraftBukkit end + tag.read("bees", BeehiveBlockEntity.Occupant.LIST_CODEC).orElse(List.of()).forEach(this::storeBee); + this.savedFlowerPos = tag.read("flower_pos", BlockPos.CODEC).orElse(null); ++ this.maxBees = tag.getIntOr("Bukkit.MaxEntities", MAX_OCCUPANTS); // Paper - persist max bukkit occupants } @Override -@@ -317,12 +_,13 @@ - if (this.hasSavedFlowerPos()) { - tag.put("flower_pos", NbtUtils.writeBlockPos(this.savedFlowerPos)); - } -+ tag.putInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit +@@ -302,12 +_,13 @@ + super.saveAdditional(tag, registries); + tag.store("bees", BeehiveBlockEntity.Occupant.LIST_CODEC, this.getBees()); + tag.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos); ++ tag.putInt("Bukkit.MaxEntities", this.maxBees); // Paper - persist max bukkit occupants } @Override - protected void applyImplicitComponents(BlockEntity.DataComponentInput componentInput) { - super.applyImplicitComponents(componentInput); + protected void applyImplicitComponents(DataComponentGetter componentGetter) { + super.applyImplicitComponents(componentGetter); - this.stored.clear(); + this.stored = Lists.newArrayList(); // CraftBukkit - SPIGOT-7790: create new copy (may be modified in physics event triggered by honey change) - List list = componentInput.getOrDefault(DataComponents.BEES, List.of()); + List list = componentGetter.getOrDefault(DataComponents.BEES, Bees.EMPTY).bees(); list.forEach(this::storeBee); } -@@ -345,15 +_,18 @@ +@@ -330,15 +_,18 @@ static class BeeData { private final BeehiveBlockEntity.Occupant occupant; @@ -226,7 +217,7 @@ } public BeehiveBlockEntity.Occupant toOccupant() { -@@ -424,6 +_,7 @@ +@@ -409,6 +_,7 @@ } private static void setBeeReleaseData(int ticksInHive, Bee bee) { @@ -234,7 +225,7 @@ int age = bee.getAge(); if (age < 0) { bee.setAge(Math.min(0, age + ticksInHive)); -@@ -432,6 +_,7 @@ +@@ -417,6 +_,7 @@ } bee.setInLoveTime(Math.max(0, bee.getInLoveTime() - ticksInHive)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch index c54e142ea..b72693d01 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BlockEntity.java.patch @@ -1,17 +1,17 @@ --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -26,6 +_,10 @@ +@@ -33,6 +_,10 @@ import org.slf4j.Logger; public abstract class BlockEntity { + // CraftBukkit start - data containers + private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); -+ public org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; ++ public final org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer; + // CraftBukkit end + private static final Codec> TYPE_CODEC = BuiltInRegistries.BLOCK_ENTITY_TYPE.byNameCodec(); private static final Logger LOGGER = LogUtils.getLogger(); private final BlockEntityType type; - @Nullable -@@ -40,6 +_,7 @@ +@@ -48,6 +_,7 @@ this.worldPosition = pos.immutable(); this.validateBlockState(blockState); this.blockState = blockState; @@ -19,7 +19,23 @@ } private void validateBlockState(BlockState state) { -@@ -70,6 +_,14 @@ +@@ -64,6 +_,7 @@ + int intOr = tag.getIntOr("x", 0); + int intOr1 = tag.getIntOr("y", 0); + int intOr2 = tag.getIntOr("z", 0); ++ if (chunkPos != null) { // Paper - allow reading non-validated pos from tag - used to parse block entities on items + int sectionPosCoord = SectionPos.blockToSectionCoord(intOr); + int sectionPosCoord1 = SectionPos.blockToSectionCoord(intOr2); + if (sectionPosCoord != chunkPos.x || sectionPosCoord1 != chunkPos.z) { +@@ -71,6 +_,7 @@ + intOr = chunkPos.getBlockX(SectionPos.sectionRelative(intOr)); + intOr2 = chunkPos.getBlockZ(SectionPos.sectionRelative(intOr2)); + } ++ } // Paper - allow reading non-validated pos from tag - used to parse block entities on items + + return new BlockPos(intOr, intOr1, intOr2); + } +@@ -89,6 +_,14 @@ } protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { @@ -34,12 +50,12 @@ } public final void loadWithComponents(CompoundTag tag, HolderLookup.Provider registries) { -@@ -106,12 +_,22 @@ - .encodeStart(registries.createSerializationContext(NbtOps.INSTANCE), this.components) - .resultOrPartial(string -> LOGGER.warn("Failed to save components: {}", string)) - .ifPresent(tag -> compoundTag.merge((CompoundTag)tag)); +@@ -120,12 +_,22 @@ + CompoundTag compoundTag = new CompoundTag(); + this.saveAdditional(compoundTag, registries); + compoundTag.store(BlockEntity.ComponentHelper.COMPONENTS_CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.components); + // CraftBukkit start - store container -+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { ++ if (!this.persistentDataContainer.isEmpty()) { + compoundTag.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); + } + // CraftBukkit end @@ -50,28 +66,14 @@ CompoundTag compoundTag = new CompoundTag(); this.saveAdditional(compoundTag, registries); + // Paper start - store PDC here as well -+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) { ++ if (!this.persistentDataContainer.isEmpty()) { + compoundTag.put("PublicBukkitValues", this.persistentDataContainer.toTagCompound()); + } + // Paper end return compoundTag; } -@@ -220,7 +_,12 @@ - public void fillCrashReportCategory(CrashReportCategory reportCategory) { - reportCategory.setDetail("Name", this::getNameForReporting); - if (this.level != null) { -- CrashReportCategory.populateBlockDetails(reportCategory, this.level, this.worldPosition, this.getBlockState()); -+ // Paper start - Prevent block entity and entity crashes -+ BlockState block = this.getBlockState(); -+ if (block != null) { -+ CrashReportCategory.populateBlockDetails(reportCategory, this.level, this.worldPosition, block); -+ } -+ // Paper end - Prevent block entity and entity crashes - CrashReportCategory.populateBlockDetails(reportCategory, this.level, this.worldPosition, this.level.getBlockState(this.worldPosition)); - } - } -@@ -247,6 +_,12 @@ +@@ -260,6 +_,12 @@ } public final void applyComponents(DataComponentMap components, DataComponentPatch patch) { @@ -84,7 +86,7 @@ final Set> set = new HashSet<>(); set.add(DataComponents.BLOCK_ENTITY_DATA); set.add(DataComponents.BLOCK_STATE); -@@ -267,6 +_,10 @@ +@@ -280,6 +_,10 @@ }); DataComponentPatch dataComponentPatch = patch.forget(set::contains); this.components = dataComponentPatch.split().added(); @@ -95,21 +97,19 @@ } protected void collectImplicitComponents(DataComponentMap.Builder components) { -@@ -300,6 +_,30 @@ - return null; - } +@@ -313,6 +_,28 @@ + .resultOrPartial(string -> LOGGER.warn("Failed to parse custom name, discarding: {}", string)) + .orElse(null); } + + // CraftBukkit start - add method + public org.bukkit.inventory.InventoryHolder getOwner() { -+ // Paper start + return getOwner(true); + } ++ + public org.bukkit.inventory.InventoryHolder getOwner(boolean useSnapshot) { -+ // Paper end + if (this.level == null) return null; -+ org.bukkit.block.Block block = this.level.getWorld().getBlockAt(this.worldPosition.getX(), this.worldPosition.getY(), this.worldPosition.getZ()); -+ // if (block.getType() == org.bukkit.Material.AIR) return null; // Paper - actually get the tile entity if it still exists ++ org.bukkit.block.Block block = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); + org.bukkit.block.BlockState state = block.getState(useSnapshot); // Paper + return state instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null; + } @@ -125,4 +125,4 @@ + static class ComponentHelper { - public static final Codec COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY).codec(); + public static final MapCodec COMPONENTS_CODEC = DataComponentMap.CODEC.optionalFieldOf("components", DataComponentMap.EMPTY); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index f1b0523e9..7f8f12a52 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -1,14 +1,14 @@ --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -36,6 +_,7 @@ - public static final int NUM_DATA_VALUES = 2; +@@ -38,6 +_,7 @@ + private static final byte DEFAULT_FUEL = 0; private NonNullList items = NonNullList.withSize(5, ItemStack.EMPTY); public int brewTime; + public int recipeBrewTime = 400; // Paper - Add recipeBrewTime private boolean[] lastPotionCount; private Item ingredient; public int fuel; -@@ -45,6 +_,7 @@ +@@ -47,6 +_,7 @@ return switch (index) { case 0 -> BrewingStandBlockEntity.this.brewTime; case 1 -> BrewingStandBlockEntity.this.fuel; @@ -16,7 +16,7 @@ default -> 0; }; } -@@ -57,14 +_,49 @@ +@@ -59,14 +_,54 @@ break; case 1: BrewingStandBlockEntity.this.fuel = value; @@ -39,18 +39,22 @@ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } + ++ @Override + public java.util.List getContents() { + return this.items; + } @@ -60,6 +64,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } @@ -67,7 +72,7 @@ public BrewingStandBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.BREWING_STAND, pos, state); -@@ -93,8 +_,21 @@ +@@ -95,8 +_,21 @@ public static void serverTick(Level level, BlockPos pos, BlockState state, BrewingStandBlockEntity blockEntity) { ItemStack itemStack = blockEntity.items.get(4); if (blockEntity.fuel <= 0 && itemStack.is(ItemTags.BREWING_FUEL)) { @@ -91,7 +96,7 @@ setChanged(level, pos, state); } -@@ -105,7 +_,7 @@ +@@ -107,7 +_,7 @@ blockEntity.brewTime--; boolean flag1 = blockEntity.brewTime == 0; if (flag1 && isBrewable) { @@ -100,7 +105,7 @@ } else if (!isBrewable || !itemStack1.is(blockEntity.ingredient)) { blockEntity.brewTime = 0; } -@@ -113,7 +_,14 @@ +@@ -115,7 +_,14 @@ setChanged(level, pos, state); } else if (isBrewable && blockEntity.fuel > 0) { blockEntity.fuel--; @@ -116,7 +121,7 @@ blockEntity.ingredient = itemStack1.getItem(); setChanged(level, pos, state); } -@@ -164,13 +_,37 @@ +@@ -166,13 +_,37 @@ } } @@ -157,7 +162,7 @@ itemStack.shrink(1); ItemStack craftingRemainder = itemStack.getItem().getCraftingRemainder(); -@@ -209,13 +_,13 @@ +@@ -211,13 +_,13 @@ @Override public boolean canPlaceItem(int index, ItemStack stack) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch index b8231aa9e..6f3f6b65d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrushableBlockEntity.java.patch @@ -1,23 +1,16 @@ --- a/net/minecraft/world/level/block/entity/BrushableBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrushableBlockEntity.java -@@ -138,7 +_,10 @@ +@@ -139,7 +_,12 @@ double d5 = blockPos.getZ() + 0.5 * d1 + d2; ItemEntity itemEntity = new ItemEntity(level, d3, d4, d5, this.item.split(level.random.nextInt(21) + 10)); itemEntity.setDeltaMovement(Vec3.ZERO); - level.addFreshEntity(itemEntity); + // CraftBukkit start -+ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); -+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), (ServerPlayer) player, java.util.List.of(itemEntity)); ++ if (brusher instanceof final ServerPlayer serverPlayer) { ++ org.bukkit.block.Block bblock = org.bukkit.craftbukkit.block.CraftBlock.at(this.level, this.worldPosition); ++ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, bblock.getState(), serverPlayer, java.util.List.of(itemEntity)); ++ } + // CraftBukkit end this.item = ItemStack.EMPTY; } } -@@ -167,7 +_,7 @@ - - private boolean tryLoadLootTable(CompoundTag tag) { - if (tag.contains("LootTable", 8)) { -- this.lootTable = ResourceKey.create(Registries.LOOT_TABLE, ResourceLocation.parse(tag.getString("LootTable"))); -+ this.lootTable = net.minecraft.Optionull.map(ResourceLocation.tryParse(tag.getString("LootTable")), rl -> ResourceKey.create(Registries.LOOT_TABLE, rl)); // Paper - Validate ResourceLocation - this.lootTableSeed = tag.getLong("LootTableSeed"); - return true; - } else { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch index f9fd2a513..bf5891b2d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CampfireBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java -@@ -36,6 +_,7 @@ +@@ -38,6 +_,7 @@ private final NonNullList items = NonNullList.withSize(4, ItemStack.EMPTY); public final int[] cookingProgress = new int[4]; public final int[] cookingTime = new int[4]; @@ -8,7 +8,7 @@ public CampfireBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.CAMPFIRE, pos, blockState); -@@ -54,14 +_,44 @@ +@@ -56,14 +_,44 @@ ItemStack itemStack = campfire.items.get(i); if (!itemStack.isEmpty()) { flag = true; @@ -55,25 +55,24 @@ campfire.items.set(i, ItemStack.EMPTY); level.sendBlockUpdated(pos, state, state, 3); level.gameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Context.of(state)); -@@ -133,6 +_,17 @@ - int[] intArray = tag.getIntArray("CookingTotalTimes"); - System.arraycopy(intArray, 0, this.cookingTime, 0, Math.min(this.cookingTime.length, intArray.length)); - } +@@ -135,6 +_,16 @@ + .ifPresentOrElse( + ints -> System.arraycopy(ints, 0, this.cookingTime, 0, Math.min(this.cookingTime.length, ints.length)), () -> Arrays.fill(this.cookingTime, 0) + ); + + // Paper start - Add more Campfire API -+ if (tag.contains("Paper.StopCooking", org.bukkit.craftbukkit.util.CraftMagicNumbers.NBT.TAG_BYTE_ARRAY)) { -+ byte[] abyte = tag.getByteArray("Paper.StopCooking"); -+ boolean[] cookingState = new boolean[4]; -+ for (int index = 0; index < abyte.length; index++) { -+ cookingState[index] = abyte[index] == 1; ++ tag.getByteArray("Paper.StopCooking").ifPresent(bytes -> { ++ final boolean[] cookingState = new boolean[4]; ++ for (int index = 0; index < bytes.length; index++) { ++ cookingState[index] = bytes[index] == 1; + } -+ System.arraycopy(cookingState, 0, this.stopCooking, 0, Math.min(this.stopCooking.length, abyte.length)); -+ } ++ System.arraycopy(cookingState, 0, this.stopCooking, 0, Math.min(this.stopCooking.length, bytes.length)); ++ }); + // Paper end - Add more Campfire API } @Override -@@ -141,6 +_,13 @@ +@@ -143,6 +_,13 @@ ContainerHelper.saveAllItems(tag, this.items, true, registries); tag.putIntArray("CookingTimes", this.cookingProgress); tag.putIntArray("CookingTotalTimes", this.cookingTime); @@ -87,7 +86,7 @@ } @Override -@@ -165,7 +_,15 @@ +@@ -167,7 +_,15 @@ return false; } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch index b8ba6305b..4e48da1ba 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChestBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChestBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChestBlockEntity.java -@@ -56,6 +_,36 @@ +@@ -56,6 +_,40 @@ }; private final ChestLidController chestLidController = new ChestLidController(); @@ -8,18 +8,22 @@ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public java.util.List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch index 2c8981a4c..64e5d5890 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ChiseledBookShelfBlockEntity.java -@@ -27,6 +_,42 @@ +@@ -29,6 +_,42 @@ private final NonNullList items = NonNullList.withSize(6, ItemStack.EMPTY); public int lastInteractedSlot = -1; @@ -34,16 +34,16 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @javax.annotation.Nullable org.bukkit.Location getLocation() { + if (this.level == null) return null; -+ return io.papermc.paper.util.MCUtil.toLocation(this.level, this.worldPosition); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } + // CraftBukkit end + public ChiseledBookShelfBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.CHISELED_BOOKSHELF, pos, state); } -@@ -93,7 +_,7 @@ +@@ -95,7 +_,7 @@ ItemStack itemStack = Objects.requireNonNullElse(this.items.get(slot), ItemStack.EMPTY); this.items.set(slot, ItemStack.EMPTY); if (!itemStack.isEmpty()) { @@ -52,7 +52,7 @@ } return itemStack; -@@ -108,7 +_,7 @@ +@@ -110,7 +_,7 @@ public void setItem(int slot, ItemStack stack) { if (stack.is(ItemTags.BOOKSHELF_BOOKS)) { this.items.set(slot, stack); @@ -61,7 +61,7 @@ } else if (stack.isEmpty()) { this.removeItem(slot, 1); } -@@ -124,7 +_,7 @@ +@@ -126,7 +_,7 @@ @Override public int getMaxStackSize() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch index dca791d38..71493240e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CommandBlockEntity.java.patch @@ -1,8 +1,8 @@ --- a/net/minecraft/world/level/block/entity/CommandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CommandBlockEntity.java -@@ -21,6 +_,13 @@ - private boolean auto; - private boolean conditionMet; +@@ -25,6 +_,13 @@ + private boolean auto = false; + private boolean conditionMet = false; private final BaseCommandBlock commandBlock = new BaseCommandBlock() { + // CraftBukkit start + @Override @@ -14,7 +14,7 @@ @Override public void setCommand(String command) { super.setCommand(command); -@@ -51,7 +_,7 @@ +@@ -55,7 +_,7 @@ Vec3.atCenterOf(CommandBlockEntity.this.worldPosition), new Vec2(0.0F, direction.toYRot()), this.getLevel(), diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch index 226211f28..9dec42618 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ConduitBlockEntity.java.patch @@ -1,14 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ConduitBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ConduitBlockEntity.java -@@ -9,6 +_,7 @@ - import net.minecraft.core.particles.ParticleTypes; - import net.minecraft.nbt.CompoundTag; - import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -+import net.minecraft.server.level.ServerLevel; - import net.minecraft.sounds.SoundEvent; - import net.minecraft.sounds.SoundEvents; - import net.minecraft.sounds.SoundSource; -@@ -168,8 +_,20 @@ +@@ -165,8 +_,20 @@ } private static void applyEffects(Level level, BlockPos pos, List positions) { @@ -29,7 +21,7 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -178,13 +_,19 @@ +@@ -175,13 +_,19 @@ if (!entitiesOfClass.isEmpty()) { for (Player player : entitiesOfClass) { if (pos.closerThan(player.blockPosition(), i) && player.isInWaterOrRain()) { @@ -50,7 +42,7 @@ LivingEntity livingEntity = blockEntity.destroyTarget; int size = positions.size(); if (size < 42) { -@@ -203,7 +_,8 @@ +@@ -200,7 +_,8 @@ blockEntity.destroyTarget = null; } @@ -60,7 +52,7 @@ level.playSound( null, blockEntity.destroyTarget.getX(), -@@ -214,7 +_,6 @@ +@@ -211,7 +_,6 @@ 1.0F, 1.0F ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch index edc04acff..e181e72b4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/CrafterBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/CrafterBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CrafterBlockEntity.java -@@ -56,6 +_,47 @@ +@@ -58,6 +_,47 @@ } }; @@ -39,9 +39,9 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @javax.annotation.Nullable org.bukkit.Location getLocation() { + if (this.level == null) return null; -+ return io.papermc.paper.util.MCUtil.toLocation(this.level, this.worldPosition); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } + // CraftBukkit end + diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch index 8fc38f243..5d078a085 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DecoratedPotBlockEntity.java -@@ -20,6 +_,48 @@ +@@ -24,6 +_,48 @@ import net.minecraft.world.ticks.ContainerSingleItem; public class DecoratedPotBlockEntity extends BlockEntity implements RandomizableContainer, ContainerSingleItem.BlockContainerSingleItem { @@ -35,12 +35,12 @@ + } + + @Override -+ public void setMaxStackSize(int i) { -+ this.maxStack = i; ++ public void setMaxStackSize(int size) { ++ this.maxStack = size; + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + if (this.level == null) return null; + return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level.getWorld()); + } @@ -49,18 +49,18 @@ public static final String TAG_SHERDS = "sherds"; public static final String TAG_ITEM = "item"; public static final int EVENT_POT_WOBBLES = 1; -@@ -41,8 +_,8 @@ - protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { - super.saveAdditional(tag, registries); - this.decorations.save(tag); +@@ -48,8 +_,8 @@ + tag.store("sherds", PotDecorations.CODEC, this.decorations); + } + - if (!this.trySaveLootTable(tag) && !this.item.isEmpty()) { -- tag.put("item", this.item.save(registries)); +- tag.store("item", ItemStack.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.item); + if (!this.trySaveLootTable(tag) && !this.item.isEmpty()) { // Paper - diff on change - hide unnecessary update data -+ tag.put("item", this.item.save(registries)); // Paper - diff on change - hide unnecessary update data ++ tag.store("item", ItemStack.CODEC, registries.createSerializationContext(NbtOps.INSTANCE), this.item); // Paper - diff on change - hide unnecessary update data } } -@@ -66,7 +_,12 @@ +@@ -72,7 +_,14 @@ @Override public CompoundTag getUpdateTag(HolderLookup.Provider registries) { @@ -68,7 +68,9 @@ + // Paper start - hide unnecessary update data + // Like chests, decorated pots should not allow clients to inspect their contents without breaking them. + final CompoundTag compoundTag = new CompoundTag(); -+ this.decorations.save(compoundTag); ++ if (!this.decorations.equals(PotDecorations.EMPTY)) { ++ compoundTag.store("sherds", PotDecorations.CODEC, this.decorations); ++ } + return compoundTag; + // Paper end - hide unnecessary update data } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch index 1448e2338..9f1303b21 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/DispenserBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -@@ -17,6 +_,36 @@ +@@ -17,6 +_,41 @@ public static final int CONTAINER_SIZE = 9; private NonNullList items = NonNullList.withSize(9, ItemStack.EMPTY); @@ -8,18 +8,22 @@ + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public java.util.List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } @@ -29,6 +33,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch index f654073e2..4bac34fb3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/HopperBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -37,6 +_,37 @@ +@@ -38,6 +_,40 @@ private long tickedGameTime; private Direction facing; @@ -8,18 +8,22 @@ + public List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + ++ @Override + public List getContents() { + return this.items; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public java.util.List getViewers() { + return this.transaction; + } @@ -33,12 +37,11 @@ + this.maxStack = size; + } + // CraftBukkit end -+ + public HopperBlockEntity(BlockPos pos, BlockState blockState) { super(BlockEntityType.HOPPER, pos, blockState); this.facing = blockState.getValue(HopperBlock.FACING); -@@ -97,7 +_,14 @@ +@@ -98,7 +_,14 @@ blockEntity.tickedGameTime = level.getGameTime(); if (!blockEntity.isOnCooldown()) { blockEntity.setCooldown(0); @@ -54,7 +57,7 @@ } } -@@ -116,7 +_,7 @@ +@@ -117,7 +_,7 @@ } if (flag) { @@ -63,7 +66,7 @@ setChanged(level, pos, state); return true; } -@@ -149,14 +_,47 @@ +@@ -150,14 +_,47 @@ ItemStack item = blockEntity.getItem(i); if (!item.isEmpty()) { int count = item.getCount(); @@ -113,7 +116,7 @@ blockEntity.setItem(i, item); } } -@@ -219,7 +_,7 @@ +@@ -220,7 +_,7 @@ Direction direction = Direction.DOWN; for (int i : getSlots(sourceContainer, direction)) { @@ -122,7 +125,7 @@ return true; } } -@@ -239,18 +_,56 @@ +@@ -240,18 +_,56 @@ } } @@ -182,7 +185,7 @@ container.setItem(slot, item); } } -@@ -260,12 +_,20 @@ +@@ -261,12 +_,20 @@ public static boolean addItem(Container container, ItemEntity item) { boolean flag = false; @@ -204,7 +207,7 @@ } else { item.setItem(itemStack1); } -@@ -307,11 +_,18 @@ +@@ -308,11 +_,18 @@ boolean flag = false; boolean isEmpty = destination.isEmpty(); if (item.isEmpty()) { @@ -225,7 +228,7 @@ int min = Math.min(stack.getCount(), i); stack.shrink(min); item.grow(min); -@@ -325,7 +_,7 @@ +@@ -326,7 +_,7 @@ min = 1; } @@ -234,7 +237,7 @@ } destination.setChanged(); -@@ -335,14 +_,57 @@ +@@ -336,14 +_,57 @@ return stack; } @@ -281,9 +284,9 @@ + // CraftBukkit start + final Container inventory = HopperBlockEntity.getContainerAt(level, pos, state, hopper.getLevelX(), hopper.getLevelY() + 1.0D, hopper.getLevelZ()); + -+ final BlockPos blockPosition = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY(), hopper.getLevelZ()); -+ org.bukkit.craftbukkit.block.CraftBlock hopperBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPosition); -+ org.bukkit.craftbukkit.block.CraftBlock containerBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, blockPosition.above()); ++ final BlockPos hopperPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY(), hopper.getLevelZ()); ++ org.bukkit.craftbukkit.block.CraftBlock hopperBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, hopperPos); ++ org.bukkit.craftbukkit.block.CraftBlock containerBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, hopperPos.above()); + return HopperBlockEntity.runHopperInventorySearchEvent( + inventory, + hopperBlock, @@ -294,7 +297,7 @@ } public static List getItemsAtAndAbove(Level level, Hopper hopper) { -@@ -367,6 +_,7 @@ +@@ -368,6 +_,7 @@ @Nullable private static Container getBlockContainer(Level level, BlockPos pos, BlockState state) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch index a023b4d2e..b594c6775 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JigsawBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/JigsawBlockEntity.java +++ b/net/minecraft/world/level/block/entity/JigsawBlockEntity.java -@@ -131,7 +_,12 @@ +@@ -138,7 +_,12 @@ public void generate(ServerLevel level, int maxDepth, boolean keepJigsaws) { BlockPos blockPos = this.getBlockPos().relative(this.getBlockState().getValue(JigsawBlock.ORIENTATION).front()); Registry registry = level.registryAccess().lookupOrThrow(Registries.TEMPLATE_POOL); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch index 7ef85bb6b..4c24cff26 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/JukeboxBlockEntity.java -@@ -20,6 +_,44 @@ +@@ -23,6 +_,44 @@ import net.minecraft.world.ticks.ContainerSingleItem; public class JukeboxBlockEntity extends BlockEntity implements ContainerSingleItem.BlockContainerSingleItem { @@ -36,16 +36,16 @@ + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @javax.annotation.Nullable org.bukkit.Location getLocation() { + if (this.level == null) return null; -+ return io.papermc.paper.util.MCUtil.toLocation(this.level, this.worldPosition); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); + } + // CraftBukkit end + public static final String SONG_ITEM_TAG_ID = "RecordItem"; public static final String TICKS_SINCE_SONG_STARTED_TAG_ID = "ticks_since_song_started"; private ItemStack item = ItemStack.EMPTY; -@@ -126,7 +_,7 @@ +@@ -128,7 +_,7 @@ @Override public int getMaxStackSize() { @@ -54,7 +54,7 @@ } @Override -@@ -145,11 +_,16 @@ +@@ -152,11 +_,16 @@ } @VisibleForTesting diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch index d3be2ca42..a630a1986 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/LecternBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/LecternBlockEntity.java +++ b/net/minecraft/world/level/block/entity/LecternBlockEntity.java -@@ -32,7 +_,53 @@ +@@ -36,7 +_,53 @@ public static final int NUM_DATA = 1; public static final int SLOT_BOOK = 0; public static final int NUM_SLOTS = 1; @@ -32,14 +32,14 @@ + } + + @Override -+ public void setMaxStackSize(int i) { -+ this.maxStack = i; ++ public void setMaxStackSize(int size) { ++ this.maxStack = size; + } + + @Override -+ public org.bukkit.Location getLocation() { ++ public @Nullable org.bukkit.Location getLocation() { + if (LecternBlockEntity.this.level == null) return null; -+ return io.papermc.paper.util.MCUtil.toLocation(LecternBlockEntity.this.level, LecternBlockEntity.this.worldPosition); ++ return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(LecternBlockEntity.this.worldPosition, LecternBlockEntity.this.level); + } + + @Override @@ -55,7 +55,7 @@ @Override public int getContainerSize() { return 1; -@@ -76,11 +_,19 @@ +@@ -80,11 +_,19 @@ @Override public void setItem(int slot, ItemStack stack) { @@ -76,7 +76,7 @@ } @Override -@@ -158,7 +_,7 @@ +@@ -162,7 +_,7 @@ if (i != this.page) { this.page = i; this.setChanged(); @@ -85,7 +85,7 @@ } } -@@ -179,6 +_,36 @@ +@@ -183,6 +_,36 @@ return stack; } @@ -122,7 +122,7 @@ private CommandSourceStack createCommandSourceStack(@Nullable Player player, ServerLevel level) { String string; Component component; -@@ -191,7 +_,7 @@ +@@ -195,7 +_,7 @@ } Vec3 vec3 = Vec3.atCenterOf(this.worldPosition); @@ -131,7 +131,7 @@ } @Override -@@ -223,7 +_,7 @@ +@@ -237,7 +_,7 @@ @Override public AbstractContainerMenu createMenu(int containerId, Inventory playerInventory, Player player) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch index cb89a7e6d..e5ce59bb8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java -@@ -115,4 +_,13 @@ +@@ -116,4 +_,13 @@ tag.remove("LootTable"); tag.remove("LootTableSeed"); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch index 1f46bbe4d..f6e656549 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java.patch @@ -1,34 +1,27 @@ --- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java -@@ -26,6 +_,7 @@ +@@ -24,6 +_,7 @@ private final VibrationSystem.Listener vibrationListener; - private final VibrationSystem.User vibrationUser = this.createVibrationUser(); - public int lastVibrationFrequency; + private final VibrationSystem.User vibrationUser; + public int lastVibrationFrequency = 0; + @Nullable public Integer rangeOverride = null; // Paper - Configurable sculk sensor listener range protected SculkSensorBlockEntity(BlockEntityType type, BlockPos pos, BlockState blockState) { super(type, pos, blockState); -@@ -52,8 +_,16 @@ - .resultOrPartial(string -> LOGGER.error("Failed to parse vibration listener for Sculk Sensor: '{}'", string)) - .ifPresent(data -> this.vibrationData = data); - } -+ // Paper start - Configurable sculk sensor listener range -+ if (tag.contains(PAPER_LISTENER_RANGE_NBT_KEY)) { -+ this.rangeOverride = tag.getInt(PAPER_LISTENER_RANGE_NBT_KEY); -+ } else { -+ this.rangeOverride = null; -+ } -+ // Paper end - Configurable sculk sensor listener range +@@ -46,15 +_,23 @@ + this.lastVibrationFrequency = tag.getIntOr("last_vibration_frequency", 0); + RegistryOps registryOps = registries.createSerializationContext(NbtOps.INSTANCE); + this.vibrationData = tag.read("listener", VibrationSystem.Data.CODEC, registryOps).orElseGet(VibrationSystem.Data::new); ++ this.rangeOverride = tag.getInt(PAPER_LISTENER_RANGE_NBT_KEY).orElse(null); // Paper start - Configurable sculk sensor listener range } + protected static final String PAPER_LISTENER_RANGE_NBT_KEY = "Paper.ListenerRange"; // Paper - Configurable sculk sensor listener range @Override protected void saveAdditional(CompoundTag tag, HolderLookup.Provider registries) { super.saveAdditional(tag, registries); -@@ -63,7 +_,13 @@ - .encodeStart(registryOps, this.vibrationData) - .resultOrPartial(string -> LOGGER.error("Failed to encode vibration listener for Sculk Sensor: '{}'", string)) - .ifPresent(tag1 -> tag.put("listener", tag1)); + tag.putInt("last_vibration_frequency", this.lastVibrationFrequency); + RegistryOps registryOps = registries.createSerializationContext(NbtOps.INSTANCE); + tag.store("listener", VibrationSystem.Data.CODEC, registryOps, this.vibrationData); - } + this.saveRangeOverride(tag); // Paper - Configurable sculk sensor listener range + } @@ -40,7 +33,7 @@ @Override public VibrationSystem.Data getVibrationData() { -@@ -100,6 +_,7 @@ +@@ -91,6 +_,7 @@ @Override public int getListenerRadius() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch index f6de07965..ad2ef7f8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkShriekerBlockEntity.java -@@ -105,6 +_,13 @@ +@@ -91,6 +_,13 @@ @Nullable public static ServerPlayer tryGetPlayer(@Nullable Entity entity) { -+ // Paper start - check global player list where appropriate; ensure level is the same for sculk events ++ // Paper start - check global player list where appropriate; ensure level is the same for sculk events + final ServerPlayer player = tryGetPlayer0(entity); + return player != null && player.level() == entity.level() ? player : null; + } + @Nullable + private static ServerPlayer tryGetPlayer0(@Nullable Entity entity) { -+ // Paper end - check global player list where appropriate - if (entity instanceof ServerPlayer) { - return (ServerPlayer)entity; - } else { -@@ -190,7 +_,7 @@ ++ // Paper end - check global player list where appropriate + if (entity instanceof ServerPlayer serverPlayer) { + return serverPlayer; + } else if (entity != null && entity.getControllingPassenger() instanceof ServerPlayer serverPlayer) { +@@ -166,7 +_,7 @@ private boolean trySummonWarden(ServerLevel level) { return this.warningLevel >= 4 && SpawnUtil.trySpawnMob( diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch index dba115b26..43985579a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -49,6 +_,37 @@ +@@ -49,6 +_,42 @@ @Nullable private final DyeColor color; @@ -9,18 +9,22 @@ + private int maxStack = MAX_STACK; + public boolean opened; + ++ @Override + public List getContents() { + return this.itemStacks; + } + ++ @Override + public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.add(player); + } + ++ @Override + public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) { + this.transaction.remove(player); + } + ++ @Override + public List getViewers() { + return this.transaction; + } @@ -30,6 +34,7 @@ + return this.maxStack; + } + ++ @Override + public void setMaxStackSize(int size) { + this.maxStack = size; + } @@ -38,7 +43,7 @@ public ShulkerBoxBlockEntity(@Nullable DyeColor color, BlockPos pos, BlockState blockState) { super(BlockEntityType.SHULKER_BOX, pos, blockState); this.color = color; -@@ -167,6 +_,7 @@ +@@ -171,6 +_,7 @@ } this.openCount++; @@ -46,7 +51,7 @@ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); if (this.openCount == 1) { this.level.gameEvent(player, GameEvent.CONTAINER_OPEN, this.worldPosition); -@@ -180,6 +_,7 @@ +@@ -184,6 +_,7 @@ public void stopOpen(Player player) { if (!this.remove && !player.isSpectator()) { this.openCount--; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch index 13adcff53..b03a8a8c6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SignBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SignBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SignBlockEntity.java -@@ -55,10 +_,15 @@ +@@ -58,10 +_,15 @@ } public boolean isFacingFrontText(Player player) { @@ -18,7 +18,7 @@ float yRotationDegrees = signBlock.getYRotationDegrees(this.getBlockState()); float f = (float)(Mth.atan2(d1, d) * 180.0F / (float)Math.PI) - 90.0F; return Mth.degreesDifferenceAbs(yRotationDegrees, f) <= 90.0F; -@@ -143,11 +_,13 @@ +@@ -131,11 +_,13 @@ public void updateSignText(Player player, boolean isFrontText, List filteredText) { if (!this.isWaxed() && player.getUUID().equals(this.getPlayerWhoMayEdit()) && this.level != null) { @@ -33,7 +33,7 @@ } } -@@ -156,18 +_,40 @@ +@@ -144,18 +_,40 @@ return this.setText(updater.apply(text), isFrontText); } @@ -77,13 +77,15 @@ return text; } -@@ -207,7 +_,23 @@ +@@ -193,8 +_,24 @@ + + for (Component component : this.getText(frontText).getMessages(player.isTextFilteringEnabled())) { Style style = component.getStyle(); - ClickEvent clickEvent = style.getClickEvent(); - if (clickEvent != null && clickEvent.getAction() == ClickEvent.Action.RUN_COMMAND) { -- player.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(player, level, pos), clickEvent.getValue()); +- if (style.getClickEvent() instanceof ClickEvent.RunCommand(String var14)) { +- player.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(player, level, pos), var14); ++ if (style.getClickEvent() instanceof ClickEvent.RunCommand(String var14)) { final String runCommand = var14; // Paper - OBFHELPER + // Paper start - Fix commands from signs not firing command events -+ String command = clickEvent.getValue().startsWith("/") ? clickEvent.getValue() : "/" + clickEvent.getValue(); ++ String command = runCommand.startsWith("/") ? runCommand : "/" + runCommand; + if (org.spigotmc.SpigotConfig.logCommands) { + LOGGER.info("{} issued server command: {}", player.getScoreboardName(), command); + } @@ -97,12 +99,12 @@ + if (!event.callEvent()) { + return false; + } -+ player.getServer().getCommands().performPrefixedCommand(this.createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), level, pos), event.getMessage()); ++ player.getServer().getCommands().performPrefixedCommand(createCommandSourceStack(((org.bukkit.craftbukkit.entity.CraftPlayer) event.getPlayer()).getHandle(), level, pos), event.getMessage()); + // Paper end - Fix commands from signs not firing command events flag = true; } } -@@ -215,10 +_,55 @@ +@@ -202,10 +_,55 @@ return flag; } @@ -160,7 +162,7 @@ } @Override -@@ -237,12 +_,17 @@ +@@ -224,12 +_,17 @@ @Nullable public UUID getPlayerWhoMayEdit() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch index 89553e4e2..9e047d5b5 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/SkullBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/SkullBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SkullBlockEntity.java -@@ -41,7 +_,7 @@ +@@ -40,7 +_,7 @@ @Nullable private static LoadingCache>> profileCacheByName; @Nullable @@ -9,7 +9,7 @@ public static final Executor CHECKED_MAIN_THREAD_EXECUTOR = runnable -> { Executor executor = mainThreadExecutor; if (executor != null) { -@@ -76,9 +_,9 @@ +@@ -75,9 +_,9 @@ profileCacheById = CacheBuilder.newBuilder() .expireAfterAccess(Duration.ofMinutes(10L)) .maximumSize(256L) @@ -21,7 +21,7 @@ return SkullBlockEntity.fetchProfileById(id, services, booleanSupplier); } }); -@@ -89,23 +_,29 @@ +@@ -88,23 +_,29 @@ .getAsync(name) .thenCompose( optional -> { @@ -56,7 +56,7 @@ } public static void clear() { -@@ -210,9 +_,11 @@ +@@ -188,9 +_,11 @@ : CompletableFuture.completedFuture(Optional.empty()); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch new file mode 100644 index 000000000..82324d9d1 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestBlockEntity.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/level/block/entity/TestBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TestBlockEntity.java +@@ -36,6 +_,7 @@ + + @Override + public void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { ++ super.loadAdditional(tag, registries); // Paper - load the PDC + this.mode = tag.read("mode", TestBlockMode.CODEC).orElse(TestBlockMode.FAIL); + this.message = tag.getStringOr("message", ""); + this.powered = tag.getBooleanOr("powered", false); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch new file mode 100644 index 000000000..ee7a1ecc7 --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java.patch @@ -0,0 +1,19 @@ +--- a/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java ++++ b/net/minecraft/world/level/block/entity/TestInstanceBlockEntity.java +@@ -157,6 +_,7 @@ + + @Override + protected void loadAdditional(CompoundTag tag, HolderLookup.Provider registries) { ++ super.loadAdditional(tag, registries); // Paper - load the PDC + Tag tag1 = tag.get("data"); + if (tag1 != null) { + TestInstanceBlockEntity.Data.CODEC.parse(NbtOps.INSTANCE, tag1).ifSuccess(this::set); +@@ -320,7 +_,7 @@ + } + + private void removeEntities() { +- this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach(Entity::discard); ++ this.level.getEntities(null, this.getStructureBounds()).stream().filter(entity -> !(entity instanceof Player)).forEach((entity) -> entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DISCARD)); // Paper + } + + private void forceLoadChunks() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch index 09f5bd372..7c9a9bdfb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java +++ b/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java -@@ -131,7 +_,7 @@ +@@ -129,7 +_,7 @@ @Nullable public Vec3 getPortalPosition(ServerLevel level, BlockPos pos) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch index 52a66eabe..1a32ca900 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java.patch @@ -1,22 +1,22 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawner.java -@@ -237,7 +_,14 @@ - nextSpawnData.getEquipment().ifPresent(mob::equip); - } +@@ -238,7 +_,14 @@ + nextSpawnData.getEquipment().ifPresent(mob::equip); + } -- if (!level.tryAddFreshEntityWithPassengers(entity)) { -+ entity.spawnedViaMobSpawner = true; // Paper -+ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER; // Paper - Entity#getEntitySpawnReason -+ // CraftBukkit start -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, pos).isCancelled()) { -+ return Optional.empty(); -+ } -+ if (!level.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) { -+ // CraftBukkit end - return Optional.empty(); - } else { - TrialSpawner.FlameParticle flameParticle = this.isOminous -@@ -260,6 +_,19 @@ +- if (!level.tryAddFreshEntityWithPassengers(entity)) { ++ // Paper start - TrialSpawnerSpawnEvent + SpawnReason ++ entity.spawnedViaMobSpawner = true; // Mark entity as spawned via spawner ++ entity.spawnReason = org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER; // Paper - Entity#getEntitySpawnReason ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callTrialSpawnerSpawnEvent(entity, pos).isCancelled()) { ++ return Optional.empty(); ++ } ++ if (!level.tryAddFreshEntityWithPassengers(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRIAL_SPAWNER)) { ++ // Paper end - TrialSpawnerSpawnEvent + SpawnReason + return Optional.empty(); + } else { + TrialSpawner.FlameParticle flameParticle = this.isOminous ? TrialSpawner.FlameParticle.OMINOUS : TrialSpawner.FlameParticle.NORMAL; +@@ -258,6 +_,19 @@ LootParams lootParams = new LootParams.Builder(level).create(LootContextParamSets.EMPTY); ObjectArrayList randomItems = lootTable1.getRandomItems(lootParams); if (!randomItems.isEmpty()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch index b1ff9e67b..b8359650d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java +++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java -@@ -206,7 +_,7 @@ +@@ -197,7 +_,7 @@ mob.dropPreservedEquipment(level); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch index 055a081be..a84630639 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java +++ b/net/minecraft/world/level/block/entity/vault/VaultBlockEntity.java -@@ -272,6 +_,11 @@ +@@ -260,6 +_,11 @@ if (!list.isEmpty()) { player.awardStat(Stats.ITEM_USED.get(stack.getItem())); stack.consume(config.keyItem().getCount(), player); @@ -12,7 +12,7 @@ unlock(level, state, pos, config, serverData, sharedData, list); serverData.addToRewardedPlayers(player); sharedData.updateConnectedPlayersWithinRange(level, pos, serverData, config, config.deactivationRange()); -@@ -294,6 +_,11 @@ +@@ -282,6 +_,11 @@ ItemStack randomDisplayItemFromLootTable = getRandomDisplayItemFromLootTable( level, pos, config.overrideLootTableToDisplay().orElse(config.lootTable()) ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch index 4447be70e..3b7f68bd0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/vault/VaultServerData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/entity/vault/VaultServerData.java +++ b/net/minecraft/world/level/block/entity/vault/VaultServerData.java -@@ -66,7 +_,12 @@ +@@ -62,7 +_,12 @@ @VisibleForTesting public void addToRewardedPlayers(Player player) { @@ -14,7 +14,7 @@ if (this.rewardedPlayers.size() > 128) { Iterator iterator = this.rewardedPlayers.iterator(); if (iterator.hasNext()) { -@@ -76,6 +_,7 @@ +@@ -72,6 +_,7 @@ } this.markChanged(); @@ -22,7 +22,7 @@ } public long stateUpdatingResumesAt() { -@@ -131,4 +_,15 @@ +@@ -127,4 +_,15 @@ public float ejectionProgress() { return this.totalEjectionsNeeded == 1 ? 1.0F : 1.0F - Mth.inverseLerp((float)this.getItemsToEject().size(), 1.0F, (float)this.totalEjectionsNeeded); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch index c4316b4d6..90872ab8d 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/grower/TreeGrower.java.patch @@ -15,63 +15,62 @@ + this.setTreeType(holder1); // CraftBukkit ConfiguredFeature configuredFeature2 = holder1.value(); BlockState blockState1 = level.getFluidState(pos).createLegacyBlock(); - level.setBlock(pos, blockState1, 4); -@@ -198,4 +_,59 @@ + level.setBlock(pos, blockState1, 260); +@@ -198,4 +_,58 @@ return false; } + + // CraftBukkit start -+ private void setTreeType(Holder> holder) { -+ ResourceKey> treeFeature = holder.unwrapKey().get(); -+ if (treeFeature == TreeFeatures.OAK || treeFeature == TreeFeatures.OAK_BEES_005) { ++ private void setTreeType(Holder> feature) { ++ if (feature.is(TreeFeatures.OAK) || feature.is(TreeFeatures.OAK_BEES_005)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TREE; -+ } else if (treeFeature == TreeFeatures.HUGE_RED_MUSHROOM) { ++ } else if (feature.is(TreeFeatures.HUGE_RED_MUSHROOM)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.RED_MUSHROOM; -+ } else if (treeFeature == TreeFeatures.HUGE_BROWN_MUSHROOM) { ++ } else if (feature.is(TreeFeatures.HUGE_BROWN_MUSHROOM)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BROWN_MUSHROOM; -+ } else if (treeFeature == TreeFeatures.JUNGLE_TREE) { ++ } else if (feature.is(TreeFeatures.JUNGLE_TREE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.COCOA_TREE; -+ } else if (treeFeature == TreeFeatures.JUNGLE_TREE_NO_VINE) { ++ } else if (feature.is(TreeFeatures.JUNGLE_TREE_NO_VINE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SMALL_JUNGLE; -+ } else if (treeFeature == TreeFeatures.PINE) { ++ } else if (feature.is(TreeFeatures.PINE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_REDWOOD; -+ } else if (treeFeature == TreeFeatures.SPRUCE) { ++ } else if (feature.is(TreeFeatures.SPRUCE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.REDWOOD; -+ } else if (treeFeature == TreeFeatures.ACACIA) { ++ } else if (feature.is(TreeFeatures.ACACIA)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.ACACIA; -+ } else if (treeFeature == TreeFeatures.BIRCH || treeFeature == TreeFeatures.BIRCH_BEES_005) { ++ } else if (feature.is(TreeFeatures.BIRCH) || feature.is(TreeFeatures.BIRCH_BEES_005)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIRCH; -+ } else if (treeFeature == TreeFeatures.SUPER_BIRCH_BEES_0002) { ++ } else if (feature.is(TreeFeatures.SUPER_BIRCH_BEES_0002)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_BIRCH; -+ } else if (treeFeature == TreeFeatures.SWAMP_OAK) { ++ } else if (feature.is(TreeFeatures.SWAMP_OAK)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.SWAMP; -+ } else if (treeFeature == TreeFeatures.FANCY_OAK || treeFeature == TreeFeatures.FANCY_OAK_BEES_005) { ++ } else if (feature.is(TreeFeatures.FANCY_OAK) || feature.is(TreeFeatures.FANCY_OAK_BEES_005)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.BIG_TREE; -+ } else if (treeFeature == TreeFeatures.JUNGLE_BUSH) { ++ } else if (feature.is(TreeFeatures.JUNGLE_BUSH)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE_BUSH; -+ } else if (treeFeature == TreeFeatures.DARK_OAK) { ++ } else if (feature.is(TreeFeatures.DARK_OAK)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.DARK_OAK; -+ } else if (treeFeature == TreeFeatures.MEGA_SPRUCE) { ++ } else if (feature.is(TreeFeatures.MEGA_SPRUCE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_REDWOOD; -+ } else if (treeFeature == TreeFeatures.MEGA_PINE) { ++ } else if (feature.is(TreeFeatures.MEGA_PINE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MEGA_PINE; -+ } else if (treeFeature == TreeFeatures.MEGA_JUNGLE_TREE) { ++ } else if (feature.is(TreeFeatures.MEGA_JUNGLE_TREE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.JUNGLE; -+ } else if (treeFeature == TreeFeatures.AZALEA_TREE) { ++ } else if (feature.is(TreeFeatures.AZALEA_TREE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.AZALEA; -+ } else if (treeFeature == TreeFeatures.MANGROVE) { ++ } else if (feature.is(TreeFeatures.MANGROVE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.MANGROVE; -+ } else if (treeFeature == TreeFeatures.TALL_MANGROVE) { ++ } else if (feature.is(TreeFeatures.TALL_MANGROVE)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.TALL_MANGROVE; -+ } else if (treeFeature == TreeFeatures.CHERRY || treeFeature == TreeFeatures.CHERRY_BEES_005) { ++ } else if (feature.is(TreeFeatures.CHERRY) || feature.is(TreeFeatures.CHERRY_BEES_005)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.CHERRY; -+ } else if (treeFeature == TreeFeatures.PALE_OAK || treeFeature == TreeFeatures.PALE_OAK_BONEMEAL) { ++ } else if (feature.is(TreeFeatures.PALE_OAK) || feature.is(TreeFeatures.PALE_OAK_BONEMEAL)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.PALE_OAK; -+ } else if (treeFeature == TreeFeatures.PALE_OAK_CREAKING) { ++ } else if (feature.is(TreeFeatures.PALE_OAK_CREAKING)) { + net.minecraft.world.level.block.SaplingBlock.treeType = org.bukkit.TreeType.PALE_OAK_CREAKING; + } else { -+ throw new IllegalArgumentException("Unknown tree generator " + treeFeature); ++ throw new IllegalArgumentException("Unknown tree generator " + feature); + } + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch index bf7c9d9fe..aec5fcce3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonBaseBlock.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -174,6 +_,12 @@ +@@ -151,6 +_,12 @@ @Override protected boolean triggerEvent(BlockState state, Level level, BlockPos pos, int id, int param) { Direction direction = state.getValue(FACING); @@ -10,10 +10,10 @@ + return false; + } + // Paper end - Protect Bedrock and End Portal/Frames from being destroyed - BlockState blockState = state.setValue(EXTENDED, Boolean.valueOf(true)); + BlockState blockState = state.setValue(EXTENDED, true); if (!level.isClientSide) { boolean neighborSignal = this.getNeighborSignal(level, pos, direction); -@@ -205,10 +_,17 @@ +@@ -182,10 +_,17 @@ .defaultBlockState() .setValue(MovingPistonBlock.FACING, direction) .setValue(MovingPistonBlock.TYPE, this.isSticky ? PistonType.STICKY : PistonType.DEFAULT); @@ -24,15 +24,15 @@ + } + } + // Paper end - Fix sticky pistons and BlockPistonRetractEvent - level.setBlock(pos, blockState1, 20); + level.setBlock(pos, blockState1, 276); level.setBlockEntity( MovingPistonBlock.newMovingBlockEntity( - pos, blockState1, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(param & 7)), direction, false, true + pos, blockState1, this.defaultBlockState().setValue(FACING, Direction.from3DDataValue(param & 7)), direction, false, true // Paper - Protect Bedrock and End Portal/Frames from being destroyed; diff on change ) ); - level.blockUpdated(pos, blockState1.getBlock()); -@@ -232,13 +_,27 @@ + level.updateNeighborsAt(pos, blockState1.getBlock()); +@@ -209,13 +_,27 @@ || blockState2.getPistonPushReaction() != PushReaction.NORMAL && !blockState2.is(Blocks.PISTON) && !blockState2.is(Blocks.STICKY_PISTON)) { @@ -52,7 +52,7 @@ - level.removeBlock(pos.relative(direction), false); + // Paper start - Protect Bedrock and End Portal/Frames from being destroyed; fix headless pistons breaking blocks + BlockPos headPos = pos.relative(direction); -+ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits || level.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, direction)) { // double check to make sure we're not a headless piston. ++ if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPermanentBlockBreakExploits || level.getBlockState(headPos) == Blocks.PISTON_HEAD.defaultBlockState().setValue(FACING, direction)) { // double check to make sure we're not a headless piston + level.removeBlock(headPos, false); + } else { + ((ServerLevel) level).getChunkSource().blockChanged(headPos); // ... fix client desync @@ -61,7 +61,7 @@ } level.playSound(null, pos, SoundEvents.PISTON_CONTRACT, SoundSource.BLOCKS, 0.5F, level.random.nextFloat() * 0.15F + 0.6F); -@@ -249,7 +_,7 @@ +@@ -226,7 +_,7 @@ } public static boolean isPushable(BlockState state, Level level, BlockPos pos, Direction movementDirection, boolean allowDestroy, Direction pistonFacing) { @@ -70,12 +70,12 @@ return false; } else if (state.isAir()) { return true; -@@ -305,12 +_,54 @@ +@@ -282,12 +_,54 @@ BlockState[] blockStates = new BlockState[toPush.size() + toDestroy.size()]; Direction direction = extending ? facing : facing.getOpposite(); int i = 0; + // CraftBukkit start -+ final org.bukkit.block.Block bblock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ final org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + + final List moved = pistonStructureResolver.getToPush(); + final List broken = pistonStructureResolver.getToDestroy(); @@ -92,26 +92,26 @@ + if (index >= this.size() || index < 0) { + throw new ArrayIndexOutOfBoundsException(index); + } ++ + BlockPos pos = index < moved.size() ? moved.get(index) : broken.get(index - moved.size()); -+ return bblock.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ return org.bukkit.craftbukkit.block.CraftBlock.at(level, pos); + } + }; -+ org.bukkit.event.block.BlockPistonEvent event; -+ if (extending) { -+ event = new org.bukkit.event.block.BlockPistonExtendEvent(bblock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); -+ } else { -+ event = new org.bukkit.event.block.BlockPistonRetractEvent(bblock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); -+ } -+ level.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ for (BlockPos b : broken) { -+ level.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), level.getBlockState(b), 3); ++ final org.bukkit.event.block.BlockPistonEvent event; ++ if (extending) { ++ event = new org.bukkit.event.block.BlockPistonExtendEvent(bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); ++ } else { ++ event = new org.bukkit.event.block.BlockPistonRetractEvent(bukkitBlock, blocks, org.bukkit.craftbukkit.block.CraftBlock.notchToBlockFace(direction)); ++ } ++ if (!event.callEvent()) { ++ for (BlockPos brokenPos : broken) { ++ level.sendBlockUpdated(brokenPos, Blocks.AIR.defaultBlockState(), level.getBlockState(brokenPos), Block.UPDATE_ALL); + } -+ for (BlockPos b : moved) { -+ level.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), level.getBlockState(b), 3); -+ b = b.relative(direction); -+ level.sendBlockUpdated(b, Blocks.AIR.defaultBlockState(), level.getBlockState(b), 3); ++ for (BlockPos movedPos : moved) { ++ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); ++ movedPos = movedPos.relative(direction); ++ level.sendBlockUpdated(movedPos, Blocks.AIR.defaultBlockState(), level.getBlockState(movedPos), Block.UPDATE_ALL); + } + return false; + } @@ -123,10 +123,10 @@ BlockEntity blockEntity = blockState1.hasBlockEntity() ? level.getBlockEntity(blockPos2) : null; - dropResources(blockState1, level, blockPos2, blockEntity); + dropResources(blockState1, level, blockPos2, blockEntity, pos); // Paper - Add BlockBreakBlockEvent - level.setBlock(blockPos2, Blocks.AIR.defaultBlockState(), 18); - level.gameEvent(GameEvent.BLOCK_DESTROY, blockPos2, GameEvent.Context.of(blockState1)); - if (!blockState1.is(BlockTags.FIRE)) { -@@ -321,13 +_,26 @@ + if (!blockState1.is(BlockTags.FIRE) && level.isClientSide()) { + level.levelEvent(2001, blockPos2, getId(blockState1)); + } +@@ -298,13 +_,26 @@ } for (int i1 = toPush.size() - 1; i1 >= 0; i1--) { @@ -141,7 +141,7 @@ blockPos2 = blockPos2.relative(direction); map.remove(blockPos2); BlockState blockState2 = Blocks.MOVING_PISTON.defaultBlockState().setValue(FACING, facing); - level.setBlock(blockPos2, blockState2, 68); + level.setBlock(blockPos2, blockState2, 324); - level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, list.get(i1), facing, extending, false)); + // Paper start - fix a variety of piston desync dupes + if (!allowDesync) { @@ -150,7 +150,7 @@ + } + level.setBlockEntity(MovingPistonBlock.newMovingBlockEntity(blockPos2, blockState2, allowDesync ? list.get(i1) : blockState1, facing, extending, false)); + if (!allowDesync) { -+ level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | 1024); // set air to prevent later physics updates from seeing this block ++ level.setBlock(oldPos, Blocks.AIR.defaultBlockState(), Block.UPDATE_CLIENTS | Block.UPDATE_KNOWN_SHAPE | Block.UPDATE_MOVE_BY_PISTON | Block.UPDATE_SKIP_ON_PLACE); // set air to prevent later physics updates from seeing this block + } + // Paper end - fix a variety of piston desync dupes blockStates[i++] = blockState1; diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch index afaa13a66..7eeba3cf9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java.patch @@ -1,20 +1,20 @@ --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -35,7 +_,7 @@ - private static final double PUSH_OFFSET = 0.01; - public static final double TICK_MOVEMENT = 0.51; - private BlockState movedState = Blocks.AIR.defaultBlockState(); +@@ -39,7 +_,7 @@ + private static final boolean DEFAULT_EXTENDING = false; + private static final boolean DEFAULT_SOURCE = false; + private BlockState movedState = DEFAULT_BLOCK_STATE; - private Direction direction; + private Direction direction = Direction.DOWN; // Paper - default to first value to avoid NPE - private boolean extending; - private boolean isSourcePiston; + private boolean extending = false; + private boolean isSourcePiston = false; private static final ThreadLocal NOCLIP = ThreadLocal.withInitial(() -> null); -@@ -299,7 +_,7 @@ +@@ -310,7 +_,7 @@ if (level.getBlockState(pos).is(Blocks.MOVING_PISTON)) { BlockState blockState = Block.updateFromNeighbourShapes(blockEntity.movedState, level, pos); if (blockState.isAir()) { -- level.setBlock(pos, blockEntity.movedState, 84); -+ level.setBlock(pos, blockEntity.movedState, io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication ? 84 : (84 | Block.UPDATE_CLIENTS)); // Paper - fix a variety of piston desync dupes; force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air +- level.setBlock(pos, blockEntity.movedState, 340); ++ level.setBlock(pos, blockEntity.movedState, io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowPistonDuplication ? 340 : (340 | Block.UPDATE_CLIENTS)); // Paper - fix a variety of piston desync dupes; force notify (flag 2), it's possible the set type by the piston block (which doesn't notify) set this block to air Block.updateOrDestroy(blockEntity.movedState, blockState, level, pos, 3); } else { if (blockState.hasProperty(BlockStateProperties.WATERLOGGED) && blockState.getValue(BlockStateProperties.WATERLOGGED)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch index f9c4ef45c..2cb6e4913 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/state/BlockBehaviour.java.patch @@ -1,33 +1,28 @@ --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -167,16 +_,24 @@ +@@ -168,13 +_,20 @@ } protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { -- } + org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot -+ } -+ + } + + protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { + } + + // CraftBukkit start + protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston, @Nullable net.minecraft.world.item.context.UseOnContext context) { + this.onPlace(state, level, pos, oldState, movedByPiston); + } + // CraftBukkit end - - protected void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean movedByPiston) { -+ org.spigotmc.AsyncCatcher.catchOp("block remove"); // Spigot - if (state.hasBlockEntity() && !state.is(newState.getBlock())) { - level.removeBlockEntity(pos); - } - } - ++ protected void onExplosionHit(BlockState state, ServerLevel level, BlockPos pos, Explosion explosion, BiConsumer dropConsumer) { - if (!state.isAir() && explosion.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK) { + if (!state.isAir() && explosion.getBlockInteraction() != Explosion.BlockInteraction.TRIGGER_BLOCK && state.isDestroyable()) { // Paper - Protect Bedrock and End Portal/Frames from being destroyed Block block = state.getBlock(); boolean flag = explosion.getIndirectSourceEntity() instanceof Player; if (block.dropFromExplosion(explosion)) { -@@ -186,8 +_,10 @@ +@@ -184,8 +_,10 @@ .withParameter(LootContextParams.TOOL, ItemStack.EMPTY) .withOptionalParameter(LootContextParams.BLOCK_ENTITY, blockEntity) .withOptionalParameter(LootContextParams.THIS_ENTITY, explosion.getDirectSourceEntity()); @@ -40,7 +35,7 @@ } state.spawnAfterBreak(level, pos, ItemStack.EMPTY, flag); -@@ -255,7 +_,7 @@ +@@ -253,7 +_,7 @@ } protected boolean canBeReplaced(BlockState state, BlockPlaceContext useContext) { @@ -49,7 +44,7 @@ } protected boolean canBeReplaced(BlockState state, Fluid fluid) { -@@ -468,6 +_,16 @@ +@@ -466,6 +_,16 @@ this.instrument = properties.instrument; this.replaceable = properties.replaceable; } @@ -66,7 +61,7 @@ private boolean calculateSolid() { if (this.owner.properties.forceSolidOn) { -@@ -487,12 +_,14 @@ +@@ -485,12 +_,14 @@ } } @@ -81,7 +76,7 @@ this.legacySolid = this.calculateSolid(); this.occlusionShape = this.canOcclude ? this.owner.getOcclusionShape(this.asState()) : Shapes.empty(); -@@ -531,6 +_,11 @@ +@@ -529,6 +_,11 @@ public boolean isSolid() { return this.legacySolid; } @@ -93,7 +88,7 @@ public boolean isValidSpawn(BlockGetter level, BlockPos pos, EntityType entityType) { return this.getBlock().properties.isValidSpawn.test(this.asState(), level, pos, entityType); -@@ -552,19 +_,19 @@ +@@ -550,19 +_,19 @@ return this.occlusionShape; } @@ -118,7 +113,7 @@ return this.isAir; } -@@ -634,14 +_,14 @@ +@@ -632,14 +_,14 @@ } public PushReaction getPistonPushReaction() { @@ -135,7 +130,7 @@ return this.canOcclude; } -@@ -725,7 +_,13 @@ +@@ -727,7 +_,13 @@ } public void onPlace(Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { @@ -149,8 +144,8 @@ + // CraftBukkit end } - public void onRemove(Level level, BlockPos pos, BlockState newState, boolean movedByPiston) { -@@ -754,6 +_,7 @@ + public void affectNeighborsAfterRemoval(ServerLevel level, BlockPos pos, boolean movedByPiston) { +@@ -752,6 +_,7 @@ public void spawnAfterBreak(ServerLevel level, BlockPos pos, ItemStack stack, boolean dropExperience) { this.getBlock().spawnAfterBreak(this.asState(), level, pos, stack, dropExperience); @@ -158,7 +153,7 @@ } public List getDrops(LootParams.Builder lootParams) { -@@ -858,11 +_,11 @@ +@@ -856,11 +_,11 @@ return this.getBlock().builtInRegistryHolder().is(block); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch index a7a605709..b61033289 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/border/WorldBorder.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/border/WorldBorder.java +++ b/net/minecraft/world/level/border/WorldBorder.java -@@ -28,6 +_,7 @@ +@@ -31,6 +_,7 @@ int absoluteMaxSize = 29999984; private WorldBorder.BorderExtent extent = new WorldBorder.StaticBorderExtent(5.999997E7F); public static final WorldBorder.Settings DEFAULT_SETTINGS = new WorldBorder.Settings(0.0, 0.0, 0.2, 5.0, 5, 15, 5.999997E7F, 0L, 0.0); @@ -8,7 +8,7 @@ public boolean isWithinBounds(BlockPos pos) { return this.isWithinBounds(pos.getX(), pos.getZ()); -@@ -41,6 +_,20 @@ +@@ -44,6 +_,20 @@ return this.isWithinBounds(chunkPos.getMinBlockX(), chunkPos.getMinBlockZ()) && this.isWithinBounds(chunkPos.getMaxBlockX(), chunkPos.getMaxBlockZ()); } @@ -29,7 +29,7 @@ public boolean isWithinBounds(AABB box) { return this.isWithinBounds(box.minX, box.minZ, box.maxX - 1.0E-5F, box.maxZ - 1.0E-5F); } -@@ -129,6 +_,14 @@ +@@ -142,6 +_,14 @@ } public void setCenter(double x, double z) { @@ -44,7 +44,7 @@ this.centerX = x; this.centerZ = z; this.extent.onCenterChange(); -@@ -151,6 +_,17 @@ +@@ -164,6 +_,17 @@ } public void setSize(double size) { @@ -62,7 +62,7 @@ this.extent = new WorldBorder.StaticBorderExtent(size); for (BorderChangeListener borderChangeListener : this.getListeners()) { -@@ -159,6 +_,20 @@ +@@ -172,6 +_,20 @@ } public void lerpSizeBetween(double oldSize, double newSize, long time) { @@ -83,7 +83,7 @@ this.extent = (WorldBorder.BorderExtent)(oldSize == newSize ? new WorldBorder.StaticBorderExtent(newSize) : new WorldBorder.MovingBorderExtent(oldSize, newSize, time)); -@@ -173,6 +_,7 @@ +@@ -186,6 +_,7 @@ } public void addListener(BorderChangeListener listener) { @@ -91,7 +91,7 @@ this.listeners.add(listener); } -@@ -369,6 +_,7 @@ +@@ -385,6 +_,7 @@ @Override public WorldBorder.BorderExtent update() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch index f20d2cd0c..9b18db1f7 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkAccess.java.patch @@ -39,15 +39,16 @@ } private static void replaceMissingSections(Registry biomeRegistry, LevelChunkSection[] sections) { -@@ -123,6 +_,7 @@ +@@ -123,6 +_,8 @@ return GameEventListenerRegistry.NOOP; } + public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper ++ @Nullable - public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving); - -@@ -273,6 +_,7 @@ + public BlockState setBlockState(BlockPos pos, BlockState state) { + return this.setBlockState(pos, state, 3); +@@ -278,6 +_,7 @@ public boolean tryMarkSaved() { if (this.unsaved) { this.unsaved = false; @@ -55,7 +56,7 @@ return true; } else { return false; -@@ -280,7 +_,7 @@ +@@ -285,7 +_,7 @@ } public boolean isUnsaved() { @@ -64,7 +65,7 @@ } public abstract ChunkStatus getPersistedStatus(); -@@ -446,6 +_,22 @@ +@@ -451,6 +_,22 @@ throw new ReportedException(crashReport); } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch index b2e3cf186..ef6b8c7fa 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ChunkGenerator.java.patch @@ -17,7 +17,7 @@ ) { + // Paper start - StructuresLocateEvent + final org.bukkit.World bukkitWorld = level.getWorld(); -+ final org.bukkit.Location origin = io.papermc.paper.util.MCUtil.toLocation(level, pos); ++ final org.bukkit.Location origin = org.bukkit.craftbukkit.util.CraftLocation.toBukkit(pos, level); + final List apiStructures = structure.stream().map(Holder::value).map(nms -> org.bukkit.craftbukkit.generator.structure.CraftStructure.minecraftToBukkit(nms)).toList(); + if (!apiStructures.isEmpty()) { + final io.papermc.paper.event.world.StructuresLocateEvent event = new io.papermc.paper.event.world.StructuresLocateEvent(bukkitWorld, origin, apiStructures, searchRadius, skipKnownStructures); @@ -27,7 +27,7 @@ + if (event.getResult() != null) { + return Pair.of(io.papermc.paper.util.MCUtil.toBlockPos(event.getResult().pos()), level.registryAccess().lookupOrThrow(Registries.STRUCTURE).wrapAsHolder(org.bukkit.craftbukkit.generator.structure.CraftStructure.bukkitToMinecraft(event.getResult().structure()))); + } -+ pos = io.papermc.paper.util.MCUtil.toBlockPosition(event.getOrigin()); ++ pos = org.bukkit.craftbukkit.util.CraftLocation.toBlockPosition(event.getOrigin()); + searchRadius = event.getRadius(); + skipKnownStructures = event.shouldFindUnexplored(); + structure = HolderSet.direct(api -> level.registryAccess().lookupOrThrow(Registries.STRUCTURE).wrapAsHolder(org.bukkit.craftbukkit.generator.structure.CraftStructure.bukkitToMinecraft(api)), event.getStructures()); @@ -36,7 +36,7 @@ ChunkGeneratorStructureState generatorState = level.getChunkSource().getGeneratorState(); Map>> map = new Object2ObjectArrayMap<>(); -@@ -222,6 +_,7 @@ +@@ -221,6 +_,7 @@ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); for (ChunkPos chunkPos : ringPositionsFor) { @@ -44,7 +44,7 @@ mutableBlockPos.set(SectionPos.sectionToBlockCoord(chunkPos.x, 8), 32, SectionPos.sectionToBlockCoord(chunkPos.z, 8)); double d1 = mutableBlockPos.distSqr(pos); boolean flag = pair == null || d1 < d; -@@ -255,11 +_,15 @@ +@@ -254,11 +_,15 @@ int spacing = spreadPlacement.spacing(); for (int i = -z; i <= z; i++) { @@ -64,7 +64,7 @@ int i2 = x + spacing * i; int i3 = y + spacing * i1; ChunkPos potentialStructureChunk = spreadPlacement.getPotentialStructureChunk(seed, i2, i3); -@@ -312,7 +_,7 @@ +@@ -311,7 +_,7 @@ } } @@ -73,7 +73,7 @@ ChunkPos pos = chunk.getPos(); if (!SharedConstants.debugVoidTerrain(pos)) { SectionPos sectionPos = SectionPos.of(pos, level.getMinSectionY()); -@@ -385,7 +_,14 @@ +@@ -382,7 +_,14 @@ int i3 = ints[i2]; PlacedFeature placedFeature = stepFeatureData1.features().get(i3); Supplier supplier1 = () -> registry1.getResourceKey(placedFeature).map(Object::toString).orElseGet(placedFeature::toString); @@ -89,7 +89,7 @@ try { level.setCurrentlyGenerating(supplier1); -@@ -407,6 +_,32 @@ +@@ -404,6 +_,32 @@ } } } @@ -122,7 +122,7 @@ private static BoundingBox getWritableArea(ChunkAccess chunk) { ChunkPos pos = chunk.getPos(); -@@ -483,7 +_,7 @@ +@@ -478,7 +_,7 @@ } } @@ -131,7 +131,7 @@ if (list.size() == 1) { this.tryGenerateStructure( list.get(0), -@@ -577,6 +_,14 @@ +@@ -572,6 +_,14 @@ predicate ); if (structureStart.isValid()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch index a67013f5f..44b507e43 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/EmptyLevelChunk.java.patch @@ -1,15 +1,16 @@ --- a/net/minecraft/world/level/chunk/EmptyLevelChunk.java +++ b/net/minecraft/world/level/chunk/EmptyLevelChunk.java -@@ -25,6 +_,12 @@ - public BlockState getBlockState(BlockPos pos) { +@@ -26,6 +_,13 @@ return Blocks.VOID_AIR.defaultBlockState(); } + + // Paper start + @Override + public BlockState getBlockState(final int x, final int y, final int z) { + return Blocks.VOID_AIR.defaultBlockState(); + } + // Paper end - ++ @Nullable @Override + public BlockState setBlockState(BlockPos pos, BlockState state, int flags) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch index da521db81..72ad1f9a1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ImposterProtoChunk.java.patch @@ -1,15 +1,16 @@ --- a/net/minecraft/world/level/chunk/ImposterProtoChunk.java +++ b/net/minecraft/world/level/chunk/ImposterProtoChunk.java -@@ -56,6 +_,12 @@ - public BlockState getBlockState(BlockPos pos) { +@@ -57,6 +_,13 @@ return this.wrapped.getBlockState(pos); } + + // Paper start + @Override + public final BlockState getBlockState(final int x, final int y, final int z) { + return this.wrapped.getBlockStateFinal(x, y, z); + } + // Paper end - ++ @Override public FluidState getFluidState(BlockPos pos) { + return this.wrapped.getFluidState(pos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch index 29f06860a..f6a2d24db 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunk.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -76,7 +_,7 @@ +@@ -77,7 +_,7 @@ }; private final Map tickersInLevel = Maps.newHashMap(); public boolean loaded; @@ -9,7 +9,7 @@ @Nullable private Supplier fullStatus; @Nullable -@@ -85,6 +_,14 @@ +@@ -86,6 +_,14 @@ private final LevelChunkTicks blockTicks; private final LevelChunkTicks fluidTicks; private LevelChunk.UnsavedListener unsavedListener = chunkPos -> {}; @@ -24,7 +24,7 @@ public LevelChunk(Level level, ChunkPos pos) { this(level, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, null, null, null); -@@ -102,7 +_,7 @@ +@@ -103,7 +_,7 @@ @Nullable BlendingData blendingData ) { super(pos, data, level, level.registryAccess().lookupOrThrow(Registries.BIOME), inhabitedTime, sections, blendingData); @@ -33,7 +33,7 @@ this.gameEventListenerRegistrySections = new Int2ObjectOpenHashMap<>(); for (Heightmap.Types types : Heightmap.Types.values()) { -@@ -154,6 +_,10 @@ +@@ -155,6 +_,10 @@ this.skyLightSources = chunk.skyLightSources; this.setLightCorrect(chunk.isLightCorrect()); this.markUnsaved(); @@ -44,7 +44,7 @@ } public void setUnsavedListener(LevelChunk.UnsavedListener unsavedListener) { -@@ -162,6 +_,12 @@ +@@ -163,6 +_,12 @@ unsavedListener.setUnsaved(this.chunkPos); } } @@ -57,14 +57,16 @@ @Override public void markUnsaved() { -@@ -195,8 +_,25 @@ +@@ -196,8 +_,28 @@ : super.getListenerRegistry(sectionY); } + // Paper start - Perf: Reduce instructions and provide final method ++ @Override + public BlockState getBlockState(final int x, final int y, final int z) { + return this.getBlockStateFinal(x, y, z); + } ++ + public BlockState getBlockStateFinal(final int x, final int y, final int z) { + // Copied and modified from below + final int sectionIndex = this.getSectionIndex(y); @@ -74,6 +76,7 @@ + } + return this.sections[sectionIndex].states.get((y & 15) << 8 | (z & 15) << 4 | x & 15); + } ++ @Override public BlockState getBlockState(BlockPos pos) { + if (true) { @@ -83,19 +86,19 @@ int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); -@@ -231,33 +_,54 @@ +@@ -232,28 +_,42 @@ } } + // Paper start - If loaded util + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { -+ return this.getFluidState(blockposition); ++ public final FluidState getFluidIfLoaded(BlockPos pos) { ++ return this.getFluidState(pos); + } + + @Override -+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { -+ return this.getBlockState(blockposition); ++ public final BlockState getBlockStateIfLoaded(BlockPos pos) { ++ return this.getBlockState(pos); + } + // Paper end + @@ -128,37 +131,16 @@ } @Nullable - @Override - public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving) { -+// CraftBukkit start -+ return this.setBlockState(pos, state, isMoving, true); -+ } -+ -+ @Nullable -+ public BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving, boolean doPlace) { -+ // CraftBukkit end - int y = pos.getY(); - LevelChunkSection section = this.getSection(this.getSectionIndex(y)); - boolean hasOnlyAir = section.hasOnlyAir(); -@@ -292,7 +_,7 @@ - } - - boolean hasBlockEntity = blockState.hasBlockEntity(); -- if (!this.level.isClientSide) { -+ if (!this.level.isClientSide && !this.level.isBlockPlaceCancelled) { // Paper - prevent calling cleanup logic when undoing a block place upon a cancelled BlockPlaceEvent - blockState.onRemove(this.level, pos, state, isMoving); - } else if (!blockState.is(block) && hasBlockEntity) { - this.removeBlockEntity(pos); -@@ -301,7 +_,7 @@ +@@ -313,7 +_,7 @@ if (!section.getBlockState(i, i1, i2).is(block)) { return null; } else { -- if (!this.level.isClientSide) { -+ if (!this.level.isClientSide && doPlace && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. - state.onPlace(this.level, pos, blockState, isMoving); +- if (!this.level.isClientSide && (flags & 512) == 0) { ++ if (!this.level.isClientSide && (flags & 512) == 0 && (!this.level.captureBlockStates || block instanceof net.minecraft.world.level.block.BaseEntityBlock)) { // CraftBukkit - Don't place while processing the BlockPlaceEvent, unless it's a BlockContainer. Prevents blocks such as TNT from activating when cancelled. + state.onPlace(this.level, pos, blockState, flag1); } -@@ -355,7 +_,12 @@ +@@ -367,7 +_,12 @@ @Nullable public BlockEntity getBlockEntity(BlockPos pos, LevelChunk.EntityCreationType creationType) { @@ -172,7 +154,7 @@ if (blockEntity == null) { CompoundTag compoundTag = this.pendingBlockEntities.remove(pos); if (compoundTag != null) { -@@ -409,7 +_,13 @@ +@@ -421,7 +_,13 @@ BlockPos blockPos = blockEntity.getBlockPos(); BlockState blockState = this.getBlockState(blockPos); if (!blockState.hasBlockEntity()) { @@ -187,7 +169,7 @@ } else { BlockState blockState1 = blockEntity.getBlockState(); if (blockState != blockState1) { -@@ -457,6 +_,11 @@ +@@ -469,6 +_,11 @@ public void removeBlockEntity(BlockPos pos) { if (this.isInLevel()) { BlockEntity blockEntity = this.blockEntities.remove(pos); @@ -199,7 +181,7 @@ if (blockEntity != null) { if (this.level instanceof ServerLevel serverLevel) { this.removeGameEventListener(blockEntity, serverLevel); -@@ -499,6 +_,65 @@ +@@ -511,6 +_,65 @@ } } @@ -265,7 +247,7 @@ public boolean isEmpty() { return false; } -@@ -711,23 +_,24 @@ +@@ -719,23 +_,24 @@ if (this.blockEntity.getType().isValid(blockState)) { this.ticker.tick(LevelChunk.this.level, this.blockEntity.getBlockPos(), blockState, this.blockEntity); this.loggedInvalidBlockState = false; diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch index 96c848d7c..b81fe5114 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/LevelChunkSection.java.patch @@ -28,7 +28,7 @@ public FluidState getFluidState(int x, int y, int z) { - return this.states.get(x, y, z).getFluidState(); -+ return this.states.get(x, y, z).getFluidState(); // Paper - Perf: Optimise Chunk#getFluid; diff on change - we expect this to be effectively just getType(x, y, z).getFluid(). If this changes we need to check other patches that use IBlockData#getFluid. ++ return this.states.get(x, y, z).getFluidState(); // Paper - Perf: Optimise LevelChunk#getFluidState; diff on change - we expect this to be effectively just get(x, y, z).getFluidState(). If this changes we need to check other patches that use BlockBehaviour#getFluidState. } public void acquire() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch index d0111479a..e3d51ebf1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/ProtoChunk.java.patch @@ -1,18 +1,18 @@ --- a/net/minecraft/world/level/chunk/ProtoChunk.java +++ b/net/minecraft/world/level/chunk/ProtoChunk.java -@@ -85,14 +_,32 @@ +@@ -85,14 +_,33 @@ return new ChunkAccess.PackedTicks(this.blockTicks.pack(gametime), this.fluidTicks.pack(gametime)); } + // Paper start - If loaded util + @Override -+ public final FluidState getFluidIfLoaded(BlockPos blockposition) { -+ return this.getFluidState(blockposition); ++ public final FluidState getFluidIfLoaded(BlockPos pos) { ++ return this.getFluidState(pos); + } + + @Override -+ public final BlockState getBlockStateIfLoaded(BlockPos blockposition) { -+ return this.getBlockState(blockposition); ++ public final BlockState getBlockStateIfLoaded(BlockPos pos) { ++ return this.getBlockState(pos); + } + // Paper end + @@ -20,8 +20,9 @@ public BlockState getBlockState(BlockPos pos) { - int y = pos.getY(); + // Paper start -+ return getBlockState(pos.getX(), pos.getY(), pos.getZ()); ++ return this.getBlockState(pos.getX(), pos.getY(), pos.getZ()); + } ++ + public BlockState getBlockState(final int x, final int y, final int z) { + // Paper end if (this.isOutsideBuildHeight(y)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/UpgradeData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/UpgradeData.java.patch index 8628e64dd..e11eae4bb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/UpgradeData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/UpgradeData.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/chunk/UpgradeData.java +++ b/net/minecraft/world/level/chunk/UpgradeData.java -@@ -113,6 +_,24 @@ +@@ -87,6 +_,25 @@ } } @@ -22,10 +22,11 @@ + } + } + // Paper end - filter out relocated neighbour ticks ++ public void upgrade(LevelChunk chunk) { this.upgradeInside(chunk); -@@ -120,6 +_,10 @@ +@@ -94,6 +_,10 @@ upgradeSides(chunk, direction8); } @@ -34,13 +35,13 @@ + filterTickList(chunk.locX, chunk.locZ, this.neighborFluidTicks); + // Paper end - filter out relocated neighbour ticks Level level = chunk.getLevel(); - this.neighborBlockTicks.forEach(blockTicker -> { - Block block = blockTicker.type() == Blocks.AIR ? level.getBlockState(blockTicker.pos()).getBlock() : blockTicker.type(); -@@ -129,6 +_,7 @@ - Fluid fluid = fluidTicker.type() == Fluids.EMPTY ? level.getFluidState(fluidTicker.pos()).getType() : fluidTicker.type(); - level.scheduleTick(fluidTicker.pos(), fluid, fluidTicker.delay(), fluidTicker.priority()); + this.neighborBlockTicks.forEach(savedTick -> { + Block block = savedTick.type() == Blocks.AIR ? level.getBlockState(savedTick.pos()).getBlock() : savedTick.type(); +@@ -103,6 +_,7 @@ + Fluid fluid = savedTick.type() == Fluids.EMPTY ? level.getFluidState(savedTick.pos()).getType() : savedTick.type(); + level.scheduleTick(savedTick.pos(), fluid, savedTick.delay(), savedTick.priority()); }); + UpgradeData.BlockFixers.values(); // Paper - force the class init so that we don't access CHUNKY_FIXERS before all BlockFixers are initialised - CHUNKY_FIXERS.forEach(fixers -> fixers.processChunk(level)); + CHUNKY_FIXERS.forEach(blockFixer -> blockFixer.processChunk(level)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch index 30e279c28..4f624eb72 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/status/ChunkStatusTasks.java.patch @@ -9,12 +9,9 @@ worldGenContext.generator() .createStructures( serverLevel.registryAccess(), -@@ -196,9 +_,60 @@ - }, worldGenContext.mainThreadExecutor()); - } +@@ -198,7 +_,58 @@ -- private static void postLoadProtoChunk(ServerLevel level, List entityTags) { -+ public static void postLoadProtoChunk(ServerLevel level, List entityTags) { // Paper - public + public static void postLoadProtoChunk(ServerLevel level, List entityTags) { if (!entityTags.isEmpty()) { - level.addWorldGenChunkEntities(EntityType.loadEntitiesRecursive(entityTags, level, EntitySpawnReason.LOAD)); - } diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch index 666d4d9cb..239c1f8ff 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/ChunkStorage.java.patch @@ -23,8 +23,8 @@ try { + // CraftBukkit start + if (version < 1466) { -+ CompoundTag level = chunkData.getCompound("Level"); -+ if (level.getBoolean("TerrainPopulated") && !level.getBoolean("LightPopulated")) { ++ CompoundTag level = chunkData.getCompoundOrEmpty("Level"); ++ if (level.getBooleanOr("TerrainPopulated", false) && !level.getBooleanOr("LightPopulated", false)) { + // Light is purged updating to 1.14+. We need to set light populated to true so the converter recognizes the chunk as being "full" + level.putBoolean("LightPopulated", true); + } @@ -32,7 +32,7 @@ + // CraftBukkit end if (version < 1493) { chunkData = DataFixTypes.CHUNK.update(this.fixerUpper, chunkData, version, 1493); - if (chunkData.getCompound("Level").getBoolean("hasLegacyStructureData")) { + if (chunkData.getCompound("Level").flatMap(compoundTag -> compoundTag.getBoolean("hasLegacyStructureData")).orElse(false)) { @@ -57,8 +_,22 @@ } } @@ -42,7 +42,7 @@ + boolean belowZeroGenerationInExistingChunks = (levelAccessor != null) ? ((net.minecraft.server.level.ServerLevel) levelAccessor).spigotConfig.belowZeroGenerationInExistingChunks : org.spigotmc.SpigotConfig.belowZeroGenerationInExistingChunks; + + if (version <= 2730 && !belowZeroGenerationInExistingChunks) { -+ stopBelowZero = "full".equals(chunkData.getCompound("Level").getString("Status")); ++ stopBelowZero = "full".equals(chunkData.getCompound("Level").flatMap(l -> l.getString("Status")).orElse(null)); + } + // Spigot end + diff --git a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch index 5461001e9..be691f9e8 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/chunk/storage/SerializableChunkData.java.patch @@ -8,7 +8,7 @@ ) { public static final Codec> BLOCK_STATE_CODEC = PalettedContainer.codecRW( Block.BLOCK_STATE_REGISTRY, BlockState.CODEC, PalettedContainer.Strategy.SECTION_STATES, Blocks.AIR.defaultBlockState() -@@ -107,12 +_,39 @@ +@@ -109,12 +_,38 @@ public static final String BLOCK_LIGHT_TAG = "BlockLight"; public static final String SKY_LIGHT_TAG = "SkyLight"; @@ -17,10 +17,10 @@ + public static ChunkPos getChunkCoordinate(final CompoundTag chunkData) { + final int dataVersion = ChunkStorage.getVersion(chunkData); + if (dataVersion < 2842) { // Level tag is removed after this version -+ final CompoundTag levelData = chunkData.getCompound("Level"); -+ return new ChunkPos(levelData.getInt("xPos"), levelData.getInt("zPos")); ++ final CompoundTag levelData = chunkData.getCompoundOrEmpty("Level"); ++ return new ChunkPos(levelData.getIntOr("xPos", 0), levelData.getIntOr("zPos", 0)); + } else { -+ return new ChunkPos(chunkData.getInt("xPos"), chunkData.getInt("zPos")); ++ return new ChunkPos(chunkData.getIntOr("xPos", 0), chunkData.getIntOr("zPos", 0)); + } + } + // Paper end - guard against serializing mismatching coordinates @@ -32,50 +32,49 @@ + @Nullable public static SerializableChunkData parse(LevelHeightAccessor levelHeightAccessor, RegistryAccess registries, CompoundTag tag) { - if (!tag.contains("Status", 8)) { + if (tag.getString("Status").isEmpty()) { return null; } else { -- ChunkPos chunkPos = new ChunkPos(tag.getInt("xPos"), tag.getInt("zPos")); +- ChunkPos chunkPos = new ChunkPos(tag.getIntOr("xPos", 0), tag.getIntOr("zPos", 0)); + // Paper start - Do not let the server load chunks from newer versions -+ if (tag.contains("DataVersion", net.minecraft.nbt.Tag.TAG_ANY_NUMERIC)) { -+ final int dataVersion = tag.getInt("DataVersion"); ++ tag.getInt("DataVersion").ifPresent(dataVersion -> { + if (!JUST_CORRUPT_IT && dataVersion > CURRENT_DATA_VERSION) { + new RuntimeException("Server attempted to load chunk saved with newer version of minecraft! " + dataVersion + " > " + CURRENT_DATA_VERSION).printStackTrace(); + System.exit(1); + } -+ } ++ }); + // Paper end - Do not let the server load chunks from newer versions -+ ChunkPos chunkPos = new ChunkPos(tag.getInt("xPos"), tag.getInt("zPos")); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate - long _long = tag.getLong("LastUpdate"); - long _long1 = tag.getLong("InhabitedTime"); - ChunkStatus chunkStatus = ChunkStatus.byName(tag.getString("Status")); -@@ -181,7 +_,7 @@ - ListTag list7 = tag.getList("sections", 10); - List list8 = new ArrayList<>(list7.size()); ++ ChunkPos chunkPos = new ChunkPos(tag.getIntOr("xPos", 0), tag.getIntOr("zPos", 0)); // Paper - guard against serializing mismatching coordinates; diff on change, see ChunkSerializer#getChunkCoordinate + long longOr = tag.getLongOr("LastUpdate", 0L); + long longOr1 = tag.getLongOr("InhabitedTime", 0L); + ChunkStatus chunkStatus = tag.read("Status", ChunkStatus.CODEC).orElse(ChunkStatus.EMPTY); +@@ -154,7 +_,7 @@ + ListTag listOrEmpty2 = tag.getListOrEmpty("sections"); + List list5 = new ArrayList<>(listOrEmpty2.size()); Registry registry = registries.lookupOrThrow(Registries.BIOME); - Codec>> codec = makeBiomeCodec(registry); + Codec>> codec = makeBiomeCodecRW(registry); // CraftBukkit - read/write - for (int i2 = 0; i2 < list7.size(); i2++) { - CompoundTag compound2 = list7.getCompound(i2); -@@ -199,7 +_,7 @@ - ); - } - -- PalettedContainerRO> palettedContainerRo; -+ PalettedContainer> palettedContainerRo; // CraftBukkit - read/write - if (compound2.contains("biomes", 10)) { - palettedContainerRo = codec.parse(NbtOps.INSTANCE, compound2.getCompound("biomes")) - .promotePartial(string -> logErrors(chunkPos, _byte, string)) -@@ -239,6 +_,7 @@ - list5, - list6, - compound1 + for (int i2 = 0; i2 < listOrEmpty2.size(); i2++) { + Optional compound = listOrEmpty2.getCompound(i2); +@@ -174,7 +_,7 @@ + Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES + ) + ); +- PalettedContainerRO> palettedContainerRo = compoundTag.getCompound("biomes") ++ PalettedContainer> palettedContainerRo = compoundTag.getCompound("biomes") // CraftBukkit - read/write + .map( + compoundTag1 -> codec.parse(NbtOps.INSTANCE, compoundTag1) + .promotePartial(string -> logErrors(chunkPos, byteOr, string)) +@@ -215,6 +_,7 @@ + list3, + list4, + compoundOrEmpty + , tag.get("ChunkBukkitValues") // CraftBukkit - ChunkBukkitValues ); } } -@@ -316,6 +_,12 @@ +@@ -292,6 +_,12 @@ } } @@ -88,21 +87,7 @@ chunkAccess.setLightCorrect(this.lightCorrect); EnumSet set = EnumSet.noneOf(Heightmap.Types.class); -@@ -346,6 +_,13 @@ - } - - for (CompoundTag compoundTag : this.blockEntities) { -+ // Paper start - do not read tile entities positioned outside the chunk -+ final BlockPos blockposition = BlockEntity.getPosFromTag(compoundTag); -+ if ((blockposition.getX() >> 4) != this.chunkPos.x || (blockposition.getZ() >> 4) != this.chunkPos.z) { -+ LOGGER.warn("Tile entity serialized in chunk {} in world '{}' positioned at {} is located outside of the chunk", this.chunkPos, level.getWorld().getName(), blockposition); -+ continue; -+ } -+ // Paper end - do not read tile entities positioned outside the chunk - protoChunk1.setBlockEntityNbt(compoundTag); - } - -@@ -370,6 +_,12 @@ +@@ -346,6 +_,12 @@ ); } @@ -115,7 +100,7 @@ public static SerializableChunkData copyOf(ServerLevel level, ChunkAccess chunk) { if (!chunk.canBeSerialized()) { throw new IllegalArgumentException("Chunk can't be serialized: " + chunk); -@@ -428,6 +_,12 @@ +@@ -404,6 +_,12 @@ CompoundTag compoundTag = packStructureData( StructurePieceSerializationContext.fromLevel(level), pos, chunk.getAllStarts(), chunk.getAllReferences() ); @@ -128,7 +113,7 @@ return new SerializableChunkData( level.registryAccess().lookupOrThrow(Registries.BIOME), pos, -@@ -447,6 +_,7 @@ +@@ -423,6 +_,7 @@ list2, list1, compoundTag @@ -136,7 +121,7 @@ ); } } -@@ -525,6 +_,11 @@ +@@ -489,6 +_,11 @@ this.heightmaps.forEach((types, longs) -> compoundTag2.put(types.getSerializationKey(), new LongArrayTag(longs))); compoundTag.put("Heightmaps", compoundTag2); compoundTag.put("structures", this.structureData); @@ -148,26 +133,12 @@ return compoundTag; } -@@ -562,6 +_,13 @@ - chunk.setBlockEntityNbt(compoundTag); - } else { - BlockPos posFromTag = BlockEntity.getPosFromTag(compoundTag); -+ // Paper start - do not read tile entities positioned outside the chunk -+ ChunkPos chunkPos = chunk.getPos(); -+ if ((posFromTag.getX() >> 4) != chunkPos.x || (posFromTag.getZ() >> 4) != chunkPos.z) { -+ LOGGER.warn("Tile entity serialized in chunk " + chunkPos + " in world '" + level.getWorld().getName() + "' positioned at " + posFromTag + " is located outside of the chunk"); -+ continue; -+ } -+ // Paper end - do not read tile entities positioned outside the chunk - BlockEntity blockEntity = BlockEntity.loadStatic(posFromTag, chunk.getBlockState(posFromTag), compoundTag, level.registryAccess()); - if (blockEntity != null) { - chunk.setBlockEntity(blockEntity); -@@ -610,6 +_,12 @@ +@@ -562,6 +_,12 @@ } else { - StructureStart structureStart = StructureStart.loadStaticStart(context, compound.getCompound(string), seed); + StructureStart structureStart = StructureStart.loadStaticStart(context, compoundOrEmpty.getCompoundOrEmpty(string), seed); if (structureStart != null) { + // CraftBukkit start - load persistent data for structure start -+ net.minecraft.nbt.Tag persistentBase = compound.getCompound(string).get("StructureBukkitValues"); ++ net.minecraft.nbt.Tag persistentBase = compoundOrEmpty.getCompoundOrEmpty(string).get("StructureBukkitValues"); + if (persistentBase instanceof CompoundTag compoundTag) { + structureStart.persistentDataContainer.putAll(compoundTag); + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch index c1082899a..5b405ca4a 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/dimension/end/EndDragonFight.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -70,8 +_,9 @@ +@@ -69,8 +_,9 @@ private static final int GATEWAY_DISTANCE = 96; public static final int DRAGON_SPAWN_Y = 128; private final Predicate validPlayer; @@ -11,7 +11,7 @@ ) .setPlayBossMusic(true) .setCreateWorldFog(true); -@@ -112,7 +_,12 @@ +@@ -111,7 +_,12 @@ if (data.isRespawning) { this.respawnStage = DragonRespawnAnimation.START; } @@ -25,7 +25,7 @@ this.portalLocation = data.exitPortalLocation.orElse(null); this.gateways.addAll(data.gateways.orElseGet(() -> { ObjectArrayList list = new ObjectArrayList<>(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers())); -@@ -209,9 +_,9 @@ +@@ -208,9 +_,9 @@ this.dragonUUID = enderDragon.getUUID(); LOGGER.info("Found that there's a dragon still alive ({})", enderDragon); this.dragonKilled = false; @@ -37,7 +37,7 @@ this.dragonUUID = null; } } -@@ -366,12 +_,22 @@ +@@ -365,12 +_,22 @@ this.dragonEvent.setVisible(false); this.spawnExitPortal(true); this.spawnNewGateway(); @@ -61,12 +61,12 @@ + eggEvent.setCancelled(true); + } + if (eggEvent.callEvent()) { -+ eggEvent.getNewState().update(true); ++ ((org.bukkit.craftbukkit.block.CraftBlockState) eggEvent.getNewState()).place(3); + // Paper end - Add DragonEggFormEvent } this.previouslyKilled = true; -@@ -385,6 +_,24 @@ +@@ -384,6 +_,24 @@ this.gateways.clear(); } @@ -91,8 +91,8 @@ private void spawnNewGateway() { if (!this.gateways.isEmpty()) { int i = this.gateways.remove(this.gateways.size() - 1); -@@ -413,6 +_,11 @@ - } +@@ -414,6 +_,11 @@ + this.portalLocation = this.portalLocation.atY(Math.max(this.level.getMinY() + 1, this.portalLocation.getY())); } + // Paper start - Prevent "softlocked" exit portal generation @@ -103,15 +103,15 @@ if (endPodiumFeature.place( FeatureConfiguration.NONE, this.level, this.level.getChunkSource().getGenerator(), RandomSource.create(), this.portalLocation )) { -@@ -432,6 +_,7 @@ - enderDragon.moveTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F); +@@ -433,6 +_,7 @@ + enderDragon.snapTo(this.origin.getX(), 128 + this.origin.getY(), this.origin.getZ(), this.level.random.nextFloat() * 360.0F, 0.0F); this.level.addFreshEntity(enderDragon); this.dragonUUID = enderDragon.getUUID(); + this.resetSpikeCrystals(); // Paper - Reset ender crystals on dragon spawn } return enderDragon; -@@ -443,6 +_,10 @@ +@@ -444,6 +_,10 @@ this.ticksSinceDragonSeen = 0; if (dragon.hasCustomName()) { this.dragonEvent.setName(dragon.getDisplayName()); @@ -122,7 +122,7 @@ } } } -@@ -470,7 +_,13 @@ +@@ -471,7 +_,13 @@ return this.previouslyKilled; } @@ -137,7 +137,7 @@ if (this.dragonKilled && this.respawnStage == null) { BlockPos blockPos = this.portalLocation; if (blockPos == null) { -@@ -485,6 +_,22 @@ +@@ -486,6 +_,22 @@ blockPos = this.portalLocation; } @@ -160,7 +160,7 @@ List list = Lists.newArrayList(); BlockPos blockPos1 = blockPos.above(1); -@@ -492,18 +_,19 @@ +@@ -493,18 +_,19 @@ for (Direction direction : Direction.Plane.HORIZONTAL) { List entitiesOfClass = this.level.getEntitiesOfClass(EndCrystal.class, new AABB(blockPos1.relative(direction, 2))); if (entitiesOfClass.isEmpty()) { @@ -183,7 +183,7 @@ if (this.dragonKilled && this.respawnStage == null) { for (BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal(); blockPatternMatch != null; blockPatternMatch = this.findExitPortal()) { for (int i = 0; i < this.exitPortalPattern.getWidth(); i++) { -@@ -522,7 +_,9 @@ +@@ -523,7 +_,9 @@ this.respawnTime = 0; this.spawnExitPortal(false); this.respawnCrystals = crystals; diff --git a/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch b/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch index fb266ce5b..f5c795978 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/entity/EntityAccess.java.patch @@ -1,15 +1,17 @@ --- a/net/minecraft/world/level/entity/EntityAccess.java +++ b/net/minecraft/world/level/entity/EntityAccess.java -@@ -23,6 +_,12 @@ +@@ -18,7 +_,13 @@ - void setRemoved(Entity.RemovalReason removalReason); + Stream getPassengersAndSelf(); +- void setRemoved(Entity.RemovalReason removalReason); + // CraftBukkit start - add Bukkit remove cause -+ default void setRemoved(Entity.RemovalReason removalReason, org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause) { -+ this.setRemoved(removalReason); ++ default void setRemoved(Entity.RemovalReason removalReason) { ++ this.setRemoved(removalReason, null); + } -+ // CraftBukkit end + ++ void setRemoved(Entity.RemovalReason removalReason, @javax.annotation.Nullable org.bukkit.event.entity.EntityRemoveEvent.Cause eventCause); ++ // CraftBukkit end - add Bukkit remove cause + boolean shouldBeSaved(); - boolean isAlwaysTicking(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch index 18b27de6e..b7f4e172f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/entity/PersistentEntitySectionManager.java.patch @@ -43,7 +43,7 @@ if (!this.addEntityUuid(entity)) { return false; } else { -@@ -109,19 +_,23 @@ +@@ -113,19 +_,23 @@ } void startTicking(T entity) { @@ -67,7 +67,7 @@ this.callbacks.onTrackingEnd(entity); this.visibleEntityStorage.remove(entity); } -@@ -132,6 +_,7 @@ +@@ -136,6 +_,7 @@ } public void updateChunkStatus(ChunkPos pos, Visibility visibility) { @@ -75,7 +75,7 @@ long packedChunkPos = pos.toLong(); if (visibility == Visibility.HIDDEN) { this.chunkVisibility.remove(packedChunkPos); -@@ -165,6 +_,7 @@ +@@ -169,6 +_,7 @@ } public void ensureChunkQueuedForLoad(long chunkPosValue) { @@ -83,7 +83,7 @@ PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPosValue); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.FRESH) { this.requestChunkLoad(chunkPosValue); -@@ -172,6 +_,11 @@ +@@ -176,6 +_,11 @@ } private boolean storeChunkSections(long chunkPosValue, Consumer entityAction) { @@ -95,7 +95,7 @@ PersistentEntitySectionManager.ChunkLoadStatus chunkLoadStatus = this.chunkLoadStatuses.get(chunkPosValue); if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.PENDING) { return false; -@@ -182,6 +_,7 @@ +@@ -186,6 +_,7 @@ .collect(Collectors.toList()); if (list.isEmpty()) { if (chunkLoadStatus == PersistentEntitySectionManager.ChunkLoadStatus.LOADED) { @@ -103,7 +103,7 @@ this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(chunkPosValue), ImmutableList.of())); } -@@ -190,6 +_,7 @@ +@@ -194,6 +_,7 @@ this.requestChunkLoad(chunkPosValue); return false; } else { @@ -111,7 +111,7 @@ this.permanentStorage.storeEntities(new ChunkEntities<>(new ChunkPos(chunkPosValue), list)); list.forEach(entityAction); return true; -@@ -198,6 +_,7 @@ +@@ -202,6 +_,7 @@ } private void requestChunkLoad(long chunkPosValue) { @@ -119,7 +119,7 @@ this.chunkLoadStatuses.put(chunkPosValue, PersistentEntitySectionManager.ChunkLoadStatus.PENDING); ChunkPos chunkPos = new ChunkPos(chunkPosValue); this.permanentStorage.loadEntities(chunkPos).thenAccept(this.loadingInbox::add).exceptionally(throwable -> { -@@ -207,7 +_,8 @@ +@@ -211,7 +_,8 @@ } private boolean processChunkUnload(long chunkPosValue) { @@ -129,7 +129,7 @@ if (!flag) { return false; } else { -@@ -217,7 +_,7 @@ +@@ -221,7 +_,7 @@ } private void unloadEntity(EntityAccess entity) { @@ -138,7 +138,7 @@ entity.setLevelCallback(EntityInLevelCallback.NULL); } -@@ -227,14 +_,20 @@ +@@ -231,14 +_,20 @@ } private void processPendingLoads() { @@ -159,7 +159,7 @@ this.processPendingLoads(); this.processUnloads(); } -@@ -252,6 +_,7 @@ +@@ -256,6 +_,7 @@ } public void autoSave() { @@ -167,7 +167,7 @@ this.getAllChunksToSave().forEach(packedChunkPos -> { boolean flag = this.chunkVisibility.get(packedChunkPos) == Visibility.HIDDEN; if (flag) { -@@ -263,6 +_,7 @@ +@@ -267,6 +_,7 @@ } public void saveAll() { @@ -175,7 +175,7 @@ LongSet allChunksToSave = this.getAllChunksToSave(); while (!allChunksToSave.isEmpty()) { -@@ -279,7 +_,13 @@ +@@ -283,7 +_,13 @@ @Override public void close() throws IOException { @@ -190,7 +190,7 @@ this.permanentStorage.close(); } -@@ -380,6 +_,7 @@ +@@ -384,6 +_,7 @@ BlockPos blockPos = this.entity.blockPosition(); long packedSectionPos = SectionPos.asLong(blockPos); if (packedSectionPos != this.currentSectionKey) { @@ -198,7 +198,7 @@ Visibility status = this.currentSection.getStatus(); if (!this.currentSection.remove(this.entity)) { PersistentEntitySectionManager.LOGGER -@@ -427,6 +_,7 @@ +@@ -431,6 +_,7 @@ @Override public void onRemove(Entity.RemovalReason reason) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch index bcefb8669..09e2140b1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/gameevent/GameEventDispatcher.java.patch @@ -1,27 +1,14 @@ --- a/net/minecraft/world/level/gameevent/GameEventDispatcher.java +++ b/net/minecraft/world/level/gameevent/GameEventDispatcher.java -@@ -11,6 +_,13 @@ - import net.minecraft.world.level.chunk.ChunkAccess; - import net.minecraft.world.phys.Vec3; - -+// CraftBukkit start -+import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.CraftGameEvent; -+import org.bukkit.craftbukkit.util.CraftLocation; -+import org.bukkit.event.world.GenericGameEvent; -+// CraftBukkit end -+ - public class GameEventDispatcher { - private final ServerLevel level; - -@@ -21,6 +_,14 @@ +@@ -21,6 +_,15 @@ public void post(Holder gameEvent, Vec3 pos, GameEvent.Context context) { int notificationRadius = gameEvent.value().notificationRadius(); BlockPos blockPos = BlockPos.containing(pos); + // CraftBukkit start -+ GenericGameEvent apiEvent = new GenericGameEvent(CraftGameEvent.minecraftToBukkit(gameEvent.value()), CraftLocation.toBukkit(blockPos, this.level.getWorld()), (context.sourceEntity() == null) ? null : context.sourceEntity().getBukkitEntity(), notificationRadius, !Bukkit.isPrimaryThread()); -+ this.level.getCraftServer().getPluginManager().callEvent(apiEvent); -+ if (apiEvent.isCancelled()) { ++ org.bukkit.event.world.GenericGameEvent apiEvent = new org.bukkit.event.world.GenericGameEvent( ++ org.bukkit.craftbukkit.CraftGameEvent.minecraftToBukkit(gameEvent.value()), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos, this.level.getWorld()), ++ (context.sourceEntity() == null) ? null : context.sourceEntity().getBukkitEntity(), notificationRadius, !org.bukkit.Bukkit.isPrimaryThread()); ++ if (!apiEvent.callEvent()) { + return; + } + notificationRadius = apiEvent.getRadius(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch index b25a25560..928c1b9f6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PatrolSpawner.java.patch @@ -1,86 +1,62 @@ --- a/net/minecraft/world/level/levelgen/PatrolSpawner.java +++ b/net/minecraft/world/level/levelgen/PatrolSpawner.java -@@ -20,28 +_,66 @@ +@@ -20,18 +_,47 @@ @Override - public int tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { -+ if (level.paperConfig().entities.behavior.pillagerPatrols.disable || level.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return 0; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options - if (!spawnEnemies) { - return 0; - } else if (!level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { - return 0; - } else { - RandomSource randomSource = level.random; -- this.nextTick--; -- if (this.nextTick > 0) { -- return 0; -- } else { -- this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); -- long l = level.getDayTime() / 24000L; -- if (l < 5L || !level.isDay()) { -- return 0; -- } else if (randomSource.nextInt(5) != 0) { -- return 0; -- } else { -- int size = level.players().size(); -+ // this.nextTick--; -+ // if (this.nextTick > 0) { -+ // return 0; -+ // } else { -+ // this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); -+ // long l = level.getDayTime() / 24000L; -+ // if (l < 5L || !level.isDay()) { -+ // return 0; -+ // } else if (randomSource.nextInt(5) != 0) { -+ // Paper start - Pillager patrol spawn settings and per player options -+ // Random player selection moved up for per player spawning and configuration -+ int size = level.players().size(); -+ if (size < 1) { -+ return 0; -+ } -+ -+ net.minecraft.server.level.ServerPlayer player = level.players().get(randomSource.nextInt(size)); -+ if (player.isSpectator()) { -+ return 0; -+ } -+ -+ int patrolSpawnDelay; -+ if (level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { -+ --player.patrolSpawnDelay; -+ patrolSpawnDelay = player.patrolSpawnDelay; -+ } else { -+ this.nextTick--; -+ patrolSpawnDelay = this.nextTick; -+ } -+ if (patrolSpawnDelay > 0) { -+ return 0; -+ } else { -+ long days; -+ if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { -+ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks -+ } else { -+ days = level.getDayTime() / 24000L; + public void tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { ++ if (level.paperConfig().entities.behavior.pillagerPatrols.disable || level.paperConfig().entities.behavior.pillagerPatrols.spawnChance == 0) return; // Paper - Add option to disable pillager patrols & Pillager patrol spawn settings and per player options + if (spawnEnemies) { + if (level.getGameRules().getBoolean(GameRules.RULE_DO_PATROL_SPAWNING)) { + RandomSource randomSource = level.random; +- this.nextTick--; +- if (this.nextTick <= 0) { +- this.nextTick = this.nextTick + 12000 + randomSource.nextInt(1200); +- long l = level.getDayTime() / 24000L; +- if (l >= 5L && level.isBrightOutside()) { +- if (randomSource.nextInt(5) == 0) { +- int size = level.players().size(); ++ // this.nextTick--; ++ // Paper start - Pillager patrol spawn settings and per player options ++ int size = level.players().size(); ++ if (size < 1) { ++ return; + } ++ ++ net.minecraft.server.level.ServerPlayer player = level.players().get(randomSource.nextInt(size)); ++ if (player.isSpectator()) { ++ return; ++ } ++ ++ int patrolSpawnDelay; + if (level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { -+ player.patrolSpawnDelay += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); ++ --player.patrolSpawnDelay; ++ patrolSpawnDelay = player.patrolSpawnDelay; + } else { -+ this.nextTick += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); ++ this.nextTick--; ++ patrolSpawnDelay = this.nextTick; + } ++ if (patrolSpawnDelay <= 0) { ++ long days; ++ if (level.paperConfig().entities.behavior.pillagerPatrols.start.perPlayer) { ++ days = player.getStats().getValue(net.minecraft.stats.Stats.CUSTOM.get(net.minecraft.stats.Stats.PLAY_TIME)) / 24000L; // PLAY_TIME is counting in ticks ++ } else { ++ days = level.getDayTime() / 24000L; ++ } ++ if (level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.perPlayer) { ++ player.patrolSpawnDelay += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); ++ } else { ++ this.nextTick += level.paperConfig().entities.behavior.pillagerPatrols.spawnDelay.ticks + randomSource.nextInt(1200); ++ } + -+ if (days < level.paperConfig().entities.behavior.pillagerPatrols.start.day || !level.isDay()) { -+ return 0; -+ } else if (randomSource.nextDouble() >= level.paperConfig().entities.behavior.pillagerPatrols.spawnChance) { -+ // Paper end - Pillager patrol spawn settings and per player options -+ return 0; -+ } else { - if (size < 1) { - return 0; - } else { -- Player player = level.players().get(randomSource.nextInt(size)); - if (player.isSpectator()) { - return 0; - } else if (level.isCloseToVillage(player.blockPosition(), 2)) { -@@ -104,7 +_,7 @@ ++ if (days >= level.paperConfig().entities.behavior.pillagerPatrols.start.day && level.isBrightOutside()) { ++ if (randomSource.nextDouble() < level.paperConfig().entities.behavior.pillagerPatrols.spawnChance) { ++ // Paper end - Pillager patrol spawn settings and per player options + if (size >= 1) { +- Player player = level.players().get(randomSource.nextInt(size)); + if (!player.isSpectator()) { + if (!level.isCloseToVillage(player.blockPosition(), 2)) { + int i = (24 + randomSource.nextInt(24)) * (randomSource.nextBoolean() ? -1 : 1); +@@ -88,7 +_,7 @@ patrollingMonster.setPos(pos.getX(), pos.getY(), pos.getZ()); patrollingMonster.finalizeSpawn(level, level.getCurrentDifficultyAt(pos), EntitySpawnReason.PATROL, null); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch index 19c728a9e..3c1cacb8f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/PhantomSpawner.java.patch @@ -1,67 +1,52 @@ --- a/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java -@@ -28,19 +_,28 @@ - } else if (!level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) { - return 0; - } else { -+ // Paper start - Ability to control player's insomnia and phantoms -+ if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) { -+ return 0; -+ } -+ // Paper end - Ability to control player's insomnia and phantoms - RandomSource randomSource = level.random; - this.nextTick--; - if (this.nextTick > 0) { - return 0; - } else { -- this.nextTick = this.nextTick + (60 + randomSource.nextInt(60)) * 20; +@@ -25,13 +_,22 @@ + public void tick(ServerLevel level, boolean spawnEnemies, boolean spawnFriendlies) { + if (spawnEnemies) { + if (level.getGameRules().getBoolean(GameRules.RULE_DOINSOMNIA)) { + // Paper start - Ability to control player's insomnia and phantoms -+ int spawnAttemptMinSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMinSeconds; -+ int spawnAttemptMaxSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds; -+ this.nextTick += (spawnAttemptMinSeconds + randomSource.nextInt(spawnAttemptMaxSeconds - spawnAttemptMinSeconds + 1)) * 20; ++ if (level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds <= 0) { ++ return; ++ } + // Paper end - Ability to control player's insomnia and phantoms - if (level.getSkyDarken() < 5 && level.dimensionType().hasSkyLight()) { - return 0; - } else { - int i = 0; + RandomSource randomSource = level.random; + this.nextTick--; + if (this.nextTick <= 0) { +- this.nextTick = this.nextTick + (60 + randomSource.nextInt(60)) * 20; ++ // Paper start - Ability to control player's insomnia and phantoms ++ int spawnAttemptMinSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMinSeconds; ++ int spawnAttemptMaxSeconds = level.paperConfig().entities.behavior.phantomsSpawnAttemptMaxSeconds; ++ this.nextTick += (spawnAttemptMinSeconds + randomSource.nextInt(spawnAttemptMaxSeconds - spawnAttemptMinSeconds + 1)) * 20; ++ // Paper end - Ability to control player's insomnia and phantoms + if (level.getSkyDarken() >= 5 || !level.dimensionType().hasSkyLight()) { + for (ServerPlayer serverPlayer : level.players()) { +- if (!serverPlayer.isSpectator()) { ++ if (!serverPlayer.isSpectator() && (!level.paperConfig().entities.behavior.phantomsDoNotSpawnOnCreativePlayers || !serverPlayer.isCreative())) { // Paper - Add phantom creative and insomniac controls + BlockPos blockPos = serverPlayer.blockPosition(); + if (!level.dimensionType().hasSkyLight() || blockPos.getY() >= level.getSeaLevel() && level.canSeeSky(blockPos)) { + DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(blockPos); +@@ -50,13 +_,23 @@ + int i2 = 1 + randomSource.nextInt(currentDifficultyAt.getDifficulty().getId() + 1); - for (ServerPlayer serverPlayer : level.players()) { -- if (!serverPlayer.isSpectator()) { -+ if (!serverPlayer.isSpectator() && (!level.paperConfig().entities.behavior.phantomsDoNotSpawnOnCreativePlayers || !serverPlayer.isCreative())) { // Paper - Add phantom creative and insomniac controls - BlockPos blockPos = serverPlayer.blockPosition(); - if (!level.dimensionType().hasSkyLight() || blockPos.getY() >= level.getSeaLevel() && level.canSeeSky(blockPos)) { - DifficultyInstance currentDifficultyAt = level.getCurrentDifficultyAt(blockPos); -@@ -48,7 +_,7 @@ - ServerStatsCounter stats = serverPlayer.getStats(); - int i1 = Mth.clamp(stats.getValue(Stats.CUSTOM.get(Stats.TIME_SINCE_REST)), 1, Integer.MAX_VALUE); - int i2 = 24000; -- if (randomSource.nextInt(i1) >= 72000) { -+ if (randomSource.nextInt(i1) >= level.paperConfig().entities.behavior.playerInsomniaStartTicks) { // Paper - Ability to control player's insomnia and phantoms - BlockPos blockPos1 = blockPos.above(20 + randomSource.nextInt(15)) - .east(-10 + randomSource.nextInt(21)) - .south(-10 + randomSource.nextInt(21)); -@@ -59,13 +_,23 @@ - int i3 = 1 + randomSource.nextInt(currentDifficultyAt.getDifficulty().getId() + 1); - - for (int i4 = 0; i4 < i3; i4++) { -+ // Paper start - PhantomPreSpawnEvent -+ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(io.papermc.paper.util.MCUtil.toLocation(level, blockPos1), serverPlayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); -+ if (!event.callEvent()) { -+ if (event.shouldAbortSpawn()) { -+ break; + for (int i3 = 0; i3 < i2; i3++) { ++ // Paper start - PhantomPreSpawnEvent ++ com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent event = new com.destroystokyo.paper.event.entity.PhantomPreSpawnEvent(org.bukkit.craftbukkit.util.CraftLocation.toBukkit(blockPos1, level), serverPlayer.getBukkitEntity(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); ++ if (!event.callEvent()) { ++ if (event.shouldAbortSpawn()) { ++ break; ++ } ++ continue; + } -+ continue; -+ } -+ // Paper end - PhantomPreSpawnEvent - Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL); - if (phantom != null) { -+ phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent - phantom.moveTo(blockPos1, 0.0F, 0.0F); - spawnGroupData = phantom.finalizeSpawn( - level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData - ); -- level.addFreshEntityWithPassengers(phantom); -+ level.addFreshEntityWithPassengers(phantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NATURAL); // CraftBukkit - i++; ++ // Paper end - PhantomPreSpawnEvent + Phantom phantom = EntityType.PHANTOM.create(level, EntitySpawnReason.NATURAL); + if (phantom != null) { ++ phantom.spawningEntity = serverPlayer.getUUID(); // Paper - PhantomPreSpawnEvent + phantom.snapTo(blockPos1, 0.0F, 0.0F); + spawnGroupData = phantom.finalizeSpawn( + level, currentDifficultyAt, EntitySpawnReason.NATURAL, spawnGroupData + ); +- level.addFreshEntityWithPassengers(phantom); ++ level.addFreshEntityWithPassengers(phantom, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PATROL); // CraftBukkit + } } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/WorldGenerationContext.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/WorldGenerationContext.java.patch index a0993bf36..4bbbbabfb 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/WorldGenerationContext.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/WorldGenerationContext.java.patch @@ -10,7 +10,7 @@ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor level) { + this(generator, level, null); + } -+ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor level, net.minecraft.world.level.Level serverLevel) { ++ public WorldGenerationContext(ChunkGenerator generator, LevelHeightAccessor level, @javax.annotation.Nullable net.minecraft.world.level.Level serverLevel) { + this.serverLevel = serverLevel; + // Paper end - Flat bedrock generator settings this.minY = Math.max(level.getMinY(), generator.getMinY()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch index bfd494df8..185e07f40 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java.patch @@ -1,33 +1,32 @@ --- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java +++ b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java -@@ -19,6 +_,12 @@ +@@ -19,6 +_,13 @@ } public static void createEndPlatform(ServerLevelAccessor level, BlockPos pos, boolean dropBlocks) { + // CraftBukkit start + createEndPlatform(level, pos, dropBlocks, null); + } -+ public static void createEndPlatform(ServerLevelAccessor level, BlockPos pos, boolean dropBlocks, net.minecraft.world.entity.Entity entity) { ++ ++ public static void createEndPlatform(ServerLevelAccessor level, BlockPos pos, boolean dropBlocks, @javax.annotation.Nullable net.minecraft.world.entity.Entity entity) { + org.bukkit.craftbukkit.util.BlockStateListPopulator blockList = new org.bukkit.craftbukkit.util.BlockStateListPopulator(level); + // CraftBukkit end BlockPos.MutableBlockPos mutableBlockPos = pos.mutable(); for (int i = -2; i <= 2; i++) { -@@ -26,15 +_,33 @@ +@@ -26,15 +_,31 @@ for (int i2 = -1; i2 < 3; i2++) { BlockPos blockPos = mutableBlockPos.set(pos).move(i1, i2, i); Block block = i2 == -1 ? Blocks.OBSIDIAN : Blocks.AIR; - if (!level.getBlockState(blockPos).is(block)) { -+ // CraftBukkit start -+ if (!blockList.getBlockState(blockPos).is(block)) { ++ if (!blockList.getBlockState(blockPos).is(block)) { // CraftBukkit if (dropBlocks) { - level.destroyBlock(blockPos, true, null); -+ blockList.destroyBlock(blockPos, true, null); ++ blockList.destroyBlock(blockPos, true, null); // CraftBukkit } - level.setBlock(blockPos, block.defaultBlockState(), 3); -+ blockList.setBlock(blockPos, block.defaultBlockState(), 3); -+ // CraftBukkit end ++ blockList.setBlock(blockPos, block.defaultBlockState(), 3); // CraftBukkit } } } @@ -37,16 +36,16 @@ + // SPIGOT-7746: Entity will only be null during world generation, which is async, so just generate without event + if (entity != null) { + org.bukkit.World bworld = level.getLevel().getWorld(); -+ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); ++ org.bukkit.event.world.PortalCreateEvent portalEvent = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getSnapshotBlocks(), bworld, entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.END_PLATFORM); + level.getLevel().getCraftServer().getPluginManager().callEvent(portalEvent); + if (portalEvent.isCancelled()) return; + } + -+ // SPIGOT-7856: End platform not dropping items after replacing blocks + if (dropBlocks) { -+ blockList.getList().forEach((state) -> level.destroyBlock(state.getPosition(), true, null)); ++ blockList.placeBlocks(state -> level.destroyBlock(state.getPosition(), true, null)); ++ } else { ++ blockList.placeBlocks(); + } -+ blockList.updateList(); + // CraftBukkit end } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/SpikeFeature.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/SpikeFeature.java.patch index 9de3934ac..c36bbede3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/SpikeFeature.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/feature/SpikeFeature.java.patch @@ -3,7 +3,7 @@ @@ -113,6 +_,7 @@ endCrystal.setBeamTarget(config.getCrystalBeamTarget()); endCrystal.setInvulnerable(config.isCrystalInvulnerable()); - endCrystal.moveTo(spike.getCenterX() + 0.5, spike.getHeight() + 1, spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F); + endCrystal.snapTo(spike.getCenterX() + 0.5, spike.getHeight() + 1, spike.getCenterZ() + 0.5, random.nextFloat() * 360.0F, 0.0F); + endCrystal.generatedByDragonFight = true; // Paper - Fix invulnerable end crystals level.addFreshEntity(endCrystal); BlockPos blockPosx = endCrystal.blockPosition(); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch index 23f014d70..ae7f643e1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java +++ b/net/minecraft/world/level/levelgen/structure/LegacyStructureDataHandler.java -@@ -217,17 +_,17 @@ +@@ -221,17 +_,17 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch index d79e90f86..30e8373a4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureCheck.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/StructureCheck.java +++ b/net/minecraft/world/level/levelgen/structure/StructureCheck.java -@@ -40,7 +_,7 @@ +@@ -41,7 +_,7 @@ private final ChunkScanAccess storageAccess; private final RegistryAccess registryAccess; private final StructureTemplateManager structureTemplateManager; @@ -9,7 +9,7 @@ private final ChunkGenerator chunkGenerator; private final RandomState randomState; private final LevelHeightAccessor heightAccessor; -@@ -54,7 +_,7 @@ +@@ -55,7 +_,7 @@ ChunkScanAccess storageAccess, RegistryAccess registryAccess, StructureTemplateManager structureTemplateManager, @@ -18,7 +18,7 @@ ChunkGenerator chunkGenerator, RandomState randomState, LevelHeightAccessor heightAccessor, -@@ -74,6 +_,20 @@ +@@ -75,6 +_,20 @@ this.fixerUpper = fixerUpper; } @@ -39,7 +39,7 @@ public StructureCheckResult checkStart(ChunkPos chunkPos, Structure structure, StructurePlacement placement, boolean skipKnownStructures) { long packedChunkPos = chunkPos.toLong(); Object2IntMap map = this.loadedChunks.get(packedChunkPos); -@@ -83,7 +_,7 @@ +@@ -84,7 +_,7 @@ StructureCheckResult structureCheckResult = this.tryLoadFromStorage(chunkPos, structure, skipKnownStructures, packedChunkPos); if (structureCheckResult != null) { return structureCheckResult; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch index aa1428c00..9f34fb937 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructurePiece.java.patch @@ -1,35 +1,27 @@ --- a/net/minecraft/world/level/levelgen/structure/StructurePiece.java +++ b/net/minecraft/world/level/levelgen/structure/StructurePiece.java -@@ -47,7 +_,7 @@ - private Rotation rotation; - protected int genDepth; - private final StructurePieceType type; -- private static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder() -+ public static final Set SHAPE_CHECK_BLOCKS = ImmutableSet.builder() // PAIL private -> public - .add(Blocks.NETHER_BRICK_FENCE) - .add(Blocks.TORCH) - .add(Blocks.WALL_TORCH) -@@ -189,6 +_,11 @@ +@@ -181,6 +_,11 @@ } level.setBlock(worldPos, blockstate, 2); + // CraftBukkit start - fluid handling is already done if we have a transformer generator access -+ if (level instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess) { ++ if (level instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess && transformerAccess.canTransformBlocks()) { + return; + } + // CraftBukkit end FluidState fluidState = level.getFluidState(worldPos); if (!fluidState.isEmpty()) { level.scheduleTick(worldPos, fluidState.getType(), 0); -@@ -201,6 +_,38 @@ +@@ -193,6 +_,39 @@ } } + // CraftBukkit start + protected boolean placeCraftBlockEntity(ServerLevelAccessor levelAccessor, BlockPos pos, org.bukkit.craftbukkit.block.CraftBlockEntityState craftBlockEntityState, int flags) { -+ if (levelAccessor instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) { ++ if (levelAccessor instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess && transformerAccess.canTransformBlocks()) { + return transformerAccess.setCraftBlock(pos, craftBlockEntityState, flags); + } ++ + boolean result = levelAccessor.setBlock(pos, craftBlockEntityState.getHandle(), flags); + BlockEntity blockEntity = levelAccessor.getBlockEntity(pos); + if (blockEntity != null) { @@ -50,7 +42,7 @@ + net.minecraft.world.level.block.entity.BlockEntity blockEntity = levelAccessor.getBlockEntity(pos); + if (blockEntity instanceof net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity lootContainerBlockEntity) { + lootContainerBlockEntity.setLootTable(lootTable, randomSource.nextLong()); -+ if (levelAccessor instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) { ++ if (levelAccessor instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess && transformerAccess.canTransformBlocks()) { + transformerAccess.setCraftBlock(pos, (org.bukkit.craftbukkit.block.CraftBlockState) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(levelAccessor, pos, blockEntity.getBlockState(), lootContainerBlockEntity.saveWithFullMetadata(levelAccessor.registryAccess())), 3); + } + } @@ -60,7 +52,7 @@ protected boolean canBeReplaced(LevelReader level, int x, int y, int z, BoundingBox box) { return true; } -@@ -429,11 +_,17 @@ +@@ -421,11 +_,17 @@ state = reorient(level, pos, Blocks.CHEST.defaultBlockState()); } @@ -83,7 +75,7 @@ return true; } else { -@@ -446,11 +_,28 @@ +@@ -438,11 +_,28 @@ ) { BlockPos worldPos = this.getWorldPos(x, y, z); if (box.isInside(worldPos) && !level.getBlockState(worldPos).is(Blocks.DISPENSER)) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch index 9efa80e8e..2f1367496 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/StructureStart.java.patch @@ -29,7 +29,7 @@ + List pieces = list.stream().filter(piece -> piece.getBoundingBox().intersects(box)).toList(); + if (!pieces.isEmpty()) { + org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess = new org.bukkit.craftbukkit.util.TransformerGeneratorAccess(); -+ transformerAccess.setHandle(level); ++ transformerAccess.setDelegate(level); + transformerAccess.setStructureTransformer(new org.bukkit.craftbukkit.util.CraftStructureTransformer(this.generationEventCause, level, structureManager, this.structure, box, chunkPos)); + for (StructurePiece piece : pieces) { + piece.postProcess(transformerAccess, structureManager, generator, random, box, chunkPos, blockPos); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch index d79551ea5..4179d6757 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java +++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java -@@ -79,14 +_,30 @@ +@@ -79,14 +_,31 @@ return this.exclusionZone; } @@ -9,7 +9,8 @@ + // Paper start - Add missing structure set seed configs + return this.isStructureChunk(structureState, x, z, null); + } -+ public boolean isStructureChunk(ChunkGeneratorStructureState structureState, int x, int z, @org.jetbrains.annotations.Nullable net.minecraft.resources.ResourceKey structureSetKey) { ++ ++ public boolean isStructureChunk(ChunkGeneratorStructureState structureState, int x, int z, @javax.annotation.Nullable net.minecraft.resources.ResourceKey structureSetKey) { + Integer saltOverride = null; + if (structureSetKey != null) { + if (structureSetKey == net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.MINESHAFTS) { @@ -28,7 +29,7 @@ - public boolean applyAdditionalChunkRestrictions(int regionX, int regionZ, long levelSeed) { - return !(this.frequency < 1.0F) || this.frequencyReductionMethod.shouldGenerate(levelSeed, this.salt, regionX, regionZ, this.frequency); + // Paper start - Add missing structure set seed configs -+ public boolean applyAdditionalChunkRestrictions(int regionX, int regionZ, long levelSeed, @org.jetbrains.annotations.Nullable Integer saltOverride) { ++ public boolean applyAdditionalChunkRestrictions(int regionX, int regionZ, long levelSeed, @javax.annotation.Nullable Integer saltOverride) { + return !(this.frequency < 1.0F) || this.frequencyReductionMethod.shouldGenerate(levelSeed, this.salt, regionX, regionZ, this.frequency, saltOverride); + // Paper end - Add missing structure set seed configs } diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch index 73853cb81..6288b7444 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java.patch @@ -1,11 +1,12 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java +++ b/net/minecraft/world/level/levelgen/structure/structures/DesertPyramidStructure.java -@@ -65,6 +_,15 @@ +@@ -65,6 +_,16 @@ private static void placeSuspiciousSand(BoundingBox boundingBox, WorldGenLevel worldGenLevel, BlockPos pos) { if (boundingBox.isInside(pos)) { + // CraftBukkit start -+ if (worldGenLevel instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) { ++ if (worldGenLevel instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess && transformerAccess.canTransformBlocks()) { ++ // todo never called cause it's called in afterPlace after the whole capture logic + org.bukkit.craftbukkit.block.CraftBrushableBlock brushableState = (org.bukkit.craftbukkit.block.CraftBrushableBlock) org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(worldGenLevel, pos, Blocks.SUSPICIOUS_SAND.defaultBlockState(), null); + brushableState.setLootTable(org.bukkit.craftbukkit.CraftLootTable.minecraftToBukkit(BuiltInLootTables.DESERT_PYRAMID_ARCHAEOLOGY)); + brushableState.setSeed(pos.asLong()); diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch index be468da02..8a635d5f1 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftPieces.java -@@ -401,10 +_,13 @@ +@@ -397,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(1, 0, i8); if (box.isInside(worldPos) && this.isInterior(level, 1, 0, i8, box)) { this.hasPlacedSpider = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch index bfd5ae053..a8fc4d333 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/NetherFortressPieces.java -@@ -1265,10 +_,13 @@ +@@ -1076,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(3, 5, 5); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch index ed5789e0f..51c57cca9 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java.patch @@ -1,21 +1,17 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/OceanRuinPieces.java -@@ -314,14 +_,20 @@ +@@ -314,12 +_,18 @@ @Override protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { if ("chest".equals(name)) { -- level.setBlock( -- pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, Boolean.valueOf(level.getFluidState(pos).is(FluidTags.WATER))), 2 -- ); +- level.setBlock(pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), 2); - BlockEntity blockEntity = level.getBlockEntity(pos); - if (blockEntity instanceof ChestBlockEntity) { - ((ChestBlockEntity)blockEntity) - .setLootTable(this.isLarge ? BuiltInLootTables.UNDERWATER_RUIN_BIG : BuiltInLootTables.UNDERWATER_RUIN_SMALL, random.nextLong()); - } + // CraftBukkit start - transform block to ensure loot table is accessible -+ // level.setBlock( -+ // pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, Boolean.valueOf(level.getFluidState(pos).is(FluidTags.WATER))), 2 -+ // ); ++ // level.setBlock(pos, Blocks.CHEST.defaultBlockState().setValue(ChestBlock.WATERLOGGED, level.getFluidState(pos).is(FluidTags.WATER)), 2); + // BlockEntity blockEntity = level.getBlockEntity(pos); + // if (blockEntity instanceof ChestBlockEntity) { + // ((ChestBlockEntity)blockEntity) diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java.patch index 08c3ca9aa..c6cdfce89 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/ShipwreckPieces.java -@@ -121,7 +_,10 @@ +@@ -126,7 +_,10 @@ protected void handleDataMarker(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box) { ResourceKey resourceKey = ShipwreckPieces.MARKERS_TO_LOOT.get(name); if (resourceKey != null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch index 75de4affe..fd336c1c4 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java +++ b/net/minecraft/world/level/levelgen/structure/structures/StrongholdPieces.java -@@ -870,10 +_,13 @@ +@@ -831,10 +_,13 @@ BlockPos worldPos = this.getWorldPos(5, 3, 6); if (box.isInside(worldPos)) { this.hasPlacedSpawner = true; diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java.patch index fe1c847fa..c2966ef14 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java.patch @@ -2,7 +2,7 @@ +++ b/net/minecraft/world/level/levelgen/structure/structures/SwampHutPiece.java @@ -97,7 +_,7 @@ witch.setPersistenceRequired(); - witch.moveTo(worldPos.getX() + 0.5, worldPos.getY(), worldPos.getZ() + 0.5, 0.0F, 0.0F); + witch.snapTo(worldPos.getX() + 0.5, worldPos.getY(), worldPos.getZ() + 0.5, 0.0F, 0.0F); witch.finalizeSpawn(level, level.getCurrentDifficultyAt(worldPos), EntitySpawnReason.STRUCTURE, null); - level.addFreshEntityWithPassengers(witch); + level.addFreshEntityWithPassengers(witch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason @@ -11,7 +11,7 @@ } @@ -116,7 +_,7 @@ cat.setPersistenceRequired(); - cat.moveTo(worldPos.getX() + 0.5, worldPos.getY(), worldPos.getZ() + 0.5, 0.0F, 0.0F); + cat.snapTo(worldPos.getX() + 0.5, worldPos.getY(), worldPos.getZ() + 0.5, 0.0F, 0.0F); cat.finalizeSpawn(level, level.getCurrentDifficultyAt(worldPos), EntitySpawnReason.STRUCTURE, null); - level.addFreshEntityWithPassengers(cat); + level.addFreshEntityWithPassengers(cat, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN); // CraftBukkit - add SpawnReason diff --git a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch index c88b4e61e..0ae516523 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java.patch @@ -1,28 +1,17 @@ --- a/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java +++ b/net/minecraft/world/level/levelgen/structure/templatesystem/StructureTemplate.java -@@ -54,6 +_,10 @@ - import net.minecraft.world.phys.Vec3; - import net.minecraft.world.phys.shapes.BitSetDiscreteVoxelShape; - import net.minecraft.world.phys.shapes.DiscreteVoxelShape; -+// CraftBukkit start -+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; -+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; -+// CraftBukkit end - - public class StructureTemplate { - public static final String PALETTE_TAG = "palette"; -@@ -71,6 +_,10 @@ +@@ -73,6 +_,10 @@ public final List entityInfoList = Lists.newArrayList(); private Vec3i size = Vec3i.ZERO; private String author = "?"; + // CraftBukkit start - data containers -+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry(); -+ public CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); ++ private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); ++ public org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(StructureTemplate.DATA_TYPE_REGISTRY); + // CraftBukkit end public Vec3i getSize() { return this.size; -@@ -245,6 +_,19 @@ +@@ -247,6 +_,19 @@ if (this.palettes.isEmpty()) { return false; } else { @@ -31,7 +20,7 @@ + ServerLevelAccessor wrappedAccess = serverLevel; + org.bukkit.craftbukkit.util.CraftStructureTransformer structureTransformer = null; + if (wrappedAccess instanceof org.bukkit.craftbukkit.util.TransformerGeneratorAccess transformerAccess) { -+ serverLevel = transformerAccess.getHandle(); ++ serverLevel = transformerAccess.getDelegate(); + structureTransformer = transformerAccess.getStructureTransformer(); + // The structureTransformer is not needed if we can not transform blocks therefore we can save a little bit of performance doing this + if (structureTransformer != null && !structureTransformer.canTransformBlocks()) { @@ -42,17 +31,8 @@ List list = settings.getRandomPalette(this.palettes, offset).blocks(); if ((!list.isEmpty() || !settings.isIgnoreEntities() && !this.entityInfoList.isEmpty()) && this.size.getX() >= 1 -@@ -268,10 +_,29 @@ - BlockState blockState = structureBlockInfo.state.mirror(settings.getMirror()).rotate(settings.getRotation()); - if (structureBlockInfo.nbt != null) { - BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos); -- Clearable.tryClear(blockEntity); -+ // Paper start - Fix NBT pieces overriding a block entity during worldgen deadlock -+ if (!(serverLevel instanceof net.minecraft.world.level.WorldGenLevel)) { -+ Clearable.tryClear(blockEntity); -+ } -+ // Paper end - Fix NBT pieces overriding a block entity during worldgen deadlock - serverLevel.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), 20); +@@ -272,6 +_,21 @@ + serverLevel.setBlock(blockPos, Blocks.BARRIER.defaultBlockState(), 820); } + // CraftBukkit start @@ -104,7 +84,11 @@ offset, settings.getMirror(), settings.getRotation(), -@@ -491,11 +_,13 @@ +@@ -488,14 +_,17 @@ + ); + } + } ++ } private static Optional createEntityIgnoreException(ServerLevelAccessor level, CompoundTag tag) { @@ -135,11 +119,10 @@ return NbtUtils.addCurrentDataVersion(tag); } -@@ -720,6 +_,12 @@ - this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockPos, compound1)); - } - } -+ +@@ -718,6 +_,11 @@ + .ifPresent(compoundTag1 -> this.entityInfoList.add(new StructureTemplate.StructureEntityInfo(vec3, blockPos, compoundTag1))); + } + ); + // CraftBukkit start - PDC + if (tag.get("BukkitValues") instanceof CompoundTag compoundTag) { + this.persistentDataContainer.putAll(compoundTag); @@ -148,7 +131,7 @@ } private void loadPalette(HolderGetter blockGetter, ListTag paletteTag, ListTag blocksTag) { -@@ -828,7 +_,7 @@ +@@ -817,7 +_,7 @@ public static final class Palette { private final List blocks; diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch index d6fbecf87..918b40bf2 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/FlowingFluid.java.patch @@ -46,7 +46,7 @@ FluidState fluidState = blockState.getFluidState(); if (fluidState.getType().isSame(this) && canPassThroughWall(direction, level, pos, state, blockPos, blockState)) { if (fluidState.isSource()) { -@@ -252,13 +_,14 @@ +@@ -252,13 +_,15 @@ liquidBlockContainer.placeLiquid(level, pos, blockState, fluidState); } else { if (!blockState.isAir()) { @@ -59,6 +59,7 @@ } + protected void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state, BlockPos source) { beforeDestroyingBlock(level, pos, state); } // Paper - Add BlockBreakBlockEvent ++ protected abstract void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state); protected int getSlopeDistance(LevelReader level, BlockPos pos, int depth, Direction direction, BlockState state, FlowingFluid.SpreadContext spreadContext) { @@ -94,7 +95,7 @@ + blockState = ((org.bukkit.craftbukkit.block.data.CraftBlockData) event.getNewData()).getState(); + // CraftBukkit end level.setBlock(pos, blockState, 3); - } else if (!newLiquid.equals(fluidState)) { + } else if (newLiquid != fluidState) { fluidState = newLiquid; blockState = newLiquid.createLegacyBlock(); + // CraftBukkit start @@ -107,7 +108,7 @@ level.setBlock(pos, blockState, 3); level.scheduleTick(pos, newLiquid.getType(), spreadDelay); } -@@ -476,9 +_,26 @@ +@@ -476,9 +_,27 @@ public BlockState getBlockState(BlockPos pos) { return this.getBlockState(pos, this.getCacheKey(pos)); } @@ -122,6 +123,7 @@ + // Paper start - Prevent chunk loading from fluid flowing + return getBlockState(pos, cacheKey, true); + } ++ + private @javax.annotation.Nullable BlockState getBlockState(BlockPos pos, short packed, boolean load) { + BlockState blockState = this.stateCache.get(packed); + if (blockState == null) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch index c37c2e873..1153a05f3 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/FluidState.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/material/FluidState.java +++ b/net/minecraft/world/level/material/FluidState.java -@@ -26,9 +_,11 @@ +@@ -29,9 +_,11 @@ public static final Codec CODEC = codec(BuiltInRegistries.FLUID.byNameCodec(), Fluid::defaultFluidState).stable(); public static final int AMOUNT_MAX = 9; public static final int AMOUNT_FULL = 8; @@ -12,7 +12,7 @@ } public Fluid getType() { -@@ -44,7 +_,7 @@ +@@ -47,7 +_,7 @@ } public boolean isEmpty() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch index ce90c9af1..beb2b7ef6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/LavaFluid.java.patch @@ -1,35 +1,46 @@ --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -88,6 +_,13 @@ - BlockState blockState = level.getBlockState(blockPos); - if (blockState.isAir()) { - if (this.hasFlammableNeighbours(level, blockPos)) { +@@ -92,6 +_,13 @@ + BlockState blockState = level.getBlockState(blockPos); + if (blockState.isAir()) { + if (this.hasFlammableNeighbours(level, blockPos)) { ++ // CraftBukkit start - Prevent lava putting something on fire ++ if (!level.getBlockState(blockPos).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { ++ continue; ++ } ++ } ++ // CraftBukkit end + level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); + return; + } +@@ -107,6 +_,14 @@ + } + + if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { + // CraftBukkit start - Prevent lava putting something on fire -+ if (level.getBlockState(blockPos).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockPos, pos).isCancelled()) { ++ BlockPos up = blockPos1.above(); ++ if (!level.getBlockState(up).is(Blocks.FIRE)) { ++ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { + continue; + } + } -+ // CraftBukkit end - level.setBlockAndUpdate(blockPos, BaseFireBlock.getState(level, blockPos)); - return; ++ // CraftBukkit end - Prevent lava putting something on fire + level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); } -@@ -103,6 +_,14 @@ } +@@ -117,8 +_,9 @@ - if (level.isEmptyBlock(blockPos1.above()) && this.isFlammable(level, blockPos1)) { -+ // CraftBukkit start - Prevent lava putting something on fire -+ BlockPos up = blockPos1.above(); -+ if (level.getBlockState(up).getBlock() != Blocks.FIRE) { -+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, up, pos).isCancelled()) { -+ continue; -+ } -+ } -+ // CraftBukkit end - level.setBlockAndUpdate(blockPos1.above(), BaseFireBlock.getState(level, blockPos1)); - } - } -@@ -195,7 +_,11 @@ + @Override + protected void entityInside(Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { ++ BlockPos savedPos = pos.immutable(); // Paper - track lava contact + effectApplier.apply(InsideBlockEffectType.LAVA_IGNITE); +- effectApplier.runAfter(InsideBlockEffectType.LAVA_IGNITE, Entity::lavaHurt); ++ effectApplier.runAfter(InsideBlockEffectType.LAVA_IGNITE, ignitedEntity -> ignitedEntity.lavaHurt(savedPos)); // Paper - track lava contact + } + + private boolean hasFlammableNeighbours(LevelReader level, BlockPos pos) { +@@ -206,7 +_,11 @@ FluidState fluidState1 = level.getFluidState(pos); if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (blockState.getBlock() instanceof LiquidBlock) { @@ -42,7 +53,7 @@ } this.fizz(level, pos); -@@ -213,7 +_,7 @@ +@@ -224,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch index 32fa03281..2d7aee20e 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/material/WaterFluid.java.patch @@ -1,21 +1,21 @@ --- a/net/minecraft/world/level/material/WaterFluid.java +++ b/net/minecraft/world/level/material/WaterFluid.java -@@ -74,7 +_,13 @@ - protected boolean canConvertToSource(ServerLevel level) { +@@ -78,6 +_,14 @@ return level.getGameRules().getBoolean(GameRules.RULE_WATER_SOURCE_CONVERSION); } -- + + // Paper start - Add BlockBreakBlockEvent + @Override + protected void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state, BlockPos source) { -+ BlockEntity tileentity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; -+ Block.dropResources(state, level, pos, tileentity, source); ++ BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; ++ Block.dropResources(state, level, pos, blockEntity, source); + } + // Paper end - Add BlockBreakBlockEvent ++ @Override protected void beforeDestroyingBlock(LevelAccessor level, BlockPos pos, BlockState state) { BlockEntity blockEntity = state.hasBlockEntity() ? level.getBlockEntity(pos) : null; -@@ -113,7 +_,7 @@ +@@ -121,7 +_,7 @@ @Override protected float getExplosionResistance() { diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch index 76fbe6802..a4ab7b978 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalForcer.java.patch @@ -4,7 +4,7 @@ this.level = level; } -+ @io.papermc.paper.annotation.DoNotUse // Paper ++ @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper public Optional findClosestPortalPosition(BlockPos exitPos, boolean isNether, WorldBorder worldBorder) { + // CraftBukkit start + return this.findClosestPortalPosition(exitPos, worldBorder, isNether ? 16 : 128); // Search Radius @@ -29,7 +29,7 @@ + return this.createPortal(pos, axis, null, 16); + } + -+ public Optional createPortal(BlockPos pos, Direction.Axis axis, net.minecraft.world.entity.Entity entity, int createRadius) { ++ public Optional createPortal(BlockPos pos, Direction.Axis axis, @javax.annotation.Nullable net.minecraft.world.entity.Entity entity, int createRadius) { + // CraftBukkit end Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis); double d = -1.0; @@ -88,13 +88,13 @@ + // CraftBukkit start + org.bukkit.World bworld = this.level.getWorld(); -+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); ++ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) blockList.getSnapshotBlocks(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.NETHER_PAIR); + + this.level.getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + return Optional.empty(); + } -+ blockList.updateList(); ++ blockList.placeBlocks(); + // CraftBukkit end return Optional.of(new BlockUtil.FoundRectangle(blockPos.immutable(), 2, 3)); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch index d92f339f4..1441958ee 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/portal/PortalShape.java.patch @@ -139,7 +139,7 @@ BlockState blockState = Blocks.NETHER_PORTAL.defaultBlockState().setValue(NetherPortalBlock.AXIS, this.axis); BlockPos.betweenClosed(this.bottomLeft, this.bottomLeft.relative(Direction.UP, this.height - 1).relative(this.rightDir, this.width - 1)) + .forEach(pos -> this.blocks.setBlock(pos, blockState, 18)); -+ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getList(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); ++ org.bukkit.event.world.PortalCreateEvent event = new org.bukkit.event.world.PortalCreateEvent((java.util.List) (java.util.List) this.blocks.getSnapshotBlocks(), bworld, (entity == null) ? null : entity.getBukkitEntity(), org.bukkit.event.world.PortalCreateEvent.CreateReason.FIRE); + level.getMinecraftWorld().getServer().server.getPluginManager().callEvent(event); + + if (event.isCancelled()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch index f5b42d763..291359151 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/DefaultRedstoneWireEvaluator.java.patch @@ -16,5 +16,5 @@ + if (oldPower != i) { + // CraftBukkit end if (level.getBlockState(pos) == state) { - level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, Integer.valueOf(i)), 2); + level.setBlock(pos, state.setValue(RedStoneWireBlock.POWER, i), 2); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch b/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch index 7c2db6c3a..fa7488532 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/redstone/NeighborUpdater.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java -@@ -42,8 +_,29 @@ +@@ -42,8 +_,26 @@ } static void executeUpdate(Level level, BlockState state, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { @@ -12,20 +12,17 @@ + // Paper end - Add source block to BlockPhysicsEvent try { + // CraftBukkit start -+ org.bukkit.craftbukkit.CraftWorld cworld = level.getWorld(); -+ if (cworld != null) { -+ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(state), org.bukkit.craftbukkit.block.CraftBlock.at(level, sourcePos)); // Paper - Add source block to BlockPhysicsEvent -+ level.getCraftServer().getPluginManager().callEvent(event); ++ org.bukkit.event.block.BlockPhysicsEvent event = new org.bukkit.event.block.BlockPhysicsEvent(org.bukkit.craftbukkit.block.CraftBlock.at(level, pos), org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(state), org.bukkit.craftbukkit.block.CraftBlock.at(level, sourcePos)); // Paper - Add source block to BlockPhysicsEvent ++ level.getCraftServer().getPluginManager().callEvent(event); + -+ if (event.isCancelled()) { -+ return; -+ } ++ if (event.isCancelled()) { ++ return; + } + // CraftBukkit end state.handleNeighborChanged(level, pos, neighborBlock, orientation, movedByPiston); + // Spigot start + } catch (StackOverflowError ex) { -+ level.lastPhysicsProblem = new BlockPos(pos); ++ level.lastPhysicsProblem = pos.immutable(); + // Spigot end } catch (Throwable var9) { CrashReport crashReport = CrashReport.forThrowable(var9, "Exception while updating neighbours"); diff --git a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch index 8e832c66a..ab441a465 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java.patch @@ -1,6 +1,15 @@ --- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -@@ -61,6 +_,7 @@ +@@ -50,7 +_,7 @@ + private static final String FRAME_PREFIX = "frame-"; + public static final Codec CODEC = RecordCodecBuilder.create( + instance -> instance.group( +- Level.RESOURCE_KEY_CODEC.fieldOf("dimension").forGetter(mapItemSavedData -> mapItemSavedData.dimension), ++ createUUIDBackedDimensionKeyCodec().forGetter(MapItemSavedData::packUUIDBackedDimension), // Paper - store target world by uuid in addition to dimension + Codec.INT.fieldOf("xCenter").forGetter(mapItemSavedData -> mapItemSavedData.centerX), + Codec.INT.fieldOf("zCenter").forGetter(mapItemSavedData -> mapItemSavedData.centerZ), + Codec.BYTE.optionalFieldOf("scale", (byte)0).forGetter(mapItemSavedData -> mapItemSavedData.scale), +@@ -74,6 +_,7 @@ public byte scale; public byte[] colors = new byte[16384]; public boolean locked; @@ -8,7 +17,7 @@ public final List carriedBy = Lists.newArrayList(); public final Map carriedByPlayers = Maps.newHashMap(); private final Map bannerMarkers = Maps.newHashMap(); -@@ -68,6 +_,13 @@ +@@ -81,6 +_,13 @@ private final Map frameMarkers = Maps.newHashMap(); private int trackedDecorationCount; @@ -19,107 +28,50 @@ + public MapId id; + // CraftBukkit end + - public static SavedData.Factory factory() { - return new SavedData.Factory<>(() -> { + public static SavedDataType type(MapId mapId) { + return new SavedDataType<>(mapId.key(), () -> { throw new IllegalStateException("Should never create an empty map saved data"); -@@ -82,6 +_,11 @@ +@@ -95,7 +_,29 @@ this.trackingPosition = trackingPosition; this.unlimitedTracking = unlimitedTracking; this.locked = locked; +- } + // CraftBukkit start + this.mapView = new org.bukkit.craftbukkit.map.CraftMapView(this); + this.server = (org.bukkit.craftbukkit.CraftServer) org.bukkit.Bukkit.getServer(); + this.vanillaRender.buffer = colors; // Paper - Use Vanilla map renderer when possible + // CraftBukkit end ++ } ++ ++ // Paper start - store target world by uuid in addition to dimension ++ private MapItemSavedData( ++ UUIDBackedDimension dimension, ++ int x, ++ int z, ++ byte scale, ++ ByteBuffer colors, ++ boolean trackingPosition, ++ boolean unlimitedTracking, ++ boolean locked, ++ List banners, ++ List frames ++ ) { ++ this(dimension.resolveOrThrow(), x, z, scale, colors, trackingPosition, unlimitedTracking, locked, banners, frames); ++ } ++ // Paper end - store target world by uuid in addition to dimension + + private MapItemSavedData( + ResourceKey dimension, +@@ -127,6 +_,8 @@ + MapDecorationTypes.FRAME, null, getFrameKey(mapFrame.entityId()), mapFrame.pos().getX(), mapFrame.pos().getZ(), mapFrame.rotation(), null + ); + } ++ ++ this.vanillaRender.buffer = colors.array(); // Paper - Use Vanilla map renderer when possible } public static MapItemSavedData createFresh( -@@ -100,9 +_,47 @@ - } - - public static MapItemSavedData load(CompoundTag tag, HolderLookup.Provider levelRegistry) { -- ResourceKey resourceKey = DimensionType.parseLegacy(new Dynamic<>(NbtOps.INSTANCE, tag.get("dimension"))) -- .resultOrPartial(LOGGER::error) -- .orElseThrow(() -> new IllegalArgumentException("Invalid map dimension: " + tag.get("dimension"))); -+ // Paper start - fix "Not a string" spam -+ Tag dimension = tag.get("dimension"); -+ if (dimension instanceof final net.minecraft.nbt.NumericTag numericTag && numericTag.getAsInt() >= org.bukkit.craftbukkit.CraftWorld.CUSTOM_DIMENSION_OFFSET) { -+ long least = tag.getLong("UUIDLeast"); -+ long most = tag.getLong("UUIDMost"); -+ -+ if (least != 0L && most != 0L) { -+ java.util.UUID uuid = new java.util.UUID(most, least); -+ org.bukkit.craftbukkit.CraftWorld world = (org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(uuid); -+ if (world != null) { -+ dimension = net.minecraft.nbt.StringTag.valueOf("minecraft:" + world.getName().toLowerCase(java.util.Locale.ENGLISH)); -+ } else { -+ dimension = net.minecraft.nbt.StringTag.valueOf("bukkit:_invalidworld_"); -+ } -+ } else { -+ dimension = net.minecraft.nbt.StringTag.valueOf("bukkit:_invalidworld_"); -+ } -+ } -+ com.mojang.serialization.DataResult> dataresult = DimensionType.parseLegacy(new Dynamic(NbtOps.INSTANCE, dimension)); // CraftBukkit - decompile error -+ // Paper end - fix "Not a string" spam -+ // CraftBukkit start -+ ResourceKey resourceKey = dataresult.resultOrPartial(LOGGER::error).orElseGet(() -> { -+ long least = tag.getLong("UUIDLeast"); -+ long most = tag.getLong("UUIDMost"); -+ -+ if (least != 0L && most != 0L) { -+ java.util.UUID uniqueId = new java.util.UUID(most, least); -+ -+ org.bukkit.craftbukkit.CraftWorld world = (org.bukkit.craftbukkit.CraftWorld) org.bukkit.Bukkit.getWorld(uniqueId); -+ // Check if the stored world details are correct. -+ if (world == null) { -+ /* All Maps which do not have their valid world loaded are set to a dimension which hopefully won't be reached. -+ This is to prevent them being corrupted with the wrong map data. */ -+ // PAIL: Use Vanilla exception handling for now -+ } else { -+ return world.getHandle().dimension(); -+ } -+ } -+ throw new IllegalArgumentException("Invalid map dimension: " + String.valueOf(tag.get("dimension"))); -+ // CraftBukkit end -+ }); - int _int = tag.getInt("xCenter"); - int _int1 = tag.getInt("zCenter"); - byte b = (byte)Mth.clamp(tag.getByte("scale"), 0, 4); -@@ -114,6 +_,7 @@ - if (byteArray.length == 16384) { - mapItemSavedData.colors = byteArray; - } -+ mapItemSavedData.vanillaRender.buffer = byteArray; // Paper - Use Vanilla map renderer when possible - - RegistryOps registryOps = levelRegistry.createSerializationContext(NbtOps.INSTANCE); - -@@ -154,6 +_,25 @@ - .encodeStart(NbtOps.INSTANCE, this.dimension.location()) - .resultOrPartial(LOGGER::error) - .ifPresent(dimension -> tag.put("dimension", dimension)); -+ // CraftBukkit start -+ if (true) { -+ if (this.uniqueId == null) { -+ for (org.bukkit.World world : this.server.getWorlds()) { -+ org.bukkit.craftbukkit.CraftWorld cWorld = (org.bukkit.craftbukkit.CraftWorld) world; -+ if (cWorld.getHandle().dimension() == this.dimension) { -+ this.uniqueId = cWorld.getUID(); -+ break; -+ } -+ } -+ } -+ /* Perform a second check to see if a matching world was found, this is a necessary -+ change incase Maps are forcefully unlinked from a World and lack a UID.*/ -+ if (this.uniqueId != null) { -+ tag.putLong("UUIDLeast", this.uniqueId.getLeastSignificantBits()); -+ tag.putLong("UUIDMost", this.uniqueId.getMostSignificantBits()); -+ } -+ } -+ // CraftBukkit end - tag.putInt("xCenter", this.centerX); - tag.putInt("zCenter", this.centerZ); - tag.putByte("scale", this.scale); -@@ -233,10 +_,12 @@ +@@ -204,6 +_,7 @@ } MapFrame mapFrame1 = new MapFrame(pos, frame.getDirection().get2DDataValue() * 90, frame.getId()); @@ -127,12 +79,15 @@ this.addDecoration( MapDecorationTypes.FRAME, player.level(), getFrameKey(frame.getId()), pos.getX(), pos.getZ(), frame.getDirection().get2DDataValue() * 90, null ); - this.frameMarkers.put(mapFrame1.getId(), mapFrame1); +@@ -211,6 +_,7 @@ + if (!mapFrame1.equals(mapFrame2)) { + this.setDirty(); + } + } // Paper - Limit item frame cursors on maps } MapDecorations mapDecorations = mapStack.getOrDefault(DataComponents.MAP_DECORATIONS, MapDecorations.EMPTY); -@@ -267,7 +_,7 @@ +@@ -241,7 +_,7 @@ this.trackedDecorationCount--; } @@ -141,7 +96,7 @@ } public static void addTargetDecoration(ItemStack stack, BlockPos pos, String type, Holder mapDecorationType) { -@@ -421,7 +_,7 @@ +@@ -395,7 +_,7 @@ return true; } @@ -149,8 +104,8 @@ + if (!this.isTrackedCountOverLimit(((Level) accessor).paperConfig().maps.itemFrameCursorLimit)) { // Paper - Limit item frame cursors on maps this.bannerMarkers.put(mapBanner.getId(), mapBanner); this.addDecoration(mapBanner.getDecoration(), accessor, mapBanner.getId(), d, d1, 180.0, mapBanner.name().orElse(null)); - return true; -@@ -521,7 +_,7 @@ + this.setDirty(); +@@ -497,7 +_,7 @@ this.player = player; } @@ -159,7 +114,7 @@ int i = this.minDirtyX; int i1 = this.minDirtyY; int i2 = this.maxDirtyX + 1 - this.minDirtyX; -@@ -530,7 +_,7 @@ +@@ -506,7 +_,7 @@ for (int i4 = 0; i4 < i2; i4++) { for (int i5 = 0; i5 < i3; i5++) { @@ -168,7 +123,7 @@ } } -@@ -540,17 +_,38 @@ +@@ -516,17 +_,38 @@ @Nullable Packet nextUpdatePacket(MapId mapId) { MapItemSavedData.MapPatch mapPatch; @@ -197,7 +152,7 @@ this.dirtyDecorations = false; - collection = MapItemSavedData.this.decorations.values(); + // CraftBukkit start -+ java.util.Collection icons = new java.util.ArrayList(); ++ Collection icons = new java.util.ArrayList<>(); + if (vanillaMaps) this.addSeenPlayers(icons); // Paper + + for (org.bukkit.map.MapCursor cursor : render.cursors) { @@ -210,7 +165,7 @@ } else { collection = null; } -@@ -578,6 +_,23 @@ +@@ -554,6 +_,23 @@ private void markDecorationsDirty() { this.dirtyDecorations = true; } @@ -234,3 +189,75 @@ } record MapDecorationLocation(Holder type, byte x, byte y, byte rot) { +@@ -598,4 +_,71 @@ + } + } + } ++ ++ // Paper start - store target world by uuid in addition to dimension ++ record UUIDAndError(java.util.UUID uuid, String faultyDimension) { ++ ++ } ++ record UUIDBackedDimension(@Nullable ResourceKey resourceKey, @Nullable UUIDAndError uuid) { ++ public UUIDBackedDimension(final @org.jetbrains.annotations.NotNull ResourceKey resourceKey) { ++ this(resourceKey, null); ++ } ++ public UUIDBackedDimension { ++ com.google.common.base.Preconditions.checkArgument(resourceKey != null || uuid != null, "Created uuid backed dimension with null level and uuid. This is a bug"); ++ } ++ ++ public @org.jetbrains.annotations.NotNull ResourceKey resolveOrThrow() { ++ if (resourceKey != null) return resourceKey; ++ ++ final org.bukkit.World worldByUUID = org.bukkit.Bukkit.getWorld(uuid.uuid()); ++ if (worldByUUID != null) return ((org.bukkit.craftbukkit.CraftWorld) worldByUUID).getHandle().dimension(); ++ ++ throw new IllegalArgumentException("Invalid dimension " + uuid.faultyDimension() + " and unknown world uuid " + uuid.uuid); ++ } ++ } ++ ++ private UUIDBackedDimension packUUIDBackedDimension() { ++ final net.minecraft.server.level.ServerLevel mappedLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(this.dimension); ++ return new UUIDBackedDimension(this.dimension, mappedLevel == null ? null : new UUIDAndError(mappedLevel.uuid, "")); ++ } ++ ++ private static com.mojang.serialization.MapCodec createUUIDBackedDimensionKeyCodec() { ++ return new com.mojang.serialization.MapCodec<>() { ++ @Override ++ public java.util.stream.Stream keys(final com.mojang.serialization.DynamicOps ops) { ++ return java.util.stream.Stream.of("dimension", "UUIDLeast", "UUIDMost").map(ops::createString); ++ } ++ ++ @Override ++ public com.mojang.serialization.DataResult decode(final com.mojang.serialization.DynamicOps ops, ++ final com.mojang.serialization.MapLike input) { ++ final com.mojang.serialization.DataResult foundDimension = Level.RESOURCE_KEY_CODEC.decode(ops, input.get("dimension")) ++ .map(Pair::getFirst) ++ .map(UUIDBackedDimension::new); // Do not pack uuid when reading as the level itself might reference an unloaded world. UUID lookup would be faulty + should be re-generated when written. ++ if (foundDimension.isSuccess()) return foundDimension; ++ ++ // Fallback attempt at parsing the uuid ++ final com.mojang.serialization.DataResult fromUUID = Codec.LONG.decode(ops, input.get("UUIDMost")).map(Pair::getFirst).apply2( ++ java.util.UUID::new, ++ Codec.LONG.decode(ops, input.get("UUIDLeast")).map(Pair::getFirst) ++ ).map(uuid -> new UUIDBackedDimension(null, new UUIDAndError(uuid, String.valueOf(input.get("dimension"))))); ++ if (fromUUID.isSuccess()) return fromUUID; ++ ++ return foundDimension; // Return the found dimension instead, it's error is more "accurate" over the bukkit added uuids. ++ } ++ ++ @Override ++ public com.mojang.serialization.RecordBuilder encode(final UUIDBackedDimension input, ++ final com.mojang.serialization.DynamicOps ops, ++ final com.mojang.serialization.RecordBuilder prefix) { ++ prefix.add("dimension", input.resourceKey(), Level.RESOURCE_KEY_CODEC); ++ if (input.uuid != null) { ++ prefix.add("UUIDMost", input.uuid.uuid().getMostSignificantBits(), Codec.LONG); ++ prefix.add("UUIDLeast", input.uuid.uuid().getLeastSignificantBits(), Codec.LONG); ++ } ++ return prefix; ++ } ++ }; ++ } ++ // Paper end - store target world by uuid in addition to dimension + } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch index 41f17dad5..7fb3ede9c 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/DimensionDataStorage.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/DimensionDataStorage.java +++ b/net/minecraft/world/level/storage/DimensionDataStorage.java -@@ -139,7 +_,7 @@ +@@ -150,7 +_,7 @@ } else { int i = Util.maxAllowedExecutorThreads(); int size = map.size(); @@ -9,12 +9,12 @@ this.pendingWriteFuture = this.pendingWriteFuture.thenCompose(object -> { List> list = new ArrayList<>(i); int i1 = Mth.positiveCeilDiv(size, i); -@@ -160,7 +_,7 @@ +@@ -171,7 +_,7 @@ object -> CompletableFuture.allOf( map.entrySet() .stream() -- .map(entry -> CompletableFuture.runAsync(() -> tryWrite(entry.getKey(), entry.getValue()), Util.ioPool())) -+ .map(entry -> CompletableFuture.runAsync(() -> tryWrite(entry.getKey(), entry.getValue()), Util.DIMENSION_DATA_IO_POOL)) // Paper - Separate dimension data IO pool +- .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.ioPool())) ++ .map(entry -> CompletableFuture.runAsync(() -> this.tryWrite(entry.getKey(), entry.getValue()), Util.DIMENSION_DATA_IO_POOL)) // Paper - Separate dimension data IO pool .toArray(CompletableFuture[]::new) ) ); diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch index 1c0cac272..9ddec5074 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/LevelStorageSource.java.patch @@ -8,7 +8,7 @@ return new LevelDataAndDimensions(primaryLevelData, complete); } -@@ -340,25 +_,39 @@ +@@ -341,25 +_,39 @@ return this.backupDir; } @@ -53,7 +53,7 @@ public record LevelCandidates(List levels) implements Iterable { public boolean isEmpty() { return this.levels.isEmpty(); -@@ -409,8 +_,12 @@ +@@ -410,8 +_,12 @@ public final LevelStorageSource.LevelDirectory levelDirectory; private final String levelId; private final Map resources = Maps.newHashMap(); @@ -67,7 +67,7 @@ this.levelId = levelId; this.levelDirectory = new LevelStorageSource.LevelDirectory(levelDir); this.lock = DirectoryLock.create(levelDir); -@@ -453,7 +_,7 @@ +@@ -454,7 +_,7 @@ } public Path getDimensionPath(ResourceKey dimensionPath) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch index a462f3265..6a336da5f 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PlayerDataStorage.java.patch @@ -1,16 +1,5 @@ --- a/net/minecraft/world/level/storage/PlayerDataStorage.java +++ b/net/minecraft/world/level/storage/PlayerDataStorage.java -@@ -14,8 +_,10 @@ - import net.minecraft.nbt.NbtAccounter; - import net.minecraft.nbt.NbtIo; - import net.minecraft.nbt.NbtUtils; -+import net.minecraft.server.level.ServerPlayer; - import net.minecraft.util.datafix.DataFixTypes; - import net.minecraft.world.entity.player.Player; -+import org.bukkit.craftbukkit.entity.CraftPlayer; - import org.slf4j.Logger; - - public class PlayerDataStorage { @@ -31,6 +_,7 @@ } @@ -82,8 +71,8 @@ - Optional optional = this.load(player, ".dat"); + // CraftBukkit start + return this.load(player.getName().getString(), player.getStringUUID()).map((tag) -> { -+ if (player instanceof ServerPlayer serverPlayer) { -+ CraftPlayer craftPlayer = serverPlayer.getBukkitEntity(); ++ if (player instanceof net.minecraft.server.level.ServerPlayer serverPlayer) { ++ org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer = serverPlayer.getBukkitEntity(); + // Only update first played if it is older than the one we have + long modified = new File(this.playerDir, player.getStringUUID() + ".dat").lastModified(); + if (modified < craftPlayer.getFirstPlayed()) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch index 8cd7249f8..f9257d8b6 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/PrimaryLevelData.java.patch @@ -31,16 +31,16 @@ .resultOrPartial(Util.prefix("WorldGenSettings: ", LOGGER::error)) .ifPresent(worldOptionsTag -> nbt.put("WorldGenSettings", worldOptionsTag)); nbt.putInt("GameType", this.settings.gameType().getId()); -@@ -281,6 +_,8 @@ - if (this.wanderingTraderId != null) { - nbt.putUUID("WanderingTraderId", this.wanderingTraderId); - } +@@ -276,6 +_,8 @@ + nbt.putInt("WanderingTraderSpawnDelay", this.wanderingTraderSpawnDelay); + nbt.putInt("WanderingTraderSpawnChance", this.wanderingTraderSpawnChance); + nbt.storeNullable("WanderingTraderId", UUIDUtil.CODEC, this.wanderingTraderId); + nbt.putString("Bukkit.Version", org.bukkit.Bukkit.getName() + "/" + org.bukkit.Bukkit.getVersion() + "/" + org.bukkit.Bukkit.getBukkitVersion()); // CraftBukkit + this.world.getWorld().storeBukkitValues(nbt); // CraftBukkit - add pdc } private static ListTag stringCollectionToTag(Set stringCollection) { -@@ -358,6 +_,25 @@ +@@ -353,6 +_,25 @@ @Override public void setThundering(boolean thundering) { @@ -66,7 +66,7 @@ this.thundering = thundering; } -@@ -378,6 +_,26 @@ +@@ -373,6 +_,26 @@ @Override public void setRaining(boolean isRaining) { @@ -93,7 +93,7 @@ this.raining = isRaining; } -@@ -444,6 +_,12 @@ +@@ -439,6 +_,12 @@ @Override public void setDifficulty(Difficulty difficulty) { this.settings = this.settings.withDifficulty(difficulty); @@ -106,7 +106,7 @@ } @Override -@@ -579,6 +_,14 @@ +@@ -574,6 +_,14 @@ public LevelSettings getLevelSettings() { return this.settings.copy(); } diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch index 53f28e336..c93c7dddd 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/LootTable.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java -@@ -48,6 +_,7 @@ +@@ -52,6 +_,7 @@ private final List pools; private final List functions; private final BiFunction compositeFunction; @@ -8,7 +8,7 @@ LootTable(ContextKeySet paramSet, Optional randomSequence, List pools, List functions) { this.paramSet = paramSet; -@@ -58,9 +_,10 @@ +@@ -62,9 +_,10 @@ } public static Consumer createStackSplitter(ServerLevel level, Consumer output) { @@ -20,7 +20,7 @@ output.accept(itemStack); } else { int count = itemStack.getCount(); -@@ -141,9 +_,22 @@ +@@ -145,9 +_,22 @@ } public void fill(Container container, LootParams params, long seed) { diff --git a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch index 29f028e11..8aa494bf0 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java +++ b/net/minecraft/world/level/storage/loot/functions/ExplorationMapFunction.java -@@ -89,7 +_,16 @@ +@@ -87,7 +_,16 @@ Vec3 vec3 = context.getOptionalParameter(LootContextParams.ORIGIN); if (vec3 != null) { ServerLevel level = context.getLevel(); diff --git a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch b/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch index c8b1a7802..35907f4c1 100644 --- a/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/scores/ScoreboardSaveData.java.patch @@ -1,10 +1,11 @@ --- a/net/minecraft/world/scores/ScoreboardSaveData.java +++ b/net/minecraft/world/scores/ScoreboardSaveData.java -@@ -148,6 +_,7 @@ - ListTag listTag = new ListTag(); +@@ -39,7 +_,7 @@ + this.scoreboard.getObjectives().stream().map(Objective::pack).toList(), + this.scoreboard.packPlayerScores(), + map, +- this.scoreboard.getPlayerTeams().stream().map(PlayerTeam::pack).toList() ++ this.scoreboard.getPlayerTeams().stream().filter(p -> io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams || !p.getPlayers().isEmpty()).map(PlayerTeam::pack).toList() // Paper - Don't save empty scoreboard teams to scoreboard.dat + ); + } - for (PlayerTeam playerTeam : this.scoreboard.getPlayerTeams()) { -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams && playerTeam.getPlayers().isEmpty()) continue; // Paper - Don't save empty scoreboard teams to scoreboard.dat - CompoundTag compoundTag = new CompoundTag(); - compoundTag.putString("Name", playerTeam.getName()); - compoundTag.putString("DisplayName", Component.Serializer.toJson(playerTeam.getDisplayName(), levelRegistry)); diff --git a/paper-server/patches/features/0015-Rewrite-dataconverter-system.patch b/paper-server/patches/unapplied/0015-Rewrite-dataconverter-system.patch similarity index 100% rename from paper-server/patches/features/0015-Rewrite-dataconverter-system.patch rename to paper-server/patches/unapplied/0015-Rewrite-dataconverter-system.patch diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java new file mode 100644 index 000000000..d931bea60 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAmethystCluster.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.AmethystClusterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.AmethystCluster; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftAmethystCluster extends CraftBlockData implements AmethystCluster { + private static final EnumProperty FACING = AmethystClusterBlock.FACING; + + private static final BooleanProperty WATERLOGGED = AmethystClusterBlock.WATERLOGGED; + + public CraftAmethystCluster(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java new file mode 100644 index 000000000..9523eb741 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAnvil.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.AnvilBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftAnvil extends CraftBlockData implements Directional { + private static final EnumProperty FACING = AnvilBlock.FACING; + + public CraftAnvil(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAttachedStem.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAttachedStem.java new file mode 100644 index 000000000..d5f2f41bb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftAttachedStem.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.AttachedStemBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftAttachedStem extends CraftBlockData implements Directional { + private static final EnumProperty FACING = AttachedStemBlock.FACING; + + public CraftAttachedStem(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBambooStalk.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBambooStalk.java new file mode 100644 index 000000000..2dac138e3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBambooStalk.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BambooStalkBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BambooLeaves; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Bamboo; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBambooStalk extends CraftBlockData implements Bamboo { + private static final IntegerProperty AGE = BambooStalkBlock.AGE; + + private static final EnumProperty LEAVES = BambooStalkBlock.LEAVES; + + private static final IntegerProperty STAGE = BambooStalkBlock.STAGE; + + public CraftBambooStalk(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public Bamboo.Leaves getLeaves() { + return this.get(LEAVES, Bamboo.Leaves.class); + } + + @Override + public void setLeaves(final Bamboo.Leaves leaves) { + Preconditions.checkArgument(leaves != null, "leaves cannot be null!"); + this.set(LEAVES, leaves); + } + + @Override + public int getStage() { + return this.get(STAGE); + } + + @Override + public void setStage(final int stage) { + this.set(STAGE, stage); + } + + @Override + public int getMaximumStage() { + return STAGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java new file mode 100644 index 000000000..f6d39e3e5 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBanner.java @@ -0,0 +1,35 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BannerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Rotatable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftBanner extends CraftBlockData implements Rotatable { + private static final IntegerProperty ROTATION = BannerBlock.ROTATION; + + public CraftBanner(BlockState state) { + super(state); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java new file mode 100644 index 000000000..67428ff04 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrel.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BarrelBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Barrel; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBarrel extends CraftBlockData implements Barrel { + private static final EnumProperty FACING = BarrelBlock.FACING; + + private static final BooleanProperty OPEN = BarrelBlock.OPEN; + + public CraftBarrel(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrier.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrier.java new file mode 100644 index 000000000..f3a1a2ebe --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBarrier.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BarrierBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBarrier extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = BarrierBlock.WATERLOGGED; + + public CraftBarrier(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralFan.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralFan.java new file mode 100644 index 000000000..ba47dc86a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralFan.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BaseCoralFanBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBaseCoralFan extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = BaseCoralFanBlock.WATERLOGGED; + + public CraftBaseCoralFan(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralPlant.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralPlant.java new file mode 100644 index 000000000..b5ba21b32 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralPlant.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BaseCoralPlantBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBaseCoralPlant extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = BaseCoralPlantBlock.WATERLOGGED; + + public CraftBaseCoralPlant(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralWallFan.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralWallFan.java new file mode 100644 index 000000000..fc818c4ca --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBaseCoralWallFan.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BaseCoralWallFanBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.CoralWallFan; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBaseCoralWallFan extends CraftBlockData implements CoralWallFan { + private static final EnumProperty FACING = BaseCoralWallFanBlock.FACING; + + private static final BooleanProperty WATERLOGGED = BaseCoralWallFanBlock.WATERLOGGED; + + public CraftBaseCoralWallFan(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBed.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBed.java new file mode 100644 index 000000000..9b03035bc --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBed.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BedBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BedPart; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Bed; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBed extends CraftBlockData implements Bed { + private static final EnumProperty FACING = BedBlock.FACING; + + private static final BooleanProperty OCCUPIED = BedBlock.OCCUPIED; + + private static final EnumProperty PART = BedBlock.PART; + + public CraftBed(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isOccupied() { + return this.get(OCCUPIED); + } + + @Override + public void setOccupied(final boolean occupied) { + this.set(OCCUPIED, occupied); + } + + @Override + public Bed.Part getPart() { + return this.get(PART, Bed.Part.class); + } + + @Override + public void setPart(final Bed.Part part) { + Preconditions.checkArgument(part != null, "part cannot be null!"); + this.set(PART, part); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeehive.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeehive.java new file mode 100644 index 000000000..758e17b22 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeehive.java @@ -0,0 +1,56 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BeehiveBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Beehive; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBeehive extends CraftBlockData implements Beehive { + private static final EnumProperty FACING = BeehiveBlock.FACING; + + private static final IntegerProperty HONEY_LEVEL = BeehiveBlock.HONEY_LEVEL; + + public CraftBeehive(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public int getHoneyLevel() { + return this.get(HONEY_LEVEL); + } + + @Override + public void setHoneyLevel(final int honeyLevel) { + this.set(HONEY_LEVEL, honeyLevel); + } + + @Override + public int getMaximumHoneyLevel() { + return HONEY_LEVEL.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java new file mode 100644 index 000000000..aff49f95d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBeetroot.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BeetrootBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBeetroot extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = BeetrootBlock.AGE; + + public CraftBeetroot(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBell.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBell.java new file mode 100644 index 000000000..d4f1ee372 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBell.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BellBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BellAttachType; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Bell; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBell extends CraftBlockData implements Bell { + private static final EnumProperty ATTACHMENT = BellBlock.ATTACHMENT; + + private static final EnumProperty FACING = BellBlock.FACING; + + private static final BooleanProperty POWERED = BellBlock.POWERED; + + public CraftBell(BlockState state) { + super(state); + } + + @Override + public Bell.Attachment getAttachment() { + return this.get(ATTACHMENT, Bell.Attachment.class); + } + + @Override + public void setAttachment(final Bell.Attachment attachment) { + Preconditions.checkArgument(attachment != null, "attachment cannot be null!"); + this.set(ATTACHMENT, attachment); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java new file mode 100644 index 000000000..a097689fc --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleaf.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BigDripleafBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.BigDripleaf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBigDripleaf extends CraftBlockData implements BigDripleaf { + private static final EnumProperty FACING = BigDripleafBlock.FACING; + + private static final EnumProperty TILT = BlockStateProperties.TILT; + + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftBigDripleaf(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public BigDripleaf.Tilt getTilt() { + return this.get(TILT, BigDripleaf.Tilt.class); + } + + @Override + public void setTilt(final BigDripleaf.Tilt tilt) { + Preconditions.checkArgument(tilt != null, "tilt cannot be null!"); + this.set(TILT, tilt); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java new file mode 100644 index 000000000..46f666338 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBigDripleafStem.java @@ -0,0 +1,52 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BigDripleafStemBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Dripleaf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBigDripleafStem extends CraftBlockData implements Dripleaf { + private static final EnumProperty FACING = BigDripleafStemBlock.FACING; + + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftBigDripleafStem(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java new file mode 100644 index 000000000..4fb939d05 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBlastFurnace.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.BlastFurnaceBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Furnace; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBlastFurnace extends CraftBlockData implements Furnace { + private static final EnumProperty FACING = BlastFurnaceBlock.FACING; + + private static final BooleanProperty LIT = BlastFurnaceBlock.LIT; + + public CraftBlastFurnace(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java new file mode 100644 index 000000000..0d1a9b20c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrewingStand.java @@ -0,0 +1,45 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.world.level.block.BrewingStandBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.BrewingStand; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBrewingStand extends CraftBlockData implements BrewingStand { + private static final BooleanProperty[] HAS_BOTTLE = BrewingStandBlock.HAS_BOTTLE; + + public CraftBrewingStand(BlockState state) { + super(state); + } + + @Override + public boolean hasBottle(final int index) { + return this.get(HAS_BOTTLE[index]); + } + + @Override + public void setBottle(final int index, final boolean bottle) { + this.set(HAS_BOTTLE[index], bottle); + } + + @Override + public Set getBottles() { + ImmutableSet.Builder bottles = ImmutableSet.builder(); + for (int index = 0, len = HAS_BOTTLE.length; index < len; index++) { + if (this.get(HAS_BOTTLE[index])) { + bottles.add(index); + } + } + return bottles.build(); + } + + @Override + public int getMaximumBottles() { + return HAS_BOTTLE.length; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrushable.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrushable.java new file mode 100644 index 000000000..a6d25ef59 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBrushable.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Brushable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBrushable extends CraftBlockData implements Brushable { + private static final IntegerProperty DUSTED = BlockStateProperties.DUSTED; + + public CraftBrushable(BlockState state) { + super(state); + } + + @Override + public int getDusted() { + return this.get(DUSTED); + } + + @Override + public void setDusted(final int dusted) { + this.set(DUSTED, dusted); + } + + @Override + public int getMaximumDusted() { + return DUSTED.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java new file mode 100644 index 000000000..48cd35fb6 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftBubbleColumn.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.BubbleColumnBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.BubbleColumn; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftBubbleColumn extends CraftBlockData implements BubbleColumn { + private static final BooleanProperty DRAG_DOWN = BubbleColumnBlock.DRAG_DOWN; + + public CraftBubbleColumn(BlockState state) { + super(state); + } + + @Override + public boolean isDrag() { + return this.get(DRAG_DOWN); + } + + @Override + public void setDrag(final boolean drag) { + this.set(DRAG_DOWN, drag); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftButton.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftButton.java new file mode 100644 index 000000000..de870c63e --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftButton.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ButtonBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Switch; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftButton extends CraftBlockData implements Switch { + private static final EnumProperty FACE = ButtonBlock.FACE; + + private static final EnumProperty FACING = ButtonBlock.FACING; + + private static final BooleanProperty POWERED = ButtonBlock.POWERED; + + public CraftButton(BlockState state) { + super(state); + } + + @Override + public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() { + return this.get(FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class); + } + + @Override + public void setAttachedFace( + final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) { + Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!"); + this.set(FACE, attachedFace); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java new file mode 100644 index 000000000..6a41d3d0f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCactus.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CactusBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCactus extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = CactusBlock.AGE; + + public CraftCactus(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCake.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCake.java new file mode 100644 index 000000000..e889abe72 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCake.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CakeBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Cake; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCake extends CraftBlockData implements Cake { + private static final IntegerProperty BITES = CakeBlock.BITES; + + public CraftCake(BlockState state) { + super(state); + } + + @Override + public int getBites() { + return this.get(BITES); + } + + @Override + public void setBites(final int bites) { + this.set(BITES, bites); + } + + @Override + public int getMaximumBites() { + return BITES.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCalibratedSculkSensor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCalibratedSculkSensor.java new file mode 100644 index 000000000..ea2a71a6e --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCalibratedSculkSensor.java @@ -0,0 +1,83 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CalibratedSculkSensorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.SculkSensorPhase; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.CalibratedSculkSensor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCalibratedSculkSensor extends CraftBlockData implements CalibratedSculkSensor { + private static final EnumProperty FACING = CalibratedSculkSensorBlock.FACING; + + private static final IntegerProperty POWER = CalibratedSculkSensorBlock.POWER; + + private static final EnumProperty PHASE = CalibratedSculkSensorBlock.PHASE; + + private static final BooleanProperty WATERLOGGED = CalibratedSculkSensorBlock.WATERLOGGED; + + public CraftCalibratedSculkSensor(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public int getPower() { + return this.get(POWER); + } + + @Override + public void setPower(final int power) { + this.set(POWER, power); + } + + @Override + public int getMaximumPower() { + return POWER.max; + } + + @Override + public org.bukkit.block.data.type.SculkSensor.Phase getSculkSensorPhase() { + return this.get(PHASE, org.bukkit.block.data.type.SculkSensor.Phase.class); + } + + @Override + public void setSculkSensorPhase(final org.bukkit.block.data.type.SculkSensor.Phase phase) { + Preconditions.checkArgument(phase != null, "phase cannot be null!"); + this.set(PHASE, phase); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java new file mode 100644 index 000000000..05d85edb1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCampfire.java @@ -0,0 +1,75 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CampfireBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Campfire; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCampfire extends CraftBlockData implements Campfire { + private static final EnumProperty FACING = CampfireBlock.FACING; + + private static final BooleanProperty LIT = CampfireBlock.LIT; + + private static final BooleanProperty SIGNAL_FIRE = CampfireBlock.SIGNAL_FIRE; + + private static final BooleanProperty WATERLOGGED = CampfireBlock.WATERLOGGED; + + public CraftCampfire(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } + + @Override + public boolean isSignalFire() { + return this.get(SIGNAL_FIRE); + } + + @Override + public void setSignalFire(final boolean signalFire) { + this.set(SIGNAL_FIRE, signalFire); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java new file mode 100644 index 000000000..db1ce7c45 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandle.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CandleBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Candle; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCandle extends CraftBlockData implements Candle { + private static final IntegerProperty CANDLES = CandleBlock.CANDLES; + + private static final BooleanProperty LIT = CandleBlock.LIT; + + private static final BooleanProperty WATERLOGGED = CandleBlock.WATERLOGGED; + + public CraftCandle(BlockState state) { + super(state); + } + + @Override + public int getCandles() { + return this.get(CANDLES); + } + + @Override + public void setCandles(final int candles) { + this.set(CANDLES, candles); + } + + @Override + public int getMinimumCandles() { + return CANDLES.min; + } + + @Override + public int getMaximumCandles() { + return CANDLES.max; + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java new file mode 100644 index 000000000..103b39b0b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCandleCake.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CandleCakeBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Lightable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCandleCake extends CraftBlockData implements Lightable { + private static final BooleanProperty LIT = CandleCakeBlock.LIT; + + public CraftCandleCake(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarrot.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarrot.java new file mode 100644 index 000000000..50a113f01 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarrot.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CarrotBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCarrot extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = CarrotBlock.AGE; + + public CraftCarrot(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarvedPumpkin.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarvedPumpkin.java new file mode 100644 index 000000000..0cdaee616 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCarvedPumpkin.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CarvedPumpkinBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCarvedPumpkin extends CraftBlockData implements Directional { + private static final EnumProperty FACING = CarvedPumpkinBlock.FACING; + + public CraftCarvedPumpkin(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java new file mode 100644 index 000000000..66d271e6c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVines.java @@ -0,0 +1,45 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CaveVinesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.CaveVines; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCaveVines extends CraftBlockData implements CaveVines { + private static final IntegerProperty AGE = CaveVinesBlock.AGE; + + private static final BooleanProperty BERRIES = CaveVinesBlock.BERRIES; + + public CraftCaveVines(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public boolean hasBerries() { + return this.get(BERRIES); + } + + @Override + public void setBerries(final boolean berries) { + this.set(BERRIES, berries); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java new file mode 100644 index 000000000..ca2074cc8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCaveVinesPlant.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CaveVinesPlantBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.CaveVinesPlant; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCaveVinesPlant extends CraftBlockData implements CaveVinesPlant { + private static final BooleanProperty BERRIES = CaveVinesPlantBlock.BERRIES; + + public CraftCaveVinesPlant(BlockState state) { + super(state); + } + + @Override + public boolean hasBerries() { + return this.get(BERRIES); + } + + @Override + public void setBerries(final boolean berries) { + this.set(BERRIES, berries); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java new file mode 100644 index 000000000..80151fbd5 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCeilingHangingSign.java @@ -0,0 +1,60 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CeilingHangingSignBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.HangingSign; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftCeilingHangingSign extends CraftBlockData implements HangingSign { + private static final BooleanProperty ATTACHED = CeilingHangingSignBlock.ATTACHED; + + private static final IntegerProperty ROTATION = CeilingHangingSignBlock.ROTATION; + + private static final BooleanProperty WATERLOGGED = CeilingHangingSignBlock.WATERLOGGED; + + public CraftCeilingHangingSign(BlockState state) { + super(state); + } + + @Override + public boolean isAttached() { + return this.get(ATTACHED); + } + + @Override + public void setAttached(final boolean attached) { + this.set(ATTACHED, attached); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChain.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChain.java new file mode 100644 index 000000000..8885f26ce --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChain.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ChainBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.type.Chain; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftChain extends CraftBlockData implements Chain { + private static final EnumProperty AXIS = ChainBlock.AXIS; + + private static final BooleanProperty WATERLOGGED = ChainBlock.WATERLOGGED; + + public CraftChain(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChest.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChest.java new file mode 100644 index 000000000..f598e7218 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChest.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ChestBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Chest; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftChest extends CraftBlockData implements Chest { + private static final EnumProperty FACING = ChestBlock.FACING; + + private static final EnumProperty TYPE = ChestBlock.TYPE; + + private static final BooleanProperty WATERLOGGED = ChestBlock.WATERLOGGED; + + public CraftChest(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public Chest.Type getType() { + return this.get(TYPE, Chest.Type.class); + } + + @Override + public void setType(final Chest.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java new file mode 100644 index 000000000..fa4118e18 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChiseledBookShelf.java @@ -0,0 +1,70 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.List; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ChiseledBookShelfBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.ChiseledBookshelf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftChiseledBookShelf extends CraftBlockData implements ChiseledBookshelf { + private static final EnumProperty HORIZONTAL_FACING = BlockStateProperties.HORIZONTAL_FACING; + + private static final List SLOT_OCCUPIED_PROPERTIES = ChiseledBookShelfBlock.SLOT_OCCUPIED_PROPERTIES; + + public CraftChiseledBookShelf(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(HORIZONTAL_FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(HORIZONTAL_FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(HORIZONTAL_FACING, BlockFace.class); + } + + @Override + public boolean isSlotOccupied(final int index) { + return this.get(SLOT_OCCUPIED_PROPERTIES.get(index)); + } + + @Override + public void setSlotOccupied(final int index, final boolean slotOccupied) { + this.set(SLOT_OCCUPIED_PROPERTIES.get(index), slotOccupied); + } + + @Override + public Set getOccupiedSlots() { + ImmutableSet.Builder slotOccupieds = ImmutableSet.builder(); + for (int index = 0, size = SLOT_OCCUPIED_PROPERTIES.size(); index < size; index++) { + if (this.get(SLOT_OCCUPIED_PROPERTIES.get(index))) { + slotOccupieds.add(index); + } + } + return slotOccupieds.build(); + } + + @Override + public int getMaximumOccupiedSlots() { + return SLOT_OCCUPIED_PROPERTIES.size(); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java new file mode 100644 index 000000000..7aaca089a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusFlower.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.ChorusFlowerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftChorusFlower extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = ChorusFlowerBlock.AGE; + + public CraftChorusFlower(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusPlant.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusPlant.java new file mode 100644 index 000000000..860eb36a8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftChorusPlant.java @@ -0,0 +1,58 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.ChorusPlantBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftChorusPlant extends CraftBlockData implements MultipleFacing { + private static final Map PROPERTY_BY_DIRECTION = ChorusPlantBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftChorusPlant(BlockState state) { + super(state); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java new file mode 100644 index 000000000..b185a1127 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCocoa.java @@ -0,0 +1,56 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CocoaBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Cocoa; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCocoa extends CraftBlockData implements Cocoa { + private static final IntegerProperty AGE = CocoaBlock.AGE; + + private static final EnumProperty FACING = CocoaBlock.FACING; + + public CraftCocoa(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCommandBlock.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCommandBlock.java new file mode 100644 index 000000000..ba8fa0b36 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCommandBlock.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.CommandBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCommandBlock extends CraftBlockData implements CommandBlock { + private static final BooleanProperty CONDITIONAL = net.minecraft.world.level.block.CommandBlock.CONDITIONAL; + + private static final EnumProperty FACING = net.minecraft.world.level.block.CommandBlock.FACING; + + public CraftCommandBlock(BlockState state) { + super(state); + } + + @Override + public boolean isConditional() { + return this.get(CONDITIONAL); + } + + @Override + public void setConditional(final boolean conditional) { + this.set(CONDITIONAL, conditional); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComparator.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComparator.java new file mode 100644 index 000000000..3354b67e6 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComparator.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ComparatorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.ComparatorMode; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Comparator; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftComparator extends CraftBlockData implements Comparator { + private static final EnumProperty FACING = ComparatorBlock.FACING; + + private static final EnumProperty MODE = ComparatorBlock.MODE; + + private static final BooleanProperty POWERED = ComparatorBlock.POWERED; + + public CraftComparator(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public Comparator.Mode getMode() { + return this.get(MODE, Comparator.Mode.class); + } + + @Override + public void setMode(final Comparator.Mode mode) { + Preconditions.checkArgument(mode != null, "mode cannot be null!"); + this.set(MODE, mode); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java new file mode 100644 index 000000000..b74562f56 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftComposter.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.ComposterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Levelled; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftComposter extends CraftBlockData implements Levelled { + private static final IntegerProperty LEVEL = ComposterBlock.LEVEL; + + public CraftComposter(BlockState state) { + super(state); + } + + @Override + public int getLevel() { + return this.get(LEVEL); + } + + @Override + public void setLevel(final int level) { + this.set(LEVEL, level); + } + + @Override + public int getMinimumLevel() { + return LEVEL.min; + } + + @Override + public int getMaximumLevel() { + return LEVEL.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java new file mode 100644 index 000000000..e4d0cb5cd --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftConduit.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.ConduitBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftConduit extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = ConduitBlock.WATERLOGGED; + + public CraftConduit(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCopperBulb.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCopperBulb.java new file mode 100644 index 000000000..53de51d7e --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCopperBulb.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CopperBulbBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.CopperBulb; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCopperBulb extends CraftBlockData implements CopperBulb { + private static final BooleanProperty LIT = CopperBulbBlock.LIT; + + private static final BooleanProperty POWERED = CopperBulbBlock.POWERED; + + public CraftCopperBulb(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java new file mode 100644 index 000000000..332901a60 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralFan.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CoralFanBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCoralFan extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = CoralFanBlock.WATERLOGGED; + + public CraftCoralFan(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java new file mode 100644 index 000000000..2c2ea21cf --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralPlant.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CoralPlantBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCoralPlant extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = CoralPlantBlock.WATERLOGGED; + + public CraftCoralPlant(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralWallFan.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralWallFan.java new file mode 100644 index 000000000..4500d844a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCoralWallFan.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CoralWallFanBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.CoralWallFan; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCoralWallFan extends CraftBlockData implements CoralWallFan { + private static final EnumProperty FACING = CoralWallFanBlock.FACING; + + private static final BooleanProperty WATERLOGGED = CoralWallFanBlock.WATERLOGGED; + + public CraftCoralWallFan(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrafter.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrafter.java new file mode 100644 index 000000000..c639553a4 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrafter.java @@ -0,0 +1,56 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.core.FrontAndTop; +import net.minecraft.world.level.block.CrafterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.type.Crafter; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCrafter extends CraftBlockData implements Crafter { + private static final BooleanProperty CRAFTING = CrafterBlock.CRAFTING; + + private static final EnumProperty ORIENTATION = BlockStateProperties.ORIENTATION; + + private static final BooleanProperty TRIGGERED = CrafterBlock.TRIGGERED; + + public CraftCrafter(BlockState state) { + super(state); + } + + @Override + public boolean isCrafting() { + return this.get(CRAFTING); + } + + @Override + public void setCrafting(final boolean crafting) { + this.set(CRAFTING, crafting); + } + + @Override + public org.bukkit.block.Orientation getOrientation() { + return this.get(ORIENTATION, org.bukkit.block.Orientation.class); + } + + @Override + public void setOrientation(final org.bukkit.block.Orientation orientation) { + Preconditions.checkArgument(orientation != null, "orientation cannot be null!"); + this.set(ORIENTATION, orientation); + } + + @Override + public boolean isTriggered() { + return this.get(TRIGGERED); + } + + @Override + public void setTriggered(final boolean triggered) { + this.set(TRIGGERED, triggered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java new file mode 100644 index 000000000..ea51c9a96 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCreakingHeart.java @@ -0,0 +1,64 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.CreakingHeartBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.CreakingHeartState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.type.CreakingHeart; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCreakingHeart extends CraftBlockData implements CreakingHeart { + private static final EnumProperty AXIS = CreakingHeartBlock.AXIS; + + private static final EnumProperty STATE = CreakingHeartBlock.STATE; + + private static final BooleanProperty NATURAL = CreakingHeartBlock.NATURAL; + + public CraftCreakingHeart(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } + + @Override + public CreakingHeart.State getCreakingHeartState() { + return this.get(STATE, CreakingHeart.State.class); + } + + @Override + public void setCreakingHeartState(final CreakingHeart.State state) { + Preconditions.checkArgument(state != null, "state cannot be null!"); + this.set(STATE, state); + } + + @Override + public boolean isNatural() { + return this.get(NATURAL); + } + + @Override + public void setNatural(final boolean natural) { + this.set(NATURAL, natural); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrop.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrop.java new file mode 100644 index 000000000..3693f5adb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftCrop.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftCrop extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = CropBlock.AGE; + + public CraftCrop(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java new file mode 100644 index 000000000..7c676ccc1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDaylightDetector.java @@ -0,0 +1,45 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.DaylightDetectorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.DaylightDetector; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDaylightDetector extends CraftBlockData implements DaylightDetector { + private static final BooleanProperty INVERTED = DaylightDetectorBlock.INVERTED; + + private static final IntegerProperty POWER = DaylightDetectorBlock.POWER; + + public CraftDaylightDetector(BlockState state) { + super(state); + } + + @Override + public boolean isInverted() { + return this.get(INVERTED); + } + + @Override + public void setInverted(final boolean inverted) { + this.set(INVERTED, inverted); + } + + @Override + public int getPower() { + return this.get(POWER); + } + + @Override + public void setPower(final int power) { + this.set(POWER, power); + } + + @Override + public int getMaximumPower() { + return POWER.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java new file mode 100644 index 000000000..e2aecaa8c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDecoratedPot.java @@ -0,0 +1,63 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.DecoratedPotBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.DecoratedPot; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDecoratedPot extends CraftBlockData implements DecoratedPot { + private static final BooleanProperty CRACKED = DecoratedPotBlock.CRACKED; + + private static final EnumProperty HORIZONTAL_FACING = DecoratedPotBlock.HORIZONTAL_FACING; + + private static final BooleanProperty WATERLOGGED = DecoratedPotBlock.WATERLOGGED; + + public CraftDecoratedPot(BlockState state) { + super(state); + } + + @Override + public boolean isCracked() { + return this.get(CRACKED); + } + + @Override + public void setCracked(final boolean cracked) { + this.set(CRACKED, cracked); + } + + @Override + public BlockFace getFacing() { + return this.get(HORIZONTAL_FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(HORIZONTAL_FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(HORIZONTAL_FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDetectorRail.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDetectorRail.java new file mode 100644 index 000000000..95ee8f4ff --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDetectorRail.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.world.level.block.DetectorRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.RailShape; +import org.bukkit.block.data.type.RedstoneRail; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDetectorRail extends CraftBlockData implements RedstoneRail { + private static final BooleanProperty POWERED = DetectorRailBlock.POWERED; + + private static final EnumProperty SHAPE = DetectorRailBlock.SHAPE; + + private static final BooleanProperty WATERLOGGED = DetectorRailBlock.WATERLOGGED; + + public CraftDetectorRail(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public org.bukkit.block.data.Rail.Shape getShape() { + return this.get(SHAPE, org.bukkit.block.data.Rail.Shape.class); + } + + @Override + public void setShape(final org.bukkit.block.data.Rail.Shape shape) { + Preconditions.checkArgument(shape != null, "shape cannot be null!"); + Preconditions.checkArgument(shape != org.bukkit.block.data.Rail.Shape.NORTH_EAST && shape != org.bukkit.block.data.Rail.Shape.NORTH_WEST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_EAST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_WEST, "Invalid rail shape, only straight rail are allowed for this property!"); + this.set(SHAPE, shape); + } + + @Override + public Set getShapes() { + return this.getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java new file mode 100644 index 000000000..c93733f7b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDispenser.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.DispenserBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Dispenser; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDispenser extends CraftBlockData implements Dispenser { + private static final EnumProperty FACING = DispenserBlock.FACING; + + private static final BooleanProperty TRIGGERED = DispenserBlock.TRIGGERED; + + public CraftDispenser(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isTriggered() { + return this.get(TRIGGERED); + } + + @Override + public void setTriggered(final boolean triggered) { + this.set(TRIGGERED, triggered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java new file mode 100644 index 000000000..3b71b22eb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoor.java @@ -0,0 +1,91 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.DoorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DoorHingeSide; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Door; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDoor extends CraftBlockData implements Door { + private static final EnumProperty FACING = DoorBlock.FACING; + + private static final EnumProperty HALF = DoorBlock.HALF; + + private static final EnumProperty HINGE = DoorBlock.HINGE; + + private static final BooleanProperty OPEN = DoorBlock.OPEN; + + private static final BooleanProperty POWERED = DoorBlock.POWERED; + + public CraftDoor(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public Door.Hinge getHinge() { + return this.get(HINGE, Door.Hinge.class); + } + + @Override + public void setHinge(final Door.Hinge hinge) { + Preconditions.checkArgument(hinge != null, "hinge cannot be null!"); + this.set(HINGE, hinge); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoublePlant.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoublePlant.java new file mode 100644 index 000000000..2b98b17b1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDoublePlant.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.DoublePlantBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.Bisected; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDoublePlant extends CraftBlockData implements Bisected { + private static final EnumProperty HALF = DoublePlantBlock.HALF; + + public CraftDoublePlant(BlockState state) { + super(state); + } + + @Override + public Bisected.Half getHalf() { + return this.get(HALF, Bisected.Half.class); + } + + @Override + public void setHalf(final Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java new file mode 100644 index 000000000..08695cf5a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftDropper.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.DropperBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Dispenser; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftDropper extends CraftBlockData implements Dispenser { + private static final EnumProperty FACING = DropperBlock.FACING; + + private static final BooleanProperty TRIGGERED = DropperBlock.TRIGGERED; + + public CraftDropper(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isTriggered() { + return this.get(TRIGGERED); + } + + @Override + public void setTriggered(final boolean triggered) { + this.set(TRIGGERED, triggered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndPortalFrame.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndPortalFrame.java new file mode 100644 index 000000000..88b8fe7c1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndPortalFrame.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.EndPortalFrameBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.EndPortalFrame; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftEndPortalFrame extends CraftBlockData implements EndPortalFrame { + private static final BooleanProperty HAS_EYE = EndPortalFrameBlock.HAS_EYE; + + private static final EnumProperty FACING = EndPortalFrameBlock.FACING; + + public CraftEndPortalFrame(BlockState state) { + super(state); + } + + @Override + public boolean hasEye() { + return this.get(HAS_EYE); + } + + @Override + public void setEye(final boolean eye) { + this.set(HAS_EYE, eye); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java new file mode 100644 index 000000000..ba790faf3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEndRod.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.EndRodBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftEndRod extends CraftBlockData implements Directional { + private static final EnumProperty FACING = EndRodBlock.FACING; + + public CraftEndRod(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java new file mode 100644 index 000000000..b119c63fd --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftEnderChest.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.EnderChestBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.EnderChest; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftEnderChest extends CraftBlockData implements EnderChest { + private static final EnumProperty FACING = EnderChestBlock.FACING; + + private static final BooleanProperty WATERLOGGED = EnderChestBlock.WATERLOGGED; + + public CraftEnderChest(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFarm.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFarm.java new file mode 100644 index 000000000..88b7c7b5b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFarm.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.FarmBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Farmland; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFarm extends CraftBlockData implements Farmland { + private static final IntegerProperty MOISTURE = FarmBlock.MOISTURE; + + public CraftFarm(BlockState state) { + super(state); + } + + @Override + public int getMoisture() { + return this.get(MOISTURE); + } + + @Override + public void setMoisture(final int moisture) { + this.set(MOISTURE, moisture); + } + + @Override + public int getMaximumMoisture() { + return MOISTURE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFence.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFence.java new file mode 100644 index 000000000..b67a02dd1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFence.java @@ -0,0 +1,70 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.FenceBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Fence; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFence extends CraftBlockData implements Fence { + private static final BooleanProperty WATERLOGGED = FenceBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = FenceBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftFence(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java new file mode 100644 index 000000000..d84ebcb7f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFenceGate.java @@ -0,0 +1,75 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.FenceGateBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Gate; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFenceGate extends CraftBlockData implements Gate { + private static final EnumProperty FACING = FenceGateBlock.FACING; + + private static final BooleanProperty IN_WALL = FenceGateBlock.IN_WALL; + + private static final BooleanProperty OPEN = FenceGateBlock.OPEN; + + private static final BooleanProperty POWERED = FenceGateBlock.POWERED; + + public CraftFenceGate(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isInWall() { + return this.get(IN_WALL); + } + + @Override + public void setInWall(final boolean inWall) { + this.set(IN_WALL, inWall); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFire.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFire.java new file mode 100644 index 000000000..a148145fb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFire.java @@ -0,0 +1,76 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.FireBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Fire; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFire extends CraftBlockData implements Fire { + private static final IntegerProperty AGE = FireBlock.AGE; + + private static final Map PROPERTY_BY_DIRECTION = FireBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftFire(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java new file mode 100644 index 000000000..0f82214df --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFlowerBed.java @@ -0,0 +1,61 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.FlowerBedBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.FlowerBed; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFlowerBed extends CraftBlockData implements FlowerBed { + private static final EnumProperty FACING = FlowerBedBlock.FACING; + + private static final IntegerProperty AMOUNT = FlowerBedBlock.AMOUNT; + + public CraftFlowerBed(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public int getFlowerAmount() { + return this.get(AMOUNT); + } + + @Override + public void setFlowerAmount(final int flowerAmount) { + this.set(AMOUNT, flowerAmount); + } + + @Override + public int getMinimumFlowerAmount() { + return AMOUNT.min; + } + + @Override + public int getMaximumFlowerAmount() { + return AMOUNT.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFrostedIce.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFrostedIce.java new file mode 100644 index 000000000..fd83ea6d3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFrostedIce.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.FrostedIceBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFrostedIce extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = FrostedIceBlock.AGE; + + public CraftFrostedIce(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java new file mode 100644 index 000000000..d9c72086d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftFurnace.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.FurnaceBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Furnace; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftFurnace extends CraftBlockData implements Furnace { + private static final EnumProperty FACING = FurnaceBlock.FACING; + + private static final BooleanProperty LIT = FurnaceBlock.LIT; + + public CraftFurnace(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java new file mode 100644 index 000000000..d21a3824c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlazedTerracotta.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.GlazedTerracottaBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftGlazedTerracotta extends CraftBlockData implements Directional { + private static final EnumProperty FACING = GlazedTerracottaBlock.FACING; + + public CraftGlazedTerracotta(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java new file mode 100644 index 000000000..ae2a5f8f3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGlowLichen.java @@ -0,0 +1,76 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.GlowLichenBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.GlowLichen; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftGlowLichen extends CraftBlockData implements GlowLichen { + private static final BooleanProperty WATERLOGGED = GlowLichenBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = Map.of( + BlockFace.DOWN, BlockStateProperties.DOWN, + BlockFace.UP, BlockStateProperties.UP, + BlockFace.NORTH, BlockStateProperties.NORTH, + BlockFace.SOUTH, BlockStateProperties.SOUTH, + BlockFace.WEST, BlockStateProperties.WEST, + BlockFace.EAST, BlockStateProperties.EAST + ); + + public CraftGlowLichen(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java new file mode 100644 index 000000000..f61480548 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrass.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.GrassBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Snowable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftGrass extends CraftBlockData implements Snowable { + private static final BooleanProperty SNOWY = GrassBlock.SNOWY; + + public CraftGrass(BlockState state) { + super(state); + } + + @Override + public boolean isSnowy() { + return this.get(SNOWY); + } + + @Override + public void setSnowy(final boolean snowy) { + this.set(SNOWY, snowy); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java new file mode 100644 index 000000000..d19c28380 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftGrindstone.java @@ -0,0 +1,53 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.GrindstoneBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Grindstone; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftGrindstone extends CraftBlockData implements Grindstone { + private static final EnumProperty FACE = GrindstoneBlock.FACE; + + private static final EnumProperty FACING = GrindstoneBlock.FACING; + + public CraftGrindstone(BlockState state) { + super(state); + } + + @Override + public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() { + return this.get(FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class); + } + + @Override + public void setAttachedFace( + final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) { + Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!"); + this.set(FACE, attachedFace); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingMoss.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingMoss.java new file mode 100644 index 000000000..a600ff8dc --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingMoss.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.HangingMossBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.HangingMoss; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHangingMoss extends CraftBlockData implements HangingMoss { + private static final BooleanProperty TIP = HangingMossBlock.TIP; + + public CraftHangingMoss(BlockState state) { + super(state); + } + + @Override + public boolean isTip() { + return this.get(TIP); + } + + @Override + public void setTip(final boolean tip) { + this.set(TIP, tip); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java new file mode 100644 index 000000000..b5936e57a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHangingRoots.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHangingRoots extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftHangingRoots(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHay.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHay.java new file mode 100644 index 000000000..c33a505f1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHay.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.HayBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.Orientable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHay extends CraftBlockData implements Orientable { + private static final EnumProperty AXIS = HayBlock.AXIS; + + public CraftHay(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHeavyCore.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHeavyCore.java new file mode 100644 index 000000000..2d59f7347 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHeavyCore.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.HeavyCoreBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHeavyCore extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = HeavyCoreBlock.WATERLOGGED; + + public CraftHeavyCore(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java new file mode 100644 index 000000000..a2a3b8177 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHopper.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.HopperBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Hopper; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHopper extends CraftBlockData implements Hopper { + private static final BooleanProperty ENABLED = HopperBlock.ENABLED; + + private static final EnumProperty FACING = HopperBlock.FACING; + + public CraftHopper(BlockState state) { + super(state); + } + + @Override + public boolean isEnabled() { + return this.get(ENABLED); + } + + @Override + public void setEnabled(final boolean enabled) { + this.set(ENABLED, enabled); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace != BlockFace.UP, "Invalid face, only cartesian face (excluding UP) are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java new file mode 100644 index 000000000..5318419eb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftHugeMushroom.java @@ -0,0 +1,63 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.HugeMushroomBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftHugeMushroom extends CraftBlockData implements MultipleFacing { + private static final Map PROPERTY_BY_DIRECTION = Map.of( + BlockFace.DOWN, HugeMushroomBlock.DOWN, + BlockFace.UP, HugeMushroomBlock.UP, + BlockFace.NORTH, HugeMushroomBlock.NORTH, + BlockFace.SOUTH, HugeMushroomBlock.SOUTH, + BlockFace.WEST, HugeMushroomBlock.WEST, + BlockFace.EAST, HugeMushroomBlock.EAST + ); + + public CraftHugeMushroom(BlockState state) { + super(state); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java new file mode 100644 index 000000000..976576eca --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftInfestedRotatedPillar.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.Orientable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftInfestedRotatedPillar extends CraftBlockData implements Orientable { + private static final EnumProperty AXIS = BlockStateProperties.AXIS; + + public CraftInfestedRotatedPillar(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java new file mode 100644 index 000000000..88805c241 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftIronBars.java @@ -0,0 +1,70 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.IronBarsBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Fence; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftIronBars extends CraftBlockData implements Fence { + private static final BooleanProperty WATERLOGGED = IronBarsBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = IronBarsBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftIronBars(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java new file mode 100644 index 000000000..bfa66201d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJigsaw.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.core.FrontAndTop; +import net.minecraft.world.level.block.JigsawBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.type.Jigsaw; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftJigsaw extends CraftBlockData implements Jigsaw { + private static final EnumProperty ORIENTATION = JigsawBlock.ORIENTATION; + + public CraftJigsaw(BlockState state) { + super(state); + } + + @Override + public org.bukkit.block.Orientation getOrientation() { + return this.get(ORIENTATION, org.bukkit.block.Orientation.class); + } + + @Override + public void setOrientation(final org.bukkit.block.Orientation orientation) { + Preconditions.checkArgument(orientation != null, "orientation cannot be null!"); + this.set(ORIENTATION, orientation); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJukebox.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJukebox.java new file mode 100644 index 000000000..0883d213e --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftJukebox.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.JukeboxBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.Jukebox; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftJukebox extends CraftBlockData implements Jukebox { + private static final BooleanProperty HAS_RECORD = JukeboxBlock.HAS_RECORD; + + public CraftJukebox(BlockState state) { + super(state); + } + + @Override + public boolean hasRecord() { + return this.get(HAS_RECORD); + } + + @Override + public void setHasRecord(final boolean hasRecord) { + this.set(HAS_RECORD, hasRecord); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java new file mode 100644 index 000000000..720370327 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftKelp.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.KelpBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftKelp extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = KelpBlock.AGE; + + public CraftKelp(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java new file mode 100644 index 000000000..01ca00b1a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLadder.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LadderBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Ladder; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLadder extends CraftBlockData implements Ladder { + private static final EnumProperty FACING = LadderBlock.FACING; + + private static final BooleanProperty WATERLOGGED = LadderBlock.WATERLOGGED; + + public CraftLadder(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java new file mode 100644 index 000000000..1f9acabeb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLantern.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.LanternBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.Lantern; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLantern extends CraftBlockData implements Lantern { + private static final BooleanProperty HANGING = LanternBlock.HANGING; + + private static final BooleanProperty WATERLOGGED = LanternBlock.WATERLOGGED; + + public CraftLantern(BlockState state) { + super(state); + } + + @Override + public boolean isHanging() { + return this.get(HANGING); + } + + @Override + public void setHanging(final boolean hanging) { + this.set(HANGING, hanging); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java new file mode 100644 index 000000000..9b77f3448 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLayeredCauldron.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.LayeredCauldronBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Levelled; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLayeredCauldron extends CraftBlockData implements Levelled { + private static final IntegerProperty LEVEL = LayeredCauldronBlock.LEVEL; + + public CraftLayeredCauldron(BlockState state) { + super(state); + } + + @Override + public int getLevel() { + return this.get(LEVEL); + } + + @Override + public void setLevel(final int level) { + this.set(LEVEL, level); + } + + @Override + public int getMinimumLevel() { + return LEVEL.min; + } + + @Override + public int getMaximumLevel() { + return LEVEL.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java new file mode 100644 index 000000000..86178e063 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLeafLitter.java @@ -0,0 +1,61 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LeafLitterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.LeafLitter; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLeafLitter extends CraftBlockData implements LeafLitter { + private static final EnumProperty FACING = LeafLitterBlock.FACING; + + private static final IntegerProperty AMOUNT = LeafLitterBlock.AMOUNT; + + public CraftLeafLitter(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public int getSegmentAmount() { + return this.get(AMOUNT); + } + + @Override + public void setSegmentAmount(final int segmentAmount) { + this.set(AMOUNT, segmentAmount); + } + + @Override + public int getMinimumSegmentAmount() { + return AMOUNT.min; + } + + @Override + public int getMaximumSegmentAmount() { + return AMOUNT.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java new file mode 100644 index 000000000..ac0235f23 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLectern.java @@ -0,0 +1,63 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LecternBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Lectern; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLectern extends CraftBlockData implements Lectern { + private static final EnumProperty FACING = LecternBlock.FACING; + + private static final BooleanProperty HAS_BOOK = LecternBlock.HAS_BOOK; + + private static final BooleanProperty POWERED = LecternBlock.POWERED; + + public CraftLectern(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean hasBook() { + return this.get(HAS_BOOK); + } + + @Override + public void setHasBook(final boolean hasBook) { + this.set(HAS_BOOK, hasBook); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLever.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLever.java new file mode 100644 index 000000000..3e8531763 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLever.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LeverBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.AttachFace; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Switch; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLever extends CraftBlockData implements Switch { + private static final EnumProperty FACE = LeverBlock.FACE; + + private static final EnumProperty FACING = LeverBlock.FACING; + + private static final BooleanProperty POWERED = LeverBlock.POWERED; + + public CraftLever(BlockState state) { + super(state); + } + + @Override + public org.bukkit.block.data.FaceAttachable.AttachedFace getAttachedFace() { + return this.get(FACE, org.bukkit.block.data.FaceAttachable.AttachedFace.class); + } + + @Override + public void setAttachedFace( + final org.bukkit.block.data.FaceAttachable.AttachedFace attachedFace) { + Preconditions.checkArgument(attachedFace != null, "attachedFace cannot be null!"); + this.set(FACE, attachedFace); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLight.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLight.java new file mode 100644 index 000000000..7f90294b4 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLight.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.LightBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Light; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLight extends CraftBlockData implements Light { + private static final IntegerProperty LEVEL = LightBlock.LEVEL; + + private static final BooleanProperty WATERLOGGED = LightBlock.WATERLOGGED; + + public CraftLight(BlockState state) { + super(state); + } + + @Override + public int getLevel() { + return this.get(LEVEL); + } + + @Override + public void setLevel(final int level) { + this.set(LEVEL, level); + } + + @Override + public int getMinimumLevel() { + return LEVEL.min; + } + + @Override + public int getMaximumLevel() { + return LEVEL.max; + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java new file mode 100644 index 000000000..b6653f2f4 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLightningRod.java @@ -0,0 +1,63 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LightningRodBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.LightningRod; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLightningRod extends CraftBlockData implements LightningRod { + private static final EnumProperty FACING = LightningRodBlock.FACING; + + private static final BooleanProperty POWERED = LightningRodBlock.POWERED; + + private static final BooleanProperty WATERLOGGED = LightningRodBlock.WATERLOGGED; + + public CraftLightningRod(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLiquid.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLiquid.java new file mode 100644 index 000000000..4d7ff9b2d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLiquid.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.LiquidBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Levelled; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLiquid extends CraftBlockData implements Levelled { + private static final IntegerProperty LEVEL = LiquidBlock.LEVEL; + + public CraftLiquid(BlockState state) { + super(state); + } + + @Override + public int getLevel() { + return this.get(LEVEL); + } + + @Override + public void setLevel(final int level) { + this.set(LEVEL, level); + } + + @Override + public int getMinimumLevel() { + return LEVEL.min; + } + + @Override + public int getMaximumLevel() { + return LEVEL.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java new file mode 100644 index 000000000..a13b2bc3c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftLoom.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.LoomBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftLoom extends CraftBlockData implements Directional { + private static final EnumProperty FACING = LoomBlock.FACING; + + public CraftLoom(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java new file mode 100644 index 000000000..b6375028c --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveLeaves.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.MangroveLeavesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Leaves; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMangroveLeaves extends CraftBlockData implements Leaves { + private static final IntegerProperty DISTANCE = MangroveLeavesBlock.DISTANCE; + + private static final BooleanProperty PERSISTENT = MangroveLeavesBlock.PERSISTENT; + + private static final BooleanProperty WATERLOGGED = MangroveLeavesBlock.WATERLOGGED; + + public CraftMangroveLeaves(BlockState state) { + super(state); + } + + @Override + public int getDistance() { + return this.get(DISTANCE); + } + + @Override + public void setDistance(final int distance) { + this.set(DISTANCE, distance); + } + + @Override + public int getMinimumDistance() { + return DISTANCE.min; + } + + @Override + public int getMaximumDistance() { + return DISTANCE.max; + } + + @Override + public boolean isPersistent() { + return this.get(PERSISTENT); + } + + @Override + public void setPersistent(final boolean persistent) { + this.set(PERSISTENT, persistent); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangrovePropagule.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangrovePropagule.java new file mode 100644 index 000000000..577d04d4d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangrovePropagule.java @@ -0,0 +1,75 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.MangrovePropaguleBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.MangrovePropagule; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMangrovePropagule extends CraftBlockData implements MangrovePropagule { + private static final IntegerProperty AGE = MangrovePropaguleBlock.AGE; + + private static final BooleanProperty HANGING = MangrovePropaguleBlock.HANGING; + + private static final IntegerProperty STAGE = MangrovePropaguleBlock.STAGE; + + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftMangrovePropagule(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public boolean isHanging() { + return this.get(HANGING); + } + + @Override + public void setHanging(final boolean hanging) { + this.set(HANGING, hanging); + } + + @Override + public int getStage() { + return this.get(STAGE); + } + + @Override + public void setStage(final int stage) { + this.set(STAGE, stage); + } + + @Override + public int getMaximumStage() { + return STAGE.max; + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveRoots.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveRoots.java new file mode 100644 index 000000000..2949bfad2 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMangroveRoots.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.MangroveRootsBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMangroveRoots extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = MangroveRootsBlock.WATERLOGGED; + + public CraftMangroveRoots(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMossyCarpet.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMossyCarpet.java new file mode 100644 index 000000000..a2d396706 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMossyCarpet.java @@ -0,0 +1,55 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Map; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.MossyCarpetBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.WallSide; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.MossyCarpet; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMossyCarpet extends CraftBlockData implements MossyCarpet { + private static final BooleanProperty BASE = MossyCarpetBlock.BASE; + + private static final Map> PROPERTY_BY_DIRECTION = MossyCarpetBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftMossyCarpet(BlockState state) { + super(state); + } + + @Override + public boolean isBottom() { + return this.get(BASE); + } + + @Override + public void setBottom(final boolean bottom) { + this.set(BASE, bottom); + } + + @Override + public org.bukkit.block.data.type.Wall.Height getHeight(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property, org.bukkit.block.data.type.Wall.Height.class); + } + + @Override + public void setHeight(final BlockFace blockFace, + final org.bukkit.block.data.type.Wall.Height height) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(height != null, "height cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, height); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMovingPiston.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMovingPiston.java new file mode 100644 index 000000000..6d5da6e40 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMovingPiston.java @@ -0,0 +1,52 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.piston.MovingPistonBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.PistonType; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.TechnicalPiston; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMovingPiston extends CraftBlockData implements TechnicalPiston { + private static final EnumProperty FACING = MovingPistonBlock.FACING; + + private static final EnumProperty TYPE = MovingPistonBlock.TYPE; + + public CraftMovingPiston(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public TechnicalPiston.Type getType() { + return this.get(TYPE, TechnicalPiston.Type.class); + } + + @Override + public void setType(final TechnicalPiston.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java new file mode 100644 index 000000000..73070fd11 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMultiface.java @@ -0,0 +1,76 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.MultifaceBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.ResinClump; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMultiface extends CraftBlockData implements ResinClump { + private static final BooleanProperty WATERLOGGED = MultifaceBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = Map.of( + BlockFace.DOWN, BlockStateProperties.DOWN, + BlockFace.UP, BlockStateProperties.UP, + BlockFace.NORTH, BlockStateProperties.NORTH, + BlockFace.SOUTH, BlockStateProperties.SOUTH, + BlockFace.WEST, BlockStateProperties.WEST, + BlockFace.EAST, BlockStateProperties.EAST + ); + + public CraftMultiface(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMycelium.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMycelium.java new file mode 100644 index 000000000..d05536eb5 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftMycelium.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.MyceliumBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Snowable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftMycelium extends CraftBlockData implements Snowable { + private static final BooleanProperty SNOWY = MyceliumBlock.SNOWY; + + public CraftMycelium(BlockState state) { + super(state); + } + + @Override + public boolean isSnowy() { + return this.get(SNOWY); + } + + @Override + public void setSnowy(final boolean snowy) { + this.set(SNOWY, snowy); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherPortal.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherPortal.java new file mode 100644 index 000000000..9c1887d2d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherPortal.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.NetherPortalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.Orientable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftNetherPortal extends CraftBlockData implements Orientable { + private static final EnumProperty AXIS = NetherPortalBlock.AXIS; + + public CraftNetherPortal(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + Preconditions.checkArgument(axis == Axis.X || axis == Axis.Z, "Invalid axis, only horizontal axis are allowed for this property!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java new file mode 100644 index 000000000..46c53c871 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNetherWart.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.NetherWartBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftNetherWart extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = NetherWartBlock.AGE; + + public CraftNetherWart(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNoteBlock.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNoteBlock.java new file mode 100644 index 000000000..42397ac3f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftNoteBlock.java @@ -0,0 +1,58 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.NoteBlockInstrument; +import org.bukkit.Instrument; +import org.bukkit.Note; +import org.bukkit.block.data.type.NoteBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftNoteBlock extends CraftBlockData implements NoteBlock { + private static final EnumProperty INSTRUMENT = net.minecraft.world.level.block.NoteBlock.INSTRUMENT; + + private static final IntegerProperty NOTE = net.minecraft.world.level.block.NoteBlock.NOTE; + + private static final BooleanProperty POWERED = net.minecraft.world.level.block.NoteBlock.POWERED; + + public CraftNoteBlock(BlockState state) { + super(state); + } + + @Override + public Instrument getInstrument() { + return this.get(INSTRUMENT, Instrument.class); + } + + @Override + public void setInstrument(final Instrument instrument) { + Preconditions.checkArgument(instrument != null, "instrument cannot be null!"); + this.set(INSTRUMENT, instrument); + } + + @Override + public Note getNote() { + return new Note(this.get(NOTE)); + } + + @Override + public void setNote(final Note note) { + Preconditions.checkArgument(note != null, "note cannot be null!"); + this.set(NOTE, (int) note.getId()); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java new file mode 100644 index 000000000..65a9cddbf --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftObserver.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ObserverBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Observer; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftObserver extends CraftBlockData implements Observer { + private static final EnumProperty FACING = ObserverBlock.FACING; + + private static final BooleanProperty POWERED = ObserverBlock.POWERED; + + public CraftObserver(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java new file mode 100644 index 000000000..d801e81f6 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPiglinWallSkull.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.PiglinWallSkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallSkull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPiglinWallSkull extends CraftBlockData implements WallSkull { + private static final EnumProperty FACING = PiglinWallSkullBlock.FACING; + + private static final BooleanProperty POWERED = PiglinWallSkullBlock.POWERED; + + public CraftPiglinWallSkull(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonBase.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonBase.java new file mode 100644 index 000000000..ac3f52745 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonBase.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.piston.PistonBaseBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Piston; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPistonBase extends CraftBlockData implements Piston { + private static final BooleanProperty EXTENDED = PistonBaseBlock.EXTENDED; + + private static final EnumProperty FACING = PistonBaseBlock.FACING; + + public CraftPistonBase(BlockState state) { + super(state); + } + + @Override + public boolean isExtended() { + return this.get(EXTENDED); + } + + @Override + public void setExtended(final boolean extended) { + this.set(EXTENDED, extended); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonHead.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonHead.java new file mode 100644 index 000000000..c6a91e8f1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPistonHead.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.piston.PistonHeadBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.PistonType; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.PistonHead; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPistonHead extends CraftBlockData implements PistonHead { + private static final EnumProperty FACING = PistonHeadBlock.FACING; + + private static final BooleanProperty SHORT = PistonHeadBlock.SHORT; + + private static final EnumProperty TYPE = PistonHeadBlock.TYPE; + + public CraftPistonHead(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isShort() { + return this.get(SHORT); + } + + @Override + public void setShort(final boolean _short) { + this.set(SHORT, _short); + } + + @Override + public org.bukkit.block.data.type.TechnicalPiston.Type getType() { + return this.get(TYPE, org.bukkit.block.data.type.TechnicalPiston.Type.class); + } + + @Override + public void setType(final org.bukkit.block.data.type.TechnicalPiston.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPitcherCrop.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPitcherCrop.java new file mode 100644 index 000000000..644ba700f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPitcherCrop.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.PitcherCropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.PitcherCrop; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPitcherCrop extends CraftBlockData implements PitcherCrop { + private static final IntegerProperty AGE = PitcherCropBlock.AGE; + + private static final EnumProperty HALF = PitcherCropBlock.HALF; + + public CraftPitcherCrop(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerHead.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerHead.java new file mode 100644 index 000000000..5c2403635 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerHead.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.PlayerHeadBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Skull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftPlayerHead extends CraftBlockData implements Skull { + private static final BooleanProperty POWERED = PlayerHeadBlock.POWERED; + + private static final IntegerProperty ROTATION = PlayerHeadBlock.ROTATION; + + public CraftPlayerHead(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerWallHead.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerWallHead.java new file mode 100644 index 000000000..7511a2a4b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPlayerWallHead.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.PlayerWallHeadBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallSkull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPlayerWallHead extends CraftBlockData implements WallSkull { + private static final EnumProperty FACING = PlayerWallHeadBlock.FACING; + + private static final BooleanProperty POWERED = PlayerWallHeadBlock.POWERED; + + public CraftPlayerWallHead(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java new file mode 100644 index 000000000..15e157cab --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPointedDripstone.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.PointedDripstoneBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DripstoneThickness; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.PointedDripstone; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPointedDripstone extends CraftBlockData implements PointedDripstone { + private static final EnumProperty THICKNESS = PointedDripstoneBlock.THICKNESS; + + private static final EnumProperty TIP_DIRECTION = PointedDripstoneBlock.TIP_DIRECTION; + + private static final BooleanProperty WATERLOGGED = PointedDripstoneBlock.WATERLOGGED; + + public CraftPointedDripstone(BlockState state) { + super(state); + } + + @Override + public PointedDripstone.Thickness getThickness() { + return this.get(THICKNESS, PointedDripstone.Thickness.class); + } + + @Override + public void setThickness(final PointedDripstone.Thickness thickness) { + Preconditions.checkArgument(thickness != null, "thickness cannot be null!"); + this.set(THICKNESS, thickness); + } + + @Override + public BlockFace getVerticalDirection() { + return this.get(TIP_DIRECTION, BlockFace.class); + } + + @Override + public void setVerticalDirection(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.getModY() != 0, "Invalid face, only vertical face are allowed for this property!"); + this.set(TIP_DIRECTION, blockFace); + } + + @Override + public Set getVerticalDirections() { + return this.getValues(TIP_DIRECTION, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotato.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotato.java new file mode 100644 index 000000000..8d7cdbe6b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPotato.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.PotatoBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPotato extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = PotatoBlock.AGE; + + public CraftPotato(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java new file mode 100644 index 000000000..709020b70 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPoweredRail.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.world.level.block.PoweredRailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.RailShape; +import org.bukkit.block.data.type.RedstoneRail; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPoweredRail extends CraftBlockData implements RedstoneRail { + private static final BooleanProperty POWERED = PoweredRailBlock.POWERED; + + private static final EnumProperty SHAPE = PoweredRailBlock.SHAPE; + + private static final BooleanProperty WATERLOGGED = PoweredRailBlock.WATERLOGGED; + + public CraftPoweredRail(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public org.bukkit.block.data.Rail.Shape getShape() { + return this.get(SHAPE, org.bukkit.block.data.Rail.Shape.class); + } + + @Override + public void setShape(final org.bukkit.block.data.Rail.Shape shape) { + Preconditions.checkArgument(shape != null, "shape cannot be null!"); + Preconditions.checkArgument(shape != org.bukkit.block.data.Rail.Shape.NORTH_EAST && shape != org.bukkit.block.data.Rail.Shape.NORTH_WEST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_EAST && shape != org.bukkit.block.data.Rail.Shape.SOUTH_WEST, "Invalid rail shape, only straight rail are allowed for this property!"); + this.set(SHAPE, shape); + } + + @Override + public Set getShapes() { + return this.getValues(SHAPE, org.bukkit.block.data.Rail.Shape.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlate.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlate.java new file mode 100644 index 000000000..75121f1f5 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftPressurePlate.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.PressurePlateBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Powerable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftPressurePlate extends CraftBlockData implements Powerable { + private static final BooleanProperty POWERED = PressurePlateBlock.POWERED; + + public CraftPressurePlate(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRail.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRail.java new file mode 100644 index 000000000..b511c458d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRail.java @@ -0,0 +1,49 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.world.level.block.RailBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.RailShape; +import org.bukkit.block.data.Rail; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRail extends CraftBlockData implements Rail { + private static final EnumProperty SHAPE = RailBlock.SHAPE; + + private static final BooleanProperty WATERLOGGED = RailBlock.WATERLOGGED; + + public CraftRail(BlockState state) { + super(state); + } + + @Override + public Rail.Shape getShape() { + return this.get(SHAPE, Rail.Shape.class); + } + + @Override + public void setShape(final Rail.Shape shape) { + Preconditions.checkArgument(shape != null, "shape cannot be null!"); + this.set(SHAPE, shape); + } + + @Override + public Set getShapes() { + return this.getValues(SHAPE, Rail.Shape.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneOre.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneOre.java new file mode 100644 index 000000000..848755668 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneOre.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.RedStoneOreBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Lightable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRedStoneOre extends CraftBlockData implements Lightable { + private static final BooleanProperty LIT = RedStoneOreBlock.LIT; + + public CraftRedStoneOre(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneWire.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneWire.java new file mode 100644 index 000000000..e807adf19 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedStoneWire.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.RedStoneWireBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RedstoneSide; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.RedstoneWire; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRedStoneWire extends CraftBlockData implements RedstoneWire { + private static final IntegerProperty POWER = RedStoneWireBlock.POWER; + + private static final Map> PROPERTY_BY_DIRECTION = RedStoneWireBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftRedStoneWire(BlockState state) { + super(state); + } + + @Override + public int getPower() { + return this.get(POWER); + } + + @Override + public void setPower(final int power) { + this.set(POWER, power); + } + + @Override + public int getMaximumPower() { + return POWER.max; + } + + @Override + public RedstoneWire.Connection getFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property, RedstoneWire.Connection.class); + } + + @Override + public void setFace(final BlockFace blockFace, final RedstoneWire.Connection connection) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(connection != null, "connection cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, connection); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java new file mode 100644 index 000000000..397d53839 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneLamp.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.RedstoneLampBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Lightable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRedstoneLamp extends CraftBlockData implements Lightable { + private static final BooleanProperty LIT = RedstoneLampBlock.LIT; + + public CraftRedstoneLamp(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java new file mode 100644 index 000000000..9f5ff81c2 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneTorch.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.RedstoneTorchBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Lightable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRedstoneTorch extends CraftBlockData implements Lightable { + private static final BooleanProperty LIT = RedstoneTorchBlock.LIT; + + public CraftRedstoneTorch(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWallTorch.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWallTorch.java new file mode 100644 index 000000000..6e2612055 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRedstoneWallTorch.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.RedstoneWallTorchBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.RedstoneWallTorch; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRedstoneWallTorch extends CraftBlockData implements RedstoneWallTorch { + private static final EnumProperty FACING = RedstoneWallTorchBlock.FACING; + + private static final BooleanProperty LIT = RedstoneWallTorchBlock.LIT; + + public CraftRedstoneWallTorch(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java new file mode 100644 index 000000000..38fbc4b47 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRepeater.java @@ -0,0 +1,86 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.RepeaterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Repeater; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRepeater extends CraftBlockData implements Repeater { + private static final IntegerProperty DELAY = RepeaterBlock.DELAY; + + private static final EnumProperty FACING = RepeaterBlock.FACING; + + private static final BooleanProperty LOCKED = RepeaterBlock.LOCKED; + + private static final BooleanProperty POWERED = RepeaterBlock.POWERED; + + public CraftRepeater(BlockState state) { + super(state); + } + + @Override + public int getDelay() { + return this.get(DELAY); + } + + @Override + public void setDelay(final int delay) { + this.set(DELAY, delay); + } + + @Override + public int getMinimumDelay() { + return DELAY.min; + } + + @Override + public int getMaximumDelay() { + return DELAY.max; + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLocked() { + return this.get(LOCKED); + } + + @Override + public void setLocked(final boolean locked) { + this.set(LOCKED, locked); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java new file mode 100644 index 000000000..c89fd9b1d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRespawnAnchor.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.RespawnAnchorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.RespawnAnchor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRespawnAnchor extends CraftBlockData implements RespawnAnchor { + private static final IntegerProperty CHARGE = RespawnAnchorBlock.CHARGE; + + public CraftRespawnAnchor(BlockState state) { + super(state); + } + + @Override + public int getCharges() { + return this.get(CHARGE); + } + + @Override + public void setCharges(final int charges) { + this.set(CHARGE, charges); + } + + @Override + public int getMaximumCharges() { + return CHARGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRotatedPillar.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRotatedPillar.java new file mode 100644 index 000000000..36586e124 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftRotatedPillar.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.RotatedPillarBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.Axis; +import org.bukkit.block.data.Orientable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftRotatedPillar extends CraftBlockData implements Orientable { + private static final EnumProperty AXIS = RotatedPillarBlock.AXIS; + + public CraftRotatedPillar(BlockState state) { + super(state); + } + + @Override + public Axis getAxis() { + return this.get(AXIS, Axis.class); + } + + @Override + public void setAxis(final Axis axis) { + Preconditions.checkArgument(axis != null, "axis cannot be null!"); + this.set(AXIS, axis); + } + + @Override + public Set getAxes() { + return this.getValues(AXIS, Axis.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java new file mode 100644 index 000000000..9f445b1cc --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSapling.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SaplingBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Sapling; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSapling extends CraftBlockData implements Sapling { + private static final IntegerProperty STAGE = SaplingBlock.STAGE; + + public CraftSapling(BlockState state) { + super(state); + } + + @Override + public int getStage() { + return this.get(STAGE); + } + + @Override + public void setStage(final int stage) { + this.set(STAGE, stage); + } + + @Override + public int getMaximumStage() { + return STAGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java new file mode 100644 index 000000000..52508b748 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftScaffolding.java @@ -0,0 +1,57 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.ScaffoldingBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Scaffolding; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftScaffolding extends CraftBlockData implements Scaffolding { + private static final BooleanProperty BOTTOM = ScaffoldingBlock.BOTTOM; + + private static final IntegerProperty DISTANCE = ScaffoldingBlock.DISTANCE; + + private static final BooleanProperty WATERLOGGED = ScaffoldingBlock.WATERLOGGED; + + public CraftScaffolding(BlockState state) { + super(state); + } + + @Override + public boolean isBottom() { + return this.get(BOTTOM); + } + + @Override + public void setBottom(final boolean bottom) { + this.set(BOTTOM, bottom); + } + + @Override + public int getDistance() { + return this.get(DISTANCE); + } + + @Override + public void setDistance(final int distance) { + this.set(DISTANCE, distance); + } + + @Override + public int getMaximumDistance() { + return DISTANCE.max; + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkCatalyst.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkCatalyst.java new file mode 100644 index 000000000..ebbf25328 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkCatalyst.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SculkCatalystBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.SculkCatalyst; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSculkCatalyst extends CraftBlockData implements SculkCatalyst { + private static final BooleanProperty PULSE = SculkCatalystBlock.PULSE; + + public CraftSculkCatalyst(BlockState state) { + super(state); + } + + @Override + public boolean isBloom() { + return this.get(PULSE); + } + + @Override + public void setBloom(final boolean bloom) { + this.set(PULSE, bloom); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java new file mode 100644 index 000000000..f9a64ea65 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkSensor.java @@ -0,0 +1,61 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SculkSensorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.SculkSensorPhase; +import org.bukkit.block.data.type.SculkSensor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSculkSensor extends CraftBlockData implements SculkSensor { + private static final IntegerProperty POWER = SculkSensorBlock.POWER; + + private static final EnumProperty PHASE = SculkSensorBlock.PHASE; + + private static final BooleanProperty WATERLOGGED = SculkSensorBlock.WATERLOGGED; + + public CraftSculkSensor(BlockState state) { + super(state); + } + + @Override + public int getPower() { + return this.get(POWER); + } + + @Override + public void setPower(final int power) { + this.set(POWER, power); + } + + @Override + public int getMaximumPower() { + return POWER.max; + } + + @Override + public SculkSensor.Phase getSculkSensorPhase() { + return this.get(PHASE, SculkSensor.Phase.class); + } + + @Override + public void setSculkSensorPhase(final SculkSensor.Phase phase) { + Preconditions.checkArgument(phase != null, "phase cannot be null!"); + this.set(PHASE, phase); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkShrieker.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkShrieker.java new file mode 100644 index 000000000..f8e10eaf2 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkShrieker.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SculkShriekerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.SculkShrieker; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSculkShrieker extends CraftBlockData implements SculkShrieker { + private static final BooleanProperty CAN_SUMMON = SculkShriekerBlock.CAN_SUMMON; + + private static final BooleanProperty SHRIEKING = SculkShriekerBlock.SHRIEKING; + + private static final BooleanProperty WATERLOGGED = SculkShriekerBlock.WATERLOGGED; + + public CraftSculkShrieker(BlockState state) { + super(state); + } + + @Override + public boolean isCanSummon() { + return this.get(CAN_SUMMON); + } + + @Override + public void setCanSummon(final boolean canSummon) { + this.set(CAN_SUMMON, canSummon); + } + + @Override + public boolean isShrieking() { + return this.get(SHRIEKING); + } + + @Override + public void setShrieking(final boolean shrieking) { + this.set(SHRIEKING, shrieking); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkVein.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkVein.java new file mode 100644 index 000000000..2d43475c8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSculkVein.java @@ -0,0 +1,76 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.SculkVeinBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.SculkVein; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSculkVein extends CraftBlockData implements SculkVein { + private static final BooleanProperty WATERLOGGED = SculkVeinBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = Map.of( + BlockFace.DOWN, BlockStateProperties.DOWN, + BlockFace.UP, BlockStateProperties.UP, + BlockFace.NORTH, BlockStateProperties.NORTH, + BlockFace.SOUTH, BlockStateProperties.SOUTH, + BlockFace.WEST, BlockStateProperties.WEST, + BlockFace.EAST, BlockStateProperties.EAST + ); + + public CraftSculkVein(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java new file mode 100644 index 000000000..3c008c76a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSeaPickle.java @@ -0,0 +1,50 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SeaPickleBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.SeaPickle; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSeaPickle extends CraftBlockData implements SeaPickle { + private static final IntegerProperty PICKLES = SeaPickleBlock.PICKLES; + + private static final BooleanProperty WATERLOGGED = SeaPickleBlock.WATERLOGGED; + + public CraftSeaPickle(BlockState state) { + super(state); + } + + @Override + public int getPickles() { + return this.get(PICKLES); + } + + @Override + public void setPickles(final int pickles) { + this.set(PICKLES, pickles); + } + + @Override + public int getMinimumPickles() { + return PICKLES.min; + } + + @Override + public int getMaximumPickles() { + return PICKLES.max; + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java new file mode 100644 index 000000000..b5836e4d8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftShulkerBox.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.ShulkerBoxBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftShulkerBox extends CraftBlockData implements Directional { + private static final EnumProperty FACING = ShulkerBoxBlock.FACING; + + public CraftShulkerBox(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian(), "Invalid face, only cartesian face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java new file mode 100644 index 000000000..5057f8a7d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSkull.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Skull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftSkull extends CraftBlockData implements Skull { + private static final BooleanProperty POWERED = SkullBlock.POWERED; + + private static final IntegerProperty ROTATION = SkullBlock.ROTATION; + + public CraftSkull(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSlab.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSlab.java new file mode 100644 index 000000000..325c8c698 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSlab.java @@ -0,0 +1,43 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.SlabType; +import org.bukkit.block.data.type.Slab; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSlab extends CraftBlockData implements Slab { + private static final EnumProperty TYPE = SlabBlock.TYPE; + + private static final BooleanProperty WATERLOGGED = SlabBlock.WATERLOGGED; + + public CraftSlab(BlockState state) { + super(state); + } + + @Override + public Slab.Type getType() { + return this.get(TYPE, Slab.Type.class); + } + + @Override + public void setType(final Slab.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java new file mode 100644 index 000000000..551649ab3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmallDripleaf.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.SmallDripleafBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.SmallDripleaf; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSmallDripleaf extends CraftBlockData implements SmallDripleaf { + private static final EnumProperty FACING = SmallDripleafBlock.FACING; + + private static final EnumProperty HALF = SmallDripleafBlock.HALF; + + private static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED; + + public CraftSmallDripleaf(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java new file mode 100644 index 000000000..82897a7d1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSmoker.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.SmokerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Furnace; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSmoker extends CraftBlockData implements Furnace { + private static final EnumProperty FACING = SmokerBlock.FACING; + + private static final BooleanProperty LIT = SmokerBlock.LIT; + + public CraftSmoker(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnifferEgg.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnifferEgg.java new file mode 100644 index 000000000..d9fbac6b9 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnifferEgg.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SnifferEggBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Hatchable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSnifferEgg extends CraftBlockData implements Hatchable { + private static final IntegerProperty HATCH = SnifferEggBlock.HATCH; + + public CraftSnifferEgg(BlockState state) { + super(state); + } + + @Override + public int getHatch() { + return this.get(HATCH); + } + + @Override + public void setHatch(final int hatch) { + this.set(HATCH, hatch); + } + + @Override + public int getMaximumHatch() { + return HATCH.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowLayer.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowLayer.java new file mode 100644 index 000000000..6f98633d1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowLayer.java @@ -0,0 +1,37 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SnowLayerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Snow; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSnowLayer extends CraftBlockData implements Snow { + private static final IntegerProperty LAYERS = SnowLayerBlock.LAYERS; + + public CraftSnowLayer(BlockState state) { + super(state); + } + + @Override + public int getLayers() { + return this.get(LAYERS); + } + + @Override + public void setLayers(final int layers) { + this.set(LAYERS, layers); + } + + @Override + public int getMinimumLayers() { + return LAYERS.min; + } + + @Override + public int getMaximumLayers() { + return LAYERS.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowyDirt.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowyDirt.java new file mode 100644 index 000000000..351882623 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSnowyDirt.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SnowyDirtBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Snowable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSnowyDirt extends CraftBlockData implements Snowable { + private static final BooleanProperty SNOWY = SnowyDirtBlock.SNOWY; + + public CraftSnowyDirt(BlockState state) { + super(state); + } + + @Override + public boolean isSnowy() { + return this.get(SNOWY); + } + + @Override + public void setSnowy(final boolean snowy) { + this.set(SNOWY, snowy); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java new file mode 100644 index 000000000..becbc7ab5 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStainedGlassPane.java @@ -0,0 +1,70 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.StainedGlassPaneBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.GlassPane; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftStainedGlassPane extends CraftBlockData implements GlassPane { + private static final BooleanProperty WATERLOGGED = StainedGlassPaneBlock.WATERLOGGED; + + private static final Map PROPERTY_BY_DIRECTION = StainedGlassPaneBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftStainedGlassPane(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStair.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStair.java new file mode 100644 index 000000000..456bf31f1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStair.java @@ -0,0 +1,78 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.StairsShape; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Stairs; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftStair extends CraftBlockData implements Stairs { + private static final EnumProperty FACING = StairBlock.FACING; + + private static final EnumProperty HALF = StairBlock.HALF; + + private static final EnumProperty SHAPE = StairBlock.SHAPE; + + private static final BooleanProperty WATERLOGGED = StairBlock.WATERLOGGED; + + public CraftStair(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public Stairs.Shape getShape() { + return this.get(SHAPE, Stairs.Shape.class); + } + + @Override + public void setShape(final Stairs.Shape shape) { + Preconditions.checkArgument(shape != null, "shape cannot be null!"); + this.set(SHAPE, shape); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStandingSign.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStandingSign.java new file mode 100644 index 000000000..849b50aee --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStandingSign.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.StandingSignBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Sign; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftStandingSign extends CraftBlockData implements Sign { + private static final IntegerProperty ROTATION = StandingSignBlock.ROTATION; + + private static final BooleanProperty WATERLOGGED = StandingSignBlock.WATERLOGGED; + + public CraftStandingSign(BlockState state) { + super(state); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStem.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStem.java new file mode 100644 index 000000000..c84c62a1d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStem.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.StemBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftStem extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = StemBlock.AGE; + + public CraftStem(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java new file mode 100644 index 000000000..5fd2f6357 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStonecutter.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.StonecutterBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftStonecutter extends CraftBlockData implements Directional { + private static final EnumProperty FACING = StonecutterBlock.FACING; + + public CraftStonecutter(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStructureBlock.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStructureBlock.java new file mode 100644 index 000000000..b30cfa582 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftStructureBlock.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.StructureMode; +import org.bukkit.block.data.type.StructureBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftStructureBlock extends CraftBlockData implements StructureBlock { + private static final EnumProperty MODE = net.minecraft.world.level.block.StructureBlock.MODE; + + public CraftStructureBlock(BlockState state) { + super(state); + } + + @Override + public StructureBlock.Mode getMode() { + return this.get(MODE, StructureBlock.Mode.class); + } + + @Override + public void setMode(final StructureBlock.Mode mode) { + Preconditions.checkArgument(mode != null, "mode cannot be null!"); + this.set(MODE, mode); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSugarCane.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSugarCane.java new file mode 100644 index 000000000..df66c18a0 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSugarCane.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SugarCaneBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSugarCane extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = SugarCaneBlock.AGE; + + public CraftSugarCane(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java new file mode 100644 index 000000000..6259d5b55 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftSweetBerryBush.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.SweetBerryBushBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftSweetBerryBush extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = SweetBerryBushBlock.AGE; + + public CraftSweetBerryBush(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallFlower.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallFlower.java new file mode 100644 index 000000000..7e3b634c6 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallFlower.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TallFlowerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.Bisected; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTallFlower extends CraftBlockData implements Bisected { + private static final EnumProperty HALF = TallFlowerBlock.HALF; + + public CraftTallFlower(BlockState state) { + super(state); + } + + @Override + public Bisected.Half getHalf() { + return this.get(HALF, Bisected.Half.class); + } + + @Override + public void setHalf(final Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java new file mode 100644 index 000000000..cac15af90 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTallSeagrass.java @@ -0,0 +1,30 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TallSeagrassBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.Bisected; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTallSeagrass extends CraftBlockData implements Bisected { + private static final EnumProperty HALF = TallSeagrassBlock.HALF; + + public CraftTallSeagrass(BlockState state) { + super(state); + } + + @Override + public Bisected.Half getHalf() { + return this.get(HALF, Bisected.Half.class); + } + + @Override + public void setHalf(final Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java new file mode 100644 index 000000000..b2967918f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTarget.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTarget extends CraftBlockData implements AnaloguePowerable { + private static final IntegerProperty OUTPUT_POWER = BlockStateProperties.POWER; + + public CraftTarget(BlockState state) { + super(state); + } + + @Override + public int getPower() { + return this.get(OUTPUT_POWER); + } + + @Override + public void setPower(final int power) { + this.set(OUTPUT_POWER, power); + } + + @Override + public int getMaximumPower() { + return OUTPUT_POWER.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTestBlock.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTestBlock.java new file mode 100644 index 000000000..c38889607 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTestBlock.java @@ -0,0 +1,29 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.TestBlockMode; +import org.bukkit.block.data.type.TestBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTestBlock extends CraftBlockData implements TestBlock { + private static final EnumProperty MODE = net.minecraft.world.level.block.TestBlock.MODE; + + public CraftTestBlock(BlockState state) { + super(state); + } + + @Override + public TestBlock.Mode getMode() { + return this.get(MODE, TestBlock.Mode.class); + } + + @Override + public void setMode(final TestBlock.Mode mode) { + Preconditions.checkArgument(mode != null, "mode cannot be null!"); + this.set(MODE, mode); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java new file mode 100644 index 000000000..397dcfb76 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTintedParticleLeaves.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TintedParticleLeavesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Leaves; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTintedParticleLeaves extends CraftBlockData implements Leaves { + private static final IntegerProperty DISTANCE = TintedParticleLeavesBlock.DISTANCE; + + private static final BooleanProperty PERSISTENT = TintedParticleLeavesBlock.PERSISTENT; + + private static final BooleanProperty WATERLOGGED = TintedParticleLeavesBlock.WATERLOGGED; + + public CraftTintedParticleLeaves(BlockState state) { + super(state); + } + + @Override + public int getDistance() { + return this.get(DISTANCE); + } + + @Override + public void setDistance(final int distance) { + this.set(DISTANCE, distance); + } + + @Override + public int getMinimumDistance() { + return DISTANCE.min; + } + + @Override + public int getMaximumDistance() { + return DISTANCE.max; + } + + @Override + public boolean isPersistent() { + return this.get(PERSISTENT); + } + + @Override + public void setPersistent(final boolean persistent) { + this.set(PERSISTENT, persistent); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTnt.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTnt.java new file mode 100644 index 000000000..525fa7e69 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTnt.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TntBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.TNT; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTnt extends CraftBlockData implements TNT { + private static final BooleanProperty UNSTABLE = TntBlock.UNSTABLE; + + public CraftTnt(BlockState state) { + super(state); + } + + @Override + public boolean isUnstable() { + return this.get(UNSTABLE); + } + + @Override + public void setUnstable(final boolean unstable) { + this.set(UNSTABLE, unstable); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java new file mode 100644 index 000000000..22274f2d8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTorchflowerCrop.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TorchflowerCropBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTorchflowerCrop extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = TorchflowerCropBlock.AGE; + + public CraftTorchflowerCrop(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrapDoor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrapDoor.java new file mode 100644 index 000000000..791656ef9 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrapDoor.java @@ -0,0 +1,88 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.TrapDoorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.TrapDoor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTrapDoor extends CraftBlockData implements TrapDoor { + private static final EnumProperty FACING = TrapDoorBlock.FACING; + + private static final EnumProperty HALF = TrapDoorBlock.HALF; + + private static final BooleanProperty OPEN = TrapDoorBlock.OPEN; + + private static final BooleanProperty POWERED = TrapDoorBlock.POWERED; + + private static final BooleanProperty WATERLOGGED = TrapDoorBlock.WATERLOGGED; + + public CraftTrapDoor(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrappedChest.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrappedChest.java new file mode 100644 index 000000000..023115973 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrappedChest.java @@ -0,0 +1,65 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.TrappedChestBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.ChestType; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Chest; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTrappedChest extends CraftBlockData implements Chest { + private static final EnumProperty FACING = TrappedChestBlock.FACING; + + private static final EnumProperty TYPE = TrappedChestBlock.TYPE; + + private static final BooleanProperty WATERLOGGED = TrappedChestBlock.WATERLOGGED; + + public CraftTrappedChest(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public Chest.Type getType() { + return this.get(TYPE, Chest.Type.class); + } + + @Override + public void setType(final Chest.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrialSpawner.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrialSpawner.java new file mode 100644 index 000000000..90ca1ce3f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTrialSpawner.java @@ -0,0 +1,43 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TrialSpawnerBlock; +import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerState; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.data.type.TrialSpawner; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTrialSpawner extends CraftBlockData implements TrialSpawner { + private static final BooleanProperty OMINOUS = TrialSpawnerBlock.OMINOUS; + + private static final EnumProperty STATE = TrialSpawnerBlock.STATE; + + public CraftTrialSpawner(BlockState state) { + super(state); + } + + @Override + public boolean isOminous() { + return this.get(OMINOUS); + } + + @Override + public void setOminous(final boolean ominous) { + this.set(OMINOUS, ominous); + } + + @Override + public TrialSpawner.State getTrialSpawnerState() { + return this.get(STATE, TrialSpawner.State.class); + } + + @Override + public void setTrialSpawnerState(final TrialSpawner.State state) { + Preconditions.checkArgument(state != null, "state cannot be null!"); + this.set(STATE, state); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWire.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWire.java new file mode 100644 index 000000000..855f3324f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWire.java @@ -0,0 +1,97 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.TripWireBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Tripwire; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTripWire extends CraftBlockData implements Tripwire { + private static final BooleanProperty ATTACHED = TripWireBlock.ATTACHED; + + private static final BooleanProperty DISARMED = TripWireBlock.DISARMED; + + private static final BooleanProperty POWERED = TripWireBlock.POWERED; + + private static final Map PROPERTY_BY_DIRECTION = Map.of( + BlockFace.WEST, TripWireBlock.WEST, + BlockFace.EAST, TripWireBlock.EAST, + BlockFace.NORTH, TripWireBlock.NORTH, + BlockFace.SOUTH, TripWireBlock.SOUTH + ); + + public CraftTripWire(BlockState state) { + super(state); + } + + @Override + public boolean isAttached() { + return this.get(ATTACHED); + } + + @Override + public void setAttached(final boolean attached) { + this.set(ATTACHED, attached); + } + + @Override + public boolean isDisarmed() { + return this.get(DISARMED); + } + + @Override + public void setDisarmed(final boolean disarmed) { + this.set(DISARMED, disarmed); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWireHook.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWireHook.java new file mode 100644 index 000000000..069f59fa0 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTripWireHook.java @@ -0,0 +1,63 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.TripWireHookBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.TripwireHook; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTripWireHook extends CraftBlockData implements TripwireHook { + private static final BooleanProperty ATTACHED = TripWireHookBlock.ATTACHED; + + private static final EnumProperty FACING = TripWireHookBlock.FACING; + + private static final BooleanProperty POWERED = TripWireHookBlock.POWERED; + + public CraftTripWireHook(BlockState state) { + super(state); + } + + @Override + public boolean isAttached() { + return this.get(ATTACHED); + } + + @Override + public void setAttached(final boolean attached) { + this.set(ATTACHED, attached); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java new file mode 100644 index 000000000..1448ffdbd --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTurtleEgg.java @@ -0,0 +1,54 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TurtleEggBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.TurtleEgg; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTurtleEgg extends CraftBlockData implements TurtleEgg { + private static final IntegerProperty EGGS = TurtleEggBlock.EGGS; + + private static final IntegerProperty HATCH = TurtleEggBlock.HATCH; + + public CraftTurtleEgg(BlockState state) { + super(state); + } + + @Override + public int getEggs() { + return this.get(EGGS); + } + + @Override + public void setEggs(final int eggs) { + this.set(EGGS, eggs); + } + + @Override + public int getMinimumEggs() { + return EGGS.min; + } + + @Override + public int getMaximumEggs() { + return EGGS.max; + } + + @Override + public int getHatch() { + return this.get(HATCH); + } + + @Override + public void setHatch(final int hatch) { + this.set(HATCH, hatch); + } + + @Override + public int getMaximumHatch() { + return HATCH.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java new file mode 100644 index 000000000..f56ee736b --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftTwistingVines.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.TwistingVinesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftTwistingVines extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = TwistingVinesBlock.AGE; + + public CraftTwistingVines(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java new file mode 100644 index 000000000..1f7204ac3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftUntintedParticleLeaves.java @@ -0,0 +1,62 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.UntintedParticleLeavesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.type.Leaves; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftUntintedParticleLeaves extends CraftBlockData implements Leaves { + private static final IntegerProperty DISTANCE = UntintedParticleLeavesBlock.DISTANCE; + + private static final BooleanProperty PERSISTENT = UntintedParticleLeavesBlock.PERSISTENT; + + private static final BooleanProperty WATERLOGGED = UntintedParticleLeavesBlock.WATERLOGGED; + + public CraftUntintedParticleLeaves(BlockState state) { + super(state); + } + + @Override + public int getDistance() { + return this.get(DISTANCE); + } + + @Override + public void setDistance(final int distance) { + this.set(DISTANCE, distance); + } + + @Override + public int getMinimumDistance() { + return DISTANCE.min; + } + + @Override + public int getMaximumDistance() { + return DISTANCE.max; + } + + @Override + public boolean isPersistent() { + return this.get(PERSISTENT); + } + + @Override + public void setPersistent(final boolean persistent) { + this.set(PERSISTENT, persistent); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVault.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVault.java new file mode 100644 index 000000000..c9ec60761 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVault.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.VaultBlock; +import net.minecraft.world.level.block.entity.vault.VaultState; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Vault; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftVault extends CraftBlockData implements Vault { + private static final EnumProperty FACING = VaultBlock.FACING; + + private static final BooleanProperty OMINOUS = VaultBlock.OMINOUS; + + private static final EnumProperty STATE = BlockStateProperties.VAULT_STATE; + + public CraftVault(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isOminous() { + return this.get(OMINOUS); + } + + @Override + public void setOminous(final boolean ominous) { + this.set(OMINOUS, ominous); + } + + @Override + public Vault.State getVaultState() { + return this.get(STATE, Vault.State.class); + } + + @Override + public void setVaultState(final Vault.State state) { + Preconditions.checkArgument(state != null, "state cannot be null!"); + this.set(STATE, state); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVine.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVine.java new file mode 100644 index 000000000..c4a86206a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftVine.java @@ -0,0 +1,58 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableSet; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.VineBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.MultipleFacing; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftVine extends CraftBlockData implements MultipleFacing { + private static final Map PROPERTY_BY_DIRECTION = VineBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftVine(BlockState state) { + super(state); + } + + @Override + public boolean hasFace(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property); + } + + @Override + public void setFace(final BlockFace blockFace, final boolean face) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + BooleanProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, face); + } + + @Override + public Set getFaces() { + ImmutableSet.Builder faces = ImmutableSet.builder(); + for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { + if (this.get(entry.getValue())) { + faces.add(entry.getKey()); + } + } + return faces.build(); + } + + @Override + public Set getAllowedFaces() { + return Collections.unmodifiableSet(PROPERTY_BY_DIRECTION.keySet()); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWall.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWall.java new file mode 100644 index 000000000..d553f03bb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWall.java @@ -0,0 +1,66 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Map; +import java.util.stream.Collectors; +import net.minecraft.world.level.block.WallBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.WallSide; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Wall; +import org.bukkit.craftbukkit.block.CraftBlock; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWall extends CraftBlockData implements Wall { + private static final BooleanProperty UP = WallBlock.UP; + + private static final BooleanProperty WATERLOGGED = WallBlock.WATERLOGGED; + + private static final Map> PROPERTY_BY_DIRECTION = WallBlock.PROPERTY_BY_DIRECTION.entrySet().stream() + .collect(Collectors.toMap(entry -> CraftBlock.notchToBlockFace(entry.getKey()), entry -> entry.getValue())); + + public CraftWall(BlockState state) { + super(state); + } + + @Override + public boolean isUp() { + return this.get(UP); + } + + @Override + public void setUp(final boolean up) { + this.set(UP, up); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } + + @Override + public Wall.Height getHeight(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + return this.get(property, Wall.Height.class); + } + + @Override + public void setHeight(final BlockFace blockFace, final Wall.Height height) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(height != null, "height cannot be null!"); + EnumProperty property = PROPERTY_BY_DIRECTION.get(blockFace); + Preconditions.checkArgument(property != null, "Invalid blockFace, only %s are allowed!", PROPERTY_BY_DIRECTION.keySet().stream().map(Enum::name).collect(Collectors.joining(", "))); + this.set(property, height); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallBanner.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallBanner.java new file mode 100644 index 000000000..af32e2e2f --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallBanner.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WallBannerBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWallBanner extends CraftBlockData implements Directional { + private static final EnumProperty FACING = WallBannerBlock.FACING; + + public CraftWallBanner(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java new file mode 100644 index 000000000..96d666be4 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallHangingSign.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WallHangingSignBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallHangingSign; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWallHangingSign extends CraftBlockData implements WallHangingSign { + private static final EnumProperty FACING = WallHangingSignBlock.FACING; + + private static final BooleanProperty WATERLOGGED = WallHangingSignBlock.WATERLOGGED; + + public CraftWallHangingSign(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java new file mode 100644 index 000000000..3583a7d91 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSign.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WallSignBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallSign; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWallSign extends CraftBlockData implements WallSign { + private static final EnumProperty FACING = WallSignBlock.FACING; + + private static final BooleanProperty WATERLOGGED = WallSignBlock.WATERLOGGED; + + public CraftWallSign(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSkull.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSkull.java new file mode 100644 index 000000000..5852d57bb --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallSkull.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WallSkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallSkull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWallSkull extends CraftBlockData implements WallSkull { + private static final EnumProperty FACING = WallSkullBlock.FACING; + + private static final BooleanProperty POWERED = WallSkullBlock.POWERED; + + public CraftWallSkull(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallTorch.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallTorch.java new file mode 100644 index 000000000..3ec8724d1 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWallTorch.java @@ -0,0 +1,38 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WallTorchBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.Directional; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWallTorch extends CraftBlockData implements Directional { + private static final EnumProperty FACING = WallTorchBlock.FACING; + + public CraftWallTorch(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWaterloggedTransparent.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWaterloggedTransparent.java new file mode 100644 index 000000000..7a7187169 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWaterloggedTransparent.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WaterloggedTransparentBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWaterloggedTransparent extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = WaterloggedTransparentBlock.WATERLOGGED; + + public CraftWaterloggedTransparent(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperBulb.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperBulb.java new file mode 100644 index 000000000..fb67d3fa3 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperBulb.java @@ -0,0 +1,39 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WeatheringCopperBulbBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.type.CopperBulb; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperBulb extends CraftBlockData implements CopperBulb { + private static final BooleanProperty LIT = WeatheringCopperBulbBlock.LIT; + + private static final BooleanProperty POWERED = WeatheringCopperBulbBlock.POWERED; + + public CraftWeatheringCopperBulb(BlockState state) { + super(state); + } + + @Override + public boolean isLit() { + return this.get(LIT); + } + + @Override + public void setLit(final boolean lit) { + this.set(LIT, lit); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperDoor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperDoor.java new file mode 100644 index 000000000..460fb7a25 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperDoor.java @@ -0,0 +1,91 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WeatheringCopperDoorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.DoorHingeSide; +import net.minecraft.world.level.block.state.properties.DoubleBlockHalf; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Door; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperDoor extends CraftBlockData implements Door { + private static final EnumProperty FACING = WeatheringCopperDoorBlock.FACING; + + private static final EnumProperty HALF = WeatheringCopperDoorBlock.HALF; + + private static final EnumProperty HINGE = WeatheringCopperDoorBlock.HINGE; + + private static final BooleanProperty OPEN = WeatheringCopperDoorBlock.OPEN; + + private static final BooleanProperty POWERED = WeatheringCopperDoorBlock.POWERED; + + public CraftWeatheringCopperDoor(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public Door.Hinge getHinge() { + return this.get(HINGE, Door.Hinge.class); + } + + @Override + public void setHinge(final Door.Hinge hinge) { + Preconditions.checkArgument(hinge != null, "hinge cannot be null!"); + this.set(HINGE, hinge); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperGrate.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperGrate.java new file mode 100644 index 000000000..7671dcc3d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperGrate.java @@ -0,0 +1,27 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WeatheringCopperGrateBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import org.bukkit.block.data.Waterlogged; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperGrate extends CraftBlockData implements Waterlogged { + private static final BooleanProperty WATERLOGGED = WeatheringCopperGrateBlock.WATERLOGGED; + + public CraftWeatheringCopperGrate(BlockState state) { + super(state); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java new file mode 100644 index 000000000..f049c773a --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperSlab.java @@ -0,0 +1,43 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WeatheringCopperSlabBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.SlabType; +import org.bukkit.block.data.type.Slab; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperSlab extends CraftBlockData implements Slab { + private static final EnumProperty TYPE = WeatheringCopperSlabBlock.TYPE; + + private static final BooleanProperty WATERLOGGED = WeatheringCopperSlabBlock.WATERLOGGED; + + public CraftWeatheringCopperSlab(BlockState state) { + super(state); + } + + @Override + public Slab.Type getType() { + return this.get(TYPE, Slab.Type.class); + } + + @Override + public void setType(final Slab.Type type) { + Preconditions.checkArgument(type != null, "type cannot be null!"); + this.set(TYPE, type); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java new file mode 100644 index 000000000..b9274d9e8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperStair.java @@ -0,0 +1,78 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WeatheringCopperStairBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import net.minecraft.world.level.block.state.properties.StairsShape; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Stairs; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperStair extends CraftBlockData implements Stairs { + private static final EnumProperty FACING = WeatheringCopperStairBlock.FACING; + + private static final EnumProperty HALF = WeatheringCopperStairBlock.HALF; + + private static final EnumProperty SHAPE = WeatheringCopperStairBlock.SHAPE; + + private static final BooleanProperty WATERLOGGED = WeatheringCopperStairBlock.WATERLOGGED; + + public CraftWeatheringCopperStair(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public Stairs.Shape getShape() { + return this.get(SHAPE, Stairs.Shape.class); + } + + @Override + public void setShape(final Stairs.Shape shape) { + Preconditions.checkArgument(shape != null, "shape cannot be null!"); + this.set(SHAPE, shape); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperTrapDoor.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperTrapDoor.java new file mode 100644 index 000000000..ee5af42a8 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeatheringCopperTrapDoor.java @@ -0,0 +1,88 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WeatheringCopperTrapDoorBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.TrapDoor; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeatheringCopperTrapDoor extends CraftBlockData implements TrapDoor { + private static final EnumProperty FACING = WeatheringCopperTrapDoorBlock.FACING; + + private static final EnumProperty HALF = WeatheringCopperTrapDoorBlock.HALF; + + private static final BooleanProperty OPEN = WeatheringCopperTrapDoorBlock.OPEN; + + private static final BooleanProperty POWERED = WeatheringCopperTrapDoorBlock.POWERED; + + private static final BooleanProperty WATERLOGGED = WeatheringCopperTrapDoorBlock.WATERLOGGED; + + public CraftWeatheringCopperTrapDoor(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public org.bukkit.block.data.Bisected.Half getHalf() { + return this.get(HALF, org.bukkit.block.data.Bisected.Half.class); + } + + @Override + public void setHalf(final org.bukkit.block.data.Bisected.Half half) { + Preconditions.checkArgument(half != null, "half cannot be null!"); + this.set(HALF, half); + } + + @Override + public boolean isOpen() { + return this.get(OPEN); + } + + @Override + public void setOpen(final boolean open) { + this.set(OPEN, open); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public boolean isWaterlogged() { + return this.get(WATERLOGGED); + } + + @Override + public void setWaterlogged(final boolean waterlogged) { + this.set(WATERLOGGED, waterlogged); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java new file mode 100644 index 000000000..7f6a0c21d --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeepingVines.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WeepingVinesBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.Ageable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeepingVines extends CraftBlockData implements Ageable { + private static final IntegerProperty AGE = WeepingVinesBlock.AGE; + + public CraftWeepingVines(BlockState state) { + super(state); + } + + @Override + public int getAge() { + return this.get(AGE); + } + + @Override + public void setAge(final int age) { + this.set(AGE, age); + } + + @Override + public int getMaximumAge() { + return AGE.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeightedPressurePlate.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeightedPressurePlate.java new file mode 100644 index 000000000..aa614ef86 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWeightedPressurePlate.java @@ -0,0 +1,32 @@ +package org.bukkit.craftbukkit.block.impl; + +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WeightedPressurePlateBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import org.bukkit.block.data.AnaloguePowerable; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWeightedPressurePlate extends CraftBlockData implements AnaloguePowerable { + private static final IntegerProperty POWER = WeightedPressurePlateBlock.POWER; + + public CraftWeightedPressurePlate(BlockState state) { + super(state); + } + + @Override + public int getPower() { + return this.get(POWER); + } + + @Override + public void setPower(final int power) { + this.set(POWER, power); + } + + @Override + public int getMaximumPower() { + return POWER.max; + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java new file mode 100644 index 000000000..711d97c62 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherSkull.java @@ -0,0 +1,48 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import net.minecraft.world.level.block.WitherSkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.IntegerProperty; +import net.minecraft.world.level.block.state.properties.RotationSegment; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.Skull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; +import org.bukkit.util.Vector; + +@GeneratedFrom("1.21.5") +public class CraftWitherSkull extends CraftBlockData implements Skull { + private static final BooleanProperty POWERED = WitherSkullBlock.POWERED; + + private static final IntegerProperty ROTATION = WitherSkullBlock.ROTATION; + + public CraftWitherSkull(BlockState state) { + super(state); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } + + @Override + public BlockFace getRotation() { + return CraftBlockData.ROTATION_CYCLE[this.get(ROTATION)]; + } + + @Override + public void setRotation(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace != BlockFace.SELF && blockFace.getModY() == 0, "Invalid face, only horizontal face are allowed for this property!"); + Vector dir = blockFace.getDirection(); + float angle = (float) -Math.toDegrees(Math.atan2(dir.getX(), dir.getZ())); + this.set(ROTATION, RotationSegment.convertToSegment(angle)); + } +} diff --git a/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherWallSkull.java b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherWallSkull.java new file mode 100644 index 000000000..13d51eaa0 --- /dev/null +++ b/paper-server/src/generated/java/org/bukkit/craftbukkit/block/impl/CraftWitherWallSkull.java @@ -0,0 +1,51 @@ +package org.bukkit.craftbukkit.block.impl; + +import com.google.common.base.Preconditions; +import io.papermc.paper.generated.GeneratedFrom; +import java.util.Set; +import net.minecraft.core.Direction; +import net.minecraft.world.level.block.WitherWallSkullBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.level.block.state.properties.EnumProperty; +import org.bukkit.block.BlockFace; +import org.bukkit.block.data.type.WallSkull; +import org.bukkit.craftbukkit.block.data.CraftBlockData; + +@GeneratedFrom("1.21.5") +public class CraftWitherWallSkull extends CraftBlockData implements WallSkull { + private static final EnumProperty FACING = WitherWallSkullBlock.FACING; + + private static final BooleanProperty POWERED = WitherWallSkullBlock.POWERED; + + public CraftWitherWallSkull(BlockState state) { + super(state); + } + + @Override + public BlockFace getFacing() { + return this.get(FACING, BlockFace.class); + } + + @Override + public void setFacing(final BlockFace blockFace) { + Preconditions.checkArgument(blockFace != null, "blockFace cannot be null!"); + Preconditions.checkArgument(blockFace.isCartesian() && blockFace.getModY() == 0, "Invalid face, only cartesian horizontal face are allowed for this property!"); + this.set(FACING, blockFace); + } + + @Override + public Set getFaces() { + return this.getValues(FACING, BlockFace.class); + } + + @Override + public boolean isPowered() { + return this.get(POWERED); + } + + @Override + public void setPowered(final boolean powered) { + this.set(POWERED, powered); + } +} diff --git a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java index c21e00812..ece6db7b9 100644 --- a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java +++ b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/list/IteratorSafeOrderedReferenceSet.java @@ -2,6 +2,7 @@ package ca.spottedleaf.moonrise.common.list; import it.unimi.dsi.fastutil.objects.Reference2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import java.lang.reflect.Array; import java.util.Arrays; import java.util.NoSuchElementException; @@ -21,15 +22,34 @@ public final class IteratorSafeOrderedReferenceSet { private int iteratorCount; public IteratorSafeOrderedReferenceSet() { - this(16, 0.75f, 16, 0.2); + this(Object.class); + } + + public IteratorSafeOrderedReferenceSet(final Class arrComponent) { + this(16, 0.75f, 16, 0.2, arrComponent); } public IteratorSafeOrderedReferenceSet(final int setCapacity, final float setLoadFactor, final int arrayCapacity, final double maxFragFactor) { + this(setCapacity, setLoadFactor, arrayCapacity, maxFragFactor, Object.class); + } + + public IteratorSafeOrderedReferenceSet(final int setCapacity, final float setLoadFactor, final int arrayCapacity, + final double maxFragFactor, final Class arrComponent) { this.indexMap = new Reference2IntLinkedOpenHashMap<>(setCapacity, setLoadFactor); this.indexMap.defaultReturnValue(-1); this.maxFragFactor = maxFragFactor; - this.listElements = (E[])new Object[arrayCapacity]; + this.listElements = (E[])Array.newInstance(arrComponent, arrayCapacity); + } + + // includes null (gravestone) elements + public E[] getListRaw() { + return this.listElements; + } + + // includes null (gravestone) elements + public int getListSize() { + return this.listSize; } /* @@ -81,7 +101,7 @@ public final class IteratorSafeOrderedReferenceSet { public int createRawIterator() { ++this.iteratorCount; if (this.indexMap.isEmpty()) { - return -1; + return Integer.MAX_VALUE; } else { return this.firstInvalidIndex == 0 ? this.indexMap.getInt(this.indexMap.firstKey()) : 0; } @@ -96,7 +116,7 @@ public final class IteratorSafeOrderedReferenceSet { } } - return -1; + return Integer.MAX_VALUE; } public void finishRawIterator() { @@ -205,10 +225,6 @@ public final class IteratorSafeOrderedReferenceSet { //this.check(); } - public E rawGet(final int index) { - return this.listElements[index]; - } - public int size() { // always returns the correct amount - listSize can be different return this.indexMap.size(); diff --git a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/PositionCountingAreaMap.java b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/PositionCountingAreaMap.java index 90560769d..09b18926f 100644 --- a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/PositionCountingAreaMap.java +++ b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/PositionCountingAreaMap.java @@ -1,6 +1,6 @@ package ca.spottedleaf.moonrise.common.misc; -import ca.spottedleaf.concurrentutil.util.IntPairUtil; +import ca.spottedleaf.moonrise.common.util.CoordinateUtils; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; import it.unimi.dsi.fastutil.longs.LongSet; import it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap; @@ -23,12 +23,16 @@ public final class PositionCountingAreaMap { return this.positions.size(); } + public boolean hasObjectsNear(final long pos) { + return this.positions.containsKey(pos); + } + public boolean hasObjectsNear(final int toX, final int toZ) { - return this.positions.containsKey(IntPairUtil.key(toX, toZ)); + return this.positions.containsKey(CoordinateUtils.getChunkKey(toX, toZ)); } public int getObjectsNear(final int toX, final int toZ) { - return this.positions.get(IntPairUtil.key(toX, toZ)); + return this.positions.get(CoordinateUtils.getChunkKey(toX, toZ)); } public boolean add(final T parameter, final int toX, final int toZ, final int distance) { @@ -85,12 +89,12 @@ public final class PositionCountingAreaMap { @Override protected void addCallback(final T parameter, final int toX, final int toZ) { - PositionCountingAreaMap.this.positions.addTo(IntPairUtil.key(toX, toZ), 1); + PositionCountingAreaMap.this.positions.addTo(CoordinateUtils.getChunkKey(toX, toZ), 1); } @Override protected void removeCallback(final T parameter, final int toX, final int toZ) { - final long key = IntPairUtil.key(toX, toZ); + final long key = CoordinateUtils.getChunkKey(toX, toZ); if (PositionCountingAreaMap.this.positions.addTo(key, -1) == 1) { PositionCountingAreaMap.this.positions.remove(key); } diff --git a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/SingleUserAreaMap.java b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/SingleUserAreaMap.java index 94689e034..7e85bb58b 100644 --- a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/SingleUserAreaMap.java +++ b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/misc/SingleUserAreaMap.java @@ -1,7 +1,5 @@ package ca.spottedleaf.moonrise.common.misc; -import ca.spottedleaf.concurrentutil.util.IntegerUtil; - public abstract class SingleUserAreaMap { public static final int NOT_SET = Integer.MIN_VALUE; @@ -99,8 +97,8 @@ public abstract class SingleUserAreaMap { final int dx = toX - fromX; final int dz = toZ - fromZ; - final int totalX = IntegerUtil.branchlessAbs(fromX - toX); - final int totalZ = IntegerUtil.branchlessAbs(fromZ - toZ); + final int totalX = Math.abs(fromX - toX); + final int totalZ = Math.abs(fromZ - toZ); if (Math.max(totalX, totalZ) > (2 * Math.max(newViewDistance, oldViewDistance))) { // teleported @@ -120,7 +118,7 @@ public abstract class SingleUserAreaMap { for (int currZ = oldMinZ; currZ <= oldMaxZ; ++currZ) { // only remove if we're outside the new view distance... - if (Math.max(IntegerUtil.branchlessAbs(currX - toX), IntegerUtil.branchlessAbs(currZ - toZ)) > newViewDistance) { + if (Math.max(Math.abs(currX - toX), Math.abs(currZ - toZ)) > newViewDistance) { this.removeCallback(parameter, currX, currZ); } } @@ -136,7 +134,7 @@ public abstract class SingleUserAreaMap { for (int currZ = newMinZ; currZ <= newMaxZ; ++currZ) { // only add if we're outside the old view distance... - if (Math.max(IntegerUtil.branchlessAbs(currX - fromX), IntegerUtil.branchlessAbs(currZ - fromZ)) > oldViewDistance) { + if (Math.max(Math.abs(currX - fromX), Math.abs(currZ - fromZ)) > oldViewDistance) { this.addCallback(parameter, currX, currZ); } } diff --git a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java index 427079ae4..15a3c2436 100644 --- a/paper-server/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java +++ b/paper-server/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystemHooks.java @@ -5,6 +5,7 @@ import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.FullChunkStatus; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.server.level.TicketType; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; @@ -74,4 +75,6 @@ public interface ChunkSystemHooks { public void removePlayerFromDistanceMaps(final ServerLevel world, final ServerPlayer player); public void updateMaps(final ServerLevel world, final ServerPlayer player); + + public long[] getCounterTypesUncached(final TicketType type); } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java b/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java index 8f6287958..6abc57669 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/Metrics.java @@ -15,6 +15,7 @@ import java.io.DataOutputStream; import java.io.File; import java.io.IOException; import java.net.URL; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.Callable; import java.util.concurrent.Executors; @@ -29,7 +30,7 @@ import java.util.zip.GZIPOutputStream; /** * bStats collects some data for plugin authors. * - * Check out https://bStats.org/ to learn more about bStats! + * Check out https://bstats.org/ to learn more about bStats! */ public class Metrics { @@ -41,7 +42,7 @@ public class Metrics { public static final int B_STATS_VERSION = 1; // The url to which the data is sent - private static final String URL = "https://bStats.org/submitData/server-implementation"; + private static final String URL = "https://bstats.org/submitData/server-implementation"; // Should failed requests be logged? private static boolean logFailedRequests = false; @@ -223,7 +224,7 @@ public class Metrics { } ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); GZIPOutputStream gzip = new GZIPOutputStream(outputStream); - gzip.write(str.getBytes("UTF-8")); + gzip.write(str.getBytes(StandardCharsets.UTF_8)); gzip.close(); return outputStream.toByteArray(); } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java index 532306cac..bad941054 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -1,7 +1,6 @@ package com.destroystokyo.paper; import com.destroystokyo.paper.util.VersionFetcher; -import com.google.common.base.Charsets; import com.google.common.io.Resources; import com.google.gson.Gson; import com.google.gson.JsonArray; @@ -15,6 +14,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URI; +import java.nio.charset.StandardCharsets; import java.util.Optional; import java.util.OptionalInt; import java.util.stream.StreamSupport; @@ -87,7 +87,7 @@ public class PaperVersionFetcher implements VersionFetcher { try { try (final BufferedReader reader = Resources.asCharSource( URI.create("https://api.papermc.io/v2/projects/paper/versions/" + build.minecraftVersionId()).toURL(), - Charsets.UTF_8 + StandardCharsets.UTF_8 ).openBufferedStream()) { final JsonObject json = new Gson().fromJson(reader, JsonObject.class); final JsonArray builds = json.getAsJsonArray("builds"); @@ -112,7 +112,7 @@ public class PaperVersionFetcher implements VersionFetcher { final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); connection.connect(); if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) return DISTANCE_UNKNOWN; // Unknown commit - try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), Charsets.UTF_8))) { + try (final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { final JsonObject obj = new Gson().fromJson(reader, JsonObject.class); final String status = obj.get("status").getAsString(); return switch (status) { diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java index 3e43beaaa..9fd2c43d2 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/PaperPathfinder.java @@ -1,8 +1,9 @@ package com.destroystokyo.paper.entity; -import org.apache.commons.lang.Validate; +import com.google.common.base.Preconditions; import org.bukkit.Location; import org.bukkit.craftbukkit.entity.CraftLivingEntity; +import org.bukkit.craftbukkit.util.CraftLocation; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Mob; import javax.annotation.Nonnull; @@ -31,77 +32,78 @@ public class PaperPathfinder implements com.destroystokyo.paper.entity.Pathfinde @Override public void stopPathfinding() { - entity.getNavigation().stop(); + this.entity.getNavigation().stop(); } @Override public boolean hasPath() { - return entity.getNavigation().getPath() != null && !entity.getNavigation().getPath().isDone(); + return this.entity.getNavigation().getPath() != null && !this.entity.getNavigation().getPath().isDone(); } @Nullable @Override public PathResult getCurrentPath() { - Path path = entity.getNavigation().getPath(); + Path path = this.entity.getNavigation().getPath(); return path != null && !path.isDone() ? new PaperPathResult(path) : null; } @Nullable @Override public PathResult findPath(Location loc) { - Validate.notNull(loc, "Location can not be null"); - Path path = entity.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 0); + Preconditions.checkArgument(loc != null, "Location can not be null"); + Path path = this.entity.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 0); return path != null ? new PaperPathResult(path) : null; } @Nullable @Override public PathResult findPath(LivingEntity target) { - Validate.notNull(target, "Target can not be null"); - Path path = entity.getNavigation().createPath(((CraftLivingEntity) target).getHandle(), 0); + Preconditions.checkArgument(target != null, "Target can not be null"); + Path path = this.entity.getNavigation().createPath(((CraftLivingEntity) target).getHandle(), 0); return path != null ? new PaperPathResult(path) : null; } @Override public boolean moveTo(@Nonnull PathResult path, double speed) { - Validate.notNull(path, "PathResult can not be null"); + Preconditions.checkArgument(path != null, "PathResult can not be null"); Path pathEntity = ((PaperPathResult) path).path; - return entity.getNavigation().moveTo(pathEntity, speed); + return this.entity.getNavigation().moveTo(pathEntity, speed); } @Override public boolean canOpenDoors() { - return entity.getNavigation().pathFinder.nodeEvaluator.canOpenDoors(); + return this.entity.getNavigation().pathFinder.nodeEvaluator.canOpenDoors(); } @Override public void setCanOpenDoors(boolean canOpenDoors) { - entity.getNavigation().pathFinder.nodeEvaluator.setCanOpenDoors(canOpenDoors); + this.entity.getNavigation().pathFinder.nodeEvaluator.setCanOpenDoors(canOpenDoors); } @Override public boolean canPassDoors() { - return entity.getNavigation().pathFinder.nodeEvaluator.canPassDoors(); + return this.entity.getNavigation().pathFinder.nodeEvaluator.canPassDoors(); } @Override public void setCanPassDoors(boolean canPassDoors) { - entity.getNavigation().pathFinder.nodeEvaluator.setCanPassDoors(canPassDoors); + this.entity.getNavigation().pathFinder.nodeEvaluator.setCanPassDoors(canPassDoors); } @Override public boolean canFloat() { - return entity.getNavigation().pathFinder.nodeEvaluator.canFloat(); + return this.entity.getNavigation().pathFinder.nodeEvaluator.canFloat(); } @Override public void setCanFloat(boolean canFloat) { - entity.getNavigation().pathFinder.nodeEvaluator.setCanFloat(canFloat); + this.entity.getNavigation().pathFinder.nodeEvaluator.setCanFloat(canFloat); } public class PaperPathResult implements com.destroystokyo.paper.entity.PaperPathfinder.PathResult { private final Path path; + PaperPathResult(Path path) { this.path = path; } @@ -109,40 +111,36 @@ public class PaperPathfinder implements com.destroystokyo.paper.entity.Pathfinde @Nullable @Override public Location getFinalPoint() { - Node point = path.getEndNode(); - return point != null ? toLoc(point) : null; + Node point = this.path.getEndNode(); + return point != null ? CraftLocation.toBukkit(point, PaperPathfinder.this.entity.level()) : null; } @Override public boolean canReachFinalPoint() { - return path.canReach(); + return this.path.canReach(); } @Override public List getPoints() { List points = new ArrayList<>(); - for (Node point : path.nodes) { - points.add(toLoc(point)); + for (Node point : this.path.nodes) { + points.add(CraftLocation.toBukkit(point, PaperPathfinder.this.entity.level())); } return points; } @Override public int getNextPointIndex() { - return path.getNextNodeIndex(); + return this.path.getNextNodeIndex(); } @Nullable @Override public Location getNextPoint() { - if (path.isDone()) { + if (this.path.isDone()) { return null; } - return toLoc(path.nodes.get(path.getNextNodeIndex())); + return CraftLocation.toBukkit(this.path.nodes.get(this.path.getNextNodeIndex()), PaperPathfinder.this.entity.level()); } } - - private Location toLoc(Node point) { - return new Location(entity.level().getWorld(), point.x, point.y, point.z); - } } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 6bdc683b5..a786d7579 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -3,6 +3,7 @@ package com.destroystokyo.paper.entity.ai; import com.destroystokyo.paper.entity.RangedEntity; import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; +import io.papermc.paper.entity.SchoolableFish; import io.papermc.paper.util.ObfHelper; import java.lang.reflect.Constructor; import java.util.EnumSet; @@ -10,120 +11,10 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import net.minecraft.world.entity.FlyingMob; -import net.minecraft.world.entity.PathfinderMob; -import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.entity.ai.goal.Goal; -import net.minecraft.world.entity.ambient.AmbientCreature; -import net.minecraft.world.entity.animal.AbstractFish; -import net.minecraft.world.entity.animal.AbstractGolem; -import net.minecraft.world.entity.animal.AbstractSchoolingFish; -import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Pufferfish; -import net.minecraft.world.entity.animal.ShoulderRidingEntity; -import net.minecraft.world.entity.animal.SnowGolem; -import net.minecraft.world.entity.animal.WaterAnimal; -import net.minecraft.world.entity.animal.camel.Camel; -import net.minecraft.world.entity.animal.horse.AbstractChestedHorse; -import net.minecraft.world.entity.boss.wither.WitherBoss; -import net.minecraft.world.entity.monster.AbstractIllager; -import net.minecraft.world.entity.monster.EnderMan; -import net.minecraft.world.entity.monster.PatrollingMonster; import net.minecraft.world.entity.monster.RangedAttackMob; -import net.minecraft.world.entity.monster.SpellcasterIllager; -import net.minecraft.world.entity.monster.ZombifiedPiglin; -import net.minecraft.world.entity.monster.breeze.Breeze; -import net.minecraft.world.entity.monster.piglin.AbstractPiglin; import org.bukkit.NamespacedKey; -import org.bukkit.entity.AbstractHorse; -import org.bukkit.entity.AbstractSkeleton; -import org.bukkit.entity.AbstractVillager; -import org.bukkit.entity.Ageable; -import org.bukkit.entity.Ambient; -import org.bukkit.entity.Animals; -import org.bukkit.entity.Bat; -import org.bukkit.entity.Bee; -import org.bukkit.entity.Blaze; -import org.bukkit.entity.Cat; -import org.bukkit.entity.CaveSpider; -import org.bukkit.entity.ChestedHorse; -import org.bukkit.entity.Chicken; -import org.bukkit.entity.Cod; -import org.bukkit.entity.Cow; -import org.bukkit.entity.Creature; -import org.bukkit.entity.Creeper; -import org.bukkit.entity.Dolphin; -import org.bukkit.entity.Donkey; -import org.bukkit.entity.Drowned; -import org.bukkit.entity.ElderGuardian; -import org.bukkit.entity.EnderDragon; -import org.bukkit.entity.Enderman; -import org.bukkit.entity.Endermite; -import org.bukkit.entity.Evoker; -import org.bukkit.entity.Fish; -import org.bukkit.entity.Flying; -import org.bukkit.entity.Fox; -import org.bukkit.entity.Ghast; -import org.bukkit.entity.Giant; -import org.bukkit.entity.Golem; -import org.bukkit.entity.Guardian; -import org.bukkit.entity.Hoglin; -import org.bukkit.entity.Horse; -import org.bukkit.entity.Husk; -import org.bukkit.entity.Illager; -import org.bukkit.entity.Illusioner; -import org.bukkit.entity.IronGolem; -import org.bukkit.entity.Llama; -import org.bukkit.entity.MagmaCube; -import org.bukkit.entity.Mob; -import org.bukkit.entity.Monster; -import org.bukkit.entity.Mule; -import org.bukkit.entity.MushroomCow; -import org.bukkit.entity.Ocelot; -import org.bukkit.entity.Panda; -import org.bukkit.entity.Parrot; -import org.bukkit.entity.Phantom; -import org.bukkit.entity.Pig; -import org.bukkit.entity.PigZombie; -import org.bukkit.entity.Piglin; -import org.bukkit.entity.PiglinAbstract; -import org.bukkit.entity.PiglinBrute; -import org.bukkit.entity.Pillager; -import org.bukkit.entity.PolarBear; -import org.bukkit.entity.PufferFish; -import org.bukkit.entity.Rabbit; -import org.bukkit.entity.Raider; -import org.bukkit.entity.Ravager; -import org.bukkit.entity.Salmon; -import org.bukkit.entity.Sheep; -import org.bukkit.entity.Shulker; -import org.bukkit.entity.Silverfish; -import org.bukkit.entity.Skeleton; -import org.bukkit.entity.SkeletonHorse; -import org.bukkit.entity.Slime; -import org.bukkit.entity.Snowman; -import org.bukkit.entity.Spellcaster; -import org.bukkit.entity.Spider; -import org.bukkit.entity.Squid; -import org.bukkit.entity.Stray; -import org.bukkit.entity.Strider; -import org.bukkit.entity.Tameable; -import org.bukkit.entity.TraderLlama; -import org.bukkit.entity.TropicalFish; -import org.bukkit.entity.Turtle; -import org.bukkit.entity.Vex; -import org.bukkit.entity.Villager; -import org.bukkit.entity.Vindicator; -import org.bukkit.entity.WanderingTrader; -import org.bukkit.entity.WaterMob; -import org.bukkit.entity.Witch; -import org.bukkit.entity.Wither; -import org.bukkit.entity.WitherSkeleton; -import org.bukkit.entity.Wolf; -import org.bukkit.entity.Zoglin; -import org.bukkit.entity.Zombie; -import org.bukkit.entity.ZombieHorse; -import org.bukkit.entity.ZombieVillager; +import org.bukkit.entity.*; public class MobGoalHelper { @@ -143,10 +34,13 @@ public class MobGoalHelper { ignored.add("selector_2"); ignored.add("wrapped"); + // + // Start generate - MobGoalHelper#bukkitMap + // @GeneratedFrom 1.21.5 bukkitMap.put(net.minecraft.world.entity.Mob.class, Mob.class); bukkitMap.put(net.minecraft.world.entity.AgeableMob.class, Ageable.class); - bukkitMap.put(AmbientCreature.class, Ambient.class); - bukkitMap.put(Animal.class, Animals.class); + bukkitMap.put(net.minecraft.world.entity.ambient.AmbientCreature.class, Ambient.class); + bukkitMap.put(net.minecraft.world.entity.animal.Animal.class, Animals.class); bukkitMap.put(net.minecraft.world.entity.ambient.Bat.class, Bat.class); bukkitMap.put(net.minecraft.world.entity.animal.Bee.class, Bee.class); bukkitMap.put(net.minecraft.world.entity.monster.Blaze.class, Blaze.class); @@ -155,56 +49,56 @@ public class MobGoalHelper { bukkitMap.put(net.minecraft.world.entity.animal.Chicken.class, Chicken.class); bukkitMap.put(net.minecraft.world.entity.animal.Cod.class, Cod.class); bukkitMap.put(net.minecraft.world.entity.animal.Cow.class, Cow.class); - bukkitMap.put(PathfinderMob.class, Creature.class); + bukkitMap.put(net.minecraft.world.entity.PathfinderMob.class, Creature.class); bukkitMap.put(net.minecraft.world.entity.monster.Creeper.class, Creeper.class); bukkitMap.put(net.minecraft.world.entity.animal.Dolphin.class, Dolphin.class); bukkitMap.put(net.minecraft.world.entity.monster.Drowned.class, Drowned.class); bukkitMap.put(net.minecraft.world.entity.boss.enderdragon.EnderDragon.class, EnderDragon.class); - bukkitMap.put(EnderMan.class, Enderman.class); + bukkitMap.put(net.minecraft.world.entity.monster.EnderMan.class, Enderman.class); bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); - bukkitMap.put(AbstractFish.class, Fish.class); - bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class); - bukkitMap.put(FlyingMob.class, Flying.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractFish.class, Fish.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractSchoolingFish.class, SchoolableFish.class); + bukkitMap.put(net.minecraft.world.entity.FlyingMob.class, Flying.class); bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); bukkitMap.put(net.minecraft.world.entity.monster.Giant.class, Giant.class); - bukkitMap.put(AbstractGolem.class, Golem.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractGolem.class, Golem.class); bukkitMap.put(net.minecraft.world.entity.monster.Guardian.class, Guardian.class); bukkitMap.put(net.minecraft.world.entity.monster.ElderGuardian.class, ElderGuardian.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Horse.class, Horse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractHorse.class, AbstractHorse.class); - bukkitMap.put(AbstractChestedHorse.class, ChestedHorse.class); + bukkitMap.put(net.minecraft.world.entity.animal.horse.AbstractChestedHorse.class, ChestedHorse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Donkey.class, Donkey.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Mule.class, Mule.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.SkeletonHorse.class, SkeletonHorse.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.ZombieHorse.class, ZombieHorse.class); - bukkitMap.put(Camel.class, org.bukkit.entity.Camel.class); - bukkitMap.put(AbstractIllager.class, Illager.class); + bukkitMap.put(net.minecraft.world.entity.animal.camel.Camel.class, Camel.class); + bukkitMap.put(net.minecraft.world.entity.monster.AbstractIllager.class, Illager.class); bukkitMap.put(net.minecraft.world.entity.monster.Illusioner.class, Illusioner.class); - bukkitMap.put(SpellcasterIllager.class, Spellcaster.class); + bukkitMap.put(net.minecraft.world.entity.monster.SpellcasterIllager.class, Spellcaster.class); bukkitMap.put(net.minecraft.world.entity.animal.IronGolem.class, IronGolem.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.Llama.class, Llama.class); bukkitMap.put(net.minecraft.world.entity.animal.horse.TraderLlama.class, TraderLlama.class); bukkitMap.put(net.minecraft.world.entity.monster.MagmaCube.class, MagmaCube.class); bukkitMap.put(net.minecraft.world.entity.monster.Monster.class, Monster.class); - bukkitMap.put(PatrollingMonster.class, Raider.class); // close enough + bukkitMap.put(net.minecraft.world.entity.monster.PatrollingMonster.class, Raider.class); bukkitMap.put(net.minecraft.world.entity.animal.MushroomCow.class, MushroomCow.class); bukkitMap.put(net.minecraft.world.entity.animal.Ocelot.class, Ocelot.class); bukkitMap.put(net.minecraft.world.entity.animal.Panda.class, Panda.class); bukkitMap.put(net.minecraft.world.entity.animal.Parrot.class, Parrot.class); - bukkitMap.put(ShoulderRidingEntity.class, Parrot.class); // close enough + bukkitMap.put(net.minecraft.world.entity.animal.ShoulderRidingEntity.class, Parrot.class); bukkitMap.put(net.minecraft.world.entity.monster.Phantom.class, Phantom.class); bukkitMap.put(net.minecraft.world.entity.animal.Pig.class, Pig.class); - bukkitMap.put(ZombifiedPiglin.class, PigZombie.class); + bukkitMap.put(net.minecraft.world.entity.monster.ZombifiedPiglin.class, PigZombie.class); bukkitMap.put(net.minecraft.world.entity.monster.Pillager.class, Pillager.class); bukkitMap.put(net.minecraft.world.entity.animal.PolarBear.class, PolarBear.class); - bukkitMap.put(Pufferfish.class, PufferFish.class); + bukkitMap.put(net.minecraft.world.entity.animal.Pufferfish.class, PufferFish.class); bukkitMap.put(net.minecraft.world.entity.animal.Rabbit.class, Rabbit.class); bukkitMap.put(net.minecraft.world.entity.raid.Raider.class, Raider.class); bukkitMap.put(net.minecraft.world.entity.monster.Ravager.class, Ravager.class); bukkitMap.put(net.minecraft.world.entity.animal.Salmon.class, Salmon.class); - bukkitMap.put(net.minecraft.world.entity.animal.Sheep.class, Sheep.class); + bukkitMap.put(net.minecraft.world.entity.animal.sheep.Sheep.class, Sheep.class); bukkitMap.put(net.minecraft.world.entity.monster.Shulker.class, Shulker.class); bukkitMap.put(net.minecraft.world.entity.monster.Silverfish.class, Silverfish.class); bukkitMap.put(net.minecraft.world.entity.monster.Skeleton.class, Skeleton.class); @@ -212,10 +106,10 @@ public class MobGoalHelper { bukkitMap.put(net.minecraft.world.entity.monster.Stray.class, Stray.class); bukkitMap.put(net.minecraft.world.entity.monster.WitherSkeleton.class, WitherSkeleton.class); bukkitMap.put(net.minecraft.world.entity.monster.Slime.class, Slime.class); - bukkitMap.put(SnowGolem.class, Snowman.class); + bukkitMap.put(net.minecraft.world.entity.animal.SnowGolem.class, Snowman.class); bukkitMap.put(net.minecraft.world.entity.monster.Spider.class, Spider.class); bukkitMap.put(net.minecraft.world.entity.animal.Squid.class, Squid.class); - bukkitMap.put(TamableAnimal.class, Tameable.class); + bukkitMap.put(net.minecraft.world.entity.TamableAnimal.class, Tameable.class); bukkitMap.put(net.minecraft.world.entity.animal.TropicalFish.class, TropicalFish.class); bukkitMap.put(net.minecraft.world.entity.animal.Turtle.class, Turtle.class); bukkitMap.put(net.minecraft.world.entity.monster.Vex.class, Vex.class); @@ -223,32 +117,35 @@ public class MobGoalHelper { bukkitMap.put(net.minecraft.world.entity.npc.AbstractVillager.class, AbstractVillager.class); bukkitMap.put(net.minecraft.world.entity.npc.WanderingTrader.class, WanderingTrader.class); bukkitMap.put(net.minecraft.world.entity.monster.Vindicator.class, Vindicator.class); - bukkitMap.put(WaterAnimal.class, WaterMob.class); + bukkitMap.put(net.minecraft.world.entity.animal.WaterAnimal.class, WaterMob.class); bukkitMap.put(net.minecraft.world.entity.monster.Witch.class, Witch.class); - bukkitMap.put(WitherBoss.class, Wither.class); - bukkitMap.put(net.minecraft.world.entity.animal.Wolf.class, Wolf.class); + bukkitMap.put(net.minecraft.world.entity.boss.wither.WitherBoss.class, Wither.class); + bukkitMap.put(net.minecraft.world.entity.animal.wolf.Wolf.class, Wolf.class); bukkitMap.put(net.minecraft.world.entity.monster.Zombie.class, Zombie.class); bukkitMap.put(net.minecraft.world.entity.monster.Husk.class, Husk.class); bukkitMap.put(net.minecraft.world.entity.monster.ZombieVillager.class, ZombieVillager.class); bukkitMap.put(net.minecraft.world.entity.monster.hoglin.Hoglin.class, Hoglin.class); bukkitMap.put(net.minecraft.world.entity.monster.piglin.Piglin.class, Piglin.class); - bukkitMap.put(AbstractPiglin.class, PiglinAbstract.class); + bukkitMap.put(net.minecraft.world.entity.monster.piglin.AbstractPiglin.class, PiglinAbstract.class); bukkitMap.put(net.minecraft.world.entity.monster.piglin.PiglinBrute.class, PiglinBrute.class); bukkitMap.put(net.minecraft.world.entity.monster.Strider.class, Strider.class); bukkitMap.put(net.minecraft.world.entity.monster.Zoglin.class, Zoglin.class); - bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, org.bukkit.entity.GlowSquid.class); - bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, org.bukkit.entity.Axolotl.class); - bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, org.bukkit.entity.Goat.class); - bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, org.bukkit.entity.Frog.class); - bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, org.bukkit.entity.Tadpole.class); - bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, org.bukkit.entity.Warden.class); - bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, org.bukkit.entity.Allay.class); - bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, org.bukkit.entity.Sniffer.class); - bukkitMap.put(Breeze.class, org.bukkit.entity.Breeze.class); - bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, org.bukkit.entity.Armadillo.class); - bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, org.bukkit.entity.Bogged.class); - bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, org.bukkit.entity.Creaking.class); - bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, org.bukkit.entity.Squid.class); // close enough + bukkitMap.put(net.minecraft.world.entity.GlowSquid.class, GlowSquid.class); + bukkitMap.put(net.minecraft.world.entity.animal.axolotl.Axolotl.class, Axolotl.class); + bukkitMap.put(net.minecraft.world.entity.animal.goat.Goat.class, Goat.class); + bukkitMap.put(net.minecraft.world.entity.animal.frog.Frog.class, Frog.class); + bukkitMap.put(net.minecraft.world.entity.animal.frog.Tadpole.class, Tadpole.class); + bukkitMap.put(net.minecraft.world.entity.monster.warden.Warden.class, Warden.class); + bukkitMap.put(net.minecraft.world.entity.animal.allay.Allay.class, Allay.class); + bukkitMap.put(net.minecraft.world.entity.animal.sniffer.Sniffer.class, Sniffer.class); + bukkitMap.put(net.minecraft.world.entity.monster.breeze.Breeze.class, Breeze.class); + bukkitMap.put(net.minecraft.world.entity.animal.armadillo.Armadillo.class, Armadillo.class); + bukkitMap.put(net.minecraft.world.entity.monster.Bogged.class, Bogged.class); + bukkitMap.put(net.minecraft.world.entity.monster.creaking.Creaking.class, Creaking.class); + bukkitMap.put(net.minecraft.world.entity.animal.AgeableWaterCreature.class, Squid.class); + bukkitMap.put(net.minecraft.world.entity.animal.AbstractCow.class, AbstractCow.class); + // End generate - MobGoalHelper#bukkitMap + // } public static String getUsableName(Class clazz) { @@ -267,7 +164,6 @@ public class MobGoalHelper { name = cut; } } - name = name.replace("PathfinderGoal", ""); name = name.replace("TargetGoal", ""); name = name.replace("Goal", ""); StringBuilder sb = new StringBuilder(); @@ -365,7 +261,7 @@ public class MobGoalHelper { } } } - throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return EntityInsentient? + throw new RuntimeException("Can't figure out applicable entity for mob goal " + goalClass); // maybe just return Mob? }); } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperGoal.java similarity index 89% rename from paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java rename to paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperGoal.java index b5c594a54..74d172166 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperVanillaGoal.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperGoal.java @@ -7,14 +7,14 @@ import org.bukkit.entity.Mob; /** * Wraps vanilla in api */ -public class PaperVanillaGoal implements VanillaGoal { +public class PaperGoal implements com.destroystokyo.paper.entity.ai.Goal { private final Goal handle; private final GoalKey key; private final EnumSet types; - public PaperVanillaGoal(Goal handle) { + public PaperGoal(Goal handle) { this.handle = handle; this.key = MobGoalHelper.getKey(handle.getClass()); this.types = MobGoalHelper.vanillaToPaper(handle); diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java index 7e72fbb16..a617e3d61 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/PaperMobGoals.java @@ -20,8 +20,8 @@ public class PaperMobGoals implements MobGoals { CraftMob craftMob = (CraftMob) mob; net.minecraft.world.entity.ai.goal.Goal mojangGoal; - if (goal instanceof PaperVanillaGoal vanillaGoal) { - mojangGoal = vanillaGoal.getHandle(); + if (goal instanceof PaperGoal paperGoal) { + mojangGoal = paperGoal.getHandle(); } else { mojangGoal = new PaperCustomGoal<>(goal); } @@ -34,8 +34,8 @@ public class PaperMobGoals implements MobGoals { CraftMob craftMob = (CraftMob) mob; if (goal instanceof PaperCustomGoal) { getHandle(craftMob, goal.getTypes()).removeGoal((net.minecraft.world.entity.ai.goal.Goal) goal); - } else if (goal instanceof PaperVanillaGoal) { - getHandle(craftMob, goal.getTypes()).removeGoal(((PaperVanillaGoal) goal).getHandle()); + } else if (goal instanceof PaperGoal) { + getHandle(craftMob, goal.getTypes()).removeGoal(((PaperGoal) goal).getHandle()); } else { List toRemove = new LinkedList<>(); for (WrappedGoal item : getHandle(craftMob, goal.getTypes()).getAvailableGoals()) { @@ -127,7 +127,7 @@ public class PaperMobGoals implements MobGoals { //noinspection unchecked goals.add(((PaperCustomGoal) item.getGoal()).getHandle()); } else { - goals.add(item.getGoal().asPaperVanillaGoal()); + goals.add(item.getGoal().asPaperGoal()); } } return goals; @@ -150,7 +150,7 @@ public class PaperMobGoals implements MobGoals { //noinspection unchecked goals.add(((PaperCustomGoal) item.getGoal()).getHandle()); } else { - goals.add(item.getGoal().asPaperVanillaGoal()); + goals.add(item.getGoal().asPaperGoal()); } } } @@ -178,7 +178,7 @@ public class PaperMobGoals implements MobGoals { //noinspection unchecked goals.add(((PaperCustomGoal) item.getGoal()).getHandle()); } else { - goals.add(item.getGoal().asPaperVanillaGoal()); + goals.add(item.getGoal().asPaperGoal()); } }); return goals; @@ -201,7 +201,7 @@ public class PaperMobGoals implements MobGoals { //noinspection unchecked goals.add(((PaperCustomGoal) item.getGoal()).getHandle()); } else { - goals.add(item.getGoal().asPaperVanillaGoal()); + goals.add(item.getGoal().asPaperGoal()); } }); } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/paper-server/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java index 861bff267..ee21a40f7 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java @@ -5,12 +5,13 @@ import io.papermc.paper.configuration.type.DurationOrDisabled; import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.Optional; import java.util.Random; import java.util.UUID; import java.util.concurrent.TimeUnit; +import net.minecraft.core.UUIDUtil; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; -import net.minecraft.nbt.Tag; import net.minecraft.world.RandomizableContainer; import net.minecraft.world.entity.vehicle.ContainerEntity; import org.bukkit.entity.Player; @@ -164,30 +165,25 @@ public class PaperLootableInventoryData { private static final String LOOTED_PLAYERS = "lootedPlayers"; public void loadNbt(final CompoundTag base) { - if (!base.contains(ROOT, Tag.TAG_COMPOUND)) { + final Optional compOpt = base.getCompound(ROOT); + if (compOpt.isEmpty()) { return; } - final CompoundTag comp = base.getCompound(ROOT); - if (comp.contains(LAST_FILL)) { - this.lastFill = comp.getLong(LAST_FILL); + CompoundTag comp = compOpt.get(); + this.lastFill = comp.getLongOr(LAST_FILL, -1); + this.nextRefill = comp.getLongOr(NEXT_REFILL, -1); + this.numRefills = comp.getIntOr(NUM_REFILLS, 0); + final ListTag list = comp.getListOrEmpty(LOOTED_PLAYERS); + final int size = list.size(); + if (size > 0) { + this.lootedPlayers = new HashMap<>(list.size()); } - if (comp.contains(NEXT_REFILL)) { - this.nextRefill = comp.getLong(NEXT_REFILL); - } - - if (comp.contains(NUM_REFILLS)) { - this.numRefills = comp.getInt(NUM_REFILLS); - } - if (comp.contains(LOOTED_PLAYERS, Tag.TAG_LIST)) { - final ListTag list = comp.getList(LOOTED_PLAYERS, Tag.TAG_COMPOUND); - final int size = list.size(); - if (size > 0) { - this.lootedPlayers = new HashMap<>(list.size()); - } - for (int i = 0; i < size; i++) { - final CompoundTag cmp = list.getCompound(i); - this.lootedPlayers.put(cmp.getUUID("UUID"), cmp.getLong("Time")); - } + for (int i = 0; i < size; i++) { + list.getCompound(i).ifPresent(tag -> { + tag.read("UUID", UUIDUtil.CODEC).ifPresent(uuid -> { + this.lootedPlayers.put(uuid, tag.getLongOr("Time", 0)); + }); + }); } } @@ -206,7 +202,7 @@ public class PaperLootableInventoryData { final ListTag list = new ListTag(); for (final Map.Entry entry : this.lootedPlayers.entrySet()) { final CompoundTag cmp = new CompoundTag(); - cmp.putUUID("UUID", entry.getKey()); + cmp.store("UUID", UUIDUtil.CODEC, entry.getKey()); cmp.putLong("Time", entry.getValue()); list.add(cmp); } diff --git a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java index 8849862b4..d2d16055d 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -3,7 +3,6 @@ package com.destroystokyo.paper.profile; import com.google.common.base.Preconditions; import com.mojang.authlib.yggdrasil.ProfileResult; import io.papermc.paper.configuration.GlobalConfiguration; -import com.google.common.base.Charsets; import com.google.common.collect.Iterables; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; @@ -14,7 +13,6 @@ import net.minecraft.server.players.GameProfileCache; import net.minecraft.util.StringUtil; import net.minecraft.world.item.component.ResolvableProfile; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.Validate; import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.craftbukkit.configuration.ConfigSerializationUtil; import org.bukkit.craftbukkit.entity.CraftPlayer; @@ -25,6 +23,7 @@ import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; +import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.CompletableFuture; @@ -47,7 +46,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { } public CraftPlayerProfile(GameProfile profile) { - Validate.notNull(profile, "GameProfile cannot be null!"); + Preconditions.checkArgument(profile != null, "GameProfile cannot be null!"); this.profile = profile; } @@ -222,7 +221,7 @@ public class CraftPlayerProfile implements PlayerProfile, SharedPlayerProfile { profile = lookupUUID ? userCache.get(name).orElse(null) : userCache.getProfileIfCached(name); } else { // Make an OfflinePlayer using an offline mode UUID since the name has no profile - profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(Charsets.UTF_8)), name); + profile = new GameProfile(UUID.nameUUIDFromBytes(("OfflinePlayer:" + name).getBytes(StandardCharsets.UTF_8)), name); } if (profile != null) { // if old has it, assume its newer, so overwrite, else use cached if it was set and ours wasn't diff --git a/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java b/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java index d57738479..bd90a3e55 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/profile/PaperMinecraftSessionService.java @@ -30,7 +30,7 @@ public class PaperMinecraftSessionService extends YggdrasilMinecraftSessionServi return result; } - @Override @io.papermc.paper.annotation.DoNotUse @Deprecated + @Override @Deprecated public @Nullable ProfileResult fetchProfile(final UUID profileId, final boolean requireSecure) { return super.fetchProfile(profileId, requireSecure); } diff --git a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java index d3c216f44..43e88cd77 100644 --- a/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java +++ b/paper-server/src/main/java/io/papermc/paper/PaperServerInternalAPIBridge.java @@ -1,5 +1,7 @@ package io.papermc.paper; +import org.bukkit.block.Biome; +import org.bukkit.craftbukkit.block.CraftBiome; import org.bukkit.craftbukkit.damage.CraftDamageEffect; import org.bukkit.damage.DamageEffect; import org.jspecify.annotations.NullMarked; @@ -12,4 +14,12 @@ public class PaperServerInternalAPIBridge implements InternalAPIBridge { public DamageEffect getDamageEffect(final String key) { return CraftDamageEffect.getById(key); } + + @Override + public Biome constructLegacyCustomBiome() { + class Holder { + static final Biome LEGACY_CUSTOM = new CraftBiome.LegacyCustomBiomeImpl(); + } + return Holder.LEGACY_CUSTOM; + } } diff --git a/paper-server/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java b/paper-server/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java index adac21ce6..a2c575e94 100644 --- a/paper-server/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java +++ b/paper-server/src/main/java/io/papermc/paper/advancement/PaperAdvancementDisplay.java @@ -51,7 +51,7 @@ public record PaperAdvancementDisplay(DisplayInfo handle) implements Advancement @Override public @Nullable NamespacedKey backgroundPath() { - return this.handle.getBackground().map(CraftNamespacedKey::fromMinecraft).orElse(null); + return this.handle.getBackground().map(asset -> CraftNamespacedKey.fromMinecraft(asset.id())).orElse(null); } @Override diff --git a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java index 7a47f0fda..2af7fb86d 100644 --- a/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java +++ b/paper-server/src/main/java/io/papermc/paper/adventure/AdventureCodecs.java @@ -1,24 +1,18 @@ package io.papermc.paper.adventure; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; -import com.mojang.brigadier.exceptions.CommandSyntaxException; import com.mojang.datafixers.util.Either; -import com.mojang.datafixers.util.Pair; import com.mojang.serialization.Codec; import com.mojang.serialization.DataResult; -import com.mojang.serialization.DynamicOps; -import com.mojang.serialization.JsonOps; import com.mojang.serialization.MapCodec; -import com.mojang.serialization.codecs.RecordCodecBuilder; +import java.net.URI; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.UUID; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Predicate; +import com.mojang.serialization.codecs.RecordCodecBuilder; import net.kyori.adventure.key.Key; import net.kyori.adventure.text.BlockNBTComponent; import net.kyori.adventure.text.Component; @@ -40,14 +34,9 @@ import net.kyori.adventure.text.format.ShadowColor; import net.kyori.adventure.text.format.Style; import net.kyori.adventure.text.format.TextColor; import net.kyori.adventure.text.format.TextDecoration; -import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; import net.minecraft.commands.arguments.selector.SelectorPattern; import net.minecraft.core.UUIDUtil; import net.minecraft.core.registries.BuiltInRegistries; -import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.NbtOps; -import net.minecraft.nbt.Tag; -import net.minecraft.nbt.TagParser; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.ComponentSerialization; import net.minecraft.network.chat.contents.KeybindContents; @@ -55,7 +44,6 @@ import net.minecraft.network.chat.contents.ScoreContents; import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.RegistryOps; import net.minecraft.util.ExtraCodecs; import net.minecraft.util.StringRepresentable; import net.minecraft.world.item.Item; @@ -76,7 +64,7 @@ import static net.kyori.adventure.text.TranslationArgument.numeric; @DefaultQualifier(NonNull.class) public final class AdventureCodecs { - public static final Codec COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec); + public static final Codec COMPONENT_CODEC = recursive("adventure Component", AdventureCodecs::createCodec); public static final StreamCodec STREAM_COMPONENT_CODEC = ByteBufCodecs.fromCodecWithRegistriesTrusted(COMPONENT_CODEC); static final Codec SHADOW_COLOR_CODEC = ExtraCodecs.ARGB_COLOR_CODEC.xmap(ShadowColor::shadowColor, ShadowColor::value); @@ -101,102 +89,92 @@ public final class AdventureCodecs { return Key.parseable(s) ? DataResult.success(Key.key(s)) : DataResult.error(() -> "Cannot convert " + s + " to adventure Key"); }, Key::asString); - static final Codec CLICK_EVENT_ACTION_CODEC = Codec.STRING.comapFlatMap(s -> { - final ClickEvent.@Nullable Action value = ClickEvent.Action.NAMES.value(s); - return value != null ? DataResult.success(value) : DataResult.error(() -> "Cannot convert " + s + " to adventure ClickEvent$Action"); - }, ClickEvent.Action.NAMES::keyOrThrow); - static final Codec CLICK_EVENT_CODEC = RecordCodecBuilder.create((instance) -> { - return instance.group( - CLICK_EVENT_ACTION_CODEC.fieldOf("action").forGetter(ClickEvent::action), - Codec.STRING.fieldOf("value").forGetter(ClickEvent::value) - ).apply(instance, ClickEvent::clickEvent); + /* + * Click + */ + static final MapCodec OPEN_URL_CODEC = mapCodec((instance) -> instance.group( + ExtraCodecs.UNTRUSTED_URI.fieldOf("url").forGetter(a -> URI.create(!a.value().contains("://") ? "https://" + a.value() : a.value())) + ).apply(instance, (url) -> ClickEvent.openUrl(url.toString()))); + static final MapCodec OPEN_FILE_CODEC = mapCodec((instance) -> instance.group( + Codec.STRING.fieldOf("path").forGetter(ClickEvent::value) + ).apply(instance, ClickEvent::openFile)); + static final MapCodec RUN_COMMAND_CODEC = mapCodec((instance) -> instance.group( + ExtraCodecs.CHAT_STRING.fieldOf("command").forGetter(ClickEvent::value) + ).apply(instance, ClickEvent::runCommand)); + static final MapCodec SUGGEST_COMMAND_CODEC = mapCodec((instance) -> instance.group( + ExtraCodecs.CHAT_STRING.fieldOf("command").forGetter(ClickEvent::value) + ).apply(instance, ClickEvent::suggestCommand)); + static final MapCodec CHANGE_PAGE_CODEC = mapCodec((instance) -> instance.group( + ExtraCodecs.POSITIVE_INT.fieldOf("page").forGetter(a -> Integer.parseInt(a.value())) + ).apply(instance, ClickEvent::changePage)); + static final MapCodec COPY_TO_CLIPBOARD_CODEC = mapCodec((instance) -> instance.group( + Codec.STRING.fieldOf("value").forGetter(ClickEvent::value) + ).apply(instance, ClickEvent::copyToClipboard)); + + static final ClickEventType OPEN_URL_CLICK_EVENT_TYPE = new ClickEventType(OPEN_URL_CODEC, "open_url"); + static final ClickEventType OPEN_FILE_CLICK_EVENT_TYPE = new ClickEventType(OPEN_FILE_CODEC, "open_file"); + static final ClickEventType RUN_COMMAND_CLICK_EVENT_TYPE = new ClickEventType(RUN_COMMAND_CODEC, "run_command"); + static final ClickEventType SUGGEST_COMMAND_CLICK_EVENT_TYPE = new ClickEventType(SUGGEST_COMMAND_CODEC, "suggest_command"); + static final ClickEventType CHANGE_PAGE_CLICK_EVENT_TYPE = new ClickEventType(CHANGE_PAGE_CODEC, "change_page"); + static final ClickEventType COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE = new ClickEventType(COPY_TO_CLIPBOARD_CODEC, "copy_to_clipboard"); + static final Codec CLICK_EVENT_TYPE_CODEC = StringRepresentable.fromValues(() -> new ClickEventType[]{OPEN_URL_CLICK_EVENT_TYPE, OPEN_FILE_CLICK_EVENT_TYPE, RUN_COMMAND_CLICK_EVENT_TYPE, SUGGEST_COMMAND_CLICK_EVENT_TYPE, CHANGE_PAGE_CLICK_EVENT_TYPE, COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE}); + + record ClickEventType(MapCodec codec, String id) implements StringRepresentable { + @Override + public String getSerializedName() { + return this.id; + } + } + + private static final Function GET_CLICK_EVENT_TYPE = he -> { + if (he.action() == ClickEvent.Action.OPEN_URL) { + return OPEN_URL_CLICK_EVENT_TYPE; + } else if (he.action() == ClickEvent.Action.OPEN_FILE) { + return OPEN_FILE_CLICK_EVENT_TYPE; + } else if (he.action() == ClickEvent.Action.RUN_COMMAND) { + return RUN_COMMAND_CLICK_EVENT_TYPE; + } else if (he.action() == ClickEvent.Action.SUGGEST_COMMAND) { + return SUGGEST_COMMAND_CLICK_EVENT_TYPE; + } else if (he.action() == ClickEvent.Action.CHANGE_PAGE) { + return CHANGE_PAGE_CLICK_EVENT_TYPE; + } else if (he.action() == ClickEvent.Action.COPY_TO_CLIPBOARD) { + return COPY_TO_CLIPBOARD_CLICK_EVENT_TYPE; + } else { + throw new IllegalStateException(); + } + }; + + static final Codec CLICK_EVENT_CODEC = CLICK_EVENT_TYPE_CODEC.dispatch("action", GET_CLICK_EVENT_TYPE, ClickEventType::codec); + + /* + * HOVER + */ + static final MapCodec> SHOW_TEXT_CODEC = mapCodec((instance) -> instance.group( + COMPONENT_CODEC.fieldOf("value").forGetter(HoverEvent::value) + ).apply(instance, HoverEvent::showText)); + + static final MapCodec> SHOW_ENTITY_CODEC = mapCodec((instance) -> instance.group( + KEY_CODEC.fieldOf("id").forGetter(a -> a.value().type()), + UUIDUtil.LENIENT_CODEC.fieldOf("uuid").forGetter(a -> a.value().id()), + COMPONENT_CODEC.lenientOptionalFieldOf("name").forGetter(a -> Optional.ofNullable(a.value().name())) + ).apply(instance, (key, uuid, component) -> HoverEvent.showEntity(key, uuid, component.orElse(null)))); + + static final MapCodec> SHOW_ITEM_CODEC = net.minecraft.network.chat.HoverEvent.ShowItem.CODEC.xmap(internal -> { + @Subst("key") final String typeKey = internal.item().getItemHolder().unwrapKey().orElseThrow().location().toString(); + return HoverEvent.showItem(Key.key(typeKey), internal.item().getCount(), PaperAdventure.asAdventure(internal.item().getComponentsPatch())); + }, adventure -> { + final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(adventure.value().item())); + final Map dataComponentsMap = adventure.value().dataComponents(); + final ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(itemType), adventure.value().count(), PaperAdventure.asVanilla(dataComponentsMap)); + return new net.minecraft.network.chat.HoverEvent.ShowItem(stack); }); - static Codec showEntityCodec(final Codec componentCodec) { - return RecordCodecBuilder.create((instance) -> { - return instance.group( - KEY_CODEC.fieldOf("type").forGetter(HoverEvent.ShowEntity::type), - UUIDUtil.LENIENT_CODEC.fieldOf("id").forGetter(HoverEvent.ShowEntity::id), - componentCodec.lenientOptionalFieldOf("name").forGetter(he -> Optional.ofNullable(he.name())) - ).apply(instance, (key, uuid, component) -> { - return HoverEvent.ShowEntity.showEntity(key, uuid, component.orElse(null)); - }); - }); - } + static final HoverEventType SHOW_ENTITY_HOVER_EVENT_TYPE = new HoverEventType<>(SHOW_ENTITY_CODEC, "show_entity"); + static final HoverEventType SHOW_ITEM_HOVER_EVENT_TYPE = new HoverEventType<>(SHOW_ITEM_CODEC, "show_item"); + static final HoverEventType SHOW_TEXT_HOVER_EVENT_TYPE = new HoverEventType<>(SHOW_TEXT_CODEC, "show_text"); + static final Codec> HOVER_EVENT_TYPE_CODEC = StringRepresentable.fromValues(() -> new HoverEventType[]{SHOW_ENTITY_HOVER_EVENT_TYPE, SHOW_ITEM_HOVER_EVENT_TYPE, SHOW_TEXT_HOVER_EVENT_TYPE}); - static Codec showItemCodec(final Codec componentCodec) { - return net.minecraft.network.chat.HoverEvent.ItemStackInfo.CODEC.xmap(isi -> { - @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().location().toString(); - return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch())); - }, si -> { - final Item itemType = BuiltInRegistries.ITEM.getValue(PaperAdventure.asVanilla(si.item())); - final Map dataComponentsMap = si.dataComponents(); - final ItemStack stack = new ItemStack(BuiltInRegistries.ITEM.wrapAsHolder(itemType), si.count(), PaperAdventure.asVanilla(dataComponentsMap)); - return new net.minecraft.network.chat.HoverEvent.ItemStackInfo(stack); - }); - } - - static final HoverEventType SHOW_ENTITY_HOVER_EVENT_TYPE = new HoverEventType<>(AdventureCodecs::showEntityCodec, HoverEvent.Action.SHOW_ENTITY, "show_entity", AdventureCodecs::legacyDeserializeEntity); - static final HoverEventType SHOW_ITEM_HOVER_EVENT_TYPE = new HoverEventType<>(AdventureCodecs::showItemCodec, HoverEvent.Action.SHOW_ITEM, "show_item", AdventureCodecs::legacyDeserializeItem); - static final HoverEventType SHOW_TEXT_HOVER_EVENT_TYPE = new HoverEventType<>(identity(), HoverEvent.Action.SHOW_TEXT, "show_text", (component, registryOps, codec) -> DataResult.success(component)); - static final Codec> HOVER_EVENT_TYPE_CODEC = StringRepresentable.fromValues(() -> new HoverEventType[]{ SHOW_ENTITY_HOVER_EVENT_TYPE, SHOW_ITEM_HOVER_EVENT_TYPE, SHOW_TEXT_HOVER_EVENT_TYPE }); - - static DataResult legacyDeserializeEntity(final Component component, final @Nullable RegistryOps ops, final Codec componentCodec) { - try { - final CompoundTag tag = TagParser.parseTag(PlainTextComponentSerializer.plainText().serialize(component)); - final DynamicOps dynamicOps = ops != null ? ops.withParent(JsonOps.INSTANCE) : JsonOps.INSTANCE; - final DataResult entityNameResult = componentCodec.parse(dynamicOps, JsonParser.parseString(tag.getString("name"))); - @Subst("key") final String keyString = tag.getString("type"); - final UUID entityUUID = UUID.fromString(tag.getString("id")); - return entityNameResult.map(name -> HoverEvent.ShowEntity.showEntity(Key.key(keyString), entityUUID, name)); - } catch (final Exception ex) { - return DataResult.error(() -> "Failed to parse tooltip: " + ex.getMessage()); - } - } - - static DataResult legacyDeserializeItem(final Component component, final @Nullable RegistryOps ops, final Codec componentCodec) { - try { - final CompoundTag tag = TagParser.parseTag(PlainTextComponentSerializer.plainText().serialize(component)); - final DynamicOps dynamicOps = ops != null ? ops.withParent(NbtOps.INSTANCE) : NbtOps.INSTANCE; - final DataResult stackResult = ItemStack.CODEC.parse(dynamicOps, tag); - return stackResult.map(stack -> { - @Subst("key:value") final String location = stack.getItemHolder().unwrapKey().orElseThrow().location().toString(); - return HoverEvent.ShowItem.showItem(Key.key(location), stack.getCount(), PaperAdventure.asAdventure(stack.getComponentsPatch())); - }); - } catch (final CommandSyntaxException ex) { - return DataResult.error(() -> "Failed to parse item tag: " + ex.getMessage()); - } - } - - @FunctionalInterface - interface LegacyDeserializer { - DataResult apply(Component component, @Nullable RegistryOps ops, Codec componentCodec); - } - - record HoverEventType(Function, MapCodec>> codec, String id, Function, MapCodec>> legacyCodec) implements StringRepresentable { - HoverEventType(final Function, Codec> contentCodec, final HoverEvent.Action action, final String id, final LegacyDeserializer legacyDeserializer) { - this(cc -> contentCodec.apply(cc).xmap(v -> HoverEvent.hoverEvent(action, v), HoverEvent::value).fieldOf("contents"), - id, - codec -> (new Codec>() { - public DataResult, D>> decode(final DynamicOps dynamicOps, final D object) { - return codec.decode(dynamicOps, object).flatMap(pair -> { - final DataResult dataResult; - if (dynamicOps instanceof final RegistryOps registryOps) { - dataResult = legacyDeserializer.apply(pair.getFirst(), registryOps, codec); - } else { - dataResult = legacyDeserializer.apply(pair.getFirst(), null, codec); - } - - return dataResult.map(value -> Pair.of(HoverEvent.hoverEvent(action, value), pair.getSecond())); - }); - } - - public DataResult encode(final HoverEvent hoverEvent, final DynamicOps dynamicOps, final D object) { - return DataResult.error(() -> "Can't encode in legacy format"); - } - }).fieldOf("value") - ); - } + record HoverEventType(MapCodec> codec, String id) implements StringRepresentable { @Override public String getSerializedName() { return this.id; @@ -214,11 +192,12 @@ public final class AdventureCodecs { throw new IllegalStateException(); } }; - static final Codec> HOVER_EVENT_CODEC = Codec.withAlternative( - HOVER_EVENT_TYPE_CODEC.>dispatchMap("action", GET_HOVER_EVENT_TYPE, het -> het.codec.apply(COMPONENT_CODEC)).codec(), - HOVER_EVENT_TYPE_CODEC.>dispatchMap("action", GET_HOVER_EVENT_TYPE, het -> het.legacyCodec.apply(COMPONENT_CODEC)).codec() - ); + static final Codec> HOVER_EVENT_CODEC = HOVER_EVENT_TYPE_CODEC.dispatch("action", GET_HOVER_EVENT_TYPE, HoverEventType::codec); + + /* + * Style + */ public static final MapCodec